var emailRE = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

function login(the_form){
	var the_uri = $("#"+the_form).serialize();
	if($("#user_name_"+the_form).val() == ""){ alert("Please enter a username to proceed"); return(false); }
	if($("#password_"+the_form).val() == ""){ alert("Please enter a password to proceed"); return(false); }
	$.ajax({type:'GET', url:'/login/', data:the_uri, success: function(data){
			if(data == 0){
				alert('You do not have sufficient permissions to access this part of Vantage Solutions.');
			}else{
				window.location = "vantage-employee-library.html";
			}
		}
	});
	return(false);
}

function create_account(){
	var the_uri = $("#new_account_form").serialize();
	if($("#first_name").val() == ""){ alert("Please enter your first name to proceed"); return(false); }
	if($("#last_name").val() == ""){ alert("Please enter your last name to proceed"); return(false); }
	if($("#email").val() == ""){ alert("Please enter a valid email address to proceed"); return(false); }
	if(!emailRE.test($("#email").val())){
		alert("Please enter a valid email address to proceed");
		return(false);
	}
	$.ajax({type:'GET', url:'/add_user/', data:the_uri, success: function(data){
			if(data == 0){
				alert('There was a problem creating your new account. Please try again. If this problem persists please contact us at 312.440.0602. Thank you!');
			}else{
				alert("Please check your email for your user name and password information.");
				window.location = "account.html";
			}
		}
	});
	return(false);
}

function expandFaq(divNum){
	var theFaqDivName = 'a'+divNum;
	var theCurrFaq = document.getElementById(theFaqDivName);
	var theCurrStyle = theCurrFaq.style.display;
	if(theCurrStyle == "none"){
		theCurrFaq.style.display = "block";
	}else{
		theCurrFaq.style.display = "none";
	}
	
}
