function doP() {
	var email = document.getElementById("email").value;
	if ( email.length > 5 )
	{
		doAjax('/mbs/ajaxScripts/newPassword.php', 'E=' +  email, 'newPCallback','post',0);
	}
	else
		alert ("Please enter a valid email address.");
}

function checkEmail(field)
{
	var myRegExp = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	var email = document.getElementById(field).value;
	if ( !email.match(myRegExp) )
	{
		alert("The e-mail address does not appear to be valid.");
		document.getElementById(field).focus();
		return false;
	}
	else
	{
		doAjax('/mbs/ajaxScripts/newPassword.php', 'E=' +  email, 'newPCallback','post',0);
	}

} 
function newPCallback(text) {
	document.getElementById("newPasswordPanel").innerHTML = text;
}

function clearBoxes() {
	document.getElementById("f1").value = "";
	document.getElementById("f2").value = "";
}

function doFCLogin() {
	document.LOGINFORM.submit();
	clearBoxes();
}


function fcCheck() {
	var fcUser = document.getElementById('fcUser').value;
	var fcPassword = document.getElementById('fcPassword').value;
	doAjax('/mbs/ajaxScripts/password.php', 'FID=' + fcUser + '&FP=' + fcPassword + '&J=FC', 'myPasswordCallback','post',0);
}

function requestPassword() {
	var userID = document.getElementById("userID").value;
	if ( userID > 0 )
	{
		var passwordPanel = "<b>Please enter your password:</b><br />";
		passwordPanel += '<input type="password" id="passwd" onchange="checkPassword()"/>';
		passwordPanel += '<input type="hidden" id="userID" value="' + userID + '" />';
		passwordPanel += '<input type="button" value="Next" onclick="checkPassword()"/>';
		document.getElementById("mbsWebPanel").innerHTML = passwordPanel;
       // document.getElementById("newParentPrompt").innerHTML = 'New Parents: Password is 10-digit phone number.';
	}
	else
	{	
		alert("Please select your name from the list");
	}
}

function checkPassword() {
	var userID = document.getElementById("userID").value;
	var password = document.getElementById("passwd").value;
	doAjax('/mbs/ajaxScripts/password.php', 'UID=' + userID + '&P=' + password + '&J=U', 'myPasswordCallback','post',0);
}

function myPasswordCallback(text) {
	if ( text == "Done" )
		window.location.href="/mbs/user/genericUser.php";
	else	
		document.getElementById("mbsWebPanel").innerHTML = text;
}

function changePassword() {
	var oldP = document.getElementById("oldPassword").value;
	var newP = document.getElementById("newPassword").value;
	var confirmP = document.getElementById("confirmPassword").value;
	var userID = document.getElementById("userID").value;
	doAjax('/mbs/ajaxScripts/password.php', 'UID=' + userID + '&OP=' + oldP + '&NP=' + newP + '&CP=' + confirmP + '&J=C', 'myPasswordCallback','post',0);
}

function checkOldPassword() {
	var userID = document.getElementById("userID").value;
	var password = document.getElementById("oldPassword").value;
	doAjax('/mbs/ajaxScripts/password.php', 'UID=' + userID + '&P=' + password + '&J=V', 'myPasswordCallback2','post',0);
}

function myPasswordCallback2(text) {
	if ( text == "OK" )
		var myOK = text;
	else	
	{
		alert( text );
		document.getElementById("oldPassword").value = "";
		document.getElementById("oldPassword").focus();
	}
}

function checkLength ( myID, myNum) {
	var myLength = document.getElementById(myID).value.length;
	if ( myLength < myNum )
	{
		alert( "Please be sure your entry has at least " + myNum + " characters.");
		document.getElementById(myID).value = "";
		document.getElementById(myID).focus();	
	}
}

function showDiv( divName) {
	var myDiv = document.getElementById(divName);
	myDiv.setAttribute("style", "display:block");
	myDiv.style.cssText="display:block";	
}

function showInline( divName) {
	var myDiv = document.getElementById(divName);
	myDiv.setAttribute("style", "display:block");
	myDiv.style.cssText="display:inline";	
}

function hideDiv( divName) {
	var myDiv = document.getElementById(divName);
	myDiv.setAttribute("style", "display:none");
	myDiv.style.cssText="display:none";	
}


