//Javascript Document

/**************** script validation ***************/

var panBoolean = true;
var buttonClicked =true;

//Checking for Pan Validation

function checkPanValidation(obj){
		hideHelp(obj);
		var panNo = document.personal_info.PAN_Number.value;
        //var oid = oid  
          if(panNo.length < 4){
			return false;
			}
          
          
         http_request=getAjaxRequestObject(); 
          
		http_request.onreadystatechange = getAjaxResult; 
		var url="panvalidation.do";
		
		http_request.open("POST",url ,true)
		http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http_request.send("panNo="+panNo+"&oid="+oid);
}

//ajax function to get Request Object
function getAjaxRequestObject()
      {
    
       if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        return http_request;
      }
      
      
  //ajax funciton to get Response
  //check the response
function getAjaxResult(){

 if (http_request.readyState == 4) {
            if (http_request.status == 200) {
   		    	var result = http_request.responseText;		
   		    	//result = trim(result);
   		    	if(result > 0 ){
				  panBoolean = false;
				  //document.personal_info.PAN_Number.value = "";
				  openPanWindow();				  
					return false;
				}
				else{
					panBoolean = true;
				}
			
            }
        }

}
//End of function getResult  

//function to open popupWindw

function openPanWindow(){
	var url = "/kotak/px/kotak/panpopup.do";
	var popPanwin = window.open(url,'','scrollbars=yes,resizable=no,width=700,height=310'); 
	popPanwin.focus();
}
//End of function


//DWR Validation

function isPincodeAvailable(){

//alert("Inside isPincodeAvailable ");

	
	var pincode = document.personal_info.Pincode.value;
	
	if(pincode.length < 6 ){
	alert("Please enter pincode with at least 6 digit");
	return false;
	}
	if(pincode.length > 5 ){
	pvr.isPincodeAvailable(pincode,callbackValuePincode);	
	}

}// end of isPincodeAvailable

function callbackValuePincode(dataValues){	
       
		//alert("dataValues=======>"+dataValues);
		if(!dataValues){ 
		if(isNoServicefilled())
			{
			isBrowserClose = true;	
			document.personal_info.whichbuttonPress.value="SaveNExitbutton";
		 alert("Thank you for your interest in Kotak credit cards. We regret to inform you that currently we are not issuing cards in your area/city. We will get in touch with you as soon as we starts issuing cards in your area/city. ");	
		
		 document.personal_info.exitAction.value ="NAPincode";
 	     document.personal_info.submit();
 	     }
		}
			
}// end of callbackValueCreditCardNumber









var validdate = new Date();
var validmonth = validdate.getMonth();
var validyea = validdate.getFullYear();
var isFortuneAndSalaried= false;

function displayinfo()
{
	
		document.getElementById("divTwo1").style.display = "none";
		document.getElementById("divTwo2").style.display = "none";
		document.getElementById("divTwo3").style.display = "none";
		document.getElementById("divTwo4").style.display = "none";
		//document.getElementById('advancegift').style.display='none';
		document.getElementById('advTrump').style.display='none';
        document.getElementById('advRoyale').style.display='none';
        document.getElementById('advLeague').style.display='none';
        document.getElementById('advFortune').style.display='none';
		
	if (document.personal_info.cardType.value == "League Card"){
			document.getElementById("divTwo").style.display = "block";
			 //document.getElementById('advancegift').style.display='inline';
			document.getElementById('advLeague').style.display="block"; 
			}
	else {
			document.getElementById("divTwo").style.display = "none";
			}


if (document.personal_info.cardType.value == "Fortune Card"){
			document.getElementById("divFortune").style.display = "block";
			 
			 
			clearAdvantageImage();
			 //document.getElementById('advancegift').style.display='none';
			 document.getElementById('advFortune').style.display="block";
			}
	else {
			document.getElementById("divFortune").style.display = "none";
			}



if (document.personal_info.cardType.value == "Royale Signature Card"){
			document.getElementById("divRoyale2").style.display = "block";
			//document.getElementById('advancegift').style.display='inline';
			document.getElementById('advRoyale').style.display="block";
			}
	else {
			document.getElementById("divRoyale2").style.display = "none";
			}

	if (document.personal_info.cardType.value == "Trump Card"){
			document.getElementById("divTrump").style.display = "block";
			
			clearAdvantageImage();


			// document.getElementById('advancegift').style.display='none';
			document.getElementById('advTrump').style.display="block";
			
			} 
	else {
			document.getElementById("divTrump").style.display = "none";
			}


	}
//to display goodies type for Leauge card

function displayeducation()
{
	if (document.personal_info.Education.value == "Others"){
			document.getElementById("divEdu").style.display = "inline";
	}
	else{ 
			document.getElementById("divEdu").style.display = "none";
	}
	}
//to select other type of education

function displayOccupation()
{
	if (document.personal_info.Occupation.value == "Salaried"){
			document.getElementById("salaried").style.display = "inline";
			document.personal_info.Designation.focus();
			
	}
	else {
			document.getElementById("salaried").style.display = "none";
	}
	if(document.personal_info.Occupation.value == "Self-employed Business"){
			document.getElementById("Business").style.display = "inline";
			document.personal_info.Ownership.focus();
	}
	else {
			document.getElementById("Business").style.display = "none";
	}
	if(document.personal_info.Occupation.value == "Self-employed Professional"){
			document.getElementById("Professional").style.display = "inline";
			document.personal_info.Profession.focus();
	}
	else {
			document.getElementById("Professional").style.display = "none";
	}
	}
//to select other type of Occupation

function displayProfession()
{
	if (document.personal_info.Profession.value == "Others"){
			document.getElementById("divprof").style.display = "inline";
	}
	else {
			document.getElementById("divprof").style.display = "none";
	}
}

/* To load date values into dropdown boxes*/
var monthtext = ['MM','01','02','03','04','05','06','07','08','09','10','11','12'];

function populatedropdown(DOB, MM, YY, MemberSince, MemberSince1){

var today=new Date()
var DOB=document.getElementById(DOB)
var MM=document.getElementById(MM)
var YY=document.getElementById(YY)
var MemberSince=document.getElementById(MemberSince)
var MemberSince1=document.getElementById(MemberSince1)
	
DOB.options[0]=new Option('DD', 'DD', true, true) //select today's day
var k =0 
var dayText = "";
for (var i=0; i<31; i++){
 k++;

 if(i < 9){
	dayText = "0" + (i+1);
 }else{
 
	dayText = i+1;
 }
DOB.options[k]=new Option(dayText, dayText)
}

for (var m=0; m<13; m++)
MM.options[m]=new Option(monthtext[m], monthtext[m])

var thisyear= 1935;// old thisyear = 1950 and y<=55
YY.options[0]=new Option('YYYY', 'YYYY');
for (var y=1; y<=61; y++){
YY.options[y]=new Option(thisyear, thisyear)
thisyear+=1
}

for (var l=0;l<13 ;l++ )
{
MemberSince.options[l]=new Option(monthtext[l], monthtext[l])
}

var years= 1970;
MemberSince1.options[0]=new Option('YYYY', 'YYYY');
for (var v=1; v<=45; v++){
MemberSince1.options[v]=new Option(years, years)
years+=1
}
}
/* End load date values into dropdown boxes*/


/* Start Date Validation */
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
}
/* End Date Validation*/


///auto tab

function autotab(original,destination){
	if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
	destination.focus()
}



function fortuneCard()
{


var fortuneCard=document.personal_info.cardType.value;
	var salired=document.personal_info.Occupation.value;
	if(fortuneCard=="Fortune Card" && salired=="Salaried")
	{
	return false;
	}
	else{
	
	return true;
	}
}

	
function submitPersonalDetails(){
	
	document.personal_info.whichbuttonPress.value="SaveButton";	
	if(personalInfo()== false){
		return false;		
	}else{
	isBrowserClose = true;
	return true;
	//document.personal_info.submit();	 
		//validatePersonalDetails();
	}
	
	return false;
}


// function to copy persent address to permanent address

	function copyPresentAddresToPermanentAddr(formName){	
		Object= document.forms[formName];
		if(Object.checkid.checked==false){
		
				document.personal_info.Permanent_Address.value=Object.Address.value;
				document.personal_info.Permanent_Address1.value=Object.Address1.value;
				document.personal_info.Permanent_Address2.value=Object.Address2.value;
				//alert(document.Contact_details.Permanent_Address2.value);
				//document.Contact_details.Permanent_Landmark.value=Object.Landmark.value;
				document.personal_info.City2.value=Object.City1.value;
				if(document.personal_info.City2.value=="Others"){
				document.getElementById("divOtherCity2").style.display = "inline";
				}
				document.personal_info.OtherCity2.value=Object.OtherCity1.value;
				document.personal_info.pincode1.value=Object.Pincode.value;
				document.personal_info.Perm_stdcode.value=Object.stdno.value;
				document.personal_info.Perm_phoneno.value=Object.phoneno.value;
				 
		}// End of if
	}

function personalInfo(){


 //Starts validation for Name  
var nameRegEx = /^([a-zA-Z])*$/
var candidateFName = document.personal_info.FirstName.value;
var candidateMName = document.personal_info.SecondName.value;
var candidateLName = document.personal_info.LastName.value;
//var candidateMotherName = document.personal_info.MotherName.value;


if((nameRegEx.test(candidateFName)==false)||(candidateFName == "First Name")||(candidateFName.length < 3)||(candidateFName.length > 19)){
	alert("Please enter your first name no spaces,dots & special characters");
	document.personal_info.FirstName.style.border = "2px solid red";
	document.personal_info.FirstName.focus();
	return false;
}
if(candidateMName != null && candidateMName.length >0 ){
	if(candidateMName == "Middle Name")
	{
		document.personal_info.SecondName.value = "";
	}
		else if(nameRegEx.test(candidateMName)==false){
			alert("Please enter your middle name");
			document.personal_info.SecondName.style.border = "2px solid red";
			document.personal_info.SecondName.focus();
			return false;
		}

		
}
if(candidateMName.length > 100){
    alert("Please enter your middle name without exceeding 100 characters");
    document.personal_info.SecondName.style.border = "2px solid red";
	document.personal_info.SecondName.focus();
    return false;
}
if((nameRegEx.test(candidateLName)==false)||(candidateLName == "Last Name")||(candidateLName.length < 1)||(candidateLName.length > 19)){
	alert("Please enter your last name no spaces,dots & special characters");
	document.personal_info.LastName.style.border = "2px solid red";
	document.personal_info.LastName.focus();
	return false;
}
// Ends validation for Name 

// starts validation for mobilenum 
var mno=document.personal_info.Mobileno.value;
var mnoRegEx = /^([0-9])*$/
if(mno.length == 0)
{
    document.personal_info.Mobileno.style.border = "2px solid red";
    alert("Please enter your mobile number");
	document.personal_info.Mobileno.focus();
    return false;
}
else if(mno.charAt(0) != '9' && mno.charAt(0) != '8' &&  mno.charAt(0) != '7')
{
    document.personal_info.Mobileno.style.border = "2px solid red";
    alert("Please check your mobile number, it should start with 8,9 or 7.");
	document.personal_info.Mobileno.focus();
    return false;
}
else if(mno.length < 10)
{   document.personal_info.Mobileno.style.border = "2px solid red";
    alert("Please check your mobile number, it should be 10 digit");
	document.personal_info.Mobileno.focus();
    return false;
}
else if(mnoRegEx.test(mno) == false)
{
    document.personal_info.Mobileno.style.border = "2px solid red";
    alert("Please enter valid mobile number with digits only");
	document.personal_info.Mobileno.focus();
    return false;
}
// End of Validation for mobile no


//Start validation for Email
	var emailid = document.personal_info.EmailId.value;
	if((emailid.indexOf("--") != -1)||(emailid.indexOf("..") !== -1)||(emailid.indexOf("__") !== -1)||(emailid.indexOf("++") !== -1)){
		alert("Please enter a valid email-id");
		document.personal_info.EmailId.style.border = "2px solid red";
		document.personal_info.EmailId.focus();
		return false;
		}
	var emailIDRegEx = /^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/
	if(emailIDRegEx.test(emailid)==false){
		alert("Please enter a valid email-id");
		document.personal_info.EmailId.style.border = "2px solid red";
		document.personal_info.EmailId.focus();
		return false;
	}
//End validation for Email
// Starts validation for Address Details 

	
	var addrRegEx = /^([a-zA-Z0-9 #,.\-\/])*$/
	//alert(document.personal_info.ResidentialStatus[0].checked);	
		var resStatusFlag=false;
				for(var i=0; i<document.personal_info.ResidentialStatus.length;i++){ 
						
					if(document.personal_info.ResidentialStatus[i].checked){
						document.personal_info.ResidentialStatus.value = document.personal_info.ResidentialStatus[i].value; //unni
						resStatusFlag=true;
						//alert('checked');
						break;
					}
				}
		if(!resStatusFlag){
			alert("Please select a Residential status");
			return false;
			}

	var addr=document.personal_info.Address.value;
	var addr1=document.personal_info.Address1.value;
	var addr2=document.personal_info.Address2.value;
	var addrRegEx = /^([a-zA-Z0-9 #,.\-\/])*$/;
	//alert(addr+'=='+addr1+'==='+addr2);

	if(addr.length == 0)
		{     
			alert("Please enter present address");
			document.personal_info.Address.style.border = "2px solid red";
			document.personal_info.Address.focus();
			return false;
		} 

		else if(addr.length>30)
		{
			alert("Please enter present address,without exceeding 30 characters");
			document.personal_info.Address.style.border = "2px solid red";
			document.personal_info.Address.focus();
			return false;
		}
		else if(addrRegEx.test(addr) == false) 
		{     
			alert("Please enter valid present address, without special characters");
			document.personal_info.Address.style.border = "2px solid red";
			document.personal_info.Address.focus();
			return false;
		 
		}

		var cityRegex = /^([a-zA-Z])*$/;
		var city=document.personal_info.City1.value;
		var ocity=document.personal_info.OtherCity1.value;
			//Validation for city
			if(city == "")
			{
				alert("Please select your present city");
				document.personal_info.City1.style.border = "2px solid red";
				document.personal_info.City1.focus();
				return false;
			}else if(city == "Others")
			{ 

				if(ocity.length == 0){
					alert("Please enter your present other city name");
					document.personal_info.OtherCity1.style.border = "2px solid red";
					document.personal_info.OtherCity1.focus();
					return false;
				}
				if(ocity.length>30){
					alert("Please enter your present city name,without exceeding 30 characters");
					document.personal_info.OtherCity1.style.border = "2px solid red";
					document.personal_info.OtherCity1.focus();
					return false;
				}else if(cityRegex.test(ocity) == false){
					alert("Please enter your present city name,without any special characters or numbers");
					document.personal_info.OtherCity1.style.border = "2px solid red";
					document.personal_info.OtherCity1.focus();
					return false;
				}
				 
			}
			
			
		if(city == "Others" && (ocity!=" " || ocity!=""))
		{
			//alert("in others")
			saveNoService();
			return false;
		}

		var pincode=document.personal_info.Pincode.value;		
		var pincodeRegEx = /^([0-9])*$/;
			//Validation for pincode
			if(pincode.length == 0){
				alert("Please enter your present city pincode");
				document.personal_info.Pincode.style.border = "2px solid red";
				document.personal_info.Pincode.focus();
				return false;
			}else if(pincode.length<6){
				alert("Please enter valid present address pincode with 6 digits");
				document.personal_info.Pincode.style.border = "2px solid red";
				document.personal_info.Pincode.focus();
				return false;
			}else if(pincodeRegEx.test(pincode)==false){
				alert("Please enter valid present address pincode");
				document.personal_info.Pincode.style.border = "2px solid red";
				document.personal_info.Pincode.focus();
				return false;
			}
		
		var addressDiff= document.personal_info.checkid.checked;		
	 if( addressDiff == false){
		copyPresentAddresToPermanentAddr('personal_info');
	 }else if(addressDiff == true){
			//Validation for Permanent Address starts here...
			var paddr=document.personal_info.Permanent_Address.value;
			//var paddr1=document.personal_info.Permanent_Address1.value;
			//var paddr2=document.personal_info.Permanent_Address2.value;
			var permanentcity=document.personal_info.City2.value;
			var opcity=document.personal_info.OtherCity2.value;
			var addrRegEx = /^([a-zA-Z0-9 #,.\-\/])*$/;
			var cityRegex = /^([a-zA-Z])*$/;
			
			if(paddr.length == 0)
			{   
				alert("Please enter your permanent address");
				document.personal_info.Permanent_Address.style.border = "2px solid red";
				document.personal_info.Permanent_Address.focus();
				return false;
			}else if(paddr.length>30)
			{
				alert("Please enter your permanent address,without exceeding 30 characters");
				document.personal_info.Permanent_Address.style.border = "2px solid red";
				document.personal_info.Permanent_Address.focus();
				return false;
			}else if(addrRegEx.test(paddr) == false) 
			{     
				alert("Please enter a valid permanent address, without special characters");
				document.personal_info.Permanent_Address.style.border = "2px solid red";
				document.personal_info.Permanent_Address.focus();
				return false;
			}
			 
					 
		//Validation for city
		//alert(permanentcity);
			if(permanentcity == "")
			{				 
				alert("Please select your permanent city");
				document.personal_info.City2.focus();
				return false;
			}else if(permanentcity == "Others")
			{
				if(opcity.length == 0){
					alert("Please enter your permanent city name");
					document.personal_info.OtherCity2.style.border = "2px solid red";
					document.personal_info.OtherCity2.focus();
					return false;
				}else if(opcity.length > 30){
					alert("Please enter your permanent city name,without exceeding 30 characters");
					document.personal_info.OtherCity2.style.border = "2px solid red";
					document.personal_info.OtherCity2.focus();
					return false;
				}else if(cityRegex.test(opcity) == false){
					alert("Please enter your permanent city name,without any special characters or numbers");
					document.personal_info.OtherCity2.style.border = "2px solid red";
					document.personal_info.OtherCity2.focus();
					return false;
				}
			}
			 
				//Validation for pincode
			var pincode1=document.personal_info.pincode1.value;
		    var pincodeRegEx = /^([0-9])*$/;
				if(pincode1.length == 0){
					alert("Please enter your permanent city pincode");
					document.personal_info.pincode1.style.border = "2px solid red";
					document.personal_info.pincode1.focus();
					return false;
				}else if(pincode1.length<6){
					alert("Please enter a valid permanent address pincode with 6 digits");
					document.personal_info.pincode1.style.border = "2px solid red";
					document.personal_info.pincode1.focus();
					return false;
				}else if(pincodeRegEx.test(pincode1) == false){ 
					alert("Please enter valid permanent address pincode");
					document.personal_info.pincode1.style.border = "2px solid red";
					document.personal_info.pincode1.focus();
					return false;
				}
		 
		 }
		 
		 
	

//addresss validation finished

	
	// for date of birth
	var dateofBirth = document.personal_info.DOB.value;
	var monthofBirth = document.personal_info.MM.value;
	var yearofBirth = document.personal_info.YY.value;

	var dt= dateofBirth+"/"+monthofBirth+"/"+yearofBirth;

	if((dateofBirth == "DD")||(monthofBirth == "MM")||(yearofBirth == "YYYY")){
	 alert("Please select your date of birth");
	 return false;
	}

	if (isDate(dt)==false){
			return false;
	}

	
	// Starts validation for gender 
	var genderFlag=false;
			for(var i=0; i<document.personal_info.gender.length;i++){ 

				if(document.personal_info.gender[i].checked){
					document.personal_info.genderVal.value = document.personal_info.gender[i].value; //unni
					genderFlag=true;
					break;
				}
			}
	if(!genderFlag){
		alert("Please select a gender");
		return false;
	}
	

	// Starts validation for occupationFlag 
	
	var occupationFlag=false;
	var Occupation;
			for(var i=0; i<document.personal_info.occupation.length;i++){ 

				if(document.personal_info.occupation[i].checked){
					document.personal_info.occupation.value = document.personal_info.occupation[i].value; //unni
					Occupation = document.personal_info.occupation.value;
					occupationFlag=true;
					break;
				}
			}
	
	if(!occupationFlag){
		alert("Please select a Occupation");
		return false;
	}



	// start validation for Type of Companyname
	var CompanyName = document.personal_info.CompanyName.value;


	if(CompanyName == 0){
		alert("Please Enter Company Name");
		document.personal_info.CompanyName.style.border = "2px solid red";
		document.personal_info.CompanyName.focus();
		return false;
	}
	// End validation for Type of Vechile
	// starts validation for industry type
	var IndustrySection = document.personal_info.IndustrySection.value;
	if(IndustrySection == 0){
		alert("Please select Industry Section");
		document.personal_info.IndustrySection.style.border = "2px solid red";
		document.personal_info.IndustrySection.focus();
		return false;
	}

	// for salaried Monthly Salary compulsary
	if(Occupation=="Salaried"){
		var NetMonthlySalary = document.personal_info.NetSalary.value;
			if(NetMonthlySalary == 0 || NetMonthlySalary=="" ){
				alert("please Enter your Net Monthly Salary");
				document.personal_info.NetSalary.style.border = "2px solid red";
				document.personal_info.NetSalary.focus();
				return false;
			}
	}
	
	// start validation for PAN card 
	var panRegEx = /^([0-9a-zA-Z])*$/
	var panNoRegEx = /^([0-9])*$/
	var panCharsRegEx = /^([a-zA-Z])*$/
	var panLastCharRegEx = /^([a-zA-Z]){1}$/
	 
	var panNo = document.personal_info.PAN_Number.value;
	var panChars = panNo.substr(0,5);
	var pandigits = panNo.substr(5,4);

	if((panRegEx.test(panNo)==false)||(panNo.length != 10)){
		 alert("Please enter the correct PAN details");
		 document.personal_info.PAN_Number.style.border = "2px solid red";
		 document.personal_info.PAN_Number.focus();
		 return false;
	}
	 
	if(panCharsRegEx.test(panChars)==false){
		alert("Please enter the correct PAN details");
		document.personal_info.PAN_Number.style.border = "2px solid red";
		 document.personal_info.PAN_Number.focus();
		return false;
	}
	if(panNoRegEx.test(pandigits)==false){
		alert("Please enter the correct PAN details");
		document.personal_info.PAN_Number.style.border = "2px solid red";
		 document.personal_info.PAN_Number.focus();
		return false;
	}
	if(panLastCharRegEx.test(panNo.charAt(9))== false){
		alert("Please enter the correct PAN details");
		document.personal_info.PAN_Number.style.border = "2px solid red";
		 document.personal_info.PAN_Number.focus();
		return false;
	}
	 
	 
	if(((panNo.charAt(3)!='P')&&(panNo.charAt(3)!='p'))&&((panNo.charAt(3)!='F')&&(panNo.charAt(3)!='f'))&&((panNo.charAt(3)!='C')&&(panNo.charAt(3)!='c'))&&((panNo.charAt(3)!='H')&&(panNo.charAt(3)!='h'))&&((panNo.charAt(3)!='A')&&(panNo.charAt(3)!='a'))&&((panNo.charAt(3)!='T')&&(panNo.charAt(3)!='t'))&&((panNo.charAt(3)!='B')&&(panNo.charAt(3)!='b'))&&((panNo.charAt(3)!='L')&&(panNo.charAt(3)!='l'))&&((panNo.charAt(3)!='J')&&(panNo.charAt(3)!='j'))){
		alert("Please enter the correct PAN details");
		document.personal_info.PAN_Number.style.border = "2px solid red";
		 document.personal_info.PAN_Number.focus();
		return false;
	}
	var Fname = candidateFName.toUpperCase();
	var firstName = candidateFName.toLowerCase();
	var Lname = candidateLName.toUpperCase();
	var lastName = candidateLName.toLowerCase();
	 
	if((panNo.charAt(4)!=Fname.charAt(0)) && (panNo.charAt(4)!=firstName.charAt(0)) && (panNo.charAt(4)!=Lname.charAt(0)) && (panNo.charAt(4)!=lastName.charAt(0))){
	alert("Please enter the correct PAN details");
	document.personal_info.PAN_Number.style.border = "2px solid red";
	 document.personal_info.PAN_Number.focus();
	return false;
	} 
	 
	 if(!panBoolean){
		document.personal_info.PAN_Number.style.border = "2px solid red";
		document.personal_info.PAN_Number.focus();
		return false;
	 }

//alert("end of PersonalInfo()");
    if(buttonClicked){
       buttonClicked =false;
		}
		else{
		alert("You have already did Submit");
		return false;
		}
   document.getElementById('applySubmit').style.visibility='hidden'; // hide 
	return true;
}
// End of Validation for the form of Personal Information.



/*this function used to bring back the normal border*/
function clearBorder(obj){
obj.style.border = "2px inset ActiveBorder";
}
/*End function used to bring back the normal border*/



function showAccount(){
	
	if(document.Bank_details.Account_type.value == "Others")
			document.getElementById("divAccType").style.display = "inline";
	else 
			document.getElementById("divAccType").style.display = "none";
	
}
// validation for account type


function bankdetails(){

//calling validation for loyalty program

if(validateLoyalty() == false){
	return false;
}



/*Start of validation for Bank Name*/

var bankName = document.Bank_details.BankName.value;
var accountNo = document.Bank_details.Account_number.value;
var branchName = document.Bank_details.Branch.value;
var Accounttype = document.Bank_details.Account_type.value;
var accountypecounter = 0;

if(Accounttype == "Others"){
accountypecounter++;
var accountType = document.Bank_details.OtherAccType.value;
var accTypeRegEx = /^([a-zA-Z .\-\/&])*$/
 
    if((accTypeRegEx.test(accountType)==false)||(accountType.length<1)){
        alert("Please enter a valid account type");
        document.Bank_details.OtherAccType.style.border = "2px solid red";
		document.Bank_details.OtherAccType.focus();
        return false;
    }
}

if((bankName != "")||(accountNo != "")||(branchName != "")||(accountypecounter > 0)){

/*Start of validation for Bank Name*/
var bankRegEx = /^([A-Za-z .,&])*$/
var bankNamespaces = 0;
var bankNamedots = 0;
var bankNamesemi = 0;
 
 
     
    if((bankRegEx.test(bankName)==false)||(bankName.length < 1)||(bankName.length > 50)){
        alert("Please enter a valid bank name");
        document.Bank_details.BankName.style.border = "2px solid red";
		document.Bank_details.BankName.focus();
        return false;
    }
 
    if((bankName.indexOf("  ") != -1)||(bankName.indexOf("..") !== -1)||(bankName.charAt(0) == ' ')||(bankName.charAt(0) == '.')){
        alert("Please enter a valid bank name without continuous special characters");
        document.Bank_details.BankName.style.border = "2px solid red";
		document.Bank_details.BankName.focus();
        return false;
        }
/*End of validation for Bank Name*/

/*Start of Validation for Account Number*/
var accountRegExp = /^([a-zA-Z0-9., \-\/&])*$/

if((accountRegExp.test(accountNo)== false)||(accountNo.length<1)){
    alert("Please enter your account number without special characters");
    document.Bank_details.Account_number.style.border = "2px solid red";
	document.Bank_details.Account_number.focus();
    return false;
    }
    if(accountNo.length >30){
        alert("Please enter your account number without exceeding 30 characters");
        document.Bank_details.Account_number.style.border = "2px solid red";
		document.Bank_details.Account_number.focus();
        return false;
    }

/*End of Validation for Account Number*/

/*start of validation for Bank Branch*/
var branchNameEmpRegEx = /^([a-zA-Z, .])*$/

if((branchNameEmpRegEx.test(branchName)==false)||(branchName.length<1)){
    alert("Please enter a valid branch name");
    document.Bank_details.Branch.style.border = "2px solid red";
	document.Bank_details.Branch.focus();
    return false;
    }

if(branchName.length > 30){
    alert("Please enter a valid branch name without exceeding 30 characters");
    document.Bank_details.Branch.style.border = "2px solid red";
	document.Bank_details.Branch.focus();
    return false;
    }
 
if((branchName.indexOf("  ") != -1)||(branchName.indexOf("..") != -1)||(branchName.charAt(0) == ' ')||(branchName.charAt(0) == '.')||((branchName.indexOf(",,") !== -1))){
    alert("Please enter a valid branch name without continuous special characters");
    document.Bank_details.Branch.style.border = "2px solid red";
	document.Bank_details.Branch.focus();
    return false;
    }
/*End of validation for Bank Branch*/


/*Start validation for Account type*/

if(Accounttype == "Others"){
var accountType1 = document.Bank_details.OtherAccType.value;
var accTypeRegEx1 = /^([a-zA-Z .\-\/&])*$/
 
    if((accTypeRegEx1.test(accountType1)==false)||(accountType1.length<1)){
        alert("Please enter a valid account type");
        document.Bank_details.OtherAccType.style.border = "2px solid red";
		document.Bank_details.OtherAccType.focus();
        return false;
    }
   
    if(accountType1.length > 30){
    alert("Please enter a valid account type without exceeding 30 characters");
        document.Bank_details.OtherAccType.style.border = "2px solid red";
		document.Bank_details.OtherAccType.focus();
        return false;
    }
 
}
/*End Validation for Accout Type*/
}
/*End of validation if Bank Exsist*/



/*Start validation for Credit card if Exsit*/

var creditBankName = document.Bank_details.Bank.value;
var card1 = document.Bank_details.Card_number.value;
var card2 = document.Bank_details.Card_number1.value;
var card3 = document.Bank_details.Card_number2.value;
var card4 = document.Bank_details.Card_number3.value;
var cardlimit = document.Bank_details.Credit_limit.value;

if((creditBankName != "")||(card1 != "")||(card2 != "")||(card3 != "")||(card4 != "")||(cardlimit != "")){
/*Bank Name*/
var creditbankNamedots = 0;
var creditbankNamespaces = 0;
 
var creditBankNameRegEx = /^([a-zA-Z, .&])*$/
    if((creditBankNameRegEx.test(creditBankName)==false)||(creditBankName.length<1)){
        alert("Please enter your credit card bank name");
         document.Bank_details.Bank.style.border = "2px solid red";
		 document.Bank_details.Bank.focus();
         return false;
    }

    if(creditBankName.length > 50){
    alert("Please enter your credit card bank name without exceeding 50 characters");
         document.Bank_details.Bank.style.border = "2px solid red";
		  document.Bank_details.Bank.focus();
         return false;
    }
 
 
    if((creditBankName.indexOf("  ") != -1)||(creditBankName.indexOf("..") !== -1)||(creditBankName.charAt(0) == ' ')||(creditBankName.charAt(0) == '.')){
            alert("Please enter a valid bank name without continuous special characters");
            document.Bank_details.Bank.style.border = "2px solid red";
			 document.Bank_details.Bank.focus();
            return false;
        }
/*End Bank Name*/

/*Start validating credit card Number*/
var cardRegEx = /^([0-9]){4}$/
var cardEndRegEx = /^([0-9]){2,4}$/

if((cardRegEx.test(card1)==false)||(cardRegEx.test(card2)==false)||(cardRegEx.test(card3)==false)||(cardEndRegEx.test(card4)==false)){
    alert("Please enter a valid card number");
    return false;
}

/*End validating credit card Number*/

/*vaildate for member month & year*/

var membermonth = document.Bank_details.MemberSince.value;
var memberyear = document.Bank_details.MemberSince1.value;



if(membermonth == "MM"){
	alert("Please enter the member since month");
	return false;
}

if(memberyear == "YYYY"){
	alert("Please enter the member since year");
	return false;
}

/* 
if((membermonth >(validmonth+01))&&(validyea == memberyear)){
    alert("please enter the member since month");
    return false;
}
 
if(memberyear > validyea){
    alert("please enter the member since year");
    return false;
}
*/
/*End vaildate for member month & year*/

/*Start validation Limit*/
var limitRegExp = /^([0-9]){1,9}$/
 
if(limitRegExp.test(cardlimit)==false){
    alert("Please enter your credit limit with digits only");
    document.Bank_details.Credit_limit.style.border = "2px solid red";
	 document.Bank_details.Credit_limit.focus();
    return false;
}
/*End validation Limit*/
}
/*End validation for Credit card if Exsit*/

if(document.Bank_details.termCondition.checked == false){
	alert("Please check the term & condition");
	return false;
	}

	return true;
}
//End of function for Bank details


//converting to capital

function convertToCapital(obj){
 
var setanceCase = obj.value;
var firstChar = setanceCase.charAt(0);
var restLetters = "";

if(setanceCase !="" && setanceCase!= null && setanceCase.length > 1){
 restLetters = setanceCase.substring(1);
}
//obj.value = firstChar.toUpperCase()+restLetters.toLowerCase();
obj.value = firstChar.toUpperCase()+restLetters;
obj.style.color="#000000"; 

}
// End of function converting to capital

function printArray(){
for(var i=0;i<leaguegoodyArray.length;i++){

	
	for(var k=0;k<leaguegoodyArray[i].length;k++){
		
	//	alert(i+" "+ k + leaguegoodyArray[i][k]);
	
	
	}											
	
}											

}


//funtion for displaying cards in drop down box



function displayCadetToDropDown(cardType){
//displyaing cards


document.personal_info.cardType.length = 0;
document.personal_info.cardType.options[0] = new Option('Select Card Type','0');
document.personal_info.cardType.options[1] = new Option('Trump Gold Card - Free for life',displaycardType[0]); //Trump Card
document.personal_info.cardType.options[2] = new Option('Fortune Gold Card - Free for life',displaycardType[3]);//Fortune Card
document.personal_info.cardType.options[3] = new Option('League Platinum Card - One time joining fee',displaycardType[2]);//League Card
document.personal_info.cardType.options[4] = new Option('Royale Signature Card - One time joining fee',displaycardType[1]);//Royale Signature Card


}

function displayLoyality(){
	document.Bank_details.programmName.value  = loyalityName;
	if(loyalityName != 'null'){
		document.Bank_details.loylalmemberId.value = loyalityName
		document.Bank_details.loylalmemberId.style.color  = 'grey';
	}
}
	
	
//logic to validate loyalty program
function validateLoyalty(){

var loylalmemberId = document.Bank_details.loylalmemberId.value;
var programmName = document.Bank_details.programmName.value;
var limitRegExp = /^([a-zA-Z0-9]){0,16}$/


if((loylalmemberId != "")&&(loylalmemberId.length > 0)){
	if(limitRegExp.test(loylalmemberId)==false){
		alert("Please enter member id in characters or numbers only");
		document.Bank_details.loylalmemberId.style.border = "2px solid red";
		 document.Bank_details.loylalmemberId.focus();
         return false;
	}
	
	if(programmName == ""){
		alert("Please select a loyalty program");
		return false;
	}
}//End of outer if condition if only member id is entered

}//End of function 


//function to validate advacegift
// Validation for Advanced Gift
function validateAdvanceGift(cardType){
     var giftIdAdv;
     var radio_selected = false;
     var isAdvanceSelected = false;
     
   if(cardType =="League Card"){
		giftIdAdv = "giftLeague";
		}

  if(cardType =="Trump Card"){
	giftIdAdv = "giftTrump";
	}

	if(cardType =="Royale Signature Card"){
		giftIdAdv = "giftRoyale";
	}
	if(cardType =="Fortune Card"){
		giftIdAdv = "giftFortune";
	}
	if(document.personal_info.advanceGiftName == null || document.personal_info.advanceGiftName == undefined ){
		document.personal_info.advanceGiftVal.value = "";
	}
	else if(document.personal_info.advanceGiftName.length){
	for(var i=0;i<document.personal_info.advanceGiftName.length && document.personal_info.advanceGiftName[i] != null;i++){
		objGift = document.personal_info.advanceGiftName[i];
		if(objGift.id ==giftIdAdv){
			isAdvanceSelected = true;
			if(objGift.checked == true){
				radio_selected = true;	
				document.personal_info.advanceGiftVal.value=objGift.value;
				break;
			}	
		}
		
	}
}
       else{    
        if((document.personal_info.advanceGiftName.value != "")||(document.personal_info.advanceGiftName.length) ){
              objGift = document.personal_info.advanceGiftName;
                       if(objGift.id == giftIdAdv){
                       		isAdvanceSelected = true;
                       		if(objGift.checked == true){
                       			document.personal_info.advanceGiftVal.value = objGift.value;
                       			radio_selected = true;
                      		 }//End of if condition
               }//End 2nd if cond
}//End of outer if condition
}// End of else
       if(isAdvanceSelected && !radio_selected){
               alert("Please select an advanced gift");
               return false;
               }
               
 
}//End of function validateAdvanceGift


//function to clear the selected values for the advance image
function clearAdvantageImage(){

if(document.personal_info.advanceGiftName == null || document.personal_info.advanceGiftName == undefined ){
}else{
        for(var h =0; h<document.personal_info.advanceGiftName.length; h++){
              document.personal_info.advanceGiftName[h].checked = false;
                }
                
         }
}


//Start of functions from LBI - for cardtype

function displayCardInfo()
{

if (document.personal_info.cardType.value == "0")
			{
			document.getElementById("cardCustName").style.display = "none";
			document.getElementById("defaultCard").style.display = "none";
			document.getElementById("trumpCard").style.display = "none";
			document.getElementById("fortuneCard").style.display = "none";
			document.getElementById("leagueCard").style.display = "none";
			document.getElementById("royalCard").style.display = "none";
			}
	else 
		if (document.personal_info.cardType.value == "Trump Card")
		{
			document.getElementById("cardCustName").style.display = "block";
			document.getElementById("cardCustName").style.color = "#000000";
			document.getElementById("defaultCard").style.display = "none";
			document.getElementById("trumpCard").style.display = "block";
			document.getElementById("fortuneCard").style.display = "none";
			document.getElementById("leagueCard").style.display = "none";
			document.getElementById("royalCard").style.display = "none";
		}
		else
			if (document.personal_info.cardType.value == "Fortune Card")
			{
				document.getElementById("cardCustName").style.display = "block";
				document.getElementById("cardCustName").style.color = "#000000";
				document.getElementById("defaultCard").style.display = "none";
				document.getElementById("trumpCard").style.display = "none";
				document.getElementById("fortuneCard").style.display = "block";
				document.getElementById("leagueCard").style.display = "none";
				document.getElementById("royalCard").style.display = "none";
			}	
			else
				if (document.personal_info.cardType.value == "League Card")
				{
					document.getElementById("cardCustName").style.display = "block";
					document.getElementById("cardCustName").style.color = "#ffffff";
					document.getElementById("defaultCard").style.display = "none";
					document.getElementById("trumpCard").style.display = "none";
					document.getElementById("fortuneCard").style.display = "none";
					document.getElementById("leagueCard").style.display = "block";
					document.getElementById("royalCard").style.display = "none";
				}
				else
					if (document.personal_info.cardType.value == "Royale Signature Card")
					{
						document.getElementById("cardCustName").style.display = "block";
						document.getElementById("cardCustName").style.color = "#ffffff";
						document.getElementById("defaultCard").style.display = "none";
						document.getElementById("trumpCard").style.display = "none";
						document.getElementById("fortuneCard").style.display = "none";
						document.getElementById("leagueCard").style.display = "none";
						document.getElementById("royalCard").style.display = "block";
					}
			
	
	
}
function detectchange(a){
	document.getElementById('cardCustName').value=a;
}


// addresss details validation for personalInfo form
function checkAddressDetails(document){


//var rs=document.personal_info.ResidentialStatus.selectedIndex;
 
		var addr=document.personal_info.Address.value;
		var addr1=document.personal_info.Address1.value;
		var addr2=document.personal_info.Address2.value;
		var city=document.personal_info.City1.value;
		var ocity=document.personal_info.OtherCity1.value;
		var pincode=document.personal_info.Pincode.value;
		var stdno=document.personal_info.stdno.value;
		var phoneno=document.personal_info.phoneno.value;
		/* Mobile number field moved to Personal details page
		var mno=document.Contact_details.Mobileno.value;
		*/
		var cid=document.Contact_details.checkid.value;
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
		 
		 
		 
		//Validation field for Permanent Adrress
		var paddr=document.personal_info.Permanent_Address.value;
		var paddr1=document.personal_info.Permanent_Address1.value;
		var paddr2=document.personal_info.Permanent_Address2.value;
		var permanentcity=document.personal_info.City2.value;
		var opcity=document.personal_info.OtherCity2.value;
		var pincode1=document.personal_info.pincode1.value;
		var pstdno=document.personal_info.Perm_stdcode.value;
		var pphoneno=document.personal_info.Perm_phoneno.value;
		 
 
 alert('checkAddressDetails'+document.personal_info.ResidentialStatus.length);
//Validation for address 
		var addrRegEx = /^([a-zA-Z0-9 #,.\-\/])*$/
			alert(document.personal_info.ResidentialStatus[0].checked);	
		var resStatusFlag=false;
				for(var i=0; i<document.personal_info.ResidentialStatus.length;i++){ 
						
					if(document.personal_info.ResidentialStatus[i].checked){
						document.personal_info.ResidentialStatus.value = document.personal_info.ResidentialStatus[i].value; //unni
						resStatusFlag=true;
						alert('checked');
						break;
					}
				}
		if(!resStatusFlag){
			alert("Please select a Residential status");
			return false;
			}

		if(addr.length == 0)
		{     
			document.personal_info.Address.style.border = "2px solid red";
			alert("Please enter present address");
			document.personal_info.Address.focus();
			return false;
		} 

		else if(addr.length>30)
		{
			document.personal_info.Address.style.border = "2px solid red";
			alert("Please enter present address,without exceeding 30 characters");
			document.personal_info.Address.focus();
			return false;
		}
		else if(addrRegEx.test(addr) == false) 
		{     
			document.personal_info.Address.style.border = "2px solid red";
			alert("Please enter valid present address, without special characters");
			document.personal_info.Address.focus();
			return false;
		 
		}
 
 

			var cityRegex = /^([a-zA-Z])*$/
			//Validation for city
			if(city == "")
			{
				alert("Please select your present city");
				return false;
			}
			 
			else if(city == "Others")
			{ 

			if(ocity.length == 0)
			{
				document.personal_info.OtherCity1.style.border = "2px solid red";
				alert("Please enter your present other city name");
				document.personal_info.OtherCity1.focus();
				return false;
			}


			if(ocity.length>30)
			{
				document.personal_info.OtherCity1.style.border = "2px solid red";
				alert("Please enter your present city name,without exceeding 30 characters");
				document.personal_info.OtherCity1.focus();
				return false;
			}
			 
			else if(cityRegex.test(ocity) == false)
			{
				document.personal_info.OtherCity1.style.border = "2px solid red";
				alert("Please enter your present city name,without any special characters or numbers");
				document.personal_info.OtherCity1.focus();
				return false;
				}
			 
			}
			 
			var pincodeRegEx = /^([0-9])*$/
			//Validation for pincode
			if(pincode.length == 0){
				 
				document.personal_info.Pincode.style.border = "2px solid red";
				alert("Please enter your present city pincode");
				document.personal_info.Pincode.focus();
				return false;
			}
			else if(pincode.length<6){
				document.personal_info.Pincode.style.border = "2px solid red";
				alert("Please enter valid present address pincode with 6 digits");
				document.personal_info.Pincode.focus();
				return false;
			}
			else if(pincodeRegEx.test(pincode)==false)
				{
				document.personal_info.Pincode.style.border = "2px solid red";
				alert("Please enter valid present address pincode");
				document.personal_info.Pincode.focus();
				return false;
				}
     
 
			//valdation for phone no.
			 
			var noRegEx = /^([0-9])*$/
			if(stdno.length == 0)
			{    document.personal_info.stdno.style.border = "2px solid red";
				alert("Please enter present city std code");
				document.personal_info.stdno.focus();
				return false;
			}
			else if(stdno.length < 2)
			{
				document.personal_info.stdno.style.border = "2px solid red";
				alert("Please enter present city valid std code");
				document.personal_info.stdno.focus();
				return false;
				 
			}
			else if(noRegEx.test(stdno) == false)
				{
				document.personal_info.stdno.style.border = "2px solid red";
				alert("Please enter present city std code with digits only");
				document.personal_info.stdno.focus();
				return false;
				}
			 
			 
			if(phoneno.length == 0)
			{   document.personal_info.phoneno.style.border = "2px solid red";
				alert("Please enter your present telephone number");
				document.personal_info.phoneno.focus();
				return false;
			}
			else if(noRegEx.test(phoneno) == false)
			{    document.personal_info.phoneno.style.border = "2px solid red";
				alert("Please enter a valid present telephone number");
				document.personal_info.phoneno.focus();
				return false;
			 
			}

 
	 if(document.personal_info.checkid.checked == false){
		copyPresentAddresToPermanentAddress('personal_info');
	 }
	 
	 
	if(document.personal_info.checkid.checked == true){
			//Validation for Permanent Address starts here...
			 
			if(paddr.length == 0)
			{   document.personal_info.Permanent_Address.style.border = "2px solid red";
				alert("Please enter your permanent address");
				document.personal_info.Permanent_Address.focus();
				return false;
			}
			else if(paddr.length>30)
			{
				document.personal_info.Permanent_Address.style.border = "2px solid red";
				alert("Please enter your permanent address,without exceeding 30 characters");
				document.personal_info.Permanent_Address.focus();
				return false;
			}
			else if(addrRegEx.test(paddr) == false) 
			{     
				document.personal_info.Permanent_Address.style.border = "2px solid red";
				alert("Please enter a valid permanent address, without special characters");
				document.personal_info.Permanent_Address.focus();
				return false;
			 
			}
			 
			if(addrRegEx.test(paddr1) == false) 
			{    document.personal_info.Permanent_Address1.style.border = "2px solid red";
				alert("Please enter a valid permanent address, without special characters");
				document.personal_info.Permanent_Address1.focus();
				return false;
			 
			}

			else if(paddr1.length>30)
			{
				document.personal_info.Permanent_Address1.style.border = "2px solid red";
				alert("Please enter your permanent address,without exceeding 30 characters");
				document.personal_info.Permanent_Address1.focus();
				return false;
			}
			if(addrRegEx.test(paddr2) == false) 
			{    document.personal_info.Permanent_Address2.style.border = "2px solid red";
				alert("Please enter a valid permanent address, without special characters");
				document.personal_info.Permanent_Address2.focus();
				return false;
			 
			}

			else if(paddr2.length>30)
			{
				document.personal_info.Permanent_Address2.style.border = "2px solid red";
				alert("Please enter your permanent address,without exceeding 30 characters");
				document.personal_info.Permanent_Address2.focus();
				return false;
			}
		 
		 

		 
		//Validation for city
		 
			 
			if(permanentcity == "")
			{
				 
				alert("Please select your permanent city");
				return false;
			}
			 
			else if(permanentcity == "Others")
			{
				if(opcity.length == 0){
				document.personal_info.OtherCity2.style.border = "2px solid red";
				alert("Please enter your permanent city name");
				document.personal_info.OtherCity2.focus();
				return false;
				}
				else if(opcity.length > 30){
					document.personal_info.OtherCity2.style.border = "2px solid red";
					alert("Please enter your permanent city name,without exceeding 30 characters");
					document.personal_info.OtherCity2.focus();
					return false;
				}
				
				else if(cityRegex.test(opcity) == false){
					document.personal_info.OtherCity2.style.border = "2px solid red";
					alert("Please enter your permanent city name,without any special characters or numbers");
					document.personal_info.OtherCity2.focus();
					return false;
				}
			}
			 
				//Validation for pincode
				if(pincode1.length == 0){
				document.personal_info.pincode1.style.border = "2px solid red";
				alert("Please enter your permanent city pincode");
				document.personal_info.pincode1.focus();
				return false;
				}
				
				else if(pincode1.length<6){
				  document.personal_info.pincode1.style.border = "2px solid red";
				  alert("Please enter a valid permanent address pincode with 6 digits");
					document.personal_info.pincode1.focus();
				   return false;
				}
				
				else if(pincodeRegEx.test(pincode1) == false){ 
				document.personal_info.pincode1.style.border = "2px solid red";
				alert("Please enter valid permanent address pincode");
				document.personal_info.pincode1.focus();
				return false;
				}
		 
		 
		 
				//valdation for phone no.
				 
					if(pstdno.length == 0){
					  document.personal_info.Perm_stdcode.style.border = "2px solid red";
					  alert("Please enter permanent city std code");
						document.personal_info.Perm_stdcode.focus();
					 return false;
					}
						else if(pstdno.length<2)
						{
						 document.personal_info.Perm_stdcode.style.border = "2px solid red";
					 alert("Please enter permanent city std code, with minimum 2 digits");
						document.personal_info.Perm_stdcode.focus();
					   return false;
					}
				 
						else if(noRegEx.test(pstdno) == false)
					  {
						 document.personal_info.Perm_stdcode.style.border = "2px solid red";
						 alert("Please enter permanent city std code with digits only");
						document.personal_info.Perm_stdcode.focus();
						  return false;
					 }
				 
				 
						if(pphoneno.length == 0)
						{
						document.personal_info.Perm_phoneno.style.border = "2px solid red";
						alert("Please enter permanent address telephone number");
						 document.personal_info.Perm_phoneno.focus();
							return false;
						}
				 
						else if(noRegEx.test(pphoneno) == false)
							{
							   document.personal_info.Perm_phoneno.style.border = "2px solid red";
							  alert("Please enter valid permanent address telephone number");
								document.personal_info.Perm_phoneno.focus();
							 return false;
							}
		 
		 }//End of if condition for the check box is selected
     
 
}

//function to check wether Fname,LastName & email id is filled
function isDetialfilled(){

	
		var isvalidDet = false;	
	
		var fName = document.personal_info.FirstName.value;
		var lname = document.personal_info.LastName.value;
		var emailidEntered = document.personal_info.EmailId.value;		
		var regEmail = /^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		var regName = /^([a-zA-Z])*$/;
	  
		if((regName.test(fName)== true && fName.length > 3) && (regName.test(lname)== true && lname.length > 3))
		{
			
			if(regEmail.test(emailidEntered)== true && emailidEntered.length > 4)
			{	
				isvalidDet = true;
			}
	
		}
	
		
	
	//alert("is validate"+isvalidDet);
	return isvalidDet;

	
}//End of function

function isNoServicefilled(){

		//alert("inside is detail filled");
		var isvalidDet = false;	
	
		var fName = document.personal_info.FirstName.value;
		var lname = document.personal_info.LastName.value;
		var emailidEntered = document.personal_info.EmailId.value;		
		var regEmail = /^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		var regName = /^([a-zA-Z])*$/;
	   	
	   	//alert(fName+"==="+lname+"=="+emailidEntered)
	   	
	   	//alert("regName.test(fName)="+regName.test(fName))
	   	//alert("fName.length="+fName.length)
	   	//alert("regName.test(lname)="+regName.test(lname))
	   	//alert("lname.length="+lname.length)
	   	//alert("regEmail.test(emailidEntered)="+regEmail.test(emailidEntered))	   		   		   	
	   
		if((regName.test(fName)== true && fName.length > 3) && (regName.test(lname)== true && lname.length > 3))
		{
			//alert("inside condition")
			if(regEmail.test(emailidEntered)== true && emailidEntered.length > 4)
			{	
				isvalidDet = true;
			}else
			{
				alert("Please enter proper Email Address.")
			}
	
		}else
		{
			alert("Please enter proper First and Last Name.")
		}
	//alert("is validate"+isvalidDet);
	return isvalidDet;

	
}//End of function



function checkCreditCardDetails(){
	var creditBankName = document.personal_info.Bank.value;
	var card1 = document.personal_info.Card_number1.value;
	var card2 = document.personal_info.Card_number2.value;
	var card3 = document.personal_info.Card_number3.value;
	var card4 = document.personal_info.Card_number4.value;
	var cardlimit = document.personal_info.Credit_limit.value;

	if((creditBankName != "")||(card1 != "")||(card2 != "")||(card3 != "")||(card4 != "")||(cardlimit != "")){
	/*Bank Name*/
	var creditbankNamedots = 0;
	var creditbankNamespaces = 0;
	 
	var creditBankNameRegEx = /^([a-zA-Z, .&])*$/
		if((creditBankNameRegEx.test(creditBankName)==false)||(creditBankName.length<1)){
			alert("Please enter your credit card bank name");
			 document.personal_info.Bank.style.border = "2px solid red";
			 document.personal_info.Bank.focus();
			 return false;
		}

		if(creditBankName.length > 50){
		alert("Please enter your credit card bank name without exceeding 50 characters");
			 document.personal_info.Bank.style.border = "2px solid red";
			  document.personal_info.Bank.focus();
			 return false;
		}
	 
	 
		if((creditBankName.indexOf("  ") != -1)||(creditBankName.indexOf("..") !== -1)||(creditBankName.charAt(0) == ' ')||(creditBankName.charAt(0) == '.')){
				alert("Please enter a valid bank name without continuous special characters");
				document.personal_info.Bank.style.border = "2px solid red";
				 document.personal_info.Bank.focus();
				return false;
			}
	/*End Bank Name*/

	/*Start validating credit card Number*/
	var cardRegEx = /^([0-9]){4}$/
	var cardEndRegEx = /^([0-9]){2,4}$/

	if((cardRegEx.test(card1)==false)||(cardRegEx.test(card2)==false)||(cardRegEx.test(card3)==false)||(cardEndRegEx.test(card4)==false)){
		alert("Please enter a valid card number");
		return false;
	}

	/*End validating credit card Number*/

	/*vaildate for member month & year*/

	var membermonth = document.personal_info.MemberSince.value;
	var memberyear = document.personal_info.MemberSince1.value;



	if(membermonth == "MM"){
		alert("Please enter the member since month");
		return false;
	}

	if(memberyear == "YYYY"){
		alert("Please enter the member since year");
		return false;
	}

	/* 
	if((membermonth >(validmonth+01))&&(validyea == memberyear)){
		alert("please enter the member since month");
		return false;
	}
	 
	if(memberyear > validyea){
		alert("please enter the member since year");
		return false;
	}
	*/
	/*End vaildate for member month & year*/

	/*Start validation Limit*/
	var limitRegExp = /^([0-9]){1,9}$/
	 
	if(limitRegExp.test(cardlimit)==false){
		alert("Please enter your credit limit with digits only");
		document.personal_info.Credit_limit.style.border = "2px solid red";
		 document.personal_info.Credit_limit.focus();
		return false;
	}
	/*End validation Limit*/
}

}

//End of functions from LBI - for cardtype
