/* product: macstrac */
/* last edit: 2011/05/05 */

var mtpopup;
var currentURL = '';

// open page as a child window
function start_popup (url, width, height) {
  var thisWidth = 600;
  var thisHeight = 300;

  if (typeof arguments[1] === 'number') {
    thisWidth = width;
  }
  if (typeof arguments[2] === 'number') {
    thisHeight = height;
  }
  if (mtpopup && !mtpopup.closed && url === currentURL) {
    mtpopup.close();
  }
  mtpopup = window.open(url,"mtpopup1","status=1, width=" + thisWidth + ", height=" + thisHeight);
  currentURL = url;
  mtpopup.focus();
  return false;
}

// open page as a child window
function start_popup2 (url, height, width, top, left) {
  var options='width=600, height=300';
  if (typeof arguments[1] === 'number' && typeof arguments[2] === 'number') {
     options = 'width=' + arguments[1] + ', height=' + arguments[2];
  }
  if (typeof arguments[3] === 'number' && typeof arguments[4] === 'number') {
     options += ', top=' + arguments[3] + ', left=' + arguments[4];
  }
  if (mtpopup && !mtpopup.closed) {
    mtpopup.close();
  }
//mtpopup = window.open(url,"mtpopup1","status=1, resizable=yes, scrollbars=yes, " + options);
  mtpopup = window.open(url,'',"status=1, resizable=yes, scrollbars=yes, " + options);
  currentURL = url;
  mtpopup.focus();
}

function start_NamedPopup (url, sName, height, width, top, left) {
  var options='width=600, height=300';
  if (typeof width === 'number' && typeof height === 'number') {
     options = 'width=' + width + ', height=' + height;
  }
  if (typeof top === 'number' && typeof left === 'number') {
     options += ', top=' + top + ', left=' + left;
  }
  if (mtpopup && !mtpopup.closed) {
    mtpopup.close();
  }
//mtpopup = window.open(url,"mtpopup1","status=1, resizable=yes, scrollbars=yes, " + options);
  mtpopup = window.open(url,sName,"status=1, resizable=yes, scrollbars=yes, " + options);
  currentURL = url;
  mtpopup.focus();
}

// open page as a child window
function start_popup3 (url, height, width, top, left) {
  var options='width=600, height=300';
  if (typeof arguments[1] === 'number' && typeof arguments[2] === 'number') {
     options = 'width=' + arguments[1] + ', height=' + arguments[2];
  }
  if (typeof arguments[3] === 'number' && typeof arguments[4] === 'number') {
     options += ', top=' + arguments[3] + ', left=' + arguments[4];
  }
  if (mtpopup && !mtpopup.closed) {
    mtpopup.close();
  }
  mtpopup = window.open(url,"mtpopup3","status=1, resizable=yes, scrollbars=yes, " + options);
  currentURL = url;
  mtpopup.focus();
}

// open page as a child window
function start_popup4 (url, height, width, top, left) {
  var options='width=600, height=300';
  if (typeof arguments[1] === 'number' && typeof arguments[2] === 'number') {
     options = 'width=' + arguments[1] + ', height=' + arguments[2];
  }
  if (typeof arguments[3] === 'number' && typeof arguments[4] === 'number') {
     options += ', top=' + arguments[3] + ', left=' + arguments[4];
  }
  if (mtpopup && !mtpopup.closed) {
    mtpopup.close();
  }
  mtpopup = window.open(url,"mtpopup3","status=1, menubar=yes, resizable=yes, scrollbars=yes, " + options);
  currentURL = url;
  mtpopup.focus();
}

// close the child
function close_popup () {
  var str;
  if (mtpopup && !mtpopup.closed) {
    mtpopup.close();
//  location.reload();
    str = location.href;
    if (str.indexOf('mtar_agedrpt') === -1)
      setTimeout("location.reload();",500);
    return true;
  }
  return false;
}

// make sure the child gets closed if the parent is closed
//window.onunload = close_popup;

