$(document).ready(function(){
	$("#resend_confirm_letter").click(function(){
		
		var addr=prompt("please enter your email address then press ok!","");

		if(addr !=null){
			if(checkMail(addr))
			{	
				$.post("resendconfirm.php", { email: addr } ,function(data)
				{
					if(data=='send')
					{
						alert("The confirm letter send!")
					}
					if(data=='empty')
					{
						alert("This account doesn't exsists!!")
					}
					if(data=='sent')
					{
						alert("This account already passed confirm!")
					}
				});
			}
		}
	});
});
function checkMail(email)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)){alert('error email format!!');return false;}else{return true;}
}
function CheckPassword(TheForm)
        {
          if ( TheForm.email.value =="" || TheForm.email.value !="" &&  ! /^[_\.\d\w\-]+@([\d\w][\d\w\-]+\.)+[\w]{2,3}$/.test(TheForm.email.value)) 
            { 
              alert("Email address error! Please check your Email again."); 
              TheForm.email.focus();
              return (false); 
            } 

          if ((TheForm.password1.value != TheForm.password2.value) ||
               TheForm.password1.value =='' ||
               TheForm.password2.value =='')
            {
              alert ("Your password and confirm password are not the same.");
              return(false);
            }
          else
            {
              return(true);
            }
        }

function CheckMyEmail(TheForm)
        {
          if ( TheForm.email.value =="" || TheForm.email.value !="" &&  ! /^[_\.\d\w\-]+@([\d\w][\d\w\-]+\.)+[\w]{2,3}$/.test(TheForm.email.value)) 
            { 
              alert("Email address error! Please check your Email again."); 
              TheForm.email.focus();
              return (false); 
            } 
          else
            {
              return(true);
            }
        }


function CheckPassword1(TheForm)
        {
          if (TheForm.email.value =='')
            {
              alert ("Please Input your email !");
              return(false);
            }

          if (TheForm.password.value =='')
            {
              alert ("Please Input your password !");
              return(false);
            }
          else
            {
              return(true);
            }

         
        }


function CheckInfo(TheForm)
        {
          if ((TheForm.password1.value != TheForm.password2.value) ||
               TheForm.password1.value =='' ||
               TheForm.password1.value =='')
            {
              alert ("Recheck your Password.");
              return(false);
            }
          if (TheForm.first_name.value=='' || TheForm.first_name.value=='-' || TheForm.last_name.value=='' || TheForm.last_name.value=='-')
            {
              alert ("Recheck your Name.");
              TheForm.first_name.focus();
              return(false);
            }

          if (! TheForm.company.value || TheForm.company.value=='-')
            {
              alert("Recheck your company name.");
              TheForm.company.focus();
              return(false);
            }
         
          if (! TheForm.tel_country.value || ! TheForm.tel_area.value || ! TheForm.tel_phone.value || TheForm.tel_country.value=='-' || TheForm.tel_area.value=='-' || TheForm.tel_phone.value=='-')
            {
              alert("Recheck your phone numnber.");
              TheForm.tel_country.focus();
              return(false);
            }

          if (! TheForm.fax_country.value || ! TheForm.fax_area.value || ! TheForm.fax_phone.value)
            {
              alert("Recheck your fax numnber.");
              TheForm.fax_country.focus(); 
              return(false);
            }
         
          if (! TheForm.address.value)
            {
              alert("Recheck your address.");
              TheForm.address.focus();
              return(false);
            }
  
          if (! TheForm.zip.value)
            {
              alert("Recheck your zip code.");
              TheForm.zip.focus();
              return(false);
            } 

          if (! TheForm.city.value)
            {
              alert("Recheck your city.");
              TheForm.city.focus();
              return(false);
            }

          if (! TheForm.country.value)
            {
              alert("Recheck your country.");
              TheForm.country.focus();
              return(false);
            }

          return(true);
       }
