function QuestionValid(theForm){

if (theForm.fullname.value=="Full Name"){
	alert("Please type in your name")
	theForm.fullname.focus()
	return false}

if (theForm.femail.value=="Email"){
	alert("Please type in your email address")
	theForm.femail.focus()
	return false}

if (emailCheck(theForm.femail.value)==false){
	alert("Please type in a valid email address")
	theForm.femail.focus()
	return false}

if (theForm.fQuestion.value=="Enter your questions here"){
	alert("Please type in your questions")
	theForm.fQuestion.focus()
	return false}

return true;
}

function EmailFriendValid(theForm){

if (theForm.fullname.value=="Your Name"){
	alert("Please type in your name")
	theForm.fullname.focus()
	return false}

if (theForm.femail.value=="Your Email Address"){
	alert("Please type in your email address")
	theForm.femail.focus()
	return false}

if (emailCheck(theForm.femail.value)==false){
	alert("Please type in a valid email address")
	theForm.femail.focus()
	return false}

if (theForm.friendemail.value=="Friends Email Address"){
	alert("Please type in your friends email address")
	theForm.friendemail.focus()
	return false}

if (emailCheck(theForm.friendemail.value)==false){
	alert("Please type in a valid email address")
	theForm.friendemail.focus()
	return false}

theForm.ProductPage.value=location.href

return true;
}



function emailCheck (emailStr) {
var checkTLD=0;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
return false;
}
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
return false;
}
}
if (user.match(userPat)==null) {
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray>255) {
return false;
}
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
return false;
}
}
if (len<2) {
return false;
}
return true;
}

function ClearQForm(){
	document.QuestionForm.fullname.value="Full Name"
	document.QuestionForm.fullname.style.color = '#999'	
	document.QuestionForm.femail.value="Email"
	document.QuestionForm.femail.style.color = '#999'	
	document.QuestionForm.ContactNumber.value="Contact Number"
	document.QuestionForm.ContactNumber.style.color = '#999'	
	document.QuestionForm.fQuestion.value="Enter your questions here"
	document.QuestionForm.fQuestion.style.color = '#999'	
}

function ClearSendFriendForm(){
	document.EmailFriendForm.fullname.value="Your Name"
	document.EmailFriendForm.fullname.style.color = '#999'	
	document.EmailFriendForm.femail.value="Your Email Address"
	document.EmailFriendForm.femail.style.color = '#999'	
	document.EmailFriendForm.friendemail.value="Friends Email Address"
	document.EmailFriendForm.friendemail.style.color = '#999'	
	document.EmailFriendForm.fComment.value="Enter a comment here"
	document.EmailFriendForm.fComment.style.color = '#999'	
}
