var openpopup = new Array();

function getRealPos(i,which) {
 var iPos = 0
 while (i!=null) {
  iPos += i["offset" + which]
  i = i.offsetParent
 }
 return iPos
}
function showSelect(el, popname, leftOffset, topOffset, onlyone, group) {
 leftOffset = parseInt(leftOffset);
 topOffset = parseInt(topOffset);
 if (popname == '') {
  alert('No popup name supplied');
  return;
 }
 var left = getRealPos(el,"Left");
 var top  = getRealPos(el,"Top")

 if (onlyone && openpopup[group] != null) {
  hideSelect(openpopup[group]);
  openpopup[group] = null;
 }
 var popup = document.getElementById(popname);
 if (popup) {
  popup.style.left  = left + leftOffset;
  popup.style.top   = top + topOffset;
  popup.style.visibility = "visible";
  popup.style.display = "block";
  if (onlyone) {
   openpopup[group] = popname;
  }
 }
 else {
  alert('Could not locate id with name: ' + popname);
  return;
 }
}
function hideSelect(popname) {
 if (popname == '') {
  alert('No popup name supplied');
  return;
 }
 var popup = document.getElementById(popname);
 if (popup) {
  popup.style.visibility = "hidden";
  popup.style.display = "none";
 }
 else {
  alert('Could not locate id with name: ' + popname);
  return;
 }
}  

var winRef;
function globalMakeWindow(url,width,height) {
 if (! width) {width=600;}
 if (! height) {height=400;}
 if (winRef && (! winRef.closed)) { winRef.close() }
 remote = window.open("","popupwindow","scrollbars=yes,resizable=yes,width="+width+",height="+height);
 remote.location.href = url;
 if (remote.opener == null) window.opener = window;
 winRef = remote;
 remote.focus();
}
function globalMakePlainWindow(url,width,height) {
 if (! width) {width=600;}
 if (! height) {height=400;}
 if (winRef && (! winRef.closed)) { winRef.close() }
 remote = window.open("","plainpopupwindow","scrollbars=no,resizable=no,width="+width+",height="+height);
 remote.location.href = url;
 if (remote.opener == null) window.opener = window;
 winRef = remote;
 remote.focus();
}
function globalMakeInstantMessengerWindow(url,width,height) {
 if (! width) {width=600;}
 if (! height) {height=400;}
 if (winRef && (! winRef.closed)) { winRef.close() }
 remote = window.open("","InstantMessengerWindow","scrollbars=yes,resizable=yes,width="+width+",height="+height);
 remote.location.href = url;
 if (remote.opener == null) window.opener = window;
 winRef = remote;
 remote.focus();
}
function globalMakeJavaGamesWindow(url,width,height) {
 if (! width) {width=600;}
 if (! height) {height=400;}
 if (winRef && (! winRef.closed)) { winRef.close() }
 remote = window.open("","JavaGamesWindow","scrollbars=no,resizable=no,width="+width+",height="+height);
 remote.location.href = url;
 if (remote.opener == null) window.opener = window;
 winRef = remote;
 remote.focus();
}
function globalMakeFullWindow(url) {
 if (winRef && (! winRef.closed)) { winRef.close() }
 remote = window.open("","fullwindow");
 remote.location.href = url;
 if (remote.opener == null) window.opener = window;
 winRef = remote;
 remote.focus();
} 

function globalConfirm(txt,windowlocation,url) {
 if(confirm(txt)){
  windowlocation.href = url;   
 }
}
function globalAlert(txt) {
 alert(txt);  
}
function globalDrawCalendar(url, width, height, UpdateMonthField, UpdateDayField, UpdateYearField, formname ){  
 var month = eval ('document.' + formname + '.' + UpdateMonthField + '.value');
 var day   = eval ('document.' + formname + '.' + UpdateDayField + '.value');
 var year  = eval ('document.' + formname + '.' + UpdateYearField + '.value');
 url = url + "?action=drawcalendar&month=" + month + "&day=" + day + "&year=" + year + "&UpdateDayField=" + UpdateDayField + "&UpdateMonthField=" + UpdateMonthField + "&UpdateYearField=" + UpdateYearField + "&formname=" + formname;
 if (! width) {width=250;}
 if (! height) {height=300;}
 if (winRef && (! winRef.closed)) { winRef.close() }
 remote = window.open("","popupwindow","scrollbars=no,resizable=yes,width="+width+",height="+height);
 remote.location.href = url;
 if (remote.opener == null) window.opener = window;
 winRef = remote;
 remote.focus();
}