var tmpIteration=0;
var homeLoanArray = new Array();
var personalLoanArray = new Array();
var carLoanArray = new Array();
var creditCardArray = new Array();
var helpMsgArray = new Array('Kindly enter valid email id as an activation code will be mailed & you have to enter the same code in your application form for validation or confirm by clicking on the link sent in the mail',
	'Kindly enter valid mobile number as an activation code will be sent by SMS to that number & you have to enter the same code in your application form for validation or reply to the SMS through the same mobile',
	'Select the appropriate reason for which you need this loan. Provide exact reason or purpose to facilitate appropriate action',
	
	'Provide Gross Monthly Income. You can club income of co-borrowers (i.e. Spouse+Parents+Children+Siblings). You should only include income that you can prove through relevant documents such as ITR,Salary Slip, Form 16 OR Bank Statement',
	'Directors in Pvt. Ltd.Co. with shareholding in the company should select Self Employed',
	'Provide the city name where you are presently staying',
	'The information you provide here will help us understand your needs better so that we may connect you to the correct banks. We take consumer privacy seriously. Please refer to our Privacy Policy to find out how we use this information.',
	'You can select Multiple cards that you are currently holding.',
	
	'Select the appropriate type of card that you wish to apply for',
	'Provide Gross Monthly Income. You should only include income that you can prove through relevant documents such as ITR,Salary Slip, Form 16 OR Bank Statement',
	'Directors in Pvt. Ltd.Co. with shareholding should select Self Employed',
	'This information will enable the banks to contact you',
	'This will enable the banks to understand your existing loan amounts. Some banks provide special schemes for consumers with good payment track record.',
	'Please re-enter mobile number',
	'Please enter a 4 digit numeric password / mobile pin',
	'Please re-enter the 4 digit numeric password / mobile pin',
	'Please re-enter email address');	

helpLoanMsgArray = new Array();
helpLoanMsgArray[0] ="Please select loan type from quick apply.";
helpLoanMsgArray[1] ="To buy a ready flat: Loan required to purchase a ready to occupy flat. All construction work is already finished <br /><br />"; 
helpLoanMsgArray[1] +="'To buy an under construction flat: Loan required to purchase a property where the construction work is still going  on' <br /><br /> 'To buy a resale property: Loan required to purchase a ready to occupy flat which is already owned by someone else & the owner has agreed to sell it to you for a price' <br /><br /> 'To buy a plot: Loan required to purchase a piece of land/plot' <br /><br /> 'To buy a commercial property: Loan required to purchase property which can be used as an Office, Bussiness Unit or for some other commercial purpose' <br /><br /> 'To finance self construction costs: Loan required for building of house,shop on owned plots/land' <br /><br /> 'Home Improvement Loan: Loan required to refurnish, re-develop, decorate or re-decorate the existing property' <br /><br /> 'To transfer existing loan to another lender: Also commonly known as Balance Transfer where you transfer your existing outstanding loan amount from one lender to another at lower rate of interest or for other benefits' <br /><br /> 'To transfer existing loan with top up: Avail for an Balance transfer where you transfer your existing outstanding loan amount from one lender to another alongwith additional amount which you can use for renovation or other purposes' <br /><br />"; 
helpLoanMsgArray[1] += "'To buy a shop: Loan required to purchase a property which will be used as an retail/wholesale trading place'";

helpLoanMsgArray[2] ="Select the appropriate reason for which you need this loan. Provide exact reason or purpose to facilitate appropriate action";
helpLoanMsgArray[3] ="Select the appropriate type of card that you wish to apply for";
helpLoanMsgArray[4] ="Select the appropriate type of car for which you need this loan.";
helpLoanMsgArray[19] = "Loan against property";
helpLoanMsgArray[21] = "Commercial property / shop";
helpLoanMsgArray[17] = "Plot of land";
helpLoanMsgArray[23] = "Others";

/*************** Setting BaseURL ********************/

var tempUrl = top.location.href;
tempUrl=tempUrl.split('/');
serverHost = tempUrl[2];
scriptName=tempUrl[3];
if (top.location.href.indexOf("192.168.0.126") != -1 || top.location.href.indexOf("192.168.0.127") != -1 ||top.location.href.indexOf("192.168.0.128") != -1 || top.location.href.indexOf("192.168.0.128") != -1 ){
	var baseURL="http://"+serverHost+"/"+scriptName+"/apnaloanProject";	
}else if(top.location.href.indexOf("mlep.com") != -1){
	var baseURL="http://"+serverHost+"/"+scriptName+"/apnaloan";
}else if(top.location.href.indexOf("192.168.1.117") != -1)
{
	var baseURL="http://192.168.1.117/apnaloan";
}else if(top.location.href.indexOf("apnaloan.com") != -1)
{
	var baseURL="http://www.apnaloan.com";
}

/*************** Setting BaseURL ********************/

var applyFormRegistration=new Object();
//applyFormRegistration["PRODUCT_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"type of loan you are looking for"};
applyFormRegistration["CUST_NAME"] = {blank:true,valid:true, validateFunction:[fullNameValidation],label:"your full name"};
applyFormRegistration["COUNTRY_CODE"] = {blank:true,valid:true, validateFunction:[digitValidation],label:"Country Code No."};	
applyFormRegistration["TEL_MOBILE"] = {blank:true,valid:true, validateFunction:[mobilenumberValidation],param:{isNRI:'N'},label:"your mobile-number (10-Digit Number)"};	
applyFormRegistration["OFF_LAND_LINE_AREACODE"] = {blank:true,valid:true, validateFunction:[digitValidation],label:" Landline STD code."};	
applyFormRegistration["TEL_OFF"] = {blank:true,valid:true, validateFunction:[digitValidation],label:" Landline phone no."};	
applyFormRegistration["OFF_LAND_LINE_EXT"] = {valid:true, validateFunction:[digitValidation],label:" Landline extension."};
applyFormRegistration["EMAIL"] = {blank:true,valid:true, validateFunction:[emailValidation],label:"Email Address"};


applyFormRegistration["SUB_PRODUCT_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"type of Loan you are looking for"};

applyFormRegistration["LOAN_AMT"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Desired Loan Amount",param:{min:1,max:999999999}};

applyFormRegistration["INCOME"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Monthly Income",param:{min:1,max:999999999}};

applyFormRegistration["PROFESSION_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Employment Type"};

applyFormRegistration["CITY_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Residence City"};	

applyFormRegistration["DOB_DAY"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Day of Date Of Birth"};	

applyFormRegistration["DOB_MONTH"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Month of Date Of Birth"};

applyFormRegistration["DOB_YEAR"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Year of Date Of Birth"};	


fieldMap["applyFormRegistration"]=applyFormRegistration;

var formLogin=new Object();
formLogin['COUNTRY_CODE1']={blank:true,valid:true, validateFunction:[digitValidation],label:'Country Code No.'};	
formLogin['TEL_MOBILE1'] = {blank:true,valid:true, validateFunction:[mobilenumberValidation],param:{isNRI:'Y'},label:'your mobile-number (10-Digit Number)'};
formLogin['EMAIL1'] = {blank:true,valid:true, validateFunction:[emailValidation],label:'Email Address'};
formLogin['MOBILE_CONF_CODE'] = {blank:true, valid:true, validateFunction:[digitValidation,stringLengthValidation],label:'Mobile Pin',param:{stringLen:4}};
fieldMap['formLogin']=formLogin;

var formLogedInUserRegister=new Object();
formLogedInUserRegister["PRODUCT_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"type of Loan you are looking for"};
formLogedInUserRegister["CUST_NAME"] = {blank:true,valid:true, validateFunction:[fullNameValidation],label:"your full name"};
formLogedInUserRegister["COUNTRY_CODE"] = {blank:true,valid:true, validateFunction:[digitValidation],label:"Country Code No."};	
formLogedInUserRegister["EMAIL"] = {blank:true,valid:true, validateFunction:[emailValidation],label:"Email Address"};
fieldMap["formLogedInUserRegister"]=formLogedInUserRegister;

var frmAskApna=new Object();

frmAskApna["COUNTRY_CODE_QUERY"] = {blank:true,valid:true, validateFunction:[digitValidation],label:"Country Code No."};	
frmAskApna["PRODUCT_ID_QUERY"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Question Category"};
frmAskApna["question_ask"] = {blank:true,valid:true, validateFunction:[thousandCharValidation],label:"Question"};
frmAskApna["mobile_number"] = {blank:true,valid:true, validateFunction:[mobilenumberValidation],param:{isNRI:'N'},label:"your mobile-number (10-Digit Number)"};	
frmAskApna["email_id"] = {blank:true,valid:true, validateFunction:[emailValidation],label:"Email address"};


fieldMap["frmAskApna"]=frmAskApna;


var frmViewApna=new Object();

frmViewApna["query_id"] = {blank:true,valid:true, validateFunction:[fivehundredCharValidation],label:"Query Id"};

fieldMap["frmViewApna"]=frmViewApna;

function askapnaloanValidation(){
	var errorStatus = validation(document.frmAskApna);
		if(errorStatus)
		{
			document.frmAskApna.submit();
					
		}
}
function viewApnaloanValidation()
{
	var errorStatus = validation(document.frmViewApna);
		if(errorStatus)
		{
			query_id = document.getElementById('query_id').value.replace('q','');
			//alert(query_id);		
			
			var queryUrl = top.location.href;
			
			//alert("Var---"+tempUrl)	;
			
			var flagCheck=0;
			
			queryUrl=queryUrl.split('/');
			
			for(i=0;i<queryUrl.length;i++)
			{
				if(queryUrl[i]=='query')
				{
					
					flagCheck=1;
											
				}
				
			}
			document.frmViewApna.setMoreQueries.value='2';
			
			if(flagCheck==1)
			{
					document.frmViewApna.action='Question'+query_id+'.html';
					//document.frmViewApna.submit();
					window.location.href='Question'+query_id+'.html';		
				
			}
			else
			{
					document.frmViewApna.action='query/Question'+query_id+'.html';
					//document.frmViewApna.submit();
					window.location.href='query/Question'+query_id+'.html';		
				
				
			}
			
		}
}

var frmGuestBook = new Object();

frmGuestBook['GUEST_NAME'] = {blank:true,valid:true, validateFunction:[fullNameValidation],label:"your full name"};
frmGuestBook['GUEST_EMAIL'] = {blank:true,valid:true, validateFunction:[emailValidation],label:"Email address"};
frmGuestBook['GUEST_CITY'] = {valid:true, validateFunction:[firstnameValidation],label:" City"};
frmGuestBook['GUEST_MOBILE'] = {valid:true, validateFunction:[mobilenumberValidation],param:{isNRI:'Y'},label:"mobile-number"};
frmGuestBook['GUEST_COMMENT'] = {blank:true, validateFunction:[fullNameValidation],label:"comment"};
fieldMap["frmGuestBook"]=frmGuestBook;

function validateGuestBook()
{	
	var errorStatus = validation(document.frmGuestBook);	
	
	if(errorStatus)
	{		
		var strData="";
				
		strData = 'GUEST_NAME='+escape(document.getElementById('GUEST_NAME').value);
		strData += '&GUEST_EMAIL='+escape(document.getElementById('GUEST_EMAIL').value);
		strData += '&GUEST_COMPANY='+escape(document.getElementById('GUEST_COMPANY').value);
		strData += '&GUEST_CITY='+escape(document.getElementById('GUEST_CITY').value);
		strData += '&GUEST_MOBILE='+escape(document.getElementById('GUEST_MOBILE').value);		
		strData += '&GUEST_COMMENT='+escape(document.getElementById('GUEST_COMMENT').value);
		
		if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
			tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';			
		
		xmlhttpPost("POST",tempURL+"guestBookP.php","guestBookHandler",strData);		
	}	
	return false;
}
function guestBookHandler(ajaxResponse)
{
	switch (ajaxResponse)
	{
		case "Please provide value for all mandatory fields":
			document.getElementById('tdDisplayMessage').innerHTML = "<span class='lblerror'>"+ajaxResponse+"</span>";	
			break;
		
		case "Thank you for your valuable comment. We look forward to serve you again.":
			document.getElementById('tdDisplayMessage').innerHTML = "<br /><span class='lblsuccess'>"+ajaxResponse+"</span>";
			break;
	}
	
}
function validateRegistrationForm()
{
	
	var formRegistration=new Object();
	formRegistration["PRODUCT_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"type of loan you are looking for"};
	formRegistration["CUST_NAME"] = {blank:true,valid:true, validateFunction:[fullNameValidation],label:"your full name"};
	formRegistration["COUNTRY_CODE"] = {blank:true,valid:true, validateFunction:[digitValidation],label:"Country Code No."};	
	formRegistration["OFF_LAND_LINE_AREACODE"] = {blank:true,valid:true, validateFunction:[digitValidation],label:" Landline STD code."};	
	formRegistration["TEL_OFF"] = {blank:true,valid:true, validateFunction:[digitValidation],label:" Landline phone no."};	
	formRegistration["OFF_LAND_LINE_EXT"] = {valid:true, validateFunction:[digitValidation],label:" Landline extension."};
	formRegistration["EMAIL"] = {blank:true,valid:true, validateFunction:[emailValidation],label:"Email Address"};	
	
	if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnCreditCardProdId').value)
	{
		formRegistration["SUB_PRODUCT_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Type of Card you are looking for"};
	}
	else
	{
		formRegistration["SUB_PRODUCT_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"type of Loan you are looking for"};			
		formRegistration["LOAN_AMT"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Desired Loan Amount",param:{min:1,max:999999999}};
	}
	
	formRegistration["INCOME"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Monthly Income",param:{min:1,max:999999999}};
	
	var dayValue = document.getElementById('DOB_DAY').value;
	var monthValue = document.getElementById('DOB_MONTH').value;
	var yearValue = document.getElementById('DOB_YEAR').value;	
	
	formRegistration['DOB_MONTH'] = {blank:true, valid:true, validateFunction:[DateValidation],label:'Date of birth',param:{day:dayValue,month:monthValue,year:yearValue}};		
	
	formRegistration["PROFESSION_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Employment Type"};
	formRegistration["CITY_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Residence City"};
	
	fieldMap["formRegistration"]=formRegistration;
	
	var isNRIValue=document.getElementById('IS_NRI_YN').value;
	
	formRegistration["TEL_MOBILE"] = {blank:true,valid:true, validateFunction:[mobilenumberValidation],param:{isNRI:isNRIValue},label:"your mobile-number (10-Digit Number)"};
	
	if(document.getElementById('CITY_ID').value=='other')
	formRegistration['OTHER_CITY_NAME'] = {blank:true,valid:true, validateFunction:[firstnameValidation],label:"other city"};
				
	var errorStatus = validation(document.formRegistration);
		if(errorStatus)
		{
			var chkLead = document.getElementById('CHK_AJAX_LEAD_RESPONSE').value;
			
			var flagResponse = checkAjaxResponse(chkLead);
			//alert('flagResponse=='+flagResponse)
			if(flagResponse)
			{	
				if(document.getElementById('checkTerms').checked)
				{
					document.formRegistration.submit();
				}
				else
				{
					alert("Please,Check terms and conditions for apnaloan.com. ");
				}
			}					
		}
}

function validateBuyerFormRegistration()
{
		
	var buyerFormRegistration=new Object();
	
	buyerFormRegistration["BUYER_NAME"] = {blank:true,valid:true, validateFunction:[fullNameValidation],label:"your full name"};
	buyerFormRegistration["TEL_MOBILE"] = {blank:true,valid:true, validateFunction:[mobilenumberValidation],param:{isNRI:'N'},label:"your mobile-number (10-Digit Number)"};
	buyerFormRegistration["EMAIL"] = {valid:true, validateFunction:[emailValidation],label:"Email Address"};
	
	fieldMap["buyerFormRegistration"]=buyerFormRegistration;
		
	var errorStatus = validation(document.buyerFormRegistration);
	if(errorStatus)
	{
			
			document.buyerFormRegistration.submit();
			
	}
}

function validateLogIn()
{		
		var dayValue = document.getElementById('DOB_DAY_LOGIN').value;
		var monthValue = document.getElementById('DOB_MONTH_LOGIN').value;
		var yearValue = document.getElementById('DOB_YEAR_LOGIN').value;
		formLogin['DOB_MONTH_LOGIN'] = {blank:true, valid:true, validateFunction:[DateValidation],label:'Date of Birth',param:{day:dayValue,month:monthValue,year:yearValue}};
		var errorStatus = validation(document.formLogin);
		if(errorStatus)
		{
			document.formLogin.submit();
			return false;
		}	
}

function getNRIForm()
{
	
	/*if(confirm('This will take you to an application form for Non Resident Indians. Are you sure?'))
	{*/
		var arrProdId = new Array();	
		var arrProdText = new Array();
		var j=0;
		var productLen=document.getElementById('PRODUCT_ID').options.length;
		
		document.getElementById('SUB_PRODUCT_ID').options.length=1;
		
		for(productCnt=1;productCnt<productLen;productCnt++)
		{
			if(document.getElementById('PRODUCT_ID').options[productCnt].value!=document.getElementById('hdnCreditCardProdId').value)
			{
				arrProdId[j] = document.getElementById('PRODUCT_ID').options[productCnt].value;
				arrProdText[j] = document.getElementById('PRODUCT_ID').options[productCnt].text;
				j++;
			}
		}
		document.getElementById('PRODUCT_ID').options.length=1;	
		for(i=0;i<arrProdId.length;i++)
		{		
			document.getElementById('PRODUCT_ID').options.length=document.getElementById('PRODUCT_ID').options.length+1;
			document.getElementById('PRODUCT_ID').options[i+1].value = arrProdId[i];
			document.getElementById('PRODUCT_ID').options[i+1].text = arrProdText[i];
		}
			
		document.getElementById('COUNTRY_CODE').value='';
		document.getElementById('COUNTRY_CODE').readOnly=false;
		document.getElementById('phoneLabel').innerHTML='Area&nbsp;&nbsp;Phone No&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ext';
		if(document.getElementById('QR-column-header').innerHTML!='')
		{
			document.getElementById('QR-column-header').innerHTML="<span class='mainheading1'>NRI QUICK APPLY</span>";
		}
		else
		{
			document.getElementById('nri').innerHTML="NRI QUICK APPLY";
		}
		//document.getElementById('applyLink').innerHTML="<a href='#' class='nri' onClick='getQuickForm();return false;' title='Go to Indian Quick Apply form'>Quick Apply</a>";
		document.getElementById('IS_NRI_YN').value='Y';
		document.getElementById('checkResident1').innerHTML="<input type='radio'  name='IS_NRI_YN1' value='N' id='IS_NRI_N'  style='border:0' onClick='getQuickForm();return false;'/>Indian";
		document.getElementById('checkResident2').innerHTML="<input type='radio' name='IS_NRI_YN1' value='Y' id='IS_NRI_Y'  style='border:0' onClick='getNRIForm();return false;' checked/>NRI";

		document.getElementById('TBL_OTHER_CITY_NAME').style.display="none";
		
		//CODE TO GET City Name from GEN_NRI_ CITY
		if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
			tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';
						
		xmlhttpPost("GET",tempURL+"manufacturerP.php?getNRICity=Y","assignCity","");
	//}	
	
}
function assignCity(ajaxData)
{
	//alert(ajaxData);
	var i=0;	
	arrNriCity = ajaxData.split(',');
	document.getElementById('CITY_ID').length=1;
	var tempI;
	var flag;
	flag="true";
		
	selectOptions="<select id ='CITY_ID' name='CITY_ID' style='width:140px;' onchange=\"cityGetother(document.getElementById('CITY_ID'),document.getElementById('TBL_OTHER_CITY_NAME'));\"><option value='0'>Select a City</option>";

	if(document.getElementById('IS_NRI_YN').value=="N")
	{
		selectOptions+="<option value='0' style='color: White; background-color: SlateGray; font-weight: bold;'>Metros</option>";
	}
	
	for(i=0;i<arrNriCity.length;i++)
	{	
		arrNriCityTemp = arrNriCity[i].split('-');
		arrNriCityId = arrNriCityTemp[0];
		arrNriCityName = arrNriCityTemp[1];	
		arrNriCityPri = arrNriCityTemp[2];
		
		
		tempI = parseInt(i) - 1;

		if(tempI!="-1" )
		{
			arrNriCityTemp = arrNriCity[tempI].split('-');
			arrNriCityIdPrev = arrNriCityTemp[0];
			arrNriCityNamePrev = arrNriCityTemp[1];	
			arrNriCityPriPrev = arrNriCityTemp[2];

			
		}
		
		if(arrNriCityPri=='0' && arrNriCityPriPrev!='0')
		{
			if(flag=="true")
			{
				selectOptions+='<option value="0" style="color: White; background-color: SlateGray; font-weight: bold;">Other Cities</option>';
				flag="false";

			}
			selectOptions+='<option value="'+arrNriCityId+'">'+arrNriCityName+'</option>';
			
		}else
		{
			selectOptions+='<option value="'+arrNriCityId+'">'+arrNriCityName+'</option>';
		}
				
	}
	selectOptions+='<option value="other">Other City</option>';
	selectOptions+='</select>';
	document.getElementById('Cities').innerHTML=selectOptions;
	
}
function getQuickForm()
{	
	//window.location.reload();
	
	var arrProdId = new Array();
	var arrProdText = new Array();
	var j=0;
	var productLen=document.getElementById('PRODUCT_ID').options.length;
	
	document.getElementById('SUB_PRODUCT_ID').options.length=1;
	
	for(productCnt=1;productCnt<productLen;productCnt++)
	{			
			arrProdId[j] = document.getElementById('PRODUCT_ID').options[productCnt].value;
			arrProdText[j] = document.getElementById('PRODUCT_ID').options[productCnt].text;
			j++;
	}
	document.getElementById('PRODUCT_ID').options.length=1;
	document.getElementById('PRODUCT_ID').options.length=document.getElementById('PRODUCT_ID').options.length+1;
	document.getElementById('PRODUCT_ID').options[1].value = document.getElementById('hdnCreditCardProdId').value;
	document.getElementById('PRODUCT_ID').options[1].text = document.getElementById('hdnCreditCard').value;	
	
	for(i=0;i<arrProdId.length;i++)
	{		
		document.getElementById('PRODUCT_ID').options.length=document.getElementById('PRODUCT_ID').options.length+1;
		document.getElementById('PRODUCT_ID').options[i+2].value = arrProdId[i];
		document.getElementById('PRODUCT_ID').options[i+2].text = arrProdText[i];
	}	
	document.getElementById('COUNTRY_CODE').value='91';
	document.getElementById('COUNTRY_CODE').readOnly=true;
	document.getElementById('phoneLabel').innerHTML='STD&nbsp;&nbsp;&nbsp;&nbsp;Phone No&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ext';
	if(document.getElementById('QR-column-header').innerHTML!='')
	{
		document.getElementById('QR-column-header').innerHTML="<span class='mainheading1'>QUICK APPLY</span>";
	}
	else
	{
		document.getElementById('nri').innerHTML="";
	}
	// document.getElementById('applyLink').innerHTML="<a href='#' class='nri' onClick='getNRIForm();return false;' title='Go to NRIs Apply form'>NRIs Apply here</a>";
	document.getElementById('IS_NRI_YN').value='N';	
	
	//CODE TO GET City Name from GEN_CITY_DEF

	document.getElementById('checkResident1').innerHTML="<input type='radio'  name='IS_NRI_YN1' value='N' id='IS_NRI_N'  style='border:0' onClick='getQuickForm();return false;' checked/>Indian";

	document.getElementById('checkResident2').innerHTML="<input type='radio' name='IS_NRI_YN1' value='Y' id='IS_NRI_Y'  style='border:0' onClick='getNRIForm();return false;'/>NRI";
	document.getElementById('TBL_OTHER_CITY_NAME').style.display="none";
	
	if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
		tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';
					
	xmlhttpPost("GET",tempURL+"manufacturerP.php?getNRICity=N","assignCity","");
	
}
function validateApplyRegistrationForm()
{
	if(document.getElementById('CITY_ID').value=='other')
	applyFormRegistration['OTHER_CITY_NAME'] = {blank:true,valid:true, validateFunction:[firstnameValidation],label:"other city"};

	var errorStatus = validation(document.applyFormRegistration);		
		
	//arrResponseTest = responseAjaxData;
		    	
	if(errorStatus)
	{
			
					
				if(document.getElementById('checkTerms').checked)
				{
					if(document.getElementById('SITE_HOME_URL').value!="")
					tempURL = document.getElementById('SITE_HOME_URL').value + '/' + 'registration.php?flag=campaign';		
				
					document.applyFormRegistration.action=tempURL;
						
					document.applyFormRegistration.submit();
					return false;
			    }
				else
				{
					alert("Please,Check terms and conditions for apnaloan.com. ");
			
				}
		}
}

function validateLogedInUserRegister()
{
		isNRIValue = document.getElementById('IS_NRI_YN').value;		
		formLogedInUserRegister["TEL_MOBILE"] = {blank:true,valid:true, validateFunction:[mobilenumberValidation],param:{isNRI:isNRIValue},label:"your mobile-number (10-Digit Number)"};
	
		var errorStatus = validation(document.formLogedInUserRegister);
		if(errorStatus)
		{
			document.formLogedInUserRegister.submit();
		}
}
function logInSubmit()
{
	document.formLogin.submit();
}

function validateForget()
{
	
	if(!isNullOrUndefined(document.getElementById('isInvalidEmail'))){
		document.getElementById('isInvalidEmail').innerHTML="";
	}
	if(!isNullOrUndefined(document.getElementById('isInvalidMob'))){
		document.getElementById('isInvalidMob').innerHTML="";
	}
	if(!isNullOrUndefined(document.getElementById('email'))){
		var email = document.getElementById('email').value;
	}
	if(!isNullOrUndefined(document.getElementById('mobileNo'))){
		var mobile = document.getElementById('mobileNo').value;
	}
	
	if(mobile=="")
	{
		alert('Please enter the mobile no.');
	}
	else if(email=="")
	{
		alert('Please enter the email.');
	}
	else
	{
		var forget=new Object();
		//forget["TEL_MOBILE"] = {blank:true,valid:true, validateFunction:[mobilenumberValidation],param:{isNRI:'N'},label:"your mobile-number (10-Digit Number)"};
		forget["email"] = {blank:true,valid:true, validateFunction:[emailValidation],label:"Email Address"};
		fieldMap["forget"]=forget;
		var errorStatus = validation(document.forget);
		if(errorStatus)
		{
			document.forget.submit();
		}
	}	
}

function validateNewLoggedUserRegister()
{
		var formNewLoggedUserRegister=new Object();
		formNewLoggedUserRegister["THANK_PRODUCT_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"type of Loan you are looking for"};
		fieldMap["formNewLoggedUserRegister"]=formNewLoggedUserRegister;

		var errorStatus = validation(document.formNewLoggedUserRegister);
		if(errorStatus)
		{
			document.formNewLoggedUserRegister.submit();
		}
}

function checkCookie()
{	
	var arrScript = "";
	var productName = "";
	fillSubProductOnload();
	if(document.cookie.length>0)
	{		
		// --- CODE TO CHECK apnaLoanUser Cookie
			c_name="apnaLoanUser";
			c_start=document.cookie.indexOf(c_name + "=")
			if (c_start!=-1)
			{
				c_start=c_start + c_name.length+1
				c_end=document.cookie.indexOf(";",c_start)
				if(c_end==-1) c_end=document.cookie.length
				if(unescape(document.cookie.substring(c_start,c_end))!="")
				{
					document.getElementById("footerLogin").innerHTML="<a href='"+baseURL+"/logout.php'>Log out</a>";
					document.getElementById("appStatusId").innerHTML="|&nbsp;<a href='"+baseURL+"/appStatus.php'>My Application Status</a><br />";		
					if(!isNullOrUndefined(document.getElementById('sitemapLogin')))
					{
						document.getElementById("sitemapLogin").innerHTML="<strong><a href='"+baseURL+"/appStatus.php'>My Application Status</a></strong>";
					}
					var tempURL='';
					
					if(!isNullOrUndefined(document.getElementById('CHK_AJAX_LEAD_RESPONSE')))
					{
						if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
							tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';			
						
						xmlhttpPost("GET",tempURL+"custInfo.php","assignQuickApply","");
					}	
				}
			 }
			 else // if user is not loged in then detect product name from browser url
			 {		var prodcuct_id=0;
				 	arrScript = window.location.pathname;
					arrScript = arrScript.split('/');
					productName = arrScript[arrScript.length-2];
					productName = productName.split('-');
					productName = productName[0]+' '+productName[1];
					if(document.getElementById('PRODUCT_ID').type=='select-one')
					{
						var productLen=document.getElementById('PRODUCT_ID').options.length;					
						for(productCnt=0;productCnt<productLen;productCnt++)
						{
							tmpProdName = document.getElementById('PRODUCT_ID').options[productCnt].text;
							if(tmpProdName.toLowerCase()==productName.toLowerCase())
							{
								prodcuct_id = document.getElementById('PRODUCT_ID').options[productCnt].value;
								document.getElementById('PRODUCT_ID').value=prodcuct_id;
							}
						}
						fillSubProductOnload(prodcuct_id);
					}	
			 }
			// --- CODE TO CHECK cityKeyword Cookie					
			c_name="cityKeyword";
			c_start=document.cookie.indexOf(c_name + "=")			
			if(c_start!=-1)
			{
				c_start=c_start + c_name.length+1
				c_end=document.cookie.indexOf(";",c_start)
				if(c_end==-1) c_end=document.cookie.length
				if(unescape(document.cookie.substring(c_start,c_end))!="")
				{
					var tempURL='';
					var qstr='';
					if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
						tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';
					
					//xmlhttpPost("GET",tempURL+"keywordP.php?"+qstr,"assignBanner","");
					
					// commented on 21 Aug
					//xmlhttpPost("GET",tempURL+"keywordP.php?"+qstr,"assignAllBanner","");
				}
			}		
	 }	
}

function fillSubProductOnload(productId)
{
    if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
		tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';
	if(!isNullOrUndefined(productId))
	{
	   if(productId!=0)
	     xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+productId, fillSubProductHandler, "");    
	}else{
	   xmlhttpPost("GET", tempURL+'getSubProduct.php?mode=loadSubProduct', fillSubProductOnloadPost, "");
	}
}

function fillSubProductOnloadPost(ajaxData)
{
    //alert('ajaxData:::'+ajaxData);
    arrSubProd = ajaxData.split('|');
    for(i=0;i<arrSubProd.length;i++)
	{	
		productId = arrSubProd[i].split('**');
		switch(productId[0])
		{
		    case '1': 
		          homeLoanArray += productId[1]+"|";
		          break;
		    case '2':
		          personalLoanArray += productId[1]+"|";
		          break;
		    case '3': 
		          creditCardArray += productId[1]+"|";
		          break;
		    case '4': 
		          carLoanArray += productId[1]+"|";
		          break;
		}
		
	}
	homeLoanArray = homeLoanArray.substring(0, homeLoanArray.length-1)
	personalLoanArray = personalLoanArray.substring(0, personalLoanArray.length-1)
	creditCardArray = creditCardArray.substring(0, creditCardArray.length-1)
	carLoanArray = carLoanArray.substring(0, carLoanArray.length-1)
}

function assignQuickApply(ajaxData)
{
	//alert('ajaxData=='+ajaxData);
	arrCustData = ajaxData.split("|");
		
		document.getElementById('CUST_ID').value=arrCustData[0];
		document.getElementById('CUST_NAME').value=arrCustData[1];
		document.getElementById('EMAIL').value=arrCustData[2];
		document.getElementById('CUST_NAME').readOnly='true';
		document.getElementById('EMAIL').readOnly='true';
		arrMobile=arrCustData[3].split("-");
		
		document.getElementById('COUNTRY_CODE').value=arrMobile[0];
		document.getElementById('TEL_MOBILE').value=arrMobile[1];
		
		document.getElementById('COUNTRY_CODE').readOnly='true';
		document.getElementById('TEL_MOBILE').readOnly='true';
		
		arrTelOff=arrCustData[4].split("-");
		document.getElementById('OFF_LAND_LINE_AREACODE').value=arrTelOff[1];
		document.getElementById('TEL_OFF').value=arrTelOff[2];
		document.getElementById('OFF_LAND_LINE_EXT').value=arrTelOff[3];
		
		document.getElementById('OFF_LAND_LINE_AREACODE').readOnly='true';
		document.getElementById('TEL_OFF').readOnly='true';
		document.getElementById('OFF_LAND_LINE_EXT').readOnly='true';		
		document.getElementById('IS_NRI_YN').value=arrCustData[5];
		
		if(arrCustData[5]=='Y')
		{	
				var arrProdValue = new Array();
				var arrProdText = new Array();
				
				var productLen=document.getElementById('PRODUCT_ID').options.length;
				var cnt=0;
				for(productCnt=0;productCnt<productLen;productCnt++)
				{
					if(document.getElementById('PRODUCT_ID').options[productCnt].value!=document.getElementById('hdnCreditCardProdId').value)
					{
						arrProdValue[cnt] = document.getElementById('PRODUCT_ID').options[productCnt].value;
						arrProdText[cnt] = document.getElementById('PRODUCT_ID').options[productCnt].text;					
						cnt=cnt+1;
					}
				}
				document.getElementById('PRODUCT_ID').options.length=0;			
				for(cnt=0;cnt<arrProdValue.length;cnt++)
				{	
					document.getElementById('PRODUCT_ID').options.length=document.getElementById('PRODUCT_ID').options.length+1;
					document.getElementById('PRODUCT_ID').options[cnt].value = arrProdValue[cnt];
					document.getElementById('PRODUCT_ID').options[cnt].text = arrProdText[cnt];				
				}	
				
				//CODE TO GET City Name from GEN_NRI_ CITY
				if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
					tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';
						
				xmlhttpPost("GET",tempURL+"manufacturerP.php?getNRICity=Y","assignCity","");
		}		
		dtDOB = arrCustData[6].split("-");
				
		if(dtDOB[2].substring(0,1)==0)
			dtDOB[2]=dtDOB[2].substring(1,2);
		
		if(dtDOB[1].substring(0,1)==0)
			dtDOB[1]=dtDOB[1].substring(1,2);
			
		document.getElementById('DOB_DAY').value=dtDOB[2];
		document.getElementById('DOB_MONTH').value=dtDOB[1];
		document.getElementById('DOB_YEAR').value=dtDOB[0];
		
		document.getElementById('PROFESSION_ID').value=arrCustData[7];
		
		document.getElementById('CITY_ID').value=arrCustData[8];
		
		if(arrCustData[8]<=0 && arrCustData[9]!='')
		{	
			document.getElementById('CITY_ID').value='other';
			document.getElementById('OTHER_CITY_NAME').value=arrCustData[9];
			document.getElementById('TBL_OTHER_CITY_NAME').style.display='block'
		}		
			
		var tempURL='';
		if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
			tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';
	
		tempURL=tempURL+'existsUserRegister.php';
		
		document.getElementById('formRegistration').action=tempURL;
		//document.getElementById('formRegistration').name='formLogedInUserRegister';
		//alert('AFTER==>'+document.getElementById('formRegistration').action);
		document.getElementById('CHK_AJAX_LEAD_RESPONSE').value = 'N';
		document.getElementById('tdNRIsApply').style.display = 'none';	
}

//**********Validation Of Personal Details Form Start*********//



//**********Validation Of Personal Details Form End*********//

//**********Validation Of Property Details Form Start*********//



//**********Validation Of Property Details Form End*********//
function validatePersonalDetailsForm(){
	
	//alert("str----"+document.getElementById('PROFESSION_ID').value);
	
	var formPersonalDetail=new Object();
//formPersonalDetail["Title"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Title"};

formPersonalDetail["residenceAreaNo"] = {valid:true, validateFunction:[digitValidation],label:"Residence Area Code Number"};
formPersonalDetail["residenceNo"] = {valid:true, validateFunction:[digitValidation],label:"Residence Number"};	
//formPersonalDetail["ADDRESS"] = {valid:true, validateFunction:[thousandCharValidation],label:"Residence Address"};

var isNRIValue=document.getElementById('IS_NRI_YN').value;

formPersonalDetail["PIN_CODE"] = {valid:true, validateFunction:[zipValidation],param:{isNRI:isNRIValue},label:"Residence Zipcode/Postcode"};

fieldMap["formPersonalDetail"]=formPersonalDetail;
	
	
	
	
	if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnCreditCardProdId').value)
	{
		//formPersonalDetail["SUB_PRODUCT_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Type of Card you are looking for"};
	}
	else
	{
		//formPersonalDetail["SUB_PRODUCT_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"type of Loan you are looking for"};			
		//formPersonalDetail["LOAN_AMT"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Desired Loan Amount",param:{min:1,max:999999999}};			
		formPersonalDetail["LOAN_TENURE"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Desired Loan Tenure"};
	}
	
	var errorStatus = validation(document.formPersonalDetail);	
	if(errorStatus){
		//if(document.getElementById('MAIL_CONF_CODE').value == document.getElementById('MOBILE_CONF_CODE').value)	{
		
			document.getElementById('personalDetailDiv').style.display="none";
			document.getElementById('summaryDiv').style.display="none";			
			document.getElementById('propertyDetailsDiv').style.display="block";
			
			if(document.getElementById('RESIDENTIAL_STATUS').value=="NRI")
			{
				document.getElementById('tbl_HL_NRI').style.display="block";
			}
			if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnCarLoanProdId').value)
			{		
				if(document.getElementById('SUB_PRODUCT_ID').value==document.getElementById('hdnUsedCarSubProdId').value)
				{
					document.getElementById('divTypeIsUsedCar').style.display="block";
				}else{
					document.getElementById('divTypeIsUsedCar').style.display="none";
				}
			}
			/*if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnCarLoanProdId').value)
			{
				propertyDetailsForm["CAR_ON_ROAD_PRICE"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Approx. On Road Price",param:{min:1,max:999999999}};

				propertyDetailsForm["CAR_MANUFACTURER"] = {blank:true,label:"Car Manufacturer"};
				propertyDetailsForm["CAR_MODEL"] = {blank:true,label:"Car Model"};
				
			}
			if(document.getElementById('SUB_PRODUCT_ID').value==document.getElementById('hdnUsedCarSubProdId').value)
			{
				document.getElementById('divTypeIsUsedCar').style.display="block";

				propertyDetailsForm["MONTH_OF_REGISTRATON"] = {blank:true,label:"Month of Registration"};	
				propertyDetailsForm["YEAR_OF_REGISTRATON"] = {blank:true,label:"Year of Registration"};	

				propertyDetailsForm["APPROX_MARKET_VALUE"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Approx Market Value",param:{min:1,max:999999999}};
			}*/
			/*if(document.getElementById('PROFESSION_ID').value==1)
			{
				propertyDetailsForm["OTHER_EMPLOYER_NAME"] = {valid:true, validateFunction:[empValidation],label:"Employer Name"};
			}*/			
						
			if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnCreditCardProdId').value)
			{
				insertIntoDB('CUST_ID,LEAD_ID,SUB_PRODUCT_ID,INCOME,PROFESSION_ID,residenceCode,residenceAreaNo,residenceNo,CITY_ID,OTHER_CITY_NAME,PIN_CODE,COUNTRY_ID,OTHER_COUNTRY_NAME','YES');
			}
			else
			{
				insertIntoDB('CUST_ID,LEAD_ID,SUB_PRODUCT_ID,LOAN_AMT,INCOME,LOAN_TENURE,PROFESSION_ID,residenceCode,residenceAreaNo,residenceNo,CITY_ID,OTHER_CITY_NAME,PIN_CODE,COUNTRY_ID,OTHER_COUNTRY_NAME','YES');
			}
			if(document.getElementById('CITY_ID').value!="Other City")
			{
				document.getElementById('OFF_CITY_ID').value=document.getElementById('CITY_ID').value;
			}
			else
			{
				var len=document.getElementById('OFF_CITY_ID').options.length;
				document.getElementById('OFF_CITY_ID').value=document.getElementById('OFF_CITY_ID').options[len].value;
				cityGetother(document.getElementById('OFF_CITY_ID'),document.getElementById('TBL_OFF_OTHER_CITY_NAME'));
			}
			
			
		//  } else{ 	alert('Please Enter same value for Mobile Code and Verify Mobile Code'); }
	}
	
}

function validatePropertyDetailsForm(){
	
	var propertyDetailsForm=new Object();

propertyDetailsForm["OTHER_EMPLOYER_NAME"] = {valid:true, validateFunction:[empValidation],label:"Employer Name"};
propertyDetailsForm["offAreaCode"] = {valid:true, validateFunction:[digitValidation],label:"Office Area Code Number"};
propertyDetailsForm["offNo"] = {valid:true, validateFunction:[digitValidation],label:"Office Number"};
propertyDetailsForm["offExt"] = {valid:true, validateFunction:[digitValidation],label:"Office Ext Number"};
//propertyDetailsForm["OFF_ADDRESS"] = {valid:true, validateFunction:[thousandCharValidation],label:"Office Address"};
propertyDetailsForm["OFF_CITY_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Office City"};

var isNRIValue=document.getElementById('IS_NRI_YN').value;

propertyDetailsForm["OFF_PIN_CODE"] = {valid:true, validateFunction:[zipValidation],param:{isNRI:isNRIValue},label:"Office Zipcode/Postcode"};


if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnCarLoanProdId').value)
{
	propertyDetailsForm["CAR_ON_ROAD_PRICE"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Approx. On Road Price",param:{min:1,max:999999999}};

	propertyDetailsForm["CAR_MANUFACTURER"] = {blank:true,label:"Car Manufacturer"};
	propertyDetailsForm["CAR_MODEL"] = {blank:true,label:"Car Model"};
	
}
if(document.getElementById('SUB_PRODUCT_ID').value==document.getElementById('hdnUsedCarSubProdId').value)
{
	
	propertyDetailsForm["MONTH_OF_REGISTRATON"] = {blank:true,label:"Month of Registration"};	
	propertyDetailsForm["YEAR_OF_REGISTRATON"] = {blank:true,label:"Year of Registration"};	

	propertyDetailsForm["APPROX_MARKET_VALUE"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Approx Market Value",param:{min:1,max:999999999}};
}


fieldMap["propertyDetailsForm"]=propertyDetailsForm;

	if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnCarLoanProdId').value)
	{
		
		ischeckOnRoadPrice_LoanAmount = checkOnRoadPrice_LoanAmount();
		if(ischeckOnRoadPrice_LoanAmount!=true){
			return false;
		}
	}
	if(document.getElementById('RESIDENTIAL_STATUS').value=="NRI" && document.getElementById('PRODUCT_ID').value!=document.getElementById('hdnCreditCardProdId').value)
	{
			propertyDetailsForm["LOCAL_CONTACT_NAME"] = {blank:true,valid:true, validateFunction:[fullNameValidation],label:"Local contact name"};
			propertyDetailsForm["LOCAL_CONTACT_CITY_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Local City"};
			propertyDetailsForm["LOCAL_CONTACT_COUNTRY_CODE"] = {blank:true, valid:true,validateFunction:[digitValidation],label:"Country code"};
			
			var flagValid = false;
			//alert('flagValid 1==>'+flagValid);
			if(Trim(document.getElementById('LOCAL_CONTACT_MOBILE').value)!=""){
				propertyDetailsForm["LOCAL_CONTACT_MOBILE"] = {blank:true,valid:true, validateFunction:[mobilenumberValidation],param:{isNRI:'N'},label:"your mobile-number (10-Digit Number)"};
				flagValid = true;
				//alert('flagValid 2==>'+flagValid);
			}
			else 
			{
				if(Trim(document.getElementById('LOCAL_CONTACT_LANDLINE_NUMBER').value)!="")
				{
					propertyDetailsForm["LOCAL_CONTACT_LANDLINE_CODE"] = {blank:true, valid:true,validateFunction:[digitValidation],label:"Std code"};
					propertyDetailsForm["LOCAL_CONTACT_LANDLINE_NUMBER"] = {blank:true, valid:true,validateFunction:[digitValidation],label:"Phone Number"};
					flagValid = true;
					//alert('flagValid 3==>'+flagValid);				
				}
			}
			//alert('flagValid 4==>'+flagValid);
			if(flagValid==false)
			{
				propertyDetailsForm["LOCAL_CONTACT_MOBILE"] = {blank:true, valid:true,validateFunction:[digitValidation],label:"Local Mobile Number"};								
			}
	}
			
	var errorStatus = validation(document.propertyDetailsForm);
	
	if(errorStatus){
		//document.getElementById('formRegistrationDiv').style.display="none";
		
		document.getElementById('personalDetailDiv').style.display="none";
		document.getElementById('propertyDetailsDiv').style.display="none";
		document.getElementById('summaryDiv').style.display="block";
		optValue = document.getElementById('SUB_PRODUCT_ID').selectedIndex;
		//alert('optValue::'+document.getElementById('SUB_PRODUCT_ID').selectedIndex);
		if(optValue!=0){
			document.getElementById('sumPurposeLoan').innerHTML= ": "+document.getElementById('SUB_PRODUCT_ID').options[optValue].text;
		}
		
		if(document.getElementById('PRODUCT_ID').value!=document.getElementById('hdnCreditCardProdId').value)
		{
			document.getElementById('sumLoanAmt').innerHTML= ": "+document.getElementById('LOAN_AMT').value;
			
			optValue = document.getElementById('LOAN_TENURE').value;
			if(optValue!=0){
			document.getElementById('sumTenure').innerHTML= ": "+document.getElementById('LOAN_TENURE').options[optValue].text;
			}		
		}
		document.getElementById('sumIncome').innerHTML= ": "+document.getElementById('INCOME').value;			
		document.getElementById('sumDob').innerHTML= ": "+document.getElementById('DOB_DAY').value+'-'+document.getElementById('DOB_MONTH').value+'-'+document.getElementById('DOB_YEAR').value;
		
		if(document.getElementById('residenceAreaNo').value.charAt(0)==0||document.getElementById('residenceAreaNo').value.charAt(0)=="0")
		{
			var std = document.getElementById('residenceAreaNo').value.substring(1,document.getElementById('residenceAreaNo').value.length);
			
		}
		else
		{
			var std =document.getElementById('residenceAreaNo').value;
		}
		
		document.getElementById('sumResNum').innerHTML= ": "+document.getElementById('residenceCode').value+"-"+std+"-"+document.getElementById('residenceNo').value;		
		//document.getElementById('sumResAdd').innerHTML= ": "+document.getElementById('ADDRESS').value;
		optValue = document.getElementById('CITY_ID').selectedIndex;
		//alert(optValue +'\n'+document.getElementById('CITY_ID').options[optValue-1].text)
		if(optValue!=0){
			document.getElementById('sumCity').innerHTML= ": "+document.getElementById('CITY_ID').options[optValue].text;
		}
		document.getElementById('sumPinCode').innerHTML= ": "+document.getElementById('PIN_CODE').value;
		if(document.getElementById('offAreaCode').value.charAt(0)==0||document.getElementById('offAreaCode').value.charAt(0)=="0")
		{
			var std = document.getElementById('offAreaCode').value.substring(1,document.getElementById('offAreaCode').value.length);
			
		}
		else
		{
			var std =document.getElementById('offAreaCode').value;
		}
				
		document.getElementById('sumOffNum').innerHTML= ": "+document.getElementById('offCode').value+"-"+std+"-"+document.getElementById('offNo').value+"-"+document.getElementById('offExt').value;		
		//document.getElementById('sumOffAdd').innerHTML= ": "+document.getElementById('OFF_ADDRESS').value;
		optValue = document.getElementById('OFF_CITY_ID').selectedIndex;
		if(optValue!=0){
			document.getElementById('sumOffCity').innerHTML= ": "+document.getElementById('OFF_CITY_ID').options[optValue].text;
		}
		document.getElementById('sumOffPinCode').innerHTML= ": "+document.getElementById('OFF_PIN_CODE').value;
		document.getElementById('sumEmpName').innerHTML= ": "+document.getElementById('OTHER_EMPLOYER_NAME').value;
		
		if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnHomeLoanProdId').value)
		{
			optValue = document.getElementById('IS_PROPERTY_IDENTIFIED').value;
			if(optValue=='Y'){
				document.getElementById('sumProIden').innerHTML= ": Yes";
			}
			if(optValue=='N'){
				document.getElementById('sumProIden').innerHTML= ": No";
			}
			
			document.getElementById('sumArea').innerHTML= ": "+document.getElementById('PROPERTY_AREA').value;
			optValue = document.getElementById('PROP_CITY').selectedIndex;
			if(optValue!=0){
				document.getElementById('sumProCity').innerHTML= ": "+document.getElementById('PROP_CITY').options[optValue].text;
			}
			document.getElementById('sumRegValue').innerHTML= ": "+document.getElementById('REGISTRATION_VALUE').value;
			document.getElementById('sumMarketValue').innerHTML= ": "+document.getElementById('MARKET_VALUE').value;
		}
		var fieldvalue='';
		
		cnt = document.getElementById('hdnBankCount').value; 		
  		Prodcnt = document.getElementById('hdnProdCount').value;
  				  			
		for(var k=0;k<Prodcnt;k++)
		{
			hdnProdId = document.getElementById('hdnProdId'+k).value;
			fieldvalue="";
			for(var j=0;j<cnt;j++)
			{  	  					  					
				if(!isNullOrUndefined(document.getElementById(hdnProdId+'_BANK_ID_'+j)))
				{        			
					if(document.getElementById(hdnProdId+'_BANK_ID_'+j).checked)
					{
						fieldvalue+= document.getElementById(hdnProdId+'_Bank_Name_'+j).value+',';					
					}
				}	
	   		}
	   		fieldvalue=fieldvalue.substr(0,fieldvalue.length-1)
	   		if(!isNullOrUndefined(document.getElementById(hdnProdId+'_OUTSTANDING_AMT')))
			{ 
	   			fieldvalue+=' ('+document.getElementById(hdnProdId+'_OUTSTANDING_AMT').value+')';
			}
	   		
			document.getElementById('sumBankName_'+k).innerHTML=": "+fieldvalue;	
    	} 	  		
    	if(document.getElementById('RESIDENTIAL_STATUS').value=="NRI" && document.getElementById('PRODUCT_ID').value!=document.getElementById('hdnCreditCardProdId').value)
		{
    		insertIntoDB('CUST_ID,LEAD_ID,OFF_CITY_ID,OFF_OTHER_CITY_NAME,offCode,offAreaCode,offNo,offExt,hdnBankCount,hdnProdCount,hdnProdId,BANK_ID,OUTSTANDING_AMT,COMMENTS,LOCAL_CONTACT_NAME,LOCAL_CONTACT_CITY_ID,LOCAL_CONTACT_OTHER_CITY,LOCAL_CONTACT_COUNTRY_CODE,LOCAL_CONTACT_MOBILE,LOCAL_CONTACT_LANDLINE_CODE,LOCAL_CONTACT_LANDLINE_NUMBER','');
		}else
		{
    		insertIntoDB('CUST_ID,LEAD_ID,OFF_CITY_ID,OFF_OTHER_CITY_NAME,offCode,offAreaCode,offNo,offExt,hdnBankCount,hdnProdCount,hdnProdId,BANK_ID,OUTSTANDING_AMT,COMMENTS','');
		}
	}
	
}
function historyBack(form1,form2,mode)
{	
	document.getElementById(form1).style.display="block";
	document.getElementById(form2).style.display="none";
	if(mode==1){
		/*var expdate = new Date();
		expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 31));
		setCookie('user',document.getElementById('CUST_ID').value,expdate);
		window.setTimeout("window.location.href= 'appStatus.php';",50);*/
		/*var int_cust_id = 0;
		var productId=0;
		var residence_status = "";
		int_cust_id = document.getElementById('CUST_ID').value;
		productId=document.getElementById('PRODUCT_ID').value;
		residence_status = document.getElementById('RESIDENTIAL_STATUS').value;
		window.location.href='thanks.php?int_cust_id='+int_cust_id+'&residence_status='+residence_status+'&product_id='+productId;*/
		document.thanksForm.submit();
	}
}

function setCookie (name, value, expireDate){
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}

function getother(selectField,txtField)
{
		selectField = selectField.value.toLowerCase();
		 if(selectField=="other")
		 {			
			txtField.style.display='block';
			txtField.style.visibility='visible';
		 }
	     else
		 {
			txtField.style.display='none';
			txtField.style.visibility='hidden';
		 }
}

function cityGetother(selectField,txtField)
{
		selectField = selectField.value.toLowerCase();
		 if(selectField=="other")
		 {			
			txtField.style.display='';
			txtField.style.visibility='visible';
		 }
	     else
		 {
			txtField.style.display='none';
			txtField.style.visibility='hidden';
		 }
} 
function bankGetother(selectField,txtField)
{
		selectField = selectField.value.toLowerCase();
		 if(selectField=="11")
		 {			
			txtField.style.display='';
			txtField.style.visibility='visible';
		 }
	     else
		 {
			txtField.style.display='none';
			txtField.style.visibility='hidden';
		 }
} 




function copyAddress(){
	if(document.getElementById('sameAdd').checked){
		
		document.getElementById('offAreaCode').value = document.getElementById('residenceAreaNo').value;
		document.getElementById('offNo').value = document.getElementById('residenceNo').value;
		//document.getElementById('OFF_ADDRESS').value = document.getElementById('ADDRESS').value;
		if(document.getElementById('CITY_ID').value=="other"){
			document.getElementById('TBL_OFF_OTHER_CITY_NAME').style.display='block';
			document.getElementById('OFF_OTHER_CITY_NAME').style.visibility='visible';
			document.getElementById('OFF_OTHER_CITY_NAME').value = document.getElementById('OTHER_CITY_NAME').value;
		}else{
			document.getElementById('TBL_OFF_OTHER_CITY_NAME').style.display='none';
			document.getElementById('OFF_OTHER_CITY_NAME').style.visibility='hidden';
		}
		if(document.getElementById('COUNTRY_ID').value=="other"){
			document.getElementById('OFF_OTHER_COUNTRY_NAME').style.display='block';
			document.getElementById('OFF_OTHER_COUNTRY_NAME').style.visibility='visible';
			document.getElementById('OFF_OTHER_COUNTRY_NAME').value = document.getElementById('OTHER_COUNTRY_NAME').value;
		}else{
			document.getElementById('OFF_OTHER_COUNTRY_NAME').style.display='none';
			document.getElementById('OFF_OTHER_COUNTRY_NAME').style.visibility='hidden';
		}
		
		if(document.getElementById('CITY_ID').value!="Other City")
		{
				document.getElementById('OFF_CITY_ID').value=document.getElementById('CITY_ID').value;
		}
		else
		{
				var len=document.getElementById('OFF_CITY_ID').options.length;
				document.getElementById('OFF_CITY_ID').value=document.getElementById('OFF_CITY_ID').options[len].value;
				cityGetother(document.getElementById('OFF_CITY_ID'),document.getElementById('TBL_OFF_OTHER_CITY_NAME'));
		}
		
		document.getElementById('OFF_PIN_CODE').value = document.getElementById('PIN_CODE').value;
		document.getElementById('OFF_COUNTRY_ID').value = document.getElementById('COUNTRY_ID').value;	
	
	}
	else
	{
		document.getElementById('offAreaCode').value = '';
		document.getElementById('offNo').value ='';
		document.getElementById('TBL_OFF_OTHER_CITY_NAME').style.display='none';
		document.getElementById('OFF_OTHER_CITY_NAME').style.visibility='hidden';
		document.getElementById('OFF_OTHER_COUNTRY_NAME').style.display='none';
		document.getElementById('OFF_OTHER_COUNTRY_NAME').style.visibility='hidden';
		document.getElementById('OFF_PIN_CODE').value = '';
		document.getElementById('OFF_COUNTRY_ID').value=0;
	}
}

function roundDecimals(original_number, decimals) {

 var result1 = original_number * Math.pow(10, decimals)

 var result2 = Math.round(result1)

 var result3 = result2 / Math.pow(10, decimals)

 return (result3)

}

function resetAmortization(frmObj,resetId1,resetId2,resetId3)
{
	for(var i=0;i<frmObj.elements.length;i++)
	{
		
		if(frmObj.elements[i].type=='select-one'){
			frmObj.elements[i].value=0;	
		}else{
			frmObj.elements[i].value='';
		}
		if(!isNullOrUndefined(resetId1))
			document.getElementById(resetId1).style.display='none';
		if(!isNullOrUndefined(resetId2))
			document.getElementById(resetId2).innerHTML='';
		if(!isNullOrUndefined(resetId3))
			document.getElementById(resetId3).innerHTML='';
		document.getElementById('tmp').value = tmpIteration;
	}
}

function resetCalciValue(frmObj,resetId1,resetId2,resetId3,resetId4,resetId5,resetId6,resetId7,resetId8,resetId9,resetId10)
{
	for(var i=0;i<frmObj.elements.length;i++)
	{
		if(frmObj.elements[i].type=='select-one'){
			frmObj.elements[i].value=0;	
		}else{
			frmObj.elements[i].value='';
		}
		if(!isNullOrUndefined(resetId1)){
			document.getElementById(resetId1).innerHTML='';
		}
		if(!isNullOrUndefined(resetId2)){
			document.getElementById(resetId2).innerHTML='';
		}
		if(!isNullOrUndefined(resetId3))
			document.getElementById(resetId3).innerHTML='';
		if(!isNullOrUndefined(resetId4))
			document.getElementById(resetId4).innerHTML='';
		if(!isNullOrUndefined(resetId5))
			document.getElementById(resetId5).innerHTML='';
		if(!isNullOrUndefined(resetId6))
			document.getElementById(resetId6).innerHTML='';
		if(!isNullOrUndefined(resetId7))
			document.getElementById(resetId7).innerHTML='';
		if(!isNullOrUndefined(resetId8))
			document.getElementById(resetId8).innerHTML='';
		if(!isNullOrUndefined(resetId9))
			document.getElementById(resetId9).innerHTML='';
		if(!isNullOrUndefined(resetId10))
			document.getElementById(resetId10).innerHTML='';
	}
}

function hideMe(param){
	document.getElementById(param).style.display="none";
}
function showMe(element,param,msg,mode){
	if(mode!=1){
		gapX=5;gapY=10;
	}else{
		gapX=-280;gapY=10;
	}
	posX = element.offsetLeft
	posY = element.offsetTop;
	width = element.clientWidth;
	if(!width){
		width = element.offsetWidth;
	}
	
	TheElement = element.offsetParent;
	while(TheElement != null){
		posX += TheElement.offsetLeft
		posY += TheElement.offsetTop;
		TheElement = TheElement.offsetParent;
	}
	posX += gapX;
	posY += gapY;
	document.getElementById(param).style.display="block";
	document.getElementById(param).style.left=posX+'px';
	document.getElementById(param).style.top=posY+'px';
	document.getElementById('txtMsg').innerHTML =msg;
	
}

function Trim(s) {
   var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
   return (m == null) ? "" : m[1];
} 

function changeTabs(param1,param2){
	document.getElementById(param1).style.display="block";
	document.getElementById(param2).style.display="none";
	if(document.getElementById('floatTab').style.display=="block" || document.getElementById('fixedTab').style.display=="none"){
		document.getElementById('tabFloatId').className="tabActive";
		document.getElementById('tabFixedId').className="tabInactive";
		document.getElementById('floatDiv').className="bluetxt";
		document.getElementById('fixedDiv').className="whitetxt1";
	}else{
		document.getElementById('tabFixedId').className="tabActive";
		document.getElementById('tabFloatId').className="tabFloatInactive";
		document.getElementById('fixedDiv').className="bluetxt";
		document.getElementById('floatDiv').className="whitetxt1";
	}
	
}


function onFocusBlank(element,defaultVal){
	if(element.value==defaultVal){
		element.value="";
	}
}
function onBlurDefault(element,defaultVal,mode){
	if(element.value==""){
		element.value = defaultVal;
	}else{
		if(mode==1){
			onBlurEventHandler('CUST_ID,PRODUCT_ID,CITY_ID,CUST_NAME,COUNTRY_CODE,TEL_MOBILE,ACTION_TAKEN','YES');			
			//raiseDelightCall('123');
		}
	}

}


function isNullOrUndefined(a,value)
{
    if(typeof value != 'undefined'){
                if (typeof a == 'undefined'){
                    return value;
                }else{
                    if(a==null){
                        return value;
                    }else{
                        return a;
                    }
                }
        }else{
            if(typeof a == 'undefined'){
                    return true;
            }else{
                if(a==null){
                        return true;
                }else{
                        return false;
                }
            }
       }
}

function selectCreditCard(param1,param2){
	document.getElementById(param1).style.display="block";
	document.getElementById(param2).style.display="none";
	document.getElementById(param1+'Link').className="activecardlink";
	document.getElementById(param2+'Link').className="inactivecardlink";
}

function checkTxtAreaLenght(obj){
     if(obj.value.length > 1000)
  {
      obj.value = obj.value.substring(0,1000);
  }
} 

function printIt(mode)
{
	if(mode!='1'){
		content=document.getElementById('news-column2');  
	}else{
		content=document.getElementById('paymentsDetails');
	}
	w=window.open("about:blank","Apnaloan","directories=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,left=100,top=300,width=500px,height=500px");
	w.focus();
	w.document.write(content.innerHTML);
	w.location.reload();
	w.print();
}
function sendMail(){
	var eSubject = top.location.href;
	var ebody = top.location.href;
	window.location.href = 'mailto:?subject='+eSubject+'&body=' + ebody;
}

function manageHelpTxt()
{
    subProductId = document.getElementById("SUB_PRODUCT_ID").value;
    optValue = document.getElementById('SUB_PRODUCT_ID').selectedIndex;
	document.getElementById("helpTxt").onclick = function() { 
        showMe(this,'pop-msg',document.getElementById("SUB_PRODUCT_ID").options[optValue].value);return false; 
    }
}