var isResponseCampaign = "true";
var sourceId;
/****************Ajax Xml Http Request Start***************/
function xmlhttpPost(strMethod, strURL, myFun, dataToSend) {
	//alert(strURL);	
	var xmlHttpReq = false;
    // Mozilla/Safari Http Request
    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
    }
    // IE Http Request
    else if (window.ActiveXObject) {
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
        
    xmlHttpReq.open(strMethod, strURL, true);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    if(strMethod=="POST")
    {	
    	xmlHttpReq.send(dataToSend); 
    }
    else
    {
    	xmlHttpReq.send('null');
    }
    xmlHttpReq.onreadystatechange = function() {
        if(xmlHttpReq.readyState == 4) 
        {
           responseAjaxData = xmlHttpReq.responseText;  
           if(myFun!="noFun"){
				eval(myFun)(responseAjaxData);
           }	
        }
     }
}
/****************Ajax Xml Http Request End***************/
function Trim(s) {
   var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
   return (m == null) ? "" : m[1];
} 


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 fillSubProductForMoneyControl(prodObject)
{
	
    var intProdId = prodObject;
	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;
	
	var tempURL='';
	var productName = '';	
	if(intProdId>0)
	{	
		
		if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
			tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';
		
		switch(intProdId)
		{
		    /*case '1': 
		             xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");
		          break;
		    case '2':
		              xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          break;
		    case '3': 
		              xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          
		          break;
		    case '4': 
		              xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          break;
			case '5': 
		              xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          break;
			case '6': 
		              xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          break;

			case '99': 
		              xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          break;*/
		    case homeLoanProdId: 
		          if(homeLoanArray!="")
		          {
		             fillSubProductForMoneyControlHandler(homeLoanArray);
		          }else{
		             xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");
		          }
		          break;
		    case personalLoanProdId:
		          if(personalLoanArray!="")
		          {
		              fillSubProductForMoneyControlHandler(personalLoanArray);
		          }else
		          {
                      xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          }
		          break;
		    case creditCardProdId: 
		          if(creditCardArray!="")
		          {
		              fillSubProductForMoneyControlHandler(creditCardArray);
		          }else
		          {
                      xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          }
		          break;
		    case carLoanProdId: 
		          if(carLoanArray!="")
		          {
		              fillSubProductForMoneyControlHandler(carLoanArray);
		          }else
		          {
                      xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          }		          
		          break; 
		    case educationLoanProdId:		    	  
		          if(educationLoanArray!="")
		          {
		              fillSubProductForMoneyControlHandler(educationLoanArray);
		          }else
		          {
                      xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          }		          
		          break;
			 case loanAgainstSecurityProdId:		    	  
		          if(loanAgainstSecurityArray!="")
		          {
		              fillSubProductForMoneyControlHandler(loanAgainstSecurityArray);
		          }else
		          {
                      xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          }		          
		          break; 
             case loanAgainstPropertyProdId:		    	  
		          if(loanAgainstPropertyArray!="")
		          {
		              fillSubProductForMoneyControlHandler(loanAgainstPropertyArray);
		          }else
		          {
                      xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          }		          
		          break;
				  
		     case businessLoanProdId:		    	  
		          if(businessLoanArray!="")
		          {
		              fillSubProductForMoneyControlHandler(businessLoanArray);
		          }else
		          {
                      xmlhttpPost("GET", tempURL+'getSubProduct.php?productId='+intProdId, fillSubProductForMoneyControlHandler, "");		              
		          }		          
		          break;

				  


		}
	}
	else
	{
		document.getElementById('SUB_PRODUCT_ID').options.length=1;	
	}	
}

function fillSubProductForMoneyControlHandler(ajaxData)
{
	//alert('ajaxData==>'+ajaxData);
	var strStyle = '';
	arrSubProd = ajaxData.split('|');	
	document.getElementById('SUB_PRODUCT_ID').options.length=1;	
	
	for(i=0;i<arrSubProd.length;i++)
	{	
		subProduct = arrSubProd[i].split('~~');
		//alert(arrSubProd[i]);
		document.getElementById('SUB_PRODUCT_ID').options.length=document.getElementById('SUB_PRODUCT_ID').options.length+1;
		document.getElementById('SUB_PRODUCT_ID').options[i+1].value = subProduct[0];
		document.getElementById('SUB_PRODUCT_ID').options[i+1].text = subProduct[1];		
	}	
					
	intProductId = document.getElementById('PRODUCT_ID').value;
	
	switch (intProductId)
	{
		case document.getElementById('hdnCarLoanProdId').value:
			strSubProdMsg ="Car Details";
			strSelectProdMsg ="Select Car Details";
			break;
			
		case document.getElementById('hdnCreditCardProdId').value: 
			strSubProdMsg ="Type of Card";
			strSelectProdMsg ="Select Card Type";	
			break;
		case document.getElementById('hdnBusinessLoanProdId').value: 
			strSubProdMsg ="Nature of Security";
			strSelectProdMsg ="Select Security Type";	
			break;

		default:
			strSubProdMsg ="Purpose of Loan";
			strSelectProdMsg ="Select Loan Type";
			break;

			
	}	
	if(!isNullOrUndefined(document.getElementById('SubProdMsg')))	
	{	
		document.getElementById('SubProdMsg').innerHTML=strSubProdMsg;
	}
	document.getElementById('SUB_PRODUCT_ID').options[0].value = 0;
	document.getElementById('SUB_PRODUCT_ID').options[0].text = '--'+strSelectProdMsg+'--';	
	
	if(intProductId==document.getElementById('hdnCreditCardProdId').value)
	{		
			if(!isNullOrUndefined(document.getElementById('HIDE_FOR_CREDIT_CARD')))	
			{	
				document.getElementById('HIDE_FOR_CREDIT_CARD').style.display='none';
				document.getElementById('HIDE_FOR_CREDIT_CARD').style.visibility='hidden';
			}
			else if(!isNullOrUndefined(document.getElementById('HIDE_FOR_CREDIT_CARD_GENHOME')))	
			{	
				document.getElementById('HIDE_FOR_CREDIT_CARD_GENHOME').style.display='none';
				document.getElementById('HIDE_FOR_CREDIT_CARD_GENHOME').style.visibility='hidden';
			}	
	}
	else
	{		if(!isNullOrUndefined(document.getElementById('HIDE_FOR_CREDIT_CARD')))
			{					
				document.getElementById('HIDE_FOR_CREDIT_CARD').style.display='';
				document.getElementById('HIDE_FOR_CREDIT_CARD').style.visibility='visible';
			}
			else if(!isNullOrUndefined(document.getElementById('HIDE_FOR_CREDIT_CARD_GENHOME')))
			{				
				document.getElementById('HIDE_FOR_CREDIT_CARD_GENHOME').style.display='';
				document.getElementById('HIDE_FOR_CREDIT_CARD_GENHOME').style.visibility='visible';
			}
	}
	if(intProductId==document.getElementById('hdnEducationLoanProdId').value)
	{		
			if(!isNullOrUndefined(document.getElementById('HIDE_FOR_EDUCATION_LOAN_INCOME')))	
			{	
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_INCOME').style.display='none';
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_INCOME').style.visibility='hidden';
			}
			else if(!isNullOrUndefined(document.getElementById('HIDE_FOR_EDUCATION_LOAN_INCOME_GENHOME')))	
			{	
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_INCOME_GENHOME').style.display='none';
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_INCOME_GENHOME').style.visibility='hidden';
			}
			
			// For Employment Type For Education loan
			if(!isNullOrUndefined(document.getElementById('HIDE_FOR_EDUCATION_LOAN_EMP')))	
			{	
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_EMP').style.display='none';
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_EMP').style.visibility='hidden';
			}
			else if(!isNullOrUndefined(document.getElementById('HIDE_FOR_EDUCATION_LOAN_EMP_GENHOME')))	
			{	
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_EMP_GENHOME').style.display='none';
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_EMP_GENHOME').style.visibility='hidden';
			}	
	}
	else
	{		if(!isNullOrUndefined(document.getElementById('HIDE_FOR_EDUCATION_LOAN_INCOME')))
			{					
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_INCOME').style.display='';
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_INCOME').style.visibility='visible';
			}
			else if(!isNullOrUndefined(document.getElementById('HIDE_FOR_EDUCATION_LOAN_INCOME_GENHOME')))
			{				
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_INCOME_GENHOME').style.display='';
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_INCOME_GENHOME').style.visibility='visible';
			}
			
			// For Employment Type For Education loan
			if(!isNullOrUndefined(document.getElementById('HIDE_FOR_EDUCATION_LOAN_EMP')))
			{					
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_EMP').style.display='';
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_EMP').style.visibility='visible';
			}
			else if(!isNullOrUndefined(document.getElementById('HIDE_FOR_EDUCATION_LOAN_EMP_GENHOME')))
			{				
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_EMP_GENHOME').style.display='';
				document.getElementById('HIDE_FOR_EDUCATION_LOAN_EMP_GENHOME').style.visibility='visible';
			}
	}
}

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

function validateReusableForm(element)
{
	
	var formRegistration=new Object();

	var isNRIValue;

	var resuableFlagVal;

	if(!isNullOrUndefined(document.getElementById('RESUABLEFLAG')))
	{
  		resuableFlagVal=document.getElementById('RESUABLEFLAG').value;
			
  	}

	
	if(document.getElementById('IS_NRI_YN').value=="N")
	{
			var isNRIValue='N';
	}else
	{
			var isNRIValue='Y';
	}

	formRegistration["PRODUCT_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Type of Product 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)
	{
		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}};		
	
	

	if(document.getElementById('IS_NRI_YN').value=="N")
	{
			formRegistration["TEL_MOBILE"] = {blank:true,valid:true, validateFunction:[mobilenumberValidation],param:{isNRI:isNRIValue},label:"your Mobile-Number (10-Digit Number)"};
	}else
	{
			formRegistration["TEL_MOBILE"] = {blank:true,valid:true, validateFunction:[mobilenumberValidation],param:{isNRI:isNRIValue},label:"your Mobile-Number"};
	}
	
		
	if(document.getElementById('IS_NRI_YN').value=="N")
	{
			formRegistration["CITY_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Residence City"};
			if(document.getElementById('CITY_ID').value=='other')
			{
				
				formRegistration['OTHER_CITY_NAME'] = {blank:true,valid:true, validateFunction:[firstnameValidation],label:"other city"};
			}
	}else
	{
			formRegistration["NRI_CITY_ID"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Residence City"};

			if(!isNullOrUndefined(document.getElementById('NRI_CITY_ID')))
			{
				if(document.getElementById('NRI_CITY_ID').value=='other')
				{
				
					formRegistration['OTHER_CITY_NAME'] = {blank:true,valid:true, validateFunction:[firstnameValidation],label:"other city"};
				}
			}
	}

	
	
		
		if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnCreditCardProdId').value)
		{
			
				if(resuableFlagVal=='campaignPages')
				{
					
					if(document.getElementById('monthlyIncomeSalaried').style.display=="")
					{
						formRegistration["INCOME_SALARIED"] = {valid:true, validateFunction:[selectValidation],label:"Monthly Income"};
					}else if(document.getElementById('monthlyIncomeSelfEmployed').style.display=="")
					{
						
						formRegistration["INCOME_SELF"] = {blank:true,valid:true, validateFunction:[selectValidation],label:"Monthly Income"};
					}
				}
		}
	

	fieldMap["formRegistration"]=formRegistration;
				
	var errorStatus = validation(document.formRegistration);
		if(errorStatus)
		{
			if(document.getElementById('checkTerms').checked)
			{
				if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
					tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';
					
				/*qstr = "PRODUCT_ID="+document.getElementById('PRODUCT_ID').value;

				if(document.getElementById('IS_NRI_YN').value=="N")
				{
					if(document.getElementById('CITY_ID').value=='other')
					{
							qstr += "&OTHER_CITY_NAME="+document.getElementById('OTHER_CITY_NAME').value;	

					}else
					{
							qstr += "&CITY_ID="+document.getElementById('CITY_ID').value;
					}
				}
				else
				{
					if(document.getElementById('NRI_CITY_ID').value=='other')
					{
							qstr += "&OTHER_CITY_NAME="+document.getElementById('OTHER_CITY_NAME').value;	
							qstr += "&CITY_ID=0";
					}else
					{
								qstr += "&CITY_ID="+document.getElementById('NRI_CITY_ID').value;
					}
							
				}
				qstr += "&CUST_NAME="+document.getElementById('CUST_NAME').value;
				mobileNo = document.getElementById('COUNTRY_CODE').value + "-" + document.getElementById('TEL_MOBILE').value
				qstr += "&TEL_MOBILE="+mobileNo;
				TEL_RES = document.getElementById('OFF_LAND_LINE_AREACODE').value + "-" + document.getElementById('TEL_OFF').value + "-" + document.getElementById('OFF_LAND_LINE_EXT').value			
				qstr += "&TEL_RES="+TEL_RES;
				qstr += "&EMAIL="+document.getElementById('EMAIL').value;
				qstr += "&SUB_PRODUCT_ID="+document.getElementById('SUB_PRODUCT_ID').value;
				
				if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnCreditCardProdId').value)
				{
						qstr += "&LOAN_AMT=''";

						if(resuableFlagVal=='campaignPages')
						{
					
							if(document.getElementById('monthlyIncomeSalaried').style.display=="")
							{
								qstr += "&INCOME="+document.getElementById('INCOME_SALARIED').value;							
							}else if(document.getElementById('monthlyIncomeSelfEmployed').style.display=="")
							{
								qstr += "&INCOME="+document.getElementById('INCOME_SELF').value;							
							}
						}else
						{
							qstr += "&INCOME="+document.getElementById('INCOME').value;
						}
							
				}
				else{
						qstr += "&LOAN_AMT="+document.getElementById('LOAN_AMT').value;
						qstr += "&INCOME="+document.getElementById('INCOME').value;
				}
				DOB = document.getElementById('DOB_YEAR').value + "-" + document.getElementById('DOB_MONTH').value + "-" + document.getElementById('DOB_DAY').value
				qstr += "&DOB="+DOB;
				qstr += "&PROFESSION_ID="+document.getElementById('PROFESSION_ID').value;

				if(!isNullOrUndefined(document.getElementById('SOURCE_ID')))
				{

					sourceId=document.getElementById('SOURCE_ID').value;
					qstr += "&sourceId="+sourceId;
					
				}
				qstr += "&IS_NRI_YN="+isNRIValue;
				*/
				//alert('qstr::'+qstr)

				/******* Loading  Image Start ********			
				if(navigator.userAgent.indexOf("Firefox") > -1){
				   if(document.getElementById('RESUABLEFLAG').value=='campaignPages')
					{
						gapX=-530;gapY=-15;
					}else
					{
						gapX=-230;gapY=-15;
					}
				}else{
					if(document.getElementById('RESUABLEFLAG').value=='campaignPages')
					{
						gapX=-60;gapY=-8;
					}else
					{
						gapX=-60;gapY=-8;
					}
				}
				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('infoBox').style.left=posX+'px';
				document.getElementById('infoBox').style.top=posY+'px';
				document.getElementById('infoBox').style.visibility='visible';
				document.getElementById('infoBox').style.display='';
				/******* Loading  Image End ********/

			/* if(isResponseCampaign == "true" && document.getElementById('LEAD_ID').value =='0')
	        {
	          xmlhttpPost("GET",tempURL+"reusableAjax.php?"+qstr,"reusableQuickApply","");
	          isResponseCampaign = false;
	        }*/
			document.formRegistration.action = tempURL+"reusableQuickApplyProcess.php";	
			document.formRegistration.submit();
			document.getElementById('submitHref').onclick = "";
			document.getElementById('submitHref').href = "javascript: void(0)";
			}
			else
			{
				alert("Please,Check terms and conditions for apnaloan.com. ");
			}
		}
}

function reusableQuickApply(ajaxData)
{
	//alert('ajaxData for reusableQuickApply::'+ajaxData);
	arrResponse = responseAjaxData.split(":");				
	if(!isNaN(arrResponse[0]) && arrResponse[0] > 0 && !isNaN(arrResponse[1]) && arrResponse[1] > 0)
	{
		document.getElementById('CUST_ID').value = arrResponse[0];
		document.getElementById('LEAD_ID').value = arrResponse[1];
		raiseDelightCallForReusableQuickApply(arrResponse[1]);
		//parent.location.href="registration.php?flag=otherSite";
	}
}


function raiseDelightCallForReusableQuickApply(applicationId)
{
    
		var tempURL='';
		if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
			tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';
		
		intProdId = document.getElementById('PRODUCT_ID').value;
		intSubProdId = document.getElementById('SUB_PRODUCT_ID').value;
		intCityId = document.getElementById('CITY_ID').value;
		strIsNri = document.getElementById('IS_NRI_YN').value;
				
		xmlhttpPost("GET",tempURL+"getPriorityQueue.php?PRODUCT_ID="+intProdId+"&CITY_ID="+intCityId+"&IS_NRI_YN="+strIsNri+"&SUB_PRODUCT_ID="+intSubProdId,"PriorityQueueForReusableQuickApply","");
		
		//qstr = 'activity=DelightCall&applicationid='+applicationId;
		//xmlhttpPost("GET",tempURL+"sms.php?"+qstr,"smsVerification","");
}

function PriorityQueueForReusableQuickApply(ajaxData)
{
	var priority = "";
	priority = ajaxData;
    //alert('priority==='+priority);
	//return;
	//priority = "DelightCall";
	
	applicationId = document.getElementById('LEAD_ID').value;
	
	var tempURL='';
	if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
		tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';
			
	qstr = 'activity='+priority+'&applicationid='+applicationId;
	xmlhttpPost("GET",tempURL+"sms.php?"+qstr,"smsVerificationForReusableQuickApply","");
}

function smsVerificationForReusableQuickApply(ajaxData){	
	var dbCaseId="";
	//alert('ajaxData==>'+ajaxData);
	ajaxData = ajaxData.split('Status:');
	caseId = ajaxData[0];
		
	if(ajaxData.length>1)
		ajaxData = ajaxData[1].split('*');
	
	if(!isNullOrUndefined(document.getElementById('CASE_ID')))
	{
  		dbCaseId = document.getElementById('CASE_ID').value;
  	}
  	//alert('caseId::'+caseId+'\n dbCaseId => '+dbCaseId);  	
	if(ajaxData[0]=='SUCCESS')
	{
		if(Trim(dbCaseId)=='0' || dbCaseId==0 || Trim(dbCaseId)=='')
		{	
			if(!isNullOrUndefined(document.getElementById('CASE_ID')))
			{  				
				document.getElementById('CASE_ID').value = caseId;
				//alert('caseId'+document.getElementById('CASE_ID').value);
				if(document.getElementById('CUST_ID').value>0 && document.getElementById('LEAD_ID').value>0) 
				{
					//alert('smsVerificationForReusableQuickApply CASE ID::'+document.getElementById('CASE_ID').value);
					insertIntoDBForReusableQuickApply();
				}	
			}
		}	
	}else{
		if(ajaxData[1]=='SendSMS'){
			alert("Problem in sending SMS Code");
		}else if(ajaxData[1]=='SendEmail'){
			alert("Problem in sending Email");
		}		
	}
}

function insertIntoDBForReusableQuickApply() {
  	
	var qstr='';
	
	var tempURL='';
	if(!isNullOrUndefined(document.getElementById('SITE_HOME_URL')))
	{
  		if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
			tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';
  	}
	qstr = "CUST_ID="+document.getElementById('CUST_ID').value;
			qstr += "&LEAD_ID="+document.getElementById('LEAD_ID').value;
			qstr += "&CASE_ID="+document.getElementById('CASE_ID').value;
	//alert(qstr);
  	xmlhttpPost("POST",tempURL+"registerP.php", "insertIntoDBForReusableQuickApplyPost", qstr);
}

function insertIntoDBForReusableQuickApplyPost(ajaxData)
{
	//alert('ajaxData After Case Id::'+ajaxData);
	document.getElementById('infoBox').style.visibility='hidden';
	document.getElementById('infoBox').style.display='none';
	/*if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnHomeLoanProdId').value)
	{
		AdGroupId = "15401";

	}else if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnPersonalLoanProdId').value)
	{
		AdGroupId = "14401";
	}else if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnCarLoanProdId').value)
	{
		AdGroupId = "18401";
	}else if(document.getElementById('PRODUCT_ID').value==document.getElementById('hdnCreditCardProdId').value)
	{
		AdGroupId = "16401";

	}*/

	var tempURL='';
	var flag='';
	var resuableFlagVal='';
	if(!isNullOrUndefined(document.getElementById('SITE_HOME_URL')))
	{
  		if(Trim(document.getElementById('SITE_HOME_URL').value)!="")
			tempURL = Trim(document.getElementById('SITE_HOME_URL').value) + '/';
  	}
	if(!isNullOrUndefined(document.getElementById('FLAG')))
	{
  		flag=document.getElementById('FLAG').value;
			
  	}

	if(!isNullOrUndefined(document.getElementById('SOURCE_ID')))
	{
  		sourceId=document.getElementById('SOURCE_ID').value;
			
  	}
	if(!isNullOrUndefined(document.getElementById('RESUABLEFLAG')))
	{
  		resuableFlagVal=document.getElementById('RESUABLEFLAG').value;
			
  	}
	if(resuableFlagVal=='quickApply')
	{
		parent.location.href=tempURL+"registration.php?applicationId="+document.getElementById('LEAD_ID').value;
	}
	else
	{
		parent.location.href=tempURL+"registration.php?sourceId="+sourceId+"&applicationId="+document.getElementById('LEAD_ID').value+"&flag="+flag;
	}

	
}


function selectNRIStatus(val)
{

	var resuableFlagVal;

	if(!isNullOrUndefined(document.getElementById('RESUABLEFLAG').value))
	{
  				resuableFlagVal=document.getElementById('RESUABLEFLAG').value;
			
  	}

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

			
			
			if(resuableFlagVal=='quickApply')
			{
				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];
				}	

				/*if(document.getElementById('QR-column-header').innerHTML!='')
				{
					document.getElementById('QR-column-header').innerHTML="<span class='mainheading1'>QUICK APPLY</span>";
				}*/
			}



	}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="0";

		if(resuableFlagVal=='quickApply')
		{

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

			/*if(document.getElementById('QR-column-header').innerHTML!='')
			{
				document.getElementById('QR-column-header').innerHTML="<span class='mainheading1'>NRI QUICK APPLY</span>";
			}*/
		}

	}
}

function selectMonthlyIncome(val)
{
	 if(val=='1')
	{
		document.getElementById('monthlyIncomeSelfEmployed').style.display="none";
		document.getElementById('monthlyIncomeSalaried').style.display="";
		

	}else
	{
		document.getElementById('monthlyIncomeSelfEmployed').style.display="";
		document.getElementById('monthlyIncomeSalaried').style.display="none";	
	}
}
