$(document).ready(function() {
	$('#togglereg').click( function() {
		$('div.showhide,div.registerbox').toggle();
		$('div.showhide,div.loginbox').hide();
	});
	$('#togglelogin').click( function() {
		$('div.showhide,div.loginbox').toggle();
		$('div.showhide,div.registerbox').hide();
	});
});

function verifyForm(form) {

	var email = form.email.value;	
	var password = form.password.value;
	var emailverify = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	var passwordverify = /^[a-zA-Z0-9]{4,16}$/;
	var success = 1;

	if (!email) {
		form.email.backgroundColor = "yellow";
		success = 0;
	}

	if (!password) {
		form.password.backgroundColor = "yellow";
		success = 0;
	}

	if (emailverify.test(email)) {
		emailsuccess = 1;
	} else {
		emailsuccess = 0;
	}

	if (passwordverify.test(password)) {
		passwordsuccess = 1;
	} else {
		passwordsuccess = 0;
	}

	if(!success) {
		alert("Hold your horses there hotshot, I know your excited but you missed something.");
		return false;
	} else if(!emailsuccess) {
		alert("Your email address is not valid, or our script to verify it sucks.");
		return false;
	} else if(!passwordsuccess) {
		alert("Your password is not valid. It must be Letters and/or Numbers and between 4 and 16 characters.");
		return false;
	} else {
		return true;
	}
}
