
var tmpIteration=0;
var homeLoanArray = new Array();
var personalLoanArray = new Array();
var carLoanArray = new Array();
var creditCardArray = new Array();
var educationLoanArray = new Array();
var loanAgainstSecurityArray = new Array();
var businessLoanArray = new Array();
var loanAgainstPropertyArray = new Array();
var gCheckCookie=true;		// set it to false in the page that doesn't need Smart Apply form, e.g. see loan-advisors.php


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','Enter total amount of fees such as processing fees, administrative fees, legal fees, technical fees etc',
	'Enter the rate for a genuine fixed rate loan. Genuine Fixed Interest rate means that rate which remains constant throughout the tenure of the loan.',
	'Here put in the rate available on safe investment option such as Bank Fixed Deposits ,Debt Mutual Funds, etc',
	'This is calculated as ( (pre-tax return) x (1 - Marginal Tax Rate) )',
	'Also called Adjustable rate or Variable rate of Interest',
	'Enter the expected floating rate here',
	'Enter the number of months (from the last change date) after which the change in Floating rate takes place',
	'Enter here the highest rate at which you pay tax',
	'This is a calculated figure and is your actual interest rate multiplied by (1 minus the marginal tax rate)',
	'Maximum benefit available under Section 80C for the financial year ending on March 31, 2009 is Rs. 1,00,000/-. Here enter the amount by which your current claim for deduction under this section  is falling short of the maximum amount of Rs. 1,00,000/-. If you are already enjoying the full deduction of Rs. 1,00,000 under Section 80C then enter 0 here.',
	'Amount that is pre-paid is eligible for deduction under section 80C',
	'Prepayment Charges are eligible for deduction as interest under section 24. See tax tips section.',
	'This is a calculated figure and is equal to the pre-payment charges less tax break available on the pre-payment charge',
	'Enter here the gross pre-tax return on investment avenues that you consider safe',
	'This is a calculated figure and is equivalent to the pre-tax return multiplied by (1-marginal tax rate)',
	'Enter Yes if you have been claiming deduction under section 80C on the principal portion of your loan repayment',
	'Enter what you want the bank to do – reduce the loan tenure or reduce the EMI. Normally most banks only agree to reduce the tenure',
	'hi how r u?');

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 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}};
	}

	// For Education Loan Start
	if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnEducationLoanProdId').value)
	{
		//
	}
	else
	{
		formRegistration["INCOME"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Monthly Income",param:{min:1,max:999999999}};
		formRegistration["PROFESSION_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Employment Type"};
	}

	// For Education Loan End

	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["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 salesForceCityGetother(selectField,txtField)
{

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

	function trim(str)
	{
		return str.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,"").replace(/\s+/g," ");
	}

	function mapToSForce()
	{

		sfForm = document.getElementById('buyerFormRegistration');
		name = trim(sfForm.buyer_name.value);

		spc = name.lastIndexOf(" ",name.length);
		f_name = name.substring(0,spc);
		l_name=name.substring(spc+1);

		sfForm.first_name.value=f_name;
		sfForm.last_name.value=l_name;

		banks = sfForm.BANK_ID;

		 counter=0;
		 var sfBank = new Array();
		 for(i=1 ; i<banks.length ; i++)
		 {
			if(banks[i].selected)
			{

				sfBank[counter]=banks[i].value;
				counter++;

			}
		 }

		 if(counter>0)
			document.getElementById('00N200000017c3b').value = sfBank[0];

		 if(counter>1)
			document.getElementById('00N200000017c3g').value = sfBank[1];
		 if(counter>2)
			document.getElementById('00N200000017kQi').value = sfBank[2];
		 if(counter>3)
			document.getElementById('00N200000017kQn').value = sfBank[3];


		 comment = sfForm.comment;
		 description = document.getElementById('description');
		 description.value = '';
		 other_banks = 'Other banks entered by DSA : ';
		 if(counter>4)
		 {

			for(i=4 ;i<counter;i++)
			  other_banks = other_banks + sfBank[i] + ' - ';

			description.value = other_banks + '\n' + comment.value;
		 }

		description.value = description.value + comment.value;
		sfForm.action = 'salesforce_email.php';
		sfForm.submit();

	}



function validateBuyerFormRegistration()
{


	var buyerFormRegistration=new Object();
	document.getElementById('buyer_name').value=trim(document.getElementById('buyer_name').value);

	buyerFormRegistration["buyer_name"] = {blank:true,valid:true, validateFunction:[fullNameValidation],label:"your full name"};
	buyerFormRegistration["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)
	{


			mapToSForce();


	}




}


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;
		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}};
		formLogin['DOB_MONTH_LOGIN'] = {blank:true, valid:true, validateFunction:[DateValidation],label:'Date of Birth',param:{day:dayValue,month:monthValue,year:yearValue}};
		fieldMap['formLogin']=formLogin;
		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()
{
	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"};

	if(document.getElementById('IS_NRI_YN').value=="N")
	{
		var isNRIValue='N';
	}else
	{
		var isNRIValue='Y';
	}
	applyFormRegistration["COUNTRY_CODE"] = {blank:true,valid:true, validateFunction:[digitValidation],label:"Country Code No."};
	applyFormRegistration["TEL_MOBILE"] = {blank:true,valid:true, validateFunction:[mobilenumberValidation],param:{isNRI:isNRIValue},label:"your Mobile-Number (10-Digit Number)"};
	if(document.getElementById('IS_NRI_YN').value=="N")
	{
		applyFormRegistration["CITY_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Residence City"};
		if(document.getElementById('CITY_ID').value=='other')
		{

			applyFormRegistration['OTHER_CITY_NAME'] = {blank:true,valid:true, validateFunction:[firstnameValidation],label:"other city"};
		}
	}else
	{
		applyFormRegistration["CITY_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Residence City"};
		if(document.getElementById('CITY_ID').value=='other')
		{

			applyFormRegistration['OTHER_CITY_NAME'] = {blank:true,valid:true, validateFunction:[firstnameValidation],label:"other city"};
		}
	}

	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["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 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()
{
	/*if(!gCheckCookie)
		return;
	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);
    var homeLoanProdId = document.getElementById('hdnHomeLoanProdId').value;
	var personalLoanProdId = document.getElementById('hdnPersonalLoanProdId').value;
	var carLoanProdId = document.getElementById('hdnCarLoanProdId').value;
	var creditCardProdId = document.getElementById('hdnCreditCardProdId').value;
	var educationLoanProdId = document.getElementById('hdnEducationLoanProdId').value;
	var loanAgainstSecurityProdId = document.getElementById('hdnLoanAgainstSecurityProdId').value;
	var businessLoanProdId = document.getElementById('hdnBusinessLoanProdId').value;
	var loanAgainstPropertyProdId = document.getElementById('hdnLoanAgainstPropertyProdId').value;

    arrSubProd = ajaxData.split('|');
    for(i=0;i<arrSubProd.length;i++)
	{
		productId = arrSubProd[i].split('**');
		switch(productId[0])
		{
		    case homeLoanProdId:
		          homeLoanArray += productId[1]+"|";
		          break;
		    case personalLoanProdId:
		          personalLoanArray += productId[1]+"|";
		          break;
		    case creditCardProdId:
		          creditCardArray += productId[1]+"|";
		          break;
		    case carLoanProdId:
		          carLoanArray += productId[1]+"|";
		          break;
		    case educationLoanProdId:
		          educationLoanArray += productId[1]+"|";
		          break;
			case loanAgainstSecurityProdId:
		          loanAgainstSecurityArray += productId[1]+"|";
		          break;
			case loanAgainstPropertyProdId:
		          loanAgainstPropertyArray += productId[1]+"|";
		          break;
		    case businessLoanProdId:
		          businessLoanArray += 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)
	educationLoanArray = educationLoanArray.substring(0, educationLoanArray.length-1)
	loanAgainstSecurityArray = loanAgainstSecurityArray.substring(0, loanAgainstSecurityArray.length-1)
	businessLoanArray = businessLoanArray.substring(0, businessLoanArray.length-1)
   	loanAgainstPropertyArray = loanAgainstPropertyArray.substring(0, loanAgainstPropertyArray.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(){


	var formPersonalDetail=new Object();

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["CITY_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Residence City"};
if(document.getElementById('CITY_ID').value=='other')
{

	formPersonalDetail['OTHER_CITY_NAME'] = {blank:true,valid:true, validateFunction:[firstnameValidation],label:"other city"};
}

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

if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnEducationLoanProdId').value)
{
	formPersonalDetail["EDU_YEARS_AT_CURRENT_RESIDENCE"] = {valid:true, validateFunction:[digitValidation],label:"Years At Current Residence"};
}


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"};
		formPersonalDetail["PROFESSION_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Employment Type"};
		formPersonalDetail["INCOME"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Monthly Income",param:{min:1,max:999999999}};

	}
	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["INCOME"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Monthly Income",param:{min:1,max:999999999}};
		formPersonalDetail["LOAN_TENURE"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Desired Loan Tenure"};
		formPersonalDetail["PROFESSION_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Employment Type"};
	}

	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('SUB_PRODUCT_ID').value==document.getElementById('hdnLoanAgainstPropertyBusinessLoanSubProdId').value && document.getElementById('PRODUCT_ID').value==document.getElementById('hdnLoanAgainstPropertyProdId').value)
		    {
				document.getElementById('BL_FLAG').value="Y";
			}
			else if(document.getElementById('SUB_PRODUCT_ID').value!=document.getElementById('hdnLoanAgainstPropertyBusinessLoanSubProdId').value && document.getElementById('PRODUCT_ID').value==document.getElementById('hdnLoanAgainstPropertyProdId').value)
		    {
				document.getElementById('BL_FLAG').value="N";
			}
			/*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"};
			}*/

            /* comment starts here

			// For Cross-sell insurance Start

			if(!isNullOrUndefined(document.getElementById('APPLIED_FOR_LIFE_INSURANCE_STEP3')))
			{
				if(document.getElementById('APPLIED_FOR_LIFE_INSURANCE_STEP4').checked || document.getElementById('APPLIED_FOR_LIFE_INSURANCE_STEP3').checked)
				{
					document.getElementById('APPLIED_FOR_LIFE_INSURANCE').value = "Y";
					document.getElementById('insureCheckSubmit').style.display = "none";
				}else
				{
					document.getElementById('APPLIED_FOR_LIFE_INSURANCE').value = "N";
					document.getElementById('insureCheckSubmit').style.display = "";
				}
			}else
			{
				if(document.getElementById('APPLIED_FOR_LIFE_INSURANCE_STEP4').checked)
				{
					document.getElementById('APPLIED_FOR_LIFE_INSURANCE').value = "Y";
					document.getElementById('insureCheckSubmit').style.display = "none";
				}else
				{
					document.getElementById('APPLIED_FOR_LIFE_INSURANCE').value = "N";
					document.getElementById('insureCheckSubmit').style.display = "";
				}
			}

			// For Cross-sell insurance End

			// For Tata AIG insurance start

			if(!isNullOrUndefined(document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_STEP3')))
			{
				if(document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_STEP4').checked || document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_STEP3').checked)
				{
					document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE').value = "Y";
					document.getElementById('aiginsureCheckSubmit').style.display = "none";
				}else
				{
					document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE').value = "N";
					document.getElementById('aiginsureCheckSubmit').style.display = "";
				}
			}else
			{
				if(document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_STEP4').checked)
				{
					document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE').value = "Y";
					document.getElementById('aiginsureCheckSubmit').style.display = "none";
				}else
				{
					document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE').value = "N";
					document.getElementById('aiginsureCheckSubmit').style.display = "";
				}
			}

			// For Tata AIG insurance end

			comment ends here */

			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 if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnEducationLoanProdId').value)
			{
				insertIntoDB('CUST_ID,LEAD_ID,SUB_PRODUCT_ID,LOAN_AMT,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,BL_FLAG','YES');
			}

			if(document.getElementById('PRODUCT_ID').value!=document.getElementById('hdnEducationLoanProdId').value)
			{
				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}};
}

if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnEducationLoanProdId').value)
{


	propertyDetailsForm["EDU_QUALIFICATION_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Current Qualification"};

	propertyDetailsForm["EDU_COURSE_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Type of Course"};

	propertyDetailsForm["EDU_FIELD_STUDY_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Field of Study"};

	propertyDetailsForm["EDU_COURSE_DURATION_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Course Duration"};

	propertyDetailsForm["EDU_EXPECTED_MONTHLY_INCOME"] = {blank:true,valid:true,validateFunction:[rangeValidation],label:"Expected Monthly Income After Completion",param:{min:1,max:999999999}};



}

if(!isNullOrUndefined(document.getElementById('BL_FLAG')))
{
	if(document.getElementById('BL_FLAG').value=='Y')
	{

		propertyDetailsForm["BUS_YEARS_IN_CURRENT_BUSINESS"] = {valid:true,validateFunction:[rangeValidation],label:"Years in current business",param:{min:1,max:999999999}};

		propertyDetailsForm["BUS_TOTAL_WORK_EXP_IN_YEARS"] = {valid:true,validateFunction:[rangeValidation],label:"Total work experience in years",param:{min:1,max:999999999}};

		propertyDetailsForm["BUS_EXISTING_YEARLY_BUSINESS_TURNOVER"] = {valid:true,validateFunction:[rangeValidation],label:"Existing Yearly Business Turnover",param:{min:1,max:999999999}};

		propertyDetailsForm["BUS_EXISTING_YEARLY_NET_PROFIT"] = {valid:true,validateFunction:[rangeValidation],label:"Existing Yearly Net profit",param:{min:1,max:999999999}};

		propertyDetailsForm["BUS_NO_OF_EMPLOYEES"] = {valid:true,validateFunction:[rangeValidation],label:"No. of employees",param:{min:1,max:999999999}};

		propertyDetailsForm["BUS_REGISTERED_FOR_VAT"] = {validateFunction:[selectValidation],label:"Registered for VAT"};

		propertyDetailsForm["BUS_REGISTERED_FOR_MODVAT"] = {validateFunction:[selectValidation],label:"Registered for Modvat"};

		propertyDetailsForm["BUS_REGISTERED_FOR_TAX"] = {validateFunction:[selectValidation],label:"Registered for Service Tax"};

	}



}

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;

			if(document.getElementById('PRODUCT_ID').value!=document.getElementById('hdnEducationLoanProdId').value)
			{
				optValue = document.getElementById('LOAN_TENURE').value;
				if(optValue!=0){
				document.getElementById('sumTenure').innerHTML= ": "+document.getElementById('LOAN_TENURE').options[optValue].text;
				}
			}

		}

		if(document.getElementById('PRODUCT_ID').value!=document.getElementById('hdnEducationLoanProdId').value)
		{
			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;

		// Hide Office Details for Education Loan Start
		if(document.getElementById('PRODUCT_ID').value!=document.getElementById('hdnEducationLoanProdId').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;
		}
		// Hide Office Details for Education Loan End

		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;
		}

		// Hide Existing Loan Details for Education Loan Start
		if(document.getElementById('PRODUCT_ID').value!=document.getElementById('hdnEducationLoanProdId').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;
			}
		}

		// Hide Existing Loan Details for Education Loan End

		// add Education Loan Details for Education Loan Start

		if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnEducationLoanProdId').value)
		{

			document.getElementById('sumYearsAtCurrentResidence').innerHTML= ": "+document.getElementById('EDU_YEARS_AT_CURRENT_RESIDENCE').value;



			optValue = document.getElementById('EDU_QUALIFICATION_ID').selectedIndex;
			document.getElementById('sumEduCurrQualification').innerHTML= ": "+document.getElementById('EDU_QUALIFICATION_ID').options[optValue].text;

			optValue = document.getElementById('EDU_COURSE_ID').selectedIndex;
			document.getElementById('sumEduCourse').innerHTML= ": "+document.getElementById('EDU_COURSE_ID').options[optValue].text;

			optValue = document.getElementById('EDU_FIELD_STUDY_ID').selectedIndex;
			document.getElementById('sumEduFieldStudy').innerHTML= ": "+document.getElementById('EDU_FIELD_STUDY_ID').options[optValue].text;

			optValue = document.getElementById('EDU_COURSE_DURATION_ID').selectedIndex;
			document.getElementById('sumEduCourseDuration').innerHTML= ": "+document.getElementById('EDU_COURSE_DURATION_ID').options[optValue].text;

			document.getElementById('sumEduMonthlyIncome').innerHTML= ": "+document.getElementById('EDU_EXPECTED_MONTHLY_INCOME').value;

		}

		//ends

		/*

		// For Cross-sell insurance Start
		if(!isNullOrUndefined(document.getElementById('APPLIED_FOR_LIFE_INSURANCE_STEP3')))
		{
			if(document.getElementById('APPLIED_FOR_LIFE_INSURANCE_SUBMIT').checked ||document.getElementById('APPLIED_FOR_LIFE_INSURANCE_STEP4').checked || document.getElementById('APPLIED_FOR_LIFE_INSURANCE_STEP3').checked)
			{
				document.getElementById('APPLIED_FOR_LIFE_INSURANCE').value = "Y";
				//document.getElementById('insureCheckSubmit').style.display = "none";
			}else
			{
				document.getElementById('APPLIED_FOR_LIFE_INSURANCE').value = "N";
				//document.getElementById('insureCheckSubmit').style.display = "";
			}
		}else
		{
			if(document.getElementById('APPLIED_FOR_LIFE_INSURANCE_SUBMIT').checked ||document.getElementById('APPLIED_FOR_LIFE_INSURANCE_STEP4').checked)
			{
				document.getElementById('APPLIED_FOR_LIFE_INSURANCE').value = "Y";
				//document.getElementById('insureCheckSubmit').style.display = "none";
			}else
			{
				document.getElementById('APPLIED_FOR_LIFE_INSURANCE').value = "N";
				//document.getElementById('insureCheckSubmit').style.display = "";
			}
		}
		// For Cross-sell insurance End

		// For Tata AIG insurance start

		if(!isNullOrUndefined(document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_STEP3')))
		{
			if(document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_SUBMIT').checked ||document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_STEP4').checked || document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_STEP3').checked)
			{
				document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE').value = "Y";
				//document.getElementById('aiginsureCheckSubmit').style.display = "none";
			}else
			{
				document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE').value = "N";
				//document.getElementById('aiginsureCheckSubmit').style.display = "";
			}
		}else
		{
			if(document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_SUBMIT').checked ||document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_STEP4').checked)
			{
				document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE').value = "Y";
				//document.getElementById('aiginsureCheckSubmit').style.display = "none";
			}else
			{
				document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE').value = "N";
				//document.getElementById('aiginsureCheckSubmit').style.display = "";
			}
		}

		// For Tata AIG insurance end

		*/


    	if(document.getElementById('RESIDENTIAL_STATUS').value=="NRI" && document.getElementById('PRODUCT_ID').value!=document.getElementById('hdnCreditCardProdId').value && document.getElementById('PRODUCT_ID').value!=document.getElementById('hdnEducationLoanProdId').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 if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnEducationLoanProdId').value)
		{
			if(document.getElementById('RESIDENTIAL_STATUS').value=="NRI")
			{
    			insertIntoDB('CUST_ID,LEAD_ID,EDU_QUALIFICATION_ID,EDU_COURSE_ID,EDU_FIELD_STUDY_ID,EDU_COURSE_DURATION_ID,EDU_EXPECTED_MONTHLY_INCOME,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,EDU_QUALIFICATION_ID,EDU_COURSE_ID,EDU_FIELD_STUDY_ID,EDU_COURSE_DURATION_ID,EDU_EXPECTED_MONTHLY_INCOME,COMMENTS','');
			}
		}
		else if(document.getElementById('BL_FLAG').value=='Y')
		{
			insertIntoDB('CUST_ID,LEAD_ID,OFF_CITY_ID,OFF_OTHER_CITY_NAME,offCode,offAreaCode,offNo,offExt,hdnBankCount,hdnProdCount,hdnProdId,BANK_ID,OUTSTANDING_AMT,COMMENTS,BUS_YEARS_IN_CURRENT_BUSINESS,BUS_TOTAL_WORK_EXP_IN_YEARS,BUS_EXISTING_YEARLY_BUSINESS_TURNOVER,BUS_EXISTING_YEARLY_NET_PROFIT,BUS_NO_OF_EMPLOYEES,BUS_REGISTERED_FOR_VAT,BUS_REGISTERED_FOR_MODVAT,BUS_REGISTERED_FOR_TAX','');
		}
		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();
	}
	/* comment starts here
	if(!isNullOrUndefined(document.getElementById('APPLIED_FOR_LIFE_INSURANCE_STEP3')))
	{
		if(document.getElementById('APPLIED_FOR_LIFE_INSURANCE_SUBMIT').checked ||document.getElementById('APPLIED_FOR_LIFE_INSURANCE_STEP4').checked || document.getElementById('APPLIED_FOR_LIFE_INSURANCE_STEP3').checked)
		{
			document.getElementById('APPLIED_FOR_LIFE_INSURANCE').value = "Y";
			document.getElementById('insureCheckStep4').style.display = "none";
			document.getElementById('insureCheckSubmit').style.display = "none";
		}else
		{
			document.getElementById('APPLIED_FOR_LIFE_INSURANCE').value = "N";
			document.getElementById('insureCheckStep4').style.display = "";
			document.getElementById('insureCheckSubmit').style.display = "";
		}
	}else
	{
		if(document.getElementById('APPLIED_FOR_LIFE_INSURANCE_SUBMIT').checked ||document.getElementById('APPLIED_FOR_LIFE_INSURANCE_STEP4').checked)
		{
			document.getElementById('APPLIED_FOR_LIFE_INSURANCE').value = "Y";
			document.getElementById('insureCheckStep4').style.display = "none";
			document.getElementById('insureCheckSubmit').style.display = "none";
		}else
		{
			document.getElementById('APPLIED_FOR_LIFE_INSURANCE').value = "N";
			document.getElementById('insureCheckStep4').style.display = "";
			document.getElementById('insureCheckSubmit').style.display = "";
		}
	}

	if(!isNullOrUndefined(document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_STEP3')))
	{
		if(document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_SUBMIT').checked ||document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_STEP4').checked || document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_STEP3').checked)
		{
			document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE').value = "Y";
			document.getElementById('aiginsureCheckStep4').style.display = "none";
			document.getElementById('aiginsureCheckSubmit').style.display = "none";
		}else
		{
			document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE').value = "N";
			document.getElementById('aiginsureCheckStep4').style.display = "";
			document.getElementById('aiginsureCheckSubmit').style.display = "";
		}
	}else
	{
		if(document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_SUBMIT').checked ||document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE_STEP4').checked)
		{
			document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE').value = "Y";
			document.getElementById('aiginsureCheckStep4').style.display = "none";
			document.getElementById('aiginsureCheckSubmit').style.display = "none";
		}else
		{
			document.getElementById('APPLIED_FOR_TATAAIG_GENINSURE').value = "N";
			document.getElementById('aiginsureCheckStep4').style.display = "";
			document.getElementById('aiginsureCheckSubmit').style.display = "";
		}
	} comment ends here */
}

function finalconfirm(form1,form2,mode)
{
	if(mode==1)
	{
		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 if(frmObj.elements[i].type=='text'){
			//alert(frmObj.name);
			//bug 1637 : retain default values for below specified elements.
			if( frmObj.name == "formPersonalLoanEli")
			{
				if( frmObj.elements[i].name == "interestRate" || frmObj.elements[i].name == "tenure")
				{
					//Values remain the same.
					frmObj.elements[i].value=frmObj.elements[i].value;
				}
				else
				{
					frmObj.elements[i].value='';
				}

			}
			else
			{
				frmObj.elements[i].value='';
			}

		}
		if(!isNullOrUndefined(resetId1)){
			document.getElementById(resetId1).style.display="none";
			document.getElementById(resetId1).innerHTML="";

		}
		if(!isNullOrUndefined(resetId2)){
			document.getElementById(resetId2).style.display="none";
			document.getElementById(resetId2).innerHTML="";
		}
		if(!isNullOrUndefined(resetId3)){
			document.getElementById(resetId3).style.display="none";
			document.getElementById(resetId3).innerHTML="";}

		if(!isNullOrUndefined(resetId4)){
			document.getElementById(resetId4).style.display="none";
			document.getElementById(resetId4).innerHTML="";}

		if(!isNullOrUndefined(resetId5)){
			document.getElementById(resetId5).style.display="none";
			document.getElementById(resetId5).innerHTML="";}

		if(!isNullOrUndefined(resetId6)){
			document.getElementById(resetId6).style.display="none";
			document.getElementById(resetId6).innerHTML="";}

		if(!isNullOrUndefined(resetId7)){
			document.getElementById(resetId7).style.display="none";
			document.getElementById(resetId7).innerHTML="";}

		if(!isNullOrUndefined(resetId8)){
			document.getElementById(resetId8).style.display="none";
			document.getElementById(resetId8).innerHTML="";}

		if(!isNullOrUndefined(resetId9)){
			document.getElementById(resetId9).style.display="none";
			document.getElementById(resetId9).innerHTML="";}

		if(!isNullOrUndefined(resetId10)){
			document.getElementById(resetId10).style.display="none";
			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,IS_NRI_YN,OTHER_CITY_NAME','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;
    }
}

function selectNRIStatus(val)
{

	if(val=='N')
	{
		document.getElementById('indianCity').style.display="";
		document.getElementById('nriCity').style.display="none";
		document.getElementById('TBL_OTHER_CITY_NAME').style.display="none";
		document.getElementById('IS_NRI_YN').value="N";
		document.getElementById('COUNTRY_CODE').value="91";

	}else
	{
		document.getElementById('indianCity').style.display="none";
		document.getElementById('nriCity').style.display="";
		document.getElementById('TBL_OTHER_CITY_NAME').style.display="none";
		document.getElementById('IS_NRI_YN').value="Y";
		document.getElementById('COUNTRY_CODE').value="";
	}
}

function generateLinks(id)
{
	var product;

	switch(id)
	{
		case 1:
			product = 'home-loan-query';
			break;
		case 2:
			product = 'personal-loan-query';
			break;
		case 3:
			product = 'credit-card-query';
			break;
		case 4:
			product = 'car-loan-query';
			break;
		case 6:
			product = 'bank-grievance-related-query';
			break;
		case 8:
			product = 'miscellaneous-query';
			break;
		case 9:
			product = 'education-loan-query';
			break;
	}

	var length=document.frmgenLinks.elements.length;
	var checkBoxCheckedCount=0;
	var qid;
	for(i=0;i<length;i++)
	{
		var type1=document.frmgenLinks.elements[i].type;
		if(type1=="checkbox")
		{
			if(document.frmgenLinks.elements[i].checked)
			{
				qid = document.frmgenLinks.elements[i].value;
				window.opener.document.getElementById('question_ans').value+="\n"+"http://www.apnaloan.com/"+product+"/query/Question"+qid+".html";
				checkBoxCheckedCount+=1;
			}
		}
	}

	if(checkBoxCheckedCount==0)
	{
		alert('Please select questions');
		return false;
	}

	window.close();
	return true;
}

//function for pressroom
function popitup(imgUrl)
{
	newwindow=window.open('','name','toolbar=0,scrollbars=1,directories=no,status=no,location=0,statusbar=1,menubar=0,resizable=1,width=404,height=316,left=312,top=184');

	newwindow.document.writeln('<html><head><title>ApnaLoan: Car Home Personal Loans &amp; Credit Cards in India</title>');
	newwindow.document.writeln('<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"></meta>');
	newwindow.document.writeln('<meta content="loan, loans, loan India, loans India, credit card, credit cards India, loans India, personal loan, home loan, car loan, personal loans, home loans, car loans, ICICI loans, SBI loans, HDFC loans" name="keywords"></meta>');
	newwindow.document.writeln('<meta content="Get information on home loans, car loans &amp; personal loans in India and apply for a loan online. Compare popular cards from ICICI, Citibank, State Bank and HDFC and apply for the best credit card on Apnaloan.com." name="description"></meta></head>');
	newwindow.document.writeln('<body><img src="'+imgUrl+'" /></body>');
	newwindow.document.writeln('</html>');

	newwindow.document.close();
}

function submitLifeInsurance()
{
	if(!document.getElementById('APPLIED_FOR_LIFE_INSURANCE_SUBMIT').checked)
	{
		alert("Please,Tick the checkbox first");
		return false;
	}
	document.processInsurance.submit();
}

function browserDetect()
{
	var agt=navigator.userAgent.toLowerCase();

    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

	var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
	if ((is_ie6))
	{
		document.getElementById('pop-msg').style.marginLeft="-155px";
		document.getElementById('pop-msg').style.marginTop="-5px";
	}
}

function AdGroupCookie()
			{
			//alert("hi");
				//code added for getting source id
					var sourceId = "";
					var url = document.location;
					var str = url.toString();
					var split1_res = new Array;
					var split2_res = new Array;
					// get SOURCE_ID Field from form
					var SRCID = document.getElementById("SOURCE_ID");

					// if there is an AdgroupId in URL
					if(str.indexOf("AdGroupId") != -1)
					{
						//alert("ad groupid exists");

								// split the URL
								split1_res = str.split("AdGroupId=");
								split2_res = split1_res[1].split("&");
								sourceId = split2_res[0];

								// set cookie
								var cookie_expires_date = new Date();
								cookie_expires_date.setTime( cookie_expires_date.getTime() + (24*3600*1000));
								document.cookie ='AL_ADGPID='+ sourceId + ';expires='+  cookie_expires_date.toGMTString() + ';path=/';

					}
						var cookie_detect = document.cookie.indexOf("AL_ADGPID=");
						if(cookie_detect != -1)
							{
							var sid = new Array;
							var scolon_split = new Array;
							sid = document.cookie.split("AL_ADGPID=");
							if(sid[1].indexOf(";")!= -1)
							{
							 //alert("; present");
							 scolon_split = sid[1].split(";");
							 SRCID.value = scolon_split[0];
							 //alert("colon--"+ SRCID.value);
							}else{
							// set source ID
							SRCID.value = sid[1];
							//alert("nocolon" + SRCID.value);
}
							}


			}

function validateApnabizz()
{

		//var cmpLoanCity = document.getElementById('compare_loan_city').value;


		var frmCompareBizz=new Object();

		frmCompareBizz['compare_loan_city'] = {blank:true,valid:true, validateFunction:[selectValidation],label:"the city "};

		fieldMap['frmCompareBizz']=frmCompareBizz;
		var errorStatus = validation(document.frmCompareBizz);
		if(errorStatus)
		{
			document.frmCompareBizz.submit();
			return false;
		}
}			