// login and form related functions

function acValidateLogin(){
	var validLogin = true;
	validLogin = ((document.loginform.LoginID.value.length > 0) &&
		(document.loginform.Password.value.length > 0));
	if (!validLogin)
		alert ("Please specify a login ID and a password.");
	return validLogin;
}

function validateComment(){
	var dataIsValid = true;
	if (((document.leavecomment.Name.value.length == 0) ||
		(document.leavecomment.Comments.value.length == 0)) ||
		((document.leavecomment.Email.value == 0) && (document.leavecomment.Telephone.value.length == 0))){
		alert("Please specify at least a name and a comment and either an email or telephone number");
		dataIsValid = false;
	}
	return dataIsValid;
}

function validateGuess(){
	var dataIsValid = true;
	if (((document.andyguess.Name.value.length == 0) ||
		(document.andyguess.Guess.value.length == 0)) ||
		((document.andyguess.Email.value == 0) && (document.andyguess.Telephone.value.length == 0))){
		alert("Please specify at least a name and a guess and either an email or telephone number");
		dataIsValid = false;
	}
	return dataIsValid;
}

function validateQuestion(){
	var dataIsValid = true;
	if (((document.andyquestion.Name.value.length == 0) ||
		(document.andyquestion.question.value.length == 0)) ||
		((document.andyquestion.Email.value == 0) && (document.andyquestion.Telephone.value.length == 0))){
		alert("Please specify at least a name and a question or comment and either an email or telephone number");
		dataIsValid = false;
	}
	return dataIsValid;
}

function acValidateNewLogin(){ 
	if (!acNewLoginMinFields()) 
		return false; 
	if (!acValidPassword(document.newloginform.Password)) 
		return false; 
	if (!acPasswordsMatch(document.newloginform.Password, document.newloginform.Password2)) 
		return false; 
	return true;
}

function acNewLoginMinFields(){
	if ((document.newloginform.Name.value.length > 0) &&
		(document.newloginform.Company.value.length > 0) &&
		(document.newloginform.Address.value.length > 0) &&
		(document.newloginform.City.value.length > 0) &&
		(document.newloginform.State.value.length > 0) &&
		(document.newloginform.LoginID.value.length > 0))
	return true;
	alert("Please specify at least Name, Company, Address, City, State, and Email, and LoginID");
	return false;
}

function acPasswordsMatch(Password1, Password2){
	if (Password1.value == Password2.value)
		return true;
	alert("Your passwords don't match, try again.");
	return false;
}

function acValidPassword(password){
	if (document.newloginform.Password.value.length > 7)
		return true;
	alert("Your passwords must be at least 8 characters, try again.");
	return false;
}

function acLoginUnique(){
	if (GetCookie("LoginIDUnique") != 'true')
		document.write("Login ID is not unique, try again.");
}


function acValidateLostLogin(){
	var validLostLogin = true;
	validLostLogin = (document.lostloginform.Email.value.length > 0);
	if (!validLostLogin )
		alert("Please specify the email address you used to create the login.");
	return validLostLogin;
}

function validateComment(){
	var dataIsValid = true;
	if (((document.leavecomment.Name.value.length == 0) ||
		(document.leavecomment.Comments.value.length == 0)) ||
		((document.leavecomment.Email.value == 0) && (document.leavecomment.Telephone.value.length == 0))){
		alert("Please specify at least a name and a comment and either an email or telephone number");
		dataIsValid = false;
	}
	return dataIsValid;
}
