function checkEnterEmail(e, form){
var characterCode
	 if(e && e.which){
	 e = e
	 characterCode = e.which
	 }
	 else{
	 e = event
	 characterCode = e.keyCode
	 }	 
	 if(characterCode == 13){
if (emailvalidate(form)){
form.submit();
}
 	 return false
	 }
return true
	
}

function checkEnterSearch(e, form){
var characterCode
	 if(e && e.which){
	 e = e
	 characterCode = e.which
	 }
	 else{
	 e = event
	 characterCode = e.keyCode
	 }	 
	 if(characterCode == 13){
if (searchvalidate(form)){
form.submit();
}
 	 return false
	 }
return true
	
}

function checkEnterLogin(e, form){
var characterCode
	 if(e && e.which){
	 e = e
	 characterCode = e.which
	 }
	 else{
	 e = event
	 characterCode = e.keyCode
	 }	 
	 if(characterCode == 13){
if (loginvalidate(form)){
form.submit();
}
 	 return false
	 }
return true
	
}

function checkEnterChangePwd(e, form){
var characterCode
	 if(e && e.which){
	 e = e
	 characterCode = e.which
	 }
	 else{
	 e = event
	 characterCode = e.keyCode
	 }	 
	 if(characterCode == 13){
if (changepwdvalidate(form)){
form.submit();
}
 	 return false
	 }
return true
	
}

function checkEnterHabitat(e, form){
var characterCode
	 if(e && e.which){
	 e = e
	 characterCode = e.which
	 }
	 else{
	 e = event
	 characterCode = e.keyCode
	 }	 
	 if(characterCode == 13){
if (validate(form)){
form.submit();
}
 	 return false
	 }
return true
	
}

function checkEnterEdit(e, form){
var characterCode
	 if(e && e.which){
	 e = e
	 characterCode = e.which
	 }
	 else{
	 e = event
	 characterCode = e.keyCode
	 }	 
	 if(characterCode == 13){
if (editvalidate(form)){
form.submit();
}
 	 return false
	 }
return true
	
}

function checkEnterEnquiry(e, form){
var characterCode
	 if(e && e.which){
	 e = e
	 characterCode = e.which
	 }
	 else{
	 e = event
	 characterCode = e.keyCode
	 }	 
	 if(characterCode == 13){
if (enquiryvalidate(form)){
form.submit();
}
 	 return false
	 }
return true
	
}

function emailvalidate(form)
{

checkEmail = form.txtEmail.value

aliaspos = checkEmail.indexOf("@")
dotpos = checkEmail.lastIndexOf(".")

if (checkEmail.length < 1){
alert("Please enter your e-mail")
return false
}
else if (aliaspos == -1 || dotpos == -1)
{ alert ("Not a valid e-mail");
return false
}
return true
}

function enquiryvalidate(form)
{
checkUserName = form.txtUsername.value
checkEmail = form.txtEmail.value
checkCountry = form.cbbCountry.selectedIndex
checkMessage = form.txaMessage.value

aliaspos = checkEmail.indexOf("@")
dotpos = checkEmail.lastIndexOf(".")

if (checkUserName.length < 1){
alert("Please enter your name")
return false
}
else if (checkEmail.length < 1){
alert("Please enter your e-mail")
return false
}
else if (aliaspos == -1 || dotpos == -1)
{ alert ("Not a valid e-mail")
return false
}
else if (checkCountry == 0){
alert("Please enter your country")
return false
}
else if (checkMessage.length < 1){
alert("Please enter your message")
return false
}
return true
}


function validate(form)
{
checkUserName = form.txtUsername.value
checkPassword = form.txtPassword.value
checkConfirmPassword = form.txtConfirmPassword.value
checkFirstName = form.txtFirstName.value
checkState = form.cbbState.value
checkEmail = form.txtEmail.value
checkVerifyEmail = form.txtVerifyEmail.value
checkGender = form.cbbGender.selectedIndex
checkCountry = form.cbbCountry.selectedIndex
checkDOBDay = form.cbbDOBDay.selectedIndex
checkDOBMonth = form.cbbDOBMonth.selectedIndex
checkDOBYear =form.cbbDOBYear.selectedIndex

aliaspos = checkEmail.indexOf("@")
dotpos = checkEmail.lastIndexOf(".")

if (checkUserName.length < 1){
alert("Please enter your name")
return false
}
else if (checkPassword.length < 1){
alert("Please enter your password")
return false
}
else if (checkConfirmPassword.length < 1 || checkConfirmPassword != checkPassword){
alert("Please reenter your password")
return false
}
else if (checkDOBDay == 0 || checkDOBMonth == 0 || checkDOBYear == 0){
alert("Please enter your date of birth")
return false
}
else if (checkEmail.length < 1){
alert("Please enter your e-mail")
return false
}
else if (aliaspos == -1 || dotpos == -1)
{ alert ("Not a valid e-mail")
return false
}
else if (checkVerifyEmail.length < 1 || checkEmail != checkVerifyEmail){
alert("Please reenter your e-mail")
return false
}
else if (checkFirstName.length < 1 ){
alert("Please enter your first name")
return false
}
else if (checkGender== 0){
alert("Please enter your gender")
return false
}
else if (checkState.length < 1){
alert("Please enter your state")
return false
}
else if (checkCountry == 0){
alert("Please enter your country")
return false
}
return true

}

function editvalidate(form)
{
checkFirstName = form.txtFirstName.value
checkState = form.cbbState.value
checkEmail = form.txtEmail.value
checkGender = form.cbbGender.selectedIndex
checkCountry = form.cbbCountry.selectedIndex
checkDOBDay = form.cbbDOBDay.selectedIndex
checkDOBMonth = form.cbbDOBMonth.selectedIndex
checkDOBYear =form.cbbDOBYear.selectedIndex

aliaspos = checkEmail.indexOf("@")
dotpos = checkEmail.lastIndexOf(".")


if (checkDOBDay == 0 || checkDOBMonth == 0 || checkDOBYear == 0){
alert("Please enter your date of birth")
return false
}
else if (checkEmail.length < 1){
alert("Please enter your e-mail")
return false
}
else if (aliaspos == -1 || dotpos == -1)
{ alert ("Not a valid e-mail")
return false
}
else if (checkFirstName.length < 1 ){
alert("Please enter your first name")
return false
}
else if (checkGender== 0){
alert("Please enter your gender")
return false
}
else if (checkState.length < 1){
alert("Please enter your state")
return false
}
else if (checkCountry == 0){
alert("Please enter your country")
return false
}
return true

}

function agreevalidate(form)
{
checkagree = form.chbAgree
if (!checkagree.checked){
alert("Please agree to the terms and conditions to proceed.")
return false}
return true
}

function changepwdvalidate(form)
{
	checkOldPassword=form.txtOldPassword.value
	checkNewPassword=form.txtNewPassword.value
	checkConfirmPassword=form.txtConfirmPassword.value
	if (checkOldPassword.length < 1 || checkNewPassword.length < 1 || checkConfirmPassword.length < 1){
alert("Please enter your password")
return false
}
else if (checkConfirmPassword != checkNewPassword){
alert("Please reenter your password")
return false
}
return true	
}

function loginvalidate(form)
{
checkusername = form.txtUsername.value 	
checkpassword = form.txtPassword.value
if (checkusername.length < 1 || checkpassword.length < 1)
{alert("Please enter your user name and password");
return false}
return true
}

function searchvalidate(form)
{
checkSearch = form.txtSearch.value 	
if (checkSearch.length < 1)
{alert("Please enter keyword to search");
return false}
return true
}

// ANTI-SPAM

	function antispam(name,domain) {
    	document.location = "mailto:" + name + "@" + domain;
	}

