// JavaScript Document
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
} 
function showLoader() { 
	var page_arr=getPageSize(); 
	var loader_trans=document.getElementById('loader_div_trans');
	var loader_box=document.getElementById('loader_div');
	loader_trans.style.height=page_arr[1]+"px";
	loader_trans.style.width=page_arr[0]+"px";
	loader_box.style.marginLeft="50%";
	loader_box.style.left="-125px";
	loader_box.style.top=((page_arr[1]/2)-25)+"px";
	loader_box.style.display="none";
	loader_trans.style.display="none";
}
var previous_class="";
function setLoaderStatus(status) {
	//alert(status);
	//document.getElementById(status).className="loader_progress";
	//if(previous_class!="") 
		///document.getElementById(previous_class).className="loader_done";
	//previous_class=status;
}

function hideLoader() {
	setLoaderStatus("loader_images");
	setTimeout('document.getElementById("loader_div_trans").style.display="none";document.getElementById("loader_div").style.display="none";showLoginPanel();checkBackButton();',1000);
}
function showLoginPanel() {
	var page_arr=getPageSize();
	var inner_height=page_arr[3]-115;
	if(loginAdmin==1) {
		$('reload_gbutton').style.display="";
		new Effect.Appear('content_box',{ duration: 1, direction: 'center', from: 0.0, to: 1.0});
		document.getElementById('body_wrapper').style.height=(inner_height)+"px"; 
		setTimeout(function() {
			if(document.getElementById('content_box').offsetHeight<(inner_height))
				document.getElementById('content_box').style.height=(inner_height-80)+"px";
			if(document.getElementById('loginBox').offsetHeight<(inner_height-80))
				document.getElementById('loginBox').style.height=(inner_height-80)+"px";
			if(document.getElementById('forgotBox').offsetHeight<(inner_height-80))
				document.getElementById('forgotBox').style.height=(inner_height-80)+"px";
							},1000);
	} else {
		new Effect.Appear('loginBox',{ duration: 1, direction: 'center', from: 0.0, to: 1.0});
		document.getElementById('body_wrapper').style.height=(inner_height)+"px"; 
		setTimeout(function() {
			if(document.getElementById('loginBox').offsetHeight<inner_height)
				document.getElementById('loginBox').style.height=(inner_height-80)+"px";
			if(document.getElementById('forgotBox').offsetHeight<inner_height)
				document.getElementById('forgotBox').style.height=(inner_height-80)+"px";
			if(document.getElementById('content_box').offsetHeight<(inner_height))
				document.getElementById('content_box').style.height=(inner_height-80)+"px";
							},1000);
		setTimeout("document.login_form.txtuserName.focus();",1000);
	}
	//document.getElementById('body_box').style.height="auto";
}
function resizePanel(){ 
	var page_arr=getPageSize();
	var inner_height=page_arr[3]-115;
	var inner_width=page_arr[2]-240;
	
	document.getElementById('body_wrapper').style.height=(inner_height)+"px"; 
	document.getElementById('content_box').style.height="auto";
	if(document.getElementById('content_box').offsetHeight<(inner_height))
		document.getElementById('content_box').style.height=(inner_height-80)+"px";
	document.getElementById('loginBox').style.height="auto";
	if(document.getElementById('loginBox').offsetHeight<inner_height)
		document.getElementById('loginBox').style.height=(inner_height-80)+"px";
	document.getElementById('forgotBox').style.height="auto";
	if(document.getElementById('forgotBox').offsetHeight<inner_height)
		document.getElementById('forgotBox').style.height=(inner_height-80)+"px";
	//document.getElementById('body_box').style.height="auto";
	//if(document.getElementById('body_box').offsetHeight<inner_height)
		//		document.getElementById('body_box').style.height=(inner_height)+"px";
}
 
