var nTimerId = 0;

// ---------------------------------------------------------------------------- 
// This routine disables all the select controls for the window so that users
// clicking on other things on this page while the next page is loading will be 
// disabled.  This routine will be in effect from the time a request is sent to 
// the server until the 3 second timer expires ( <3 seconds).  
// TBD: Input control are not diabled because disabling the input control will 
// uncheck all the selections.
// ----------------------------------------------------------------------------  
function disablewindow()
{
	var selectcontrols = document.getElementsByTagName("SELECT");

	// Disable all combo box controls.
	for (i=0; i < selectcontrols.length; i++) {
		selectcontrols[i].disabled = true;
	}
}

// ---------------------------------------------------------------------------- 
// This routine displays a "please wait" message to the end user when the 3 second 
// timer has expired and still waiting for the response from the server.  
// This routine will display a blank page with only the "please wait" message. 
// ----------------------------------------------------------------------------  
function pleaseWait()
{
	var selectcontrols = document.getElementsByTagName("SELECT");
	var inputcontrols = document.getElementsByTagName("INPUT");

	// Hides all controls
	for (i=0; i < selectcontrols.length; i++) {
		selectcontrols[i].style.visibility = 'hidden';
	}

	// Disable all input box controls.
	for (i=0; i < inputcontrols.length; i++) {
		if (inputcontrols[i].type != "hidden") {
			inputcontrols[i].style.visibility = 'hidden';
		}
	}

	// Replaces the current page with the blank "please wait" Cover Page so that
	// all the links on this page will be invisible.
	var cover = document.getElementById("cover");
	if(cover!=null)
	{
		cover.style.backgroundColor = GetRuleStyle(".CoverBkColor", "backgroundColor");
		cover.style.zIndex=100;
	
		// Draw the Please Wait page.
		var sTxt;
		sTxt = "<DIV id='CoverTop' align=center STYLE='position:relative; height:0; width:0; '>";
		sTxt += "<TABLE  border=0 cellpadding='0' cellspacing='0'>";
		sTxt +=	"<TR height=100px >";
		sTxt +=	"<TD width=100px></TD>";
		sTxt += "<TD>";
		sTxt += "<TABLE  width='100%' border=0 class='ModalWindowBorder' cellpadding='0' cellspacing='0'>";
		sTxt +=	"<tr height=15px>";
		sTxt +=	"<td class='Tab'></td>";
		sTxt +=	"</tr>";
		sTxt += "</TABLE>";
		sTxt += "<TABLE  border=0 class='ModalWindowBorder' cellpadding='0' cellspacing='0'>";
		sTxt +=	"<TR height=100px >";
		sTxt +=	"<TD width=100px></TD>";
		sTxt += "<TD>";
		sTxt += "<FONT class='B2020H3'>";
		sTxt += resPleaseWait;
		sTxt += "</FONT>";
		sTxt += "</TD>";
		sTxt +=	"<TD width=100px></TD>";
		sTxt +=	"</TR>";
		sTxt += "</TABLE>";
		sTxt +=	"</TD>";
		sTxt +=	"<TD width=100px></TD>";
		sTxt += "</TR>";
		sTxt += "</TABLE>";
		sTxt += "</DIV>";

		cover.innerHTML = sTxt;
		cover.style.visibility = "visible";
		nTimerId = 0;
		bFullScreen = false;
		resizeCover();
	}	
}

// ----------------------------------------------------------------------------    
function HidePleaseWait()
{
    if (document.getElementById("CoverTop")) {
        document.getElementById("cover").style.visibility = "hidden";
	    document.getElementById("CoverTop").style.visibility = "hidden";
	}
}

// ----------------------------------------------------------------------------    
function executeWait(object)
{
	if (nTimerId != 0)
		clearTimeout(nTimerId);
	disablewindow();
	nTimerId = setTimeout("pleaseWait();", 3000);
	object.submit();
}

