var htmlOfModalMessage='<table width="100%" height="100%"><tr><td valign="middle" align="center"><img src="'+ url + 'images/spinner3-black.gif"></td></tr><table>';					// html of modal message
var divs_transparentDiv;				// Transparent div covering page content
var divs_content;						// Modal message div.
var iframe;								// Iframe used in ie
var width = 200;								// Width of message box
var height = 100;								// Height of message box
var shadowDivVisible=true;					// Shadow div visible ? 
var shadowOffset = 10; 						// X and Y offset of shadow(pixels from content box)
var MSIE = false;


function showProgressBox() {
	if(navigator.userAgent.indexOf('MSIE')>=0) MSIE = true;
		createDivs();
    resizeDivs();
		divs_content.innerHTML = htmlOfModalMessage;
}

function hideProgressBox() {
		divs_transparentDiv.style.display='none';
		divs_content.style.display='none';
		divs_shadow.style.display='none';
		if(MSIE)iframe.style.display='none';
}

function createDivs() {
		// Creating transparent div
		divs_transparentDiv = document.createElement('DIV');
		// this.divs_transparentDiv.className='modalDialog_transparentDivs';
		divs_transparentDiv.style.left = '0px';
		divs_transparentDiv.style.top = '0px';
		divs_transparentDiv.style.filter = 'alpha(opacity=40)';
		divs_transparentDiv.style.opacity = '0.4';
		divs_transparentDiv.style.backgroundColor = '#AAA';
		divs_transparentDiv.style.zIndex = '1';
		divs_transparentDiv.style.position = 'absolute';
		
		document.body.appendChild(this.divs_transparentDiv);
		// Creating content div
		divs_content = document.createElement('DIV');
		// this.divs_content.className = 'modalDialog_contentDiv';
		divs_content.style.border = '1px solid #000';
		divs_content.style.padding = '2px';
		divs_content.style.backgroundColor = '#FFF';
		divs_content.style.zIndex = '100';
		divs_content.style.position = 'absolute';
		
		divs_content.id = 'DHTMLSuite_modalBox_contentDiv';
		divs_content.style.zIndex = 100000;
		
		if(MSIE){
			iframe = document.createElement('<IFRAME src="about:blank" frameborder=0>');
			iframe.style.zIndex = 90000;
			iframe.style.position = 'absolute';
			document.body.appendChild(this.iframe);	
		}
			
		document.body.appendChild(this.divs_content);
		// Creating shadow div
		divs_shadow = document.createElement('DIV');
		divs_shadow.className = 'modalDialog_contentDiv_shadow';
		
		divs_shadow.style.zIndex = 90;
		divs_shadow.style.position = 'absolute';
		divs_shadow.style.backgroundColor = '#555';
		divs_shadow.style.filter = 'alpha(opacity=30)';
		divs_shadow.style.opacity = '0.3';
		
		divs_shadow.style.zIndex = 95000;
		document.body.appendChild(divs_shadow);
		window.refToModMessage = this;
}

function getBrowserSize() {
    	var bodyWidth = document.documentElement.clientWidth;
    	var bodyHeight = document.documentElement.clientHeight;
    	
		var bodyWidth, bodyHeight; 
		if (self.innerHeight){ // all except Explorer 
		 
		   bodyWidth = self.innerWidth; 
		   bodyHeight = self.innerHeight; 
		}  else if (document.documentElement && document.documentElement.clientHeight) {
		   // Explorer 6 Strict Mode 		 
		   bodyWidth = document.documentElement.clientWidth; 
		   bodyHeight = document.documentElement.clientHeight; 
		} else if (document.body) {// other Explorers 		 
		   bodyWidth = document.body.clientWidth; 
		   bodyHeight = document.body.clientHeight; 
		} 
		return [bodyWidth,bodyHeight];
}

function resizeDivs () {
     	var topOffset = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
    	if(!divs_transparentDiv) return;
    	// Preserve scroll position
    	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
    	var sl = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
    	window.scrollTo(sl,st);
    	setTimeout('window.scrollTo(' + sl + ',' + st + ');',10);
    	repositionTransparentDiv();

		var brSize = getBrowserSize();
		var bodyWidth = brSize[0];
		var bodyHeight = brSize[1];
    	// Setting width and height of content div
      divs_content.style.width = width + 'px';
    	divs_content.style.height= height + 'px';  	
    	
    	// Creating temporary width variables since the actual width of the content div could be larger than this.width and this.height(i.e. padding and border)
    	var tmpWidth = divs_content.offsetWidth;	
    	var tmpHeight = divs_content.offsetHeight;
    	
    	// Setting width and height of left transparent div
		
    	divs_content.style.left = Math.ceil((bodyWidth - tmpWidth) / 2) + 'px';;
    	divs_content.style.top = (Math.ceil((bodyHeight - tmpHeight) / 2) +  topOffset) + 'px';
     if(MSIE){
 			iframe.style.left = divs_content.style.left;
 			iframe.style.top = divs_content.style.top;
 			iframe.style.width = divs_content.style.width;
 			iframe.style.height = divs_content.style.height;
 		}

    	divs_shadow.style.left = (divs_content.style.left.replace('px','')/1 + shadowOffset) + 'px';
    	divs_shadow.style.top = (divs_content.style.top.replace('px','')/1 + shadowOffset) + 'px';
    	divs_shadow.style.height = tmpHeight + 'px';
    	divs_shadow.style.width = tmpWidth + 'px';
    	if(!shadowDivVisible)divs_shadow.style.display='none';	// Hiding shadow if it has been disabled

}
  
function repositionTransparentDiv() {
    	divs_transparentDiv.style.top = Math.max(document.body.scrollTop,document.documentElement.scrollTop) + 'px';
    	divs_transparentDiv.style.left = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft) + 'px';
		  var brSize = getBrowserSize();
		  var bodyWidth = brSize[0];
		  var bodyHeight = brSize[1];
    	divs_transparentDiv.style.width = bodyWidth + 'px';
    	divs_transparentDiv.style.height = bodyHeight + 'px';		 	
    }

