function getTextDivWaitPlease(varWidth, varHeight, t, bIsBackground, bWithCancel )
{ 
	var txt="";
	txt+='<table border="0" cellspacing="0" cellpadding="0" width="'+varWidth+'" height="'+varHeight+'">';
	txt+='<tr>';
	txt+='<td align="center">';
	if ( !bIsBackground )
	{
		txt+='<div id="divTblWaitPlease" style="Z-INDEX: 951;"><table " id="tblWaitPlease" class="table_wait_please_style" cellspacing="0" cellpadding="0" align="center" border="0"';
		txt+='>';
		txt+='<tr>';
		txt+='<td align="center" class="td_box_wait_please_style" >';
		txt+= t;	
		txt+='<br><br><img src="'+ alertImageDir +'/ajax-loader.gif\">&nbsp;&nbsp;';	
		//txt+='<a href="#" onClick="return false;" id="lnkWaitPlease" onFocus="window.status=\'\';"></a>';
		txt+='</td>';
	    txt+='</tr>';
		if ( bWithCancel )
		{
		    txt+= '<tr><td class="td_box_wait_please_style" >';
			//txt+= '<a href=# onclick="AbortAjaxByWaitBox();return false;">Cancel</a>';
			//txt+= '<input type="button" value="Stop Request" class="btnWaitPleaseStopRequest" onclick="AbortAjaxByWaitBox(this);">';
			txt+= '<div id="divProgressToFileUpload"></div><br><br><br><br><br>';
			txt+= '</td></tr>';			
		}		
	}
	txt+='</table></div>';
	txt+='</td>';
	txt+='</tr>';
	txt+='</table>';
	return txt;
}
function ShowPleaseWaitBox( t,opDiv )
{
//document.getElementById("divWaitPlease").style.cursor = "url(../Images/peces.cur), default";
//document.getElementById("divWaitPlease").style.cursor = "wait";
	var bWithCancel = false;
	if ( t == null )
	{ 
		t = '<br><br><br><span> Loading Data</span> ';
		//t = 'Please wait<br>Loading<br>&nbsp;<a href=# onclick="AbortAjaxByWaitBox();return false;">Cancel</a>';
		bWithCancel = true;
	}
  	if (self.innerHeight) // all except Explorer
		varHeight = self.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight)	// Explorer 6 Strict Mode
		varHeight = document.documentElement.clientHeight;
	else if (document.body) // other Explorers
		varHeight = document.body.clientHeight;
		
	var spaceTop = 40;
	if ( document.getElementById( "divWaitPlease" ).style.top != "" )
		spaceTop = parseInt( document.getElementById( "divWaitPlease" ).style.top );
		
	varHeight = varHeight - spaceTop;
	
	
	var browserWidth = 0;
	if ( document.all )
		browserWidth = document.body.clientWidth;
	else
		browserWidth = window.innerWidth;

	document.getElementById('divWaitPlease').innerHTML = getTextDivWaitPlease( browserWidth, varHeight, t, false, bWithCancel );
	document.getElementById('divWaitPleaseBack').innerHTML = getTextDivWaitPlease( browserWidth, varHeight, "", true, false );

	/*if ( navigator.appName.indexOf("Microsoft") != -1 )
	{
		document.getElementById( "divWaitPleaseBack" ).style.background = "silver";
		//document.getElementById( "divWaitPleaseBack" ).style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=50)';
	}
	else
	{
		document.getElementById( "divWaitPleaseBack" ).style.background = "silver";
		//document.getElementById( "divWaitPleaseBack" ).style.opacity = ".40";
	}*/
	document.getElementById('divWaitPlease').style.display = "inline";
	document.getElementById('divWaitPleaseBack').style.display = "inline";
	HideShowElement('SELECT', document.getElementById('divTblWaitPlease'),'hidden');
	if (bAjaxIsMac)//if (!document.all)//
		showDivScroll("listhidescrollbyshowwait","list"); 
		//hideDivScroll(document.getElementById( "divWaitPlease" ),"list","listhidescroll");
}
var divTimeoutWaitPlease = null;
function HidePleaseWaitBox()
{//document.getElementById("divWaitPlease").style.cursor = "";
/**/if (divTimeoutWaitPlease != null)
	{
		window.clearTimeout( divTimeoutWaitPlease );
	}
	HideShowElement('SELECT', document.getElementById('divTblWaitPlease'),'');
	if (bAjaxIsMac)//if (!document.all)//
		showDivScroll("list","listhidescrollbyshowwait");
		//showDivScroll("list","listhidescroll");
		if (document.getElementById('divWaitPlease')!= null)
	        document.getElementById('divWaitPlease').style.display = "none";
	    if (document.getElementById('divWaitPleaseBack')!= null)
	        document.getElementById('divWaitPleaseBack').style.display = "none";
}
function HideShowElement( elmID, overDiv, h )
{

	if ( document.all )
	{
		for( i = 0; i < document.getElementsByTagName( elmID ).length; i++ )
		{
		  obj = document.getElementsByTagName( elmID )[i];
		  if( !obj || !obj.offsetParent )
		  {
			continue;
		  }
		  // Find the element's offsetTop and offsetLeft relative to the BODY tag.
		  objLeft   = obj.offsetLeft;
		  objTop    = obj.offsetTop;
		  objParent = obj.offsetParent;
		  while( objParent.tagName.toUpperCase() != 'BODY' )
		  {
			objLeft  += objParent.offsetLeft;
			objTop   += objParent.offsetTop;
			objParent = objParent.offsetParent;
		  }
		  objHeight = obj.offsetHeight;
		  objWidth = obj.offsetWidth;
		  if(( overDiv.offsetLeft-12 + overDiv.offsetWidth ) <= objLeft );
		  else if(( overDiv.offsetTop-0 + overDiv.offsetHeight ) <= objTop );//-15
		  else if( overDiv.offsetTop-15 >= ( objTop + objHeight ));
		  else if( overDiv.offsetLeft-12 >= ( objLeft + objWidth ));
		  else
		  {
			obj.style.visibility = h;
		  }
		}
	}
}
/*function AbortAjaxByWaitBox( obj )
{
	
	if ( typeof( UploadFiles ) != "undefined" )
	{
		if ( !UploadFiles.CancelUpload() )
			AjaxPro.queue.abort();
	}
	else
		AjaxPro.queue.abort();
	HidePleaseWaitBox();
}*/
        function AbortAjaxByWaitBox(sender, args)
        {
            HidePleaseWaitBox();
            if (Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack())        
            {
                alert('One postback at a time please');
                args.set_cancel(true);
                
            }
        }   


function ShowSavingBox( t )
{
	if ( t == null )
	{ 
		t = '<br><br><br><span>  Saving Data  </span> ';
		bWithCancel = true;
	}
	
	if (self.innerHeight) // all except Explorer
		varHeight = self.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight)	// Explorer 6 Strict Mode
		varHeight = document.documentElement.clientHeight;
	else if (document.body) // other Explorers
		varHeight = document.body.clientHeight;
		
	varHeight;
	
	document.getElementById('divSavingWaitPlease').innerHTML = t;
    document.getElementById('divSavingWaitPlease').style.top = varHeight-20;
    document.getElementById('divSavingWaitPlease').style.left = 0;

	document.getElementById('divSavingWaitPlease').style.display = "inline";
	
	
}

function HideSavingBox()
{
	document.getElementById('divSavingWaitPlease').style.display = "none";
}

