function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.newsletter.emailField
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

function ValidateWholesaleForm(){
	
	var emailID0=document.wholesale.emailField
	var emailID1=document.wholesale.emailFieldConfirm
	var contactName=document.wholesale.contactName
	var storeName=document.wholesale.storeName
	var storeAddress=document.wholesale.storeAddress
	var phone=document.wholesale.phone
	var storeSite=document.wholesale.storeWebsite
	
	if ((contactName.value==null)||(contactName.value=="")){
	  alert("< Contact name > is required")
	  contactName.focus()
	  return false
	}
	if ((storeName.value==null)||(storeName.value=="")){
	  alert("< Store name > is required")
	  storeName.focus()
	  return false
	}
	if ((storeAddress.value==null)||(storeAddress.value=="")){
	  alert("< Store address > is required")
	  storeAddress.focus()
	  return false
	}	
	
	if ((emailID0.value==null)||(emailID0.value=="")){
	  alert("< Email > is required")
	  emailID0.focus()
	  return false
	}
	if ((emailID1.value==null)||(emailID1.value=="")){
	  alert("Please confirm your email address")
	  emailID1.focus()
	  return false
	}

	if ((echeck(emailID0.value)==false)||(echeck(emailID1.value)==false)){
	  emailID0.value=""
	  emailID1.value=""
	  emailID0.focus()
	  return false
	}
	if (emailID0.value!=emailID1.value){
	  alert("Please make sure the email fields match.")
		emailID0.value=""
		emailID1.value=""
		emailID0.focus()
		return false
	}

	return true
 }

function poptastic(url)
{
	var newwindow;
	
	newwindow=window.open(url,'name','height=400,width=400');
	if (window.focus) {newwindow.focus()}
}

