function isEmail(theValue)	{
	var emailRegex=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	return emailRegex.test(theValue);
}
function openCustomWindow(url, width, height, winName)	{
	var width=width;
	var height=height;
	var left=(screen.availWidth - width) / 2;
	var top=(screen.availHeight - height) / 2;
	window.open(url, winName, 'top=' + top + ', left=' + left + ', scrollbars=yes,resizable=yes,toolbar=no,location=no,width='+width+',height='+height+'');
}

// Member Login Form

function checkMemberLoginForm(theForm)	{
	if(!document.forms[theForm].username.value.length)	{
		alert('Please enter your Username!');
		document.forms[theForm].username.focus();
		return false;
	} else if(!document.forms[theForm].password.value.length)	{
		alert('Please enter your Password!');
		document.forms[theForm].password.focus();
		return false;
	} else {
		return true;
	}
}

// Forgot Password Form

function checkForgotPassForm1(theForm)	{
	var emailRegex=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	if(!document.forms[theForm].emailAddress.value.length||!isEmail(document.forms[theForm].emailAddress.value))	{
		alert('Please enter an Email Address!');
		document.forms[theForm].emailAddress.focus();
		return false;
	} else {
		return true;
	}
}

function checkForgotPassForm2(theForm)	{
	if(!document.forms[theForm].newPassword.value.length)	{
		alert('Please enter a Password!');
		document.forms[theForm].newPassword.focus();
		return false;
	} else if(!document.forms[theForm].newPasswordConfirm.value.length)	{
		alert('Please Confirm your Password!');
		document.forms[theForm].newPasswordConfirm.focus();
		return false;
	} else if(document.forms[theForm].newPassword.value!=document.forms[theForm].newPasswordConfirm.value)	{
		alert('Passwords do not match, please try again!');
		document.forms[theForm].newPasswordConfirm.focus();
		return false;
	} else {
		return true;
	}
}

// Member Registration Form

function checkMemberRegistrationForm(theForm)	{
	var emailRegex=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	if(!document.forms[theForm].firstName.value.length)	{
		alert('Please enter your First Name!');
		document.forms[theForm].firstName.focus();
		return false;
	} else if(!document.forms[theForm].lastName.value.length)	{
		alert('Please enter your Last Name!');
		document.forms[theForm].lastName.focus();
		return false;
	} else if(!document.forms[theForm].emailAddress.value.length||!isEmail(document.forms[theForm].emailAddress.value))	{
		alert('Please enter your Email Address!');
		document.forms[theForm].emailAddress.focus();
		return false;
	} else if(!document.forms[theForm].address1.value.length)	{
		alert('Please enter your Address!');
		document.forms[theForm].address1.focus();
		return false;
	} else if(!document.forms[theForm].city.value.length)	{
		alert('Please enter your City/Province!');
		document.forms[theForm].city.focus();
		return false;
	} else if(!document.forms[theForm].state.options[document.forms[theForm].state.selectedIndex].value.length||(document.forms[theForm].state.selectedIndex==52&&!document.forms[theForm].stateOther.value.length))	{
		if(document.forms[theForm].state.selectedIndex==52&&!document.forms[theForm].stateOther.value.length)	{
			alert('Please enter a State/Territory!');
			document.forms[theForm].stateOther.focus();
		} else {
			alert('Please select a State/Territory!');
			document.forms[theForm].state.focus();
		}
		return false;
	} else if(!document.forms[theForm].zip.value.length)	{
		alert('Please enter your Zip/Postal Code!');
		document.forms[theForm].zip.focus();
		return false;
	} else if(document.forms[theForm].country.selectedIndex==0||(document.forms[theForm].state.options[document.forms[theForm].state.selectedIndex].value!='Other'&&document.forms[theForm].country.selectedIndex!=221))	{
		alert('Please select a Country!');
		document.forms[theForm].country.focus();
		return false;
	} else if(!document.forms[theForm].telephone.value.length)	{
		alert('Please enter your Home Phone Number!');
		document.forms[theForm].telephone.focus();
		return false;
	} else if(!document.forms[theForm].reference1Name.value.length)	{
		alert("Please enter your first Hobby Reference's Name!");
		document.forms[theForm].reference1Name.focus();
		return false;
	} else if(!document.forms[theForm].reference1Phone.value.length)	{
		alert("Please enter your first Hobby Reference's Phone Number!");
		document.forms[theForm].reference1Phone.focus();
		return false;
	} else if(!document.forms[theForm].reference2Name.value.length)	{
		alert("Please enter your second Hobby Reference's Name!");
		document.forms[theForm].reference2Name.focus();
		return false;
	} else if(!document.forms[theForm].reference2Phone.value.length)	{
		alert("Please enter your second Hobby Reference's Phone Number!");
		document.forms[theForm].reference2Phone.focus();
		return false;
	} else if(!document.forms[theForm].username.value.length)	{
		alert('Please enter a Username!');
		document.forms[theForm].username.focus();
		return false;
	} else if(!document.forms[theForm].password.value.length)	{
		alert('PLease enter a Password!');
		document.forms[theForm].password.focus();
		return false;
	} else if(!document.forms[theForm].passwordConfirm.value.length)	{
		alert('Please confirm your Password!');
		document.forms[theForm].passwordConfirm.focus();
		return false;
	} else if(document.forms[theForm].password.value!=document.forms[theForm].passwordConfirm.value)	{
		alert('Your Passwords do not match!');
		document.forms[theForm].passwordConfirm.focus();
		return false;
	} else {
		return true;
	}
}

// Member Profile

function checkMemberProfileForm(theForm)	{
	var emailRegex=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	if(!document.forms[theForm].firstName.value.length)	{
		alert('Please enter your First Name!');
		document.forms[theForm].firstName.focus();
		return false;
	} else if(!document.forms[theForm].lastName.value.length)	{
		alert('Please enter your Last Name!');
		document.forms[theForm].lastName.focus();
		return false;
	} else if(!document.forms[theForm].emailAddress.value.length||!isEmail(document.forms[theForm].emailAddress.value))	{
		alert('Please enter your Email Address!');
		document.forms[theForm].emailAddress.focus();
		return false;
	} else if(!document.forms[theForm].address1.value.length)	{
		alert('Please enter your Address!');
		document.forms[theForm].address1.focus();
		return false;
	} else if(!document.forms[theForm].city.value.length)	{
		alert('Please enter your City/Province!');
		document.forms[theForm].city.focus();
		return false;
	} else if(!document.forms[theForm].state.options[document.forms[theForm].state.selectedIndex].value.length||(document.forms[theForm].state.selectedIndex==52&&!document.forms[theForm].stateOther.value.length))	{
		if(document.forms[theForm].state.selectedIndex==52&&!document.forms[theForm].stateOther.value.length)	{
			alert('Please enter a State/Territory!');
			document.forms[theForm].stateOther.focus();
		} else {
			alert('Please select a State/Territory!');
			document.forms[theForm].state.focus();
		}
		return false;
	} else if(!document.forms[theForm].zip.value.length)	{
		alert('Please enter your Zip/Postal Code!');
		document.forms[theForm].zip.focus();
		return false;
	} else if(document.forms[theForm].country.selectedIndex==0||(document.forms[theForm].state.options[document.forms[theForm].state.selectedIndex].value!='Other'&&document.forms[theForm].country.selectedIndex!=221))	{
		alert('Please select a Country!');
		document.forms[theForm].country.focus();
		return false;		
	} else if(!document.forms[theForm].telephone.value.length)	{
		alert('Please enter your Home Phone Number!');
		document.forms[theForm].telephone.focus();
		return false;
	} else if(!document.forms[theForm].username.value.length)	{
		alert('Please enter a Username!');
		document.forms[theForm].username.focus();
		return false;
	} else if(!document.forms[theForm].password.value.length)	{
		alert('PLease enter a Password!');
		document.forms[theForm].password.focus();
		return false;
	} else if(!document.forms[theForm].passwordConfirm.value.length)	{
		alert('Please confirm your Password!');
		document.forms[theForm].passwordConfirm.focus();
		return false;
	} else if(document.forms[theForm].password.value!=document.forms[theForm].passwordConfirm.value)	{
		alert('Your Passwords do not match!');
		document.forms[theForm].passwordConfirm.focus();
		return false;
	} else {
		return true;
	}
}











