// -----------------------------------------------------------------------------------
//
//	Please Wait JavaScript
//	by Iam Clint - http://bytes.com
//
//	For more information on this script, visit:
//	http://bytes.com/topic/javascript/answers/617814-need-help-displaying-loading-please-wait-message-page
//
//	Credit also due to Peter Hawkes www.alphaentertainment.co.uk for fixing of many dugs in original code,
//  and improvements in: collect screen size cross browser, and div / html corrections.
//
// -----------------------------------------------------------------------------------

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function pwait(count, co, color) { 

var vleft = f_clientWidth()/2;
var vtop = f_clientHeight()/2;
var vsleft = f_scrollLeft()
var vstop = f_scrollTop()

if (count == 1) { document.getElementById("pwimg").src = "bits/pwait.gif"; } 
//border-top: solid 2px black; border-bottom: solid 2px black; border-right: solid 2px black; border-left: solid 2px black; 
var ftable = document.getElementById("pwtable"); 
if (co == 1) { 
ftable.style.borderTop = "solid 2px "+color; 
ftable.style.borderBottom = "solid 2px black"; 
ftable.style.borderLeft = "solid 2px black"; 
ftable.style.borderRight = "solid 2px black"; 
} 
if (co == 2) { 
ftable.style.borderTop = "solid 2px black"; 
ftable.style.borderBottom = "solid 2px black"; 
ftable.style.borderLeft = "solid 2px "+color; 
ftable.style.borderRight = "solid 2px black"; 
} 
if (co == 3) { 
ftable.style.borderTop = "solid 2px black"; 
ftable.style.borderBottom = "solid 2px "+color; 
ftable.style.borderLeft = "solid 2px black"; 
ftable.style.borderRight = "solid 2px black"; 
} 
if (co == 4) {  
ftable.style.borderTop = "solid 2px black"; 
ftable.style.borderBottom = "solid 2px black"; 
ftable.style.borderLeft = "solid 2px black"; 
ftable.style.borderRight = "solid 2px "+color; 
co = 0;  
} 

	document.getElementById("pleasewait").style.visibility = "visible"; 
	document.getElementById("pwaitblur").style.visibility = "visible"; 
    document.getElementById("pleasewait").style.top = vstop+vtop-80+"px";
    document.getElementById("pleasewait").style.left = vsleft+vleft-120+"px";
	document.getElementById("pwaitblur").style.left = vsleft+"px"; 
	document.getElementById("pwaitblur").style.top = vstop+"px"; 
	tmp = document.getElementById("pwait").innerHTML; 

if (tmp == "&nbsp;") { 
document.getElementById("pwait").innerHTML = "."; 
} 
if (tmp == ".") { 
document.getElementById("pwait").innerHTML = ".."; 
} 
if (tmp == "..") { 
document.getElementById("pwait").innerHTML = "..."; 
} 
if (tmp == "...") { 
document.getElementById("pwait").innerHTML = "&nbsp;"; 
} 
co = co + 1; 
count = count + 1; 
var pwaitint = window.setTimeout("pwait("+count+", "+co+", '"+color+"')", 200); 
}
