// JavaScript Document

// FUNCTION FOR PAYPAL INTEGRATION
function AutoSubmit()
{
	setTimeout("paypalx()",3*1000);
}
function paypalx()
{
 	pay_paypal.submit();
}


//Function for checking the login details IN Name Kard
function checklogin(frm)
{
	//alert("hi");
	var cond=true;
	if(frm.txtemail.value.length==0)
	{
		alert(" Enter Email Address ");
		if(cond==true){
			frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	if(!checkMail(frm.txtemail.value)){
		alert("Email must contain an email address.\n");
		if(cond==true){
			frm.txtemail.value="";
			frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	if(frm.txtpass.value.length==0)
	{
		alert("Enter password");
		if(cond==true){
			frm.txtpass.focus();
		}
		cond=false;
		return false;
	}
	
	if(frm.trno.value.length==0)
	{
		alert("Enter Turing Number");
		if(cond==true){
			frm.trno.focus();
		}
		cond=false;
		return false;
	}
	if(cond=true)
	{
		frm.hidlogin.value="valid";
		return true;	
	}
	
}

//Function for checking the Forget Password IN Name Kard
function checkfpass(frm)
{
	var cond=true;
	if(frm.txtemail.value.length==0)
	{
		alert(" Enter Email Address ");
		if(cond==true){
		frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	if(!checkMail(frm.txtemail.value)){
		alert("Email must contain an email address.\n");
		if(cond==true){
			frm.txtemail.value="";
			frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	if(cond=true)
	{
		frm.hidforgot.value="forgot";
		return true;	
	}
	
}

//Function  for Checking the Register Details 
function checkregister(frm)
{	
	//alert("hi");
	var cond=true;
	/*if (document.frm.zipno.value.length==0)
	{
		alert("hi");
		if(!alphanumeric(document.frm.zipno.value,"Not Valid Code"))
		{
			alert("hii");
			alert("Please Enter Proper Zipcode.");
			if(cond==true)
			{
			frm.zipno.value = "";
			frm.zipno.focus();
			}
		}
		cond=false;
		return false;
	}*/
	if (document.frm.fname.value.length==0){
		alert("Please Enter Firstname.");
		if(cond==true){
		document.frm.fname.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.lname.value.length==0){
		alert("Please Enter Lastname.");
		if(cond==true){
		document.frm.lname.focus();
		}
		cond=false;
		return false;
	}	
	
	if (document.frm.password.value.length==0){
		alert("Please Enter Password.");
		if(cond==true){
		document.frm.password.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.cpassword.value.length==0){
		alert("Please Confirm Password.");
		if(cond==true){
		document.frm.cpassword.focus();
		}
		cond=false;
		return false;
	}
	if(document.frm.password.value !== document.frm.cpassword.value)
	{
		alert("Password and Confirmed Password both should be same.");
		if(cond==true){
		document.frm.cpassword.value="";
		document.frm.cpassword.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.eadd.value.length==0){
		alert("Please Enter Email Address.");
		if(cond==true){
		document.frm.eadd.focus();
		}
		cond=false;
		return false;
	}
	if(!checkMail(document.frm.eadd.value)){
		alert("Email must contain an email address.");
		if(cond==true){
			document.frm.eadd.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.add1.value.length==0){
		alert("Please Enter Address.");
		if(cond==true){
		document.frm.add1.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.city.value.length==0){
		alert("Please Enter City.");
		if(cond==true){
		document.frm.city.focus();
		}
		cond=false;
		return false;
	}
	
	if (document.frm.selectcnty.value==""){
		alert("Please Select Country.");
		if(cond==true){
		frm.selectcnty.focus();
		}
		cond=false;
		return false;
	}	
	if (document.frm.state.value.length==0){
		alert("Please Enter State.");
		if(cond==true){
		frm.state.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.zipno.value.length==0){
		alert("Please Enter Proper Zipcode.");
		if(cond==true){
		document.frm.zipno.focus();
		}
		cond=false;
		return false;
	}
	/*if (document.frm.zipno.value.length==0)
	{
		if(!alphanumeric(document.frm.zipno.value,"Not Valid Code"))
		{
			alert("hi");
			alert("Please Enter Proper Zipcode.");
			if(cond==true)
			{
			frm.zipno.value = "";
			frm.zipno.focus();
			}
		}
		cond=false;
		return false;
	}*/
	if (document.frm.selectday.value.length==0){
		alert("Select Day.");
		if(cond==true){
		document.frm.selectday.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.selectmon.value.length==0){
		alert("Select Month.");
		if(cond==true){
		document.frm.selectmon.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.selectyr.value.length==0){
		alert("Select Year.");
		if(cond==true){
		document.frm.selectyr.focus();
		}
		cond=false;
		return false;
	}
	
	if (document.frm.phono1.value.length!=3 || isNaN(document.frm.phono1.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		document.frm.phono1.value="";
		document.frm.phono1.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.phono2.value.length!=3 || isNaN(document.frm.phono2.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		document.frm.phono2.value="";
		document.frm.phono2.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.phono3.value.length!=4 || isNaN(document.frm.phono3.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		document.frm.phono3.value="";
		document.frm.phono3.focus();
		}
		cond=false;
		return false;
	}
	
	if (document.frm.selectgen.value==""){
		alert("Please Select Gender.");
		if(cond==true){
		document.frm.selectgen.focus();
		}
		cond=false;
		return false;
	}	
	if (document.frm.membertype.value==""){
		alert("Please Select Member Type.");
		if(cond==true){
		document.frm.membertype.focus();
		}
		cond=false;
		return false;
	}	
	if(document.frm.trno.value=="")
	{
		alert("Enter the Turing Number .");
		document.frm.trno.focus();
		return false;
	}
	if(cond=true)
	{
		//alert("Hi");
		document.frm.register.value="valid";
		document.frm.action="cont_reg.php"
	
	}		
	
}
function checkeditregister(frm)
{
		
	//alert("hi");
	var cond=true;
	/*if (document.frm.zipno.value.length==0)
	{
		alert("hi");
		if(!alphanumeric(document.frm.zipno.value,"Not Valid Code"))
		{
			alert("hii");
			alert("Please Enter Proper Zipcode.");
			if(cond==true)
			{
			frm.zipno.value = "";
			frm.zipno.focus();
			}
		}
		cond=false;
		return false;
	}*/
	if (document.frm.fname.value.length==0){
		alert("Please Enter Firstname.");
		if(cond==true){
		document.frm.fname.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.lname.value.length==0){
		alert("Please Enter Lastname.");
		if(cond==true){
		document.frm.lname.focus();
		}
		cond=false;
		return false;
	}	
	
	if (document.frm.password.value.length==0){
		alert("Please Enter Password.");
		if(cond==true){
		document.frm.password.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.cpassword.value.length==0){
		alert("Please Confirm Password.");
		if(cond==true){
		document.frm.cpassword.focus();
		}
		cond=false;
		return false;
	}
	if(document.frm.password.value !== document.frm.cpassword.value)
	{
		alert("Password and Confirmed Password both should be same.");
		if(cond==true){
		document.frm.cpassword.value="";
		document.frm.cpassword.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.eadd.value.length==0){
		alert("Please Enter Email Address.");
		if(cond==true){
		document.frm.eadd.focus();
		}
		cond=false;
		return false;
	}
	if(!checkMail(document.frm.eadd.value)){
		alert("Email must contain an email address.");
		if(cond==true){
			document.frm.eadd.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.add1.value.length==0){
		alert("Please Enter Address.");
		if(cond==true){
		document.frm.add1.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.city.value.length==0){
		alert("Please Enter City.");
		if(cond==true){
		document.frm.city.focus();
		}
		cond=false;
		return false;
	}
	
	if (document.frm.selectcnty.value==""){
		alert("Please Select Country.");
		if(cond==true){
		frm.selectcnty.focus();
		}
		cond=false;
		return false;
	}	
	if (document.frm.state.value.length==0){
		alert("Please Enter State.");
		if(cond==true){
		frm.state.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.zipno.value.length==0){
		alert("Please Enter Proper Zipcode.");
		if(cond==true){
		document.frm.zipno.focus();
		}
		cond=false;
		return false;
	}
	/*if (document.frm.zipno.value.length==0)
	{
		if(!alphanumeric(document.frm.zipno.value,"Not Valid Code"))
		{
			alert("hi");
			alert("Please Enter Proper Zipcode.");
			if(cond==true)
			{
			frm.zipno.value = "";
			frm.zipno.focus();
			}
		}
		cond=false;
		return false;
	}*/
	if (document.frm.selectday.value.length==0){
		alert("Select Day.");
		if(cond==true){
		document.frm.selectday.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.selectmon.value.length==0){
		alert("Select Month.");
		if(cond==true){
		document.frm.selectmon.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.selectyr.value.length==0){
		alert("Select Year.");
		if(cond==true){
		document.frm.selectyr.focus();
		}
		cond=false;
		return false;
	}
	
	if (document.frm.phono1.value.length!=3 || isNaN(document.frm.phono1.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		document.frm.phono1.value="";
		document.frm.phono1.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.phono2.value.length!=3 || isNaN(document.frm.phono2.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		document.frm.phono2.value="";
		document.frm.phono2.focus();
		}
		cond=false;
		return false;
	}
	if (document.frm.phono3.value.length!=4 || isNaN(document.frm.phono3.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		document.frm.phono3.value="";
		document.frm.phono3.focus();
		}
		cond=false;
		return false;
	}
	
	if (document.frm.selectgen.value==""){
		alert("Please Select Gender.");
		if(cond==true){
		document.frm.selectgen.focus();
		}
		cond=false;
		return false;
	}	
	
	
	if(cond=true)
	{
		//alert("Hi");
		document.frm.hidsedit.value="valid";
		//document.frm.action="cont_reg.php"
	
	}		
	
}
//Function  for Checking the Edit Account Details IN NAME KARD
function checkeditacc(frm)
{	
	var cond=true;
	if (frm.fname.value.length==0){
		alert("Please Enter Firstname.");
		if(cond==true){
		frm.fname.focus();
		}
		cond=false;
		return false;
	}
	if (frm.lname.value.length==0){
		alert("Please Enter Lastname.");
		if(cond==true){
		frm.lname.focus();
		}
		cond=false;
		return false;
	}
	if (frm.varadd1.value.length==0){
		alert("Please Enter Address.");
		if(cond==true){
		frm.varadd1.focus();
		}
		cond=false;
		return false;
	}
	if (frm.varcity.value.length==0){
		alert("Please Enter City.");
		if(cond==true){
		frm.varcity.focus();
		}
		cond=false;
		return false;
	}
	if (frm.varstate.value.length==0){
		alert("Please Enter State.");
		if(cond==true){
		frm.varstate.focus();
		}
		cond=false;
		return false;
	}
	if (frm.varcountry.value==""){
		alert("Please Select Country.");
		if(cond==true){
		frm.varcountry.focus();
		}
		cond=false;
		return false;
	}	
	if (frm.varzipcode.value.length==0 || isNaN(frm.varzipcode.value)){
		alert("Please Enter Proper Zipcode.");
		if(cond==true){
		frm.varzipcode.value = "";
		frm.varzipcode.focus();
		}
		cond=false;
		return false;
	}
	if (frm.bdate.value.length==0){
		alert("Please Enter Birthdate.");
		if(cond==true){
		frm.bdate.value="";
		frm.bdate.focus();
		}
		cond=false;
		return false;
	}
	if (frm.phone1.value.length!=3 || isNaN(frm.phone1.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		frm.phone1.value="";
		frm.phone1.focus();
		}
		cond=false;
		return false;
	}
	if (frm.phone2.value.length!=3 || isNaN(frm.phone2.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		frm.phone2.value="";
		frm.phone2.focus();
		}
		cond=false;
		return false;
	}
	if (frm.phone3.value.length!=4 || isNaN(frm.phone3.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		frm.phone3.value="";
		frm.phone3.focus();
		}
		cond=false;
		return false;
	}
	if (frm.selectgender.value==""){
		alert("Please Select Gender.");
		if(cond==true){
		frm.selectgender.focus();
		}
		cond=false;
		return false;
	}	
	if(cond=true)
	{
		frm.hidupdate.value="upd";
		return true;	
	}
}

//Function  for Checking the Upload Front Image IN NAME KARD
function checkupimage(frm)
{	
	var cond=true;
	if (frm.txtfimg.value.length==0){
		alert("Please Upload Front Image.");
		if(cond==true){
		frm.txtfimg.focus();
		}
		cond=false;
		return false;
	}
	if(cond=true)
	{
		frm.uploading.value="uploading";
		return true;	
	}
}

function checkMail(email){
var x = email;
var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(x)){
	return true;
	}
	else {
	  return false;
	}
}


function check(frm)
{
	var cond=true;
	if(frm.fullname.value=="")
	{
		alert("Please Enter The Full Name.");
		frm.fullname.focus();
		return false;
	}
	if(frm.adminuser.value=="")
	{
		alert("Please Enter The User Name.");
		frm.adminuser.focus();
		return false;
	}
	if(frm.password2.value=="")
	{
		alert("Please Enter The Password.");
		frm.password2.focus();
		return false;
	}
	if (frm.cpassword.value=="")
	{
		alert("Please Conform Password.");
		frm.cpassword.focus();
		return false;
	}
	if(frm.password2.value !== frm.cpassword.value)
	{
		alert("Password and Confirmed Password both should be same.");
		frm.cpassword.focus();
		return false;
	}
	if (frm.aemail.value=="")
	{
		alert("Please Enter Email Address.");
		frm.aemail.focus();
		return false;
	}
	if(!checkMail(frm.aemail.value))
	{
		alert("Email must contain an email address.");
		if(cond==true)
		{
			frm.aemail.focus();
		}
		cond=false;
		return false;
	}
	return true;
	
}

function checking(frm)
{
	//alert("hi");
	if(frm.payable.value=="")
	{
		alert("Enter the value in Payable field.");
		frm.payable.focus();
		return false;
	}
	if(frm.checkamount.value=="" || isNaN(frm.checkamount.value))
	{
		alert("Enter Minimum Check Amount.");
		frm.checkamount.focus();
		return false;
	}
	if(frm.select_inc.value=="")
	{
		alert("Select the Annual Income Range.");
		frm.select_inc.focus();
		return false;
	}
	if(frm.selstatus.value=="")
	{
		alert("Select the Marital Status.");
		frm.selstatus.focus();
		return false;
	}
	if(frm.select_edu.value=="")
	{
		alert("Select the Education Field.");
		frm.select_edu.focus();
		return false;
	}
	if(frm.selhome.value=="")
	{
		alert("Select the type of Home.");
		frm.selhome.focus();
		return false;
	}
	if(frm.selpet.value=="")
	{
		alert("Select for the Pet Details .");
		frm.selpet.focus();
		return false;
	}
	if(frm.squest.value=="")
	{
		alert("Enter the Security Question .");
		frm.squest.focus();
		return false;
	}
	if(frm.sans.value=="")
	{
		alert("Enter the Security Answer .");
		frm.sans.focus();
		return false;
	}
		
	return true;
}
function checkticket(frm)
{
	var cond=true;
	
	if(document.frm.name.value.length==0)
	{
		alert("Please Enter Name");
		if(cond==true){
			document.frm.name.focus();
		}
		cond=false;
		return false;
	}	
	if(document.frm.sub.value.length==0)
	{
		alert("Please Enter Subject");
		if(cond==true){
			document.frm.sub.focus();
		}
		cond=false;
		return false;
	}
	if(document.frm.mess.value.length==0)
	{
		alert("Please Enter Message");
		if(cond==true){
			document.frm.mess.focus();
			}
		cond=false;
		return false;
	}
	if(document.frm.eadd.value.length==0)
	{
		alert(" Enter Email Address ");
		if(cond==true){
			document.frm.eadd.focus();
		}
		cond=false;
		return false;
	}
	if(!checkMail(document.frm.eadd.value)){
		alert("Enter A valid Email Address.\n");
		if(cond==true){
			document.frm.eadd.value="";
			document.frm.eadd.focus();
		}
		cond=false;
		return false;
	}
	return true;	
}

/*//FUNCTION FOR COMPARE THE VALUE AS AN ALPHANUMERIC
function alphanumeric(alphane,msg)
{
	var numaric = alphane.value;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
			  
		  }
		else	
		{
			 alert(msg);
			 alphane.focus();
			 return false;
		 }
		}
	 return true;
}
*/
