var isMSIE = /*@cc_on!@*/false;
function loading(w, h) {
	var pSize =	getPageSize();
	var contentW = (w !== undefined)?w:(pSize[0]/2);
	var contentH = (h !== undefined)?h:(pSize[1]/2);
	var contentT = 0;
	var contentL = 0;
	var arrayPageScroll = getPageScrollTop();
	
	//Stamp = new Date();
	var ts = '0';
	//ts = Stamp.getHours() +''+ Stamp.getMinutes() +''+  Stamp.getSeconds();

    if(!document.getElementById) {
		return;
	}
		
	overlay = document.getElementById('overlay_iframe');
	if (!overlay) {
		overlay = document.createElement('iframe');
		overlay.id = 'overlay_iframe';
		document.body.appendChild(overlay, 0);
		overlay.style.border = 'none';
		overlay.style.position = 'absolute';
		overlay.style.top = "0px";
		overlay.style.height = overlaySize()+"px";
		overlay.style.left = "0px";
		if (isMSIE) {
			overlay.style.width = pSize[0]+"px";
		} else {
			overlay.style.right = "0px";
		}
		overlay.style.marginLeft = "0px";
		overlay.style.marginRight = "0px";
		overlay.style.paddingLeft = "0px";
		overlay.style.paddingRight = "0px";
		overlay.style.zIndex = "1000";
		overlay.style.scrolling = "no";
		overlay.style.frameborder="0";
		overlay.style.owerflow="auto";
		overlay.className = "loading_overlay";
				
		window.onresize = function () { changePos(); }
		window.onscroll = function () { changePos(); }
		
	}
	overlay.style.display = 'block';
		
	a = document.getElementById('overlay_div');
	if(!a) {
		a = document.createElement('div');
		a.id = 'overlay_div';
		document.body.appendChild(a, 0);
		a.style.display = 'none';
		//a.style.border = 'solid 2px #556677';
		a.style.position = 'absolute';
		a.style.background = '#ffffff';
		a.style.zIndex = 1000;
		a.style.top = (arrayPageScroll[1] + pSize[1]/2 - contentH/2 - 40) +"px"
		a.style.left = (pSize[0]/2 - contentW/2) +"px"
		//a.style.marginLeft = "10px";
		//a.style.marginRight = "10px";

		a.style.fontFamily = 'Arial, verdana, sans-serif';
		a.style.fontSize   = '11px';
		

		//a.content = document.createElement('div');
		//a.content.style.padding = '9px';
		//a.appendChild(a.content);
		
	}
	a.style.display = 'block';
	a.innerHTML = '<img src="' + site_base_url + 'images/loading.gif" border="0" />';
	changePos();
}

function loaderClose()
{
	document.getElementById('overlay_iframe').style.display='none';
	document.getElementById('overlay_div').style.display='none';
}

function getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = [w,h];
	return arrayPageSize;
}

function getPageScrollTop(){
	var yScrolltop;
	yScrolltop = (document.body.scrollTop || document.documentElement.scrollTop);
	arrayPageScroll = new Array('',yScrolltop) 
	return arrayPageScroll;
}

function changePos() {	
	var pSize =	getPageSize();
	var arrayPageScroll = getPageScrollTop();
	
	
	
	var content_div = document.getElementById( 'overlay_div' );
	
	try {
		var h = parseInt( content_div.getStyle('height') );
	} catch(e) {
		var h = content_div.offsetHeight;
	}

	try {
		var w = parseInt( content_div.getStyle('width') );
	} catch(e) {
		var w = content_div.offsetWidth;
	}
		
	var contentW = (w !== undefined)? w: (pSize[0]/2);
	var contentH = (h !== undefined)? h: (pSize[1]/2);
	
	
	
	var overlay = document.getElementById( 'overlay_iframe' );
	
	overlay.style.height = overlaySize()+"px";
	if (isMSIE) {
		overlay.style.width = pSize[0]+"px";
	} else {
		overlay.style.right = "0px";
	}
	
	content_div.style.top = (arrayPageScroll[1] + pSize[1]/2 - contentH/2 - 40) +"px"
	content_div.style.left = (pSize[0]/2 - contentW/2) +"px"
}

function overlaySize(){
	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
  	}
	return yScroll;
}