function popUp(URL) {
	
	var	retVal = true;
	var w;
	
	day = new Date();
	id = day.getTime();
	
	w = window.open(URL, id, 'toolbar=0,left=150,top=400,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=300');
	if (w.location == '' || w.location == null) {
		alert("Can't launch the Page (" + URL + ")");
		w.close();
		retVal = false;
	}
	
	return retVal;
	//window.reload();
}

function handler(e) {
	e = window.event;
	alert("Error!! :" + e.type);
}

function myPopUp(URL)
{
	if (URL == "") {
		alert("Can't start page!");
	}
	else {
		w = popUp(URL);
		/* alert("Window closed (" + w + ")");
		w.close();
		*/
	}
}

function framePopUp(f, URL) 
{
	alert("help");
	alert("f="+f+"url="+URL);
	alert(frames[0]);
	f.open(URL);
	f.close();			
}

function myModalPopup(mypage,myname,w,h,a,b,pos,infocus,loc)
{
    acePopup(mypage,myname,w,h,a,b,pos,infocus,loc)
    SimulateModalDialog(acePopupWindow)
}

var acePopupWindow=null;

function test(obj)
{
    if(document.getElementById(obj))
    {
        tableobj = document.getElementById(obj);
        newHeight = tableobj.offsetHeight;
        newWidth = tableobj.offsetWidth;
	    window.resizeTo(newWidth+42,newHeight+60);
	    LeftPosition = (screen.width)?(screen.width-newWidth)/2:100;
	    TopPosition = (screen.height)?(screen.height-newHeight)/2:100;
	    window.moveTo(LeftPosition,TopPosition);	
	}
}

function acePopup(mypage,myname,w,h,a,b,pos,infocus,loc)
{
	if (pos == 'random')
	{
		LeftPosition = (screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition = (screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	else if (pos == 'center')
	{
		LeftPosition = (screen.width)?(screen.width-w)/2:100;
		TopPosition = (screen.height)?(screen.height-h)/2-20:100;
	}
	else
	{
		LeftPosition = a;
		TopPosition = b;
	}

	var settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=yes,dependent=no';

	acePopupWindow = window.open('',myname,settings);
	if (null == acePopupWindow)
	{
		alert("Unable to create the \"" + myname + "\" popup window.\n" + 
			  "Make sure you do not have a popup blocker active.");
		return;
	}

	if (infocus == 'front')
	{
		acePopupWindow.focus();
	}

	acePopupWindow.location = mypage;
	
}

function Blink(layerName)
{
	if (NS4 || IE4) 
	{ 
		if(i%2==0)
		{
			eval(layerRef+'["'+layerName+'"]'+
			styleSwitch+'.visibility="visible"');
		}
		else
		{
			eval(layerRef+'["'+layerName+'"]'+
			styleSwitch+'.visibility="hidden"');
		}
	} 

	if(i<1)
	{
		i++;
	} 
	else
	{
		i--
	}

	setTimeout("Blink('"+layerName+"')",blink_speed);
}

function SimulateModalDialog(objPopupWindow)
{
	// If the caller did not supply a Window, we're done.
	if (null == objPopupWindow)
		{return;}

	// Save the Popup Window
	window["SimulateModalDialog_PopupWindow"] = objPopupWindow;

	// Save the parent window's current OnFocus function, if it exists.
	window["SimulateModalDialog_PreviousOnFocusHandler"] = window.onfocus;

	// Activate our OnFocus handler.
	window.onfocus = SimulationOnFocusHandler;
	return;

	// This is called whenever the parent window receives focus
	function SimulationOnFocusHandler()
	{
		// If the popup window still exists, then give it focus
		var objPopupWindow = window["SimulateModalDialog_PopupWindow"];
        if(objPopupWindow != null)
        {
		    if (! objPopupWindow.closed)
		    {
			    objPopupWindow.focus();
			    return;
		    }
        }
		// The popup window no longer exists.
		window["SimulateModalDialog_PopupWindow"] = null;

		// Restore the parent window's original OnFocus handler
		// If it exists, call it.
		window.onfocus = window["SimulateModalDialog_PreviousOnFocusHandler"];
		window["SimulateModalDialog_PreviousOnFocusHandler"] = null;
		if (null != window.onfocus)
		{
			window.onfocus();
		}
	}
}

function adjustBrowser() {
    tableobj = document.getElementById("MainContainer");
    var newHeight = tableobj.offsetHeight + 40;

    if (newHeight > screen.availHeight) { newHeight = screen.availHeight; }

    var newWidth = tableobj.offsetWidth + 60;
    if (newWidth > screen.availWidth) { newWidth = screen.availWidth; }

    window.resizeTo(newWidth, newHeight);

    var moveToX, moveToY;
    moveToX = (window.screen.availWidth - newWidth) / 2;
    moveToY = (window.screen.availHeight - newHeight) / 2;
    window.moveTo(moveToX, moveToY);
}

