var tmr;

var tmr2;

var t;

var t2;

var obj;

var popup;

var regpopup;



function sFa() {

// RUN THIS =D

	popup = document.getElementById("pw_popup");

	regpopup = document.getElementById("reg_popup");

	obj = gObj();

	sLft();

	shw(true);

	t = 0;

	sTmr();

}



function sFa2() {

	// RUN THIS =D

	popup = document.getElementById("pw_popup");

	regpopup = document.getElementById("reg_popup");

	obj = gObj();

	sLft2();

	shw2(true);

	t2 = 0;

	sTmr2();



}



function hFa() {

	t = -100;

	sTmr();

	popup.style.display = "none";

	regpopup.style.display = "none";

	return false;

}



function hFa2() {

	t2 = -100;

	sTmr2();

	regpopup.style.display = "none";

	popup.style.display = "none";

	return false;

}

function sTmr() {

	tmr = setInterval("fd()",20);

}

function sTmr2() {

	tmr2 = setInterval("fd2()",20);

}



function fd() {

	var amt = Math.abs(t+=20);

	if(amt == 0 || amt == 100) clearInterval(tmr);

	amt = (amt == 100)?99.999:amt;

  	

	obj.style.filter = "alpha(opacity:"+amt+")";

	obj.style.KHTMLOpacity = amt/100;

	obj.style.MozOpacity = amt/100;

	obj.style.opacity = amt/100;

	obj.style.Msfilter = amt;
	

	

	if(amt == 0) shw(false);

}

function fd2() {

	var amt2 = Math.abs(t2+=20);

	if(amt2 == 0 || amt2 == 100) clearInterval(tmr2);

	amt2 = (amt2 == 100)?99.999:amt2;

  	

	obj.style.filter = "alpha(opacity:"+amt2+")";

	obj.style.KHTMLOpacity = amt2/100;

	obj.style.MozOpacity = amt2/100;

	obj.style.opacity = amt2/100;

	obj.style.Msfilter = amt2;

	

	

	if(amt2 == 0) shw2(false);

}



function sLft() {

	var w = 170;	// set this to 1/2 the width of the faw div defined in the style sheet 

			// there's not a reliable way to retrieve an element's width via javascript!!

					

	var l = (document.body.innerWidth)? document.body.innerWidth / 2:document.body.offsetWidth / 2;

	

	popup.style.left = (l-w)+"px";

	

}

function sLft2() {

	var w = 350;	// set this to 1/2 the width of the faw div defined in the style sheet 

			// there's not a reliable way to retrieve an element's width via javascript!!

					

	var l = (document.body.innerWidth)? document.body.innerWidth / 2:document.body.offsetWidth / 2;

	

	regpopup.style.left = (l-w)+"px";

	

}





function gObj() {

	return document.getElementById("faw");	

}



function shw(b) {

	

	(b)? obj.className = 'show':obj.className = '';	

	popup.style.display = "block";

	regpopup.style.display = "none";

}

function shw2(b) {

	

	(b)? obj.className = 'show':obj.className = '';	

	regpopup.style.display = "block";

	popup.style.display = "none";

}









function submit_new_reg() {

	var form = document.mosForm2;

	var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");



	// do field validation

	if (form.name.value == "") {

		alert( "Please enter your First Name." );

	} else if ( form.surname.value == "" ) {

		alert( "Please enter your Last Name." );

	} else if (form.username.value == "") {

		alert( "Please enter a Username." );

	} else if (r.exec(form.username.value) || form.username.value.length < 3) {

		alert( "Please enter a valid Username.  More than 2 characters and contain 0-9,a-z,A-Z." );

	} else if (form.email.value == "" || form.email.value.length < 7) {

		alert( "Please enter a valid e-mail address." );

	} else if (form.password.value.length < 6) {

		alert( "Please enter a valid password.  No spaces, more than 6 characters and contain 0-9,a-z,A-Z" );

	} else if (form.password2.value == "") {

		alert( "Please verify the password." );

	} else if ((form.password.value != "") && (form.password.value != form.password2.value)){

		alert( "Password and verification do not match, please try again." );

	} else if (r.exec(form.password.value)) {

		alert( "Please enter a valid Password:.  No spaces, more than 6 characters and contain 0-9,a-z,A-Z." );

	} else if ( form.year.value == "" || form.month.value == "" || form.day.value =="" ) {

		alert( "Please enter your Date of Birth." );

	} else if ( form.gender.value  == "") {

		alert( "Please enter your Gender." );

	} else {

		form.submit();

	}

}





function submit_forgot_pw() {

	var form = document.forgotform;



	// do field validation

	// if (form.confirmEmail.value == "") {

	//	alert( "Please enter a valid e-mail address." );

	//} else {

		form.submit();

	//}

}

