
var g_popup_window;

function popup_bring_to_front() {
	window.focus();
}

function popup_close_self() {
	if (opener) {
		opener.location.reload(1);
	}
	window.close();
}

function popup_window() {

	// This funciton accepts 1 to 3 parameters, url, width, height, the last 2 are optional and default to 900 and 600
	
	var strURL, strParam;
	var intWidth = 900;
	var intHeight= 600;
	var intI;
	
	var aryProperty = new Array("strURL", "intWidth", "intHeight");
	for (intI = 0; intI < arguments.length; intI ++) {
		eval(aryProperty[intI] + '= arguments[' + intI + ']');
	}
	
	if (popup_window_exist()) {
		g_popup_window.focus();
	}
	
	//	Philip Saa	[scrollbars=1:scrollbars=auto]
	strParam = "top=200,left=300,location=0,menubar=0,resizable=1,status=0,titlebar=0,toolbar=0,directories=0,scrollbars=auto,width=" + intWidth + ",height=" + intHeight;
	
	g_popup_window = window.open(strURL, "admin", strParam, false);
	
}
function popup_window_exist() {
	if (g_popup_window && g_popup_window.open && !g_popup_window.closed) {
		return true;
	} else {
		return false;
	}
}

function popup_layer(object,what,e,s) {
	var lead = (document.layers) ? "<TABLE  BORDER='0' ID='pT'><TR><TD CLASS='popup' NOWRAP>" : "<TABLE  CLASS='popup' ID='pT'><TR><TD NOWRAP>" ;
	var tail="</TD></TR></TABLE>";
	var d = (document.layers) ? "document.layers[" + object + "]":"document.all[" + object +"]";
	//what = "xPos>[" + event.x + "] yPos>[" + event.y + "]</TD></TR><TR><TD CLASS='pink'  WIDTH='100%' NOWRAP>scrollTop>[" + document.body.scrollTop + "] scrollLeft>[" + document.body.scrollLeft.y + "]";
	// create document
	 if (document.layers){
	  document.layers[object].document.open();
	  document.layers[object].document.write(lead+what+tail);
	  document.layers[object].document.close();
	 }
	 if (document.all){
	  document.all[object].innerHTML=lead+what+tail;
	 }
	//set position for NS and IE pop-up and display
	 if (document.layers && document.layers[object] != null) {
	  xPos=e.pageX + 10;
	  yPos=e.pageY - 2;
	  if (yPos + document.layers[object].document.height - self.pageYOffset > self.innerHeight){yPos = yPos - document.layers[object].document.height - 2}
	  if (xPos + document.layers[object].document.width - self.pageXOffset > self.innerWidth){xPos = xPos - document.layers[object].document.width - 10}
	   document.layers[object].moveTo(xPos,yPos);
	   document.layers[object].visibility = 'visible';
	 }
	 else  {
	  if (document.all) {
	   xPos=event.x + 10;
	   yPos=event.y + 3;
	   if (yPos + document.all['pT'].clientHeight - document.body.scrollTop > document.body.offsetHeight){yPos = yPos - (document.all['pT'].clientHeight - 10)}
	   if (xPos + document.all['pT'].clientWidth - document.body.scrollLeft > document.body.offsetWidth){xPos = xPos - (document.all['pT'].clientWidth + 30)}
	   document.all[object].style.pixelLeft = xPos + document.body.scrollLeft;
	   document.all[object].style.pixelTop = yPos + document.body.scrollTop;
	   document.all[object].style.visibility = 'visible';
	  }
	 }
	 var message;
	 (typeof s == "number") ? message=m[s]:message = s;
	 window.status=message;
	 return true;
}


function popup_layerhide(object)
{
 if (document.layers && document.layers[object] != null)
 document.layers[object].visibility = 'hidden';
 else if (document.all && document.all[object]){
  if (object == 'pU1'){document.all[object].innerHTML="";}
  document.all[object].style.visibility = 'hidden';
 }
}
