/*
	THIS FILE IS NOT AUTHORIZED TO BE USED OUTSIDE OF sassilization.com
	DO NOT EDIT, COPY, OR OTHERWISE USE THIS FILE. FAILURE TO DO SO WILL RESULT IN PROSECUTION TO THE FULLEST
	EXTENT OF THE LAW
	
	(C) Copyright 2008 Sassilization Team
*/
//WelcomePage Functions
var LoginCall;
var LoginCallBack_Inc = 0;
function InitiateLogin() {
	var Username = $('Username_Input').value;
	var Password = $('Password_Input').value;
	if (Username != "" && Password != "") {
		$('Username_Input').disabled = true;
		$('Password_Input').disabled = true;
		$('Login_Submit').disabled = true;
		LoginCall = new CallPage("Login.php", "Username="+Username+"&Password="+Password+"&AJAX=true", "Login_Callback()", "POST");
	} else {
		if (Username == "") {
			$('Username_Input').style.backgroundColor = "#FF6464";
		}
		if (Password == "") {
			$('Password_Input').style.backgroundColor = "#FF6464";
		}
	}
}
function Login_Callback() {
	new Effect.Fade('LoginFields', {speed: 1, from: 1.0, to: 0.0});
	setTimeout("Login_Callback_Part2()", 1000);
}
function Login_Callback_Part2() {
	$('LoginFields').style.display = 'none';
	$('Password_Input').value = '';
	$('Login_Callback').innerHTML = LoginCall.getResponse();
	var Logex = new RegExp("Redirecting");
	if (Logex.test($('Login_Callback').innerHTML)) {
		setTimeout('window.location = "' + MainPage + '"', 3000);
	} else {
		LoginCallBack_Inc += 1;
		setTimeout('Login_Timeout(' + LoginCallBack_Inc + ')', 3000);
	}
	new Effect.Appear('Login_Callback', {speed: 1, from: 0.0, to: 1.0});
}
function Login_Timeout(Valid) {
	if (LoginCallBack_Inc == Valid) {
		new Effect.Fade('Login_Callback', {speed: 1, from: 1.0, to: 0.0});
		setTimeout("Login_Timeout_Part2()", 1000);
	}
}
function Login_Timeout_Part2() {
	$('Login_Callback').innerHTML = '';
	$('Login_Callback').style.display = 'none';
	$('LoginFields').style.visibility = "hidden";
	new Effect.Appear('LoginFields', {speed: 1, from: 0.0, to: 1.0});
	setTimeout("$('LoginFields').style.visibility = 'visible'", 25);
	$('Username_Input').disabled = false;
	$('Password_Input').disabled = false;
	$('Login_Submit').disabled = false;
}

function CheckEnter(event) {
	if (event && event.which == 13) {
		InitiateLogin();
	}
}

/*
	THIS FILE IS NOT AUTHORIZED TO BE USED OUTSIDE OF sassilization.com
	DO NOT EDIT, COPY, OR OTHERWISE USE THIS FILE. FAILURE TO DO SO WILL RESULT IN PROSECUTION TO THE FULLEST
	EXTENT OF THE LAW
	
	(C) Copyright 2008 Sassilization Team
*/