// start - for the registration section only
function fContactFormValidation(oForm)
{
	var sValue = "";
	var sStyleColor = "#ff0000";
	var bValid = true;
	if (oForm.name.value == "enter your display name" || oForm.name.value == "")
	{
		oForm.name.value = "enter your display name";
		oForm.name.style.color = sStyleColor;
		bValid = false;
	}	
	if (oForm.email.value == "enter your email" || oForm.email.value == "")
	{
		oForm.email.value = "enter your email";
		oForm.email.style.color = sStyleColor;
		bValid = false;
	}
	else
	{
		/*
		if (!isValidEmail(oForm.email.value))
		{
			oForm.email.value = "enter valid email";
			oForm.email.style.color = sStyleColor;
			bValid = false;
		}
		*/
	}
	if (oForm.password.value == "enter your password" || oForm.password.value == "")
	{
		oForm.password.value = "enter your password";
		oForm.password.style.color = sStyleColor;
		bValid = false;
	}	
	if (oForm.postalcode.value == "enter your postal code" || oForm.postalcode.value == "")
	{
		oForm.postalcode.value = "enter your postal code";
		oForm.postalcode.style.color = sStyleColor;
		bValid = false;
	}
	else
	{	
		/*
		if (!validateUSZip(oForm.postalcode.value))
		{
			oForm.postalcode.value = "enter valid postal code";
			oForm.postalcode.style.color = sStyleColor;
			bValid = false;
		}
		*/
	}	
	if (oForm.confirmpassword.value == "confirm your password" || oForm.confirmpassword.value == "")
	{
		oForm.confirmpassword.value = "";
		oForm.confirmpassword.style.color = sStyleColor;
		oForm.password.value = "";
		oForm.password.style.color = sStyleColor;
		alert("passwords do not match. please re-enter.");
		bValid = false;
	}
	else if (oForm.confirmpassword.value != oForm.password.value)
	{
		oForm.confirmpassword.value = "";
		oForm.confirmpassword.style.color = sStyleColor;
		oForm.password.value = "";
		oForm.password.style.color = sStyleColor;
		alert("passwords do not match. please re-enter.");
		bValid = false;
	}
	if (!oForm.over13.checked && bValid)
	{
		alert("HiHenry.com does not seek to collect information from individuals 13 years of age and younger nor do we knowingly collect personal information from children under 13 through the service. PLEASE CONFIRM THAT YOU ARE OVER 13 YEARS OF AGE.");
		bValid = false;
	}
	
	
	return bValid;
	
}
function fResetContactForm()
{
	document.registration.name.value = "";
	document.registration.email.value = "";
	document.registration.password.value = "";
	document.registration.confirmpassword.value = "";
	document.registration.postalcode.value = "";

	document.registration.name.style.color = "#888888";
	document.registration.email.style.color = "#888888";
	document.registration.password.style.color = "#888888";
	document.registration.confirmpassword.style.color = "#888888";
	document.registration.postalcode.style.color = "#888888";
	
	return false;
}

function fContactInputOnClick(oInput)
{
	if (oInput.name == "name" && (oInput.value == "" || oInput.value == "enter your display name"))
	{
		oInput.value = "";
		oInput.style.color = "#555555";
	}
	if (oInput.name == "email" && (oInput.value == "" || oInput.value == "enter your email" || oInput.value == "enter valid email"))
	{
		oInput.value = "";
		oInput.style.color = "#555555";
	}
	if (oInput.name == "password" && (oInput.value == "" || oInput.value == "enter your password"))
	{
		oInput.value = "";
		oInput.style.color = "#555555";
	}
	if (oInput.name == "confirmpassword" && (oInput.value == "" || oInput.value == "confirm your password"))
	{
		oInput.value = "";
		oInput.style.color = "#555555";
	}
	if (oInput.name == "postalcode" && (oInput.value == "" || oInput.value == "enter your postal code" || oInput.value == "enter valid postal code"))
	{
		oInput.value = "";
		oInput.style.color = "#555555";
	}
}

function fContactInputOnBlur(oInput)
{
	var sValue = "";
	var sStyleColor = "#888888";
	
	if (oInput.name ==  "name")
	{
		sValue = "";
		fCheckUsername();
	}
	else if (oInput.name == "email")
	{
		sValue = "";
		fCheckEmail();
	}
	else if (oInput.name == "password")
		sValue = "";
	else if (oInput.name == "confirmpassword")
		sValue = "";
	else if (oInput.name == "postalcode")
		sValue = "";

	if (oInput.value == "")
	{
		oInput.value = sValue;
		oInput.style.color = sStyleColor;
	}
	else
	{
		oInput.style.color = "#555555";
	}
}
// end - for the registration section only


// start - for the registration confirmation section only
function fConfirmValidation(oForm)
{
	var sValue = "";
	var sStyleColor = "#ff0000";
	var bValid = true;
	if (oForm.email.value == "enter your email" || oForm.email.value == "")
	{
		oForm.email.value = "enter your email";
		oForm.email.style.color = sStyleColor;
		bValid = false;
	}	
	if (oForm.validationcode.value == "enter your code" || oForm.validationcode.value == "")
	{
		oForm.validationcode.value = "enter your code";
		oForm.validationcode.style.color = sStyleColor;
		bValid = false;
	}
	return bValid;
	
}
function fResetConfirmForm()
{
	document.registration.email.value = "enter your email";
	document.registration.validationcode.value = "enter your code";

	document.registration.email.style.color = "#888888";
	document.registration.validationcode.style.color = "#888888";
	
	return false;
}

function fConfirmInputOnClick(oInput)
{
	oInput.value = "";
	oInput.style.color = "#555555";
}

function fConfirmInputOnBlur(oInput)
{
	var sValue = "";
	var sStyleColor = "#888888";
	
	if (oInput.name == "email")
		sValue = "enter your email";
	else if (oInput.name == "validationcode")
		sValue = "enter your code";

	if (oInput.value == "")
	{
		oInput.value = sValue;
		oInput.style.color = sStyleColor;
	}
	else
	{
		oInput.style.color = "#555555";
	}
}
// end - for the registration section only

// start - for the write review confirmation section only
function fWriteReviewValidation(oForm)
{
	var sValue = "";
	var sStyleColor = "#ff0000";
	var bValid = true;
	if (oForm.review.value == "write your experience" || oForm.review.value == "")
	{
		oForm.review.value = "write your experience";
		oForm.review.style.color = sStyleColor;
		bValid = false;
	}	
	else if (oForm.review.value.length < 100)
	{
		document.getElementById("reviewerror").innerHTML = "<b style=\"color:#ff0000;\">Review must be of a minimum 100 characters</b><br><br>";
		bValid = false;
	}
	
	if (oForm.reviewtitle.value == "title your review" || oForm.reviewtitle.value == "")
	{
		oForm.reviewtitle.value = "title your review";
		oForm.reviewtitle.style.color = sStyleColor;
		bValid = false;
	}
	
	if (document.writereviews.rating_food.value == "0" || document.writereviews.rating_food.value == "" || document.writereviews.rating_value.value == "0" || document.writereviews.rating_value.value == "" || document.writereviews.rating_service.value == "0" || document.writereviews.rating_service.value == "" || document.writereviews.rating_atmosphere.value == "0" || document.writereviews.rating_atmosphere.value == "")
	{
		alert("You must give rating to the restaurant.");
		bValid = false;
	}

	/*	
	if (bValid == true)
	{
		document.getElementById("inputreviews").style.display = "none";
		document.getElementById("previewreviews").innerHTML = "<b style=\"color:#ff0000;\">Confirm Your Review</b><br><br><b>" + oForm.reviewtitle.value + "</b><br><br>" + oForm.review.value;
		document.getElementById("previewreviews").style.display = "block";
		document.getElementById("previewreviewsbuttons").style.display = "block";
	}
	*/
	return bValid;
	
}


// start - for the write review confirmation section only
function fWriteReviewValidationAnonymous(oForm)
{
	var sValue = "";
	var sStyleColor = "#ff0000";
	var bValid = true;
	if (oForm.review.value == "write your experience" || oForm.review.value == "")
	{
		oForm.review.value = "write your experience";
		oForm.review.style.color = sStyleColor;
		bValid = false;
	}	
	else if (oForm.review.value.length < 100)
	{
		document.getElementById("reviewerror").innerHTML = "<b style=\"color:#ff0000;\">Review must be of a minimum 100 characters</b><br><br>";
		bValid = false;
	}
	
	if (oForm.reviewtitle.value == "title your review" || oForm.reviewtitle.value == "")
	{
		oForm.reviewtitle.value = "title your review";
		oForm.reviewtitle.style.color = sStyleColor;
		bValid = false;
	}
	
	if (document.writereviews.rating_food.value == "0" || document.writereviews.rating_food.value == "" || document.writereviews.rating_value.value == "0" || document.writereviews.rating_value.value == "" || document.writereviews.rating_service.value == "0" || document.writereviews.rating_service.value == "" || document.writereviews.rating_atmosphere.value == "0" || document.writereviews.rating_atmosphere.value == "")
	{
		alert("You must give rating to the restaurant.");
		bValid = false;
	}

	if (bValid == true && oForm.user_anonymous.value == "no")
	{
		alert("Thank you for your review.  It is contributing reviewers such as yourself that make HiHenry the most informative site of its kind. Your review will be up within the next few minutes");
	}
	
	return bValid;
	
}





function fResetWriteReviewForm()
{
	document.writereviews.review.value = "write your experience";
	document.writereviews.reviewtitle.value = "title your review";

	document.writereviews.review.style.color = "#888888";
	document.writereviews.reviewtitle.style.color = "#888888";
	
	return false;
}

function fWriteReviewInputOnClick(oInput)
{
	if (oInput.name == "reviewtitle" && (oInput.value == "" || oInput.value == "title your review"))
	{
		oInput.value = "";
		oInput.style.color = "#555555";
	}
	if (oInput.name == "review" && (oInput.value == "" || oInput.value == "write your experience"))
	{
		oInput.value = "";
		oInput.style.color = "#555555";
	}
}

function fWriteReviewInputOnBlur(oInput)
{
	var sValue = "";
	var sStyleColor = "#888888";
	
	if (oInput.name == "review")
		sValue = "write your experience";
	else if (oInput.name == "reviewtitle")
		sValue = "title your review";

	if (oInput.value == "")
	{
		oInput.value = sValue;
		oInput.style.color = sStyleColor;
	}
	else
	{
		oInput.style.color = "#555555";
	}
}
// end - for the write review section only

// start - for the email friend section only
function fEmailFriendValidation(oForm)
{
	var sValue = "";
	var sStyleColor = "#ff0000";
	var bValid = true;
	if (oForm.friendemail.value == "your friend's email" || oForm.friendemail.value == "")
	{
		oForm.friendemail.value = "your friend's email";
		oForm.friendemail.style.color = sStyleColor;
		bValid = false;
	}	
	return bValid;
	
}
function fResetFriendForm()
{
	document.emailfriend.friendemail.value = "your friend's email";

	document.emailfriend.friendemail.style.color = "#888888";
	
	return false;
}

function fEmailFriendInputOnClick(oInput)
{
	oInput.value = "";
	oInput.style.color = "#555555";
}

function fEmailFriendInputOnBlur(oInput)
{
	var sValue = "";
	var sStyleColor = "#888888";
	
	if (oInput.name == "friendemail")
		sValue = "your friend's email";

	if (oInput.value == "")
	{
		oInput.value = sValue;
		oInput.style.color = sStyleColor;
	}
	else
	{
		oInput.style.color = "#555555";
	}
}
// end - for the email friend  section only

// start - for the user login section only
function fLoginValidation(oForm)
{
	var sValue = "";
	var sStyleColor = "#ff0000";
	var bValid = true;
	if (oForm.useremail.value == "enter your email" || oForm.useremail.value == "")
	{
		oForm.useremail.value = "enter your email";
		oForm.useremail.style.color = sStyleColor;
		bValid = false;
	}	
	if (oForm.userpassword.value == "enter your password" || oForm.userpassword.value == "")
	{
		oForm.userpassword.style.color = sStyleColor;
		bValid = false;
	}	
	return bValid;
	
}
function fResetLoginForm()
{
	document.login.useremail.value = "enter your email";
	document.login.userpassword.value = "enter your password";

	document.login.useremail.style.color = "#888888";
	document.login.userpassword.style.color = "#888888";
	
	return false;
}

function fLoginInputOnClick(oInput)
{
	oInput.value = "";
	oInput.style.color = "#555555";
}

function fLoginInputOnBlur(oInput)
{
	var sValue = "";
	var sStyleColor = "#888888";
	
	if (oInput.name == "useremail")
		sValue = "enter your email";
	else if (oInput.name == "userpassword")
		sValue = "enter your password";

	if (oInput.value == "")
	{
		oInput.value = sValue;
		oInput.style.color = sStyleColor;
	}
	else
	{
		oInput.style.color = "#555555";
	}
}
// end - for the user login section only






function ToggleDisplay(Items)
{
	if ((document.getElementById(Items).style.display == "") || (document.getElementById(Items).style.display == "none"))	
	{
		document.getElementById(Items).style.display = "block";
	}
	else 
	{
		document.getElementById(Items).style.display = "none";
	}
}

function isValidEmail(str)
{
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}

function validateUSZip( strValue ) 
{
	if (strValue != "")
	{
		var objRegExp  = /^\D{1}\d{1}\D{1}\ ?\d{1}\D{1}\d{1}$/;
		return objRegExp.test(strValue);
	}
	else
		return true;
	
}

function fPopupWindow(location, popW, popH)
{
	var w = 480, h = 340
	if (document.all) 
	{
		/* the following is only available after onLoad */
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	}
	else if (document.layers) 
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;		
	popup = window.open(location,'submitter','width=' + popW + ',height=' + popH + ',scrollbars=0,top=' + topPos + ',left=' + leftPos);            
}

