

var width;
var height;

function loginPos(){
	
	if (document.body && document.body.offsetWidth) { // IE
		//alert("1");
		window.width = document.body.offsetWidth;
		window.height = document.body.offsetHeight;
	} else if (document.compatMode=="CSS1Compat" && document.documentElement && document.documentElement.offsetWidth) {
		//alert("2");
		window.width = document.documentElement.offsetWidth;
		window.height = document.documentElement.offsetHeight;
	} else if (window.innerWidth && window.innerHeight) {
		//alert("3");
		window.width = window.innerWidth;
		window.height = window.innerHeight;
	} else {
		//alert("4");
		window.width = window.innerWidth;
		window.height = window.innerHeight;
	}
	
	pageHalfWidthPercent = 50;
	pageHalfHeightPercent = 50;
	
	window.loginWidth = document.getElementById("login").style.width.replace("px", "");
	window.loginHeight = document.getElementById("login").style.height.replace("px", "");
	
	window.loginWidth = loginWidth.replace("px", "");
	window.loginHeight = loginHeight.replace("px", "");
	
	window.loginHalfWidthPercent = (loginWidth / width) * 50;
	window.loginHalfHeightPercent = (loginHeight / height) * 50;
	
	window.loginX = pageHalfWidthPercent - loginHalfWidthPercent;
	window.loginY = pageHalfHeightPercent - loginHalfHeightPercent;
	
	window.scrollY = $("body").scrollTop();
	
	window.offsetY = (scrollY / height) * 100;
	
	window.loginY = loginY + offsetY;
	
	document.getElementById("fade").style.top = scrollY;
	
	//document.getElementById("login").style.left = (width * 0.5);
	//document.getElementById("login").style.top = (height * 0.5);
	
	//if (option == 1){
		//document.getElementById("login").style.left = loginX + "%";
		//document.getElementById("login").style.top = loginY + "%";
	//}
	
}

//loginPos();

function loginShow(){
	
	//alert("SUP!!!");
	
	scrollTo(0,0);
	
	document.getElementById("login").style.height = "370px";
	document.getElementById("fade").style.height = "2000px";
	document.getElementById("login").style.padding = "44px 50px 0px 60px"; // top right bottom left
	//alert(width + " = " + loginWidth + " --- " + height + " = " + loginHeight);
	//alert(loginHeight);
	document.getElementById("login").style.left = (width * 0.5) - (loginWidth * 0.5);
	document.getElementById("login").style.top = 0;//(height * 0.5) - (370 * 0.5);
	
	document.getElementById("fade").style.top = 0;
	
	document.getElementById("fade").style.visibility = "visible";
	document.getElementById("login").style.visibility = "visible";
	
	document.valogin.username.focus();
	
}

function hideLogin(){
	document.getElementById("login").style.visibility = "hidden";
	document.getElementById("fade").style.visibility = "hidden";
	document.getElementById("fade").style.height = "1px";
}

function validate(username, password, page){
	document.getElementById("validation").src = "_validate.php?username=" + username + "&password=" + password + "&page=" + page;
}
