function popthanks(){
    document.getElementById("survey_div").style.display="none";
    showdeadcenterdiv(400,100,"thanksalert");
}

function ValidateForm_survey(){
	var emailID=document.getElementById('fields_email_survey');
    var brand=document.getElementsByName('brand_survey');
    var name=document.getElementById('fields_fname_survey');
    
    if(validate_brand(brand)==false ){
         return false;
    }

    if(validate_name(name.value)==false ){
         return false;
    }

    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 submitBridgestone_survey(name,email){
    document.Bridgestone_survey.fields_fname.value=name;
    document.Bridgestone_survey.fields_email.value=email;
    document.Bridgestone_survey.submit();
}

function submitTitleist_survey(name,email){
    document.Titleist_survey.fields_fname.value=name;
    document.Titleist_survey.fields_email.value=email;
    document.Titleist_survey.submit();
}

function submitSrixon_survey(name,email){
    document.Srixon_survey.fields_fname.value=name;
    document.Srixon_survey.fields_email.value=email;
     document.Srixon_survey.submit();
}

function submitCallaway_survey(name,email){
    document.Callaway_survey.fields_fname.value=name;
    document.Callaway_survey.fields_email.value=email;
     document.Callaway_survey.submit();
}

function submitother_survey(name,email){
    document.other_survey.fields_fname.value=name;
    document.other_survey.fields_email.value=email;
    document.other_survey.submit();
}

function validate_brand(brand){
   var len = brand.length;

   var choice = "";

   for (i = 0; i <len; i++) {
        if (brand[i].checked) {
        choice = brand[i].value;
        }
   }


   if (choice == "" || choice == null ) {
       alert("Please choose a brand");
       return false;
   }
   return true;

}

function validate_name(name){
     if(name=="" || name==null){
       alert("Please enter your name");
       return false;
     }
     return true;
}

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
}
