	var _app_id = 27;
	var _append = "207";

	function initHomePage() {
		initForm();
	}
	
	function initPostRequirementForm() {
		changeUpDownCombo();
		populatePropertyChildType();
		populateCity();
		populateAreaInit();
	}
	
	function initOtherPage() {
		initForm();		
	}
	
	function initForm() {
		changeUpDownCombo();
		populatePropertyChildType();
		populateCity();
		populateAreaInit();
	}

	function initPostPropertyForm() {
		populatePropertyChildType();
		populateCity();
		populateAreaInit();
	}
	
	
	function initProjectForm() {
		populateCity();
		populateAreaInit();
	}
	
	function validateInnerProjectSearch() {
		var cstUpSide = document.getElementById("RateUpside").options[document.getElementById("RateUpside").selectedIndex].value;
		var cstDownSide = document.getElementById("RateDownside").options[document.getElementById("RateDownside").selectedIndex].value;
		if(cstUpSide < cstDownSide) {
			alert("Please verify price range.");
			return false;
		}
		document.frmProjectSearch.submit();
	}
	
	function getXMLHTTP() {
		var xmlhttp;
		if (window.XMLHttpRequest) {
  			// code for IE7+, Firefox, Chrome, Opera, Safari
		    xmlhttp=new XMLHttpRequest();
		    return xmlhttp;
  		}
		else if (window.ActiveXObject) {
  			// code for IE6, IE5
	  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  		return xmlhttp;
  		}
		else {
  			alert("Your browser does not support XMLHTTP!");
  			return;
  		}
	}
	
	
    function changeUpDownCombo() {
    	var rentComboDownSide = "<select name='CostDownside' id='CostDownside'>";
    	var rentComboUpSide = "<select name='CostUpside' id='CostUpside'>";
    	var rentComboOptions = "<option value='100000' selected='selected'>1 Lac</option>";
    	rentComboOptions += "<option value='500000'>5 Lacs</option>";
		rentComboOptions += "<option value='1000000'>10 Lacs</option>";
		rentComboOptions += "<option value='2000000'>20 Lacs</option>";
		rentComboOptions += "<option value='3000000'>30 Lacs</option>";
		rentComboOptions += "<option value='4000000'>40 Lacs</option>";
		rentComboOptions += "<option value='5000000'>50 Lacs</option>";
		rentComboOptions += "<option value='6000000'>60 Lacs</option>";
		rentComboOptions += "<option value='7000000'>70 Lacs</option>";
		rentComboOptions += "<option value='8000000'>80 Lacs</option>";
		rentComboOptions += "<option value='9000000'>90 Lacs</option>";
		rentComboOptions += "<option value='10000000'>1 Cr</option>";
		rentComboOptions += "<option value='12000000'>1.2 Cr</option>";
		rentComboOptions += "<option value='14000000'>1.4 Cr</option>";
		rentComboOptions += "<option value='16000000'>1.6 Cr</option>";
		rentComboOptions += "<option value='18000000'>1.8 Cr</option>";
		rentComboOptions += "<option value='20000000'>2 Cr</option>";
		rentComboOptions += "<option value='24000000'>2.3 Cr</option>";
		rentComboOptions += "<option value='26000000'>2.6 Cr</option>";
		rentComboOptions += "<option value='30000000'>3 Cr</option>";
		rentComboOptions += "<option value='35000000'>3.5 Cr</option>";
		rentComboOptions += "<option value='40000000'>4 Cr</option>";
		rentComboOptions +=  "<option value='50000000'>5 Cr</option>";
    	
    	var buyComboDownSide = "<select name='CostDownside' id='CostDownside'>";
    	var buyComboUpSide = "<select name='CostUpside' id='CostUpside'>";
    	var buyComboOptions = "<option value='5000' selected='selected'>5,000</option>";
			buyComboOptions += "<option value='10000'>10,000</option>";
			buyComboOptions += "<option value='15000'>15,000</option>";
			buyComboOptions += "<option value='20000'>20,000</option>";
			buyComboOptions += "<option value='25000'>25,000</option>";
			buyComboOptions += "<option value='30000'>30,000</option>";
			buyComboOptions += "<option value='35000'>35,000</option>";
			buyComboOptions += "<option value='40000'>40,000</option>";
			buyComboOptions += "<option value='50000'>50,000</option>";
			buyComboOptions += "<option value='60000'>60,000</option>";
			buyComboOptions += "<option value='70000'>70,000</option>";
			buyComboOptions += "<option value='85000'>85,000</option>";
			buyComboOptions += "<option value='100000'>1 Lac</option>";
			buyComboOptions += "<option value='150000'>1.5 Lacs</option>";
			buyComboOptions += "<option value='200000'>2 Lacs</option>";
			buyComboOptions += "<option value='250000'>2.5 Lacs</option>";
			buyComboOptions += "<option value='300000'>3 Lacs</option>";
			buyComboOptions += "<option value='350000'>3.5 Lacs</option>";
			buyComboOptions += "<option value='400000'>4 Lacs</option>";
			buyComboOptions += "<option value='500000'>5 Lacs</option>";
			buyComboOptions += "<option value='700000'>7 Lacs</option>";
			buyComboOptions += "<option value='900000'>9 Lacs</option>";
			
	  	
    		    	
		var comboPropertyTransactionType = document.getElementById("PropertyTransactionType");
		var val = comboPropertyTransactionType.options[comboPropertyTransactionType.selectedIndex].text;
		if(val == "Rent") {
			document.getElementById("spanCostDownSide").innerHTML = buyComboDownSide + buyComboOptions + "<option value='1000000'>10 Lacs</option>" + "</select>";
			document.getElementById("spanCostUpSide").innerHTML = buyComboUpSide + buyComboOptions + "<option value='500000000' selected='selected'>>10 Lacs</option>" + "</select>";
			if(document.getElementById("cstdnsd") != null) {
//				document.getElementById("CostDownside").selectedIndex = document.getElementById("cstdnsd").value;
//				document.getElementById("CostUpside").selectedIndex = document.getElementById("cstupsd").value;
			}
		}
		else {
			document.getElementById("spanCostDownSide").innerHTML = rentComboDownSide + rentComboOptions + "<option value='50000000'>5 Cr</option>" + "</select>";
			document.getElementById("spanCostUpSide").innerHTML = rentComboUpSide + rentComboOptions + "<option value='500000000' selected='selected'>>5 Cr</option>" + "</select>";
			if(document.getElementById("cstdnsd") != null) {
//				document.getElementById("CostDownside").selectedIndex = document.getElementById("cstdnsd").value;
//				document.getElementById("CostUpside").selectedIndex = document.getElementById("cstupsd").value;
			}
		}
    }
    //http://localhost:8080/RealtyRedefined/Request/query.htm?Type=PROP_SUB_TYPE&ParentValue=Residential&ReqType=LOV&JSPFileName=/populatepropertychildtype.jsp
    function populatePropertyChildType() {
    	var comboPropertyType = document.getElementById("PropertyType");
		var val = comboPropertyType.options[comboPropertyType.selectedIndex].text;
		
		var xmlhttp = getXMLHTTP();
		if(val == "Residential") {
			xmlhttp.onreadystatechange=function() {
					if(xmlhttp.readyState==4) {
						document.getElementById("spanPropertyChildType").innerHTML = xmlhttp.responseText;
						if(document.getElementById("NumberOfBedrooms") != null) {
							document.getElementById("NumberOfBedrooms")[0].selected = 1;
							document.getElementById("NumberOfBedrooms").disabled=false;
						}
//						if(document.getElementById("pptchtype") != null)
//							document.getElementById("PropertyChildType").selectedIndex = document.getElementById("pptchtype").value;
  					}
			}
			xmlhttp.open("GET","AJAX/populatepropertychildtype.jsp?Type=PROP_SUB_TYPE&ParentValue=" + _append + "103&ReqType=LOV&APP_ID=" + _app_id,true);
			xmlhttp.send(null);
		}
		else {
			xmlhttp.onreadystatechange=function(){
					if(xmlhttp.readyState==4) {
						document.getElementById("spanPropertyChildType").innerHTML = xmlhttp.responseText;
						if(document.getElementById("NumberOfBedrooms") != null) {
							document.getElementById("NumberOfBedrooms")[0].selected = 1;
							document.getElementById("NumberOfBedrooms").disabled=true;
						}
//						if(document.getElementById("pptchtype") != null)
//							document.getElementById("PropertyChildType").selectedIndex = document.getElementById("pptchtype").value;
  					}
				}
				xmlhttp.open("GET","AJAX/populatepropertychildtype.jsp?Type=PROP_SUB_TYPE&ParentValue=" + _append + "104&ReqType=LOV&APP_ID=" + _app_id,true);
				xmlhttp.send(null);
		}
    }
    
    function populateCity(){
    	var xmlhttp = getXMLHTTP();
    	xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("spanCity").innerHTML = xmlhttp.responseText;
//				if(document.getElementById("pptchtype") != null)
//					document.getElementById("CityName").selectedIndex = document.getElementById("ctnm").value;		
  			}
		}
		xmlhttp.open("GET","AJAX/populatecity.jsp?State=Maharashtra&ReqType=CSCAL&APP_ID=" + _app_id,true);
		xmlhttp.send(null);
    }
    
    function populateAreaInit(){
    	var xmlhttp = getXMLHTTP();
    	var comboCity = document.getElementById("CityName");
		var city = "Mumbai";
    	xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("spanArea").innerHTML = xmlhttp.responseText;
//				if(document.getElementById("arnm") != null)
//					document.getElementById("AreaName").selectedIndex = document.getElementById("arnm").value;		
  			}
		}
		xmlhttp.open("GET","AJAX/populatearea.jsp?City="+ city +"&ReqType=CSCAL&APP_ID=" + _app_id,true);
		xmlhttp.send(null);
    }
    
    function populateArea(){
    	var xmlhttp = getXMLHTTP();
    	var comboCity = document.getElementById("CityName");
		var city = comboCity.options[comboCity.selectedIndex].text;
    	xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("spanArea").innerHTML = xmlhttp.responseText;
//				if(document.getElementById("arnm") != null)
//  					document.getElementById("AreaName").selectedIndex = document.getElementById("arnm").value;		
  			}
		}
		xmlhttp.open("GET","AJAX/populatearea.jsp?City="+ city +"&ReqType=CSCAL&APP_ID=" + _app_id,true);
		xmlhttp.send(null);
    }
    
    function populatePropertyChildTypeInit(kkk) {
    	var comboPropertyType = document.getElementById("PropertyType");
		var val = comboPropertyType.options[comboPropertyType.selectedIndex].text;
		
		var xmlhttp = getXMLHTTP();
		if(val == "Residential") {
			xmlhttp.onreadystatechange=function() {
					if(xmlhttp.readyState==4) {
						document.getElementById("spanPropertyChildType").innerHTML = xmlhttp.responseText;
						for (var i=0; i<document.getElementById("PropertyChildType").length; i++)
		  				{
		  					if(document.getElementById("PropertyChildType").options[i].text == kkk)
		  					{
		  						document.getElementById("PropertyChildType").selectedIndex = i;
		  						break;
		  					}
		  				}
  					}
			}
			xmlhttp.open("GET","AJAX/populatepropertychildtype.jsp?Type=PROP_SUB_TYPE&ParentValue=" + _append + "103&ReqType=LOV&APP_ID=" + _app_id, true);
			xmlhttp.send(null);
		}
		else {
			xmlhttp.onreadystatechange=function()
			{
					if(xmlhttp.readyState==4) 
					{
						document.getElementById("spanPropertyChildType").innerHTML = xmlhttp.responseText;
						for (var i=0; i<document.getElementById("PropertyChildType").length; i++)
		  				{
		  					if(document.getElementById("PropertyChildType").options[i].text == kkk)
		  					{
		  						document.getElementById("PropertyChildType").selectedIndex = i;
		  						break;
		  					}
		  				}
  					}
				}
				xmlhttp.open("GET","AJAX/populatepropertychildtype.jsp?Type=PROP_SUB_TYPE&ParentValue=" + _append + "104&ReqType=LOV&APP_ID=" + _app_id, true);
				xmlhttp.send(null);
		}
    }
    
    function populateCityInit(kkk){
    	var xmlhttp = getXMLHTTP();
    	xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("spanCity").innerHTML = xmlhttp.responseText;
				for (var i=0; i<document.getElementById("CityName").length; i++)
  				{
  					if(document.getElementById("CityName").options[i].text == kkk)
  					{
  						document.getElementById("CityName").selectedIndex = i;
  						break;
  					}
  				}		
  			}
		}
		xmlhttp.open("GET","AJAX/populatecity.jsp?State=Maharashtra&ReqType=CSCAL&APP_ID=" + _app_id, true);
		xmlhttp.send(null);
    }
  				
  	function populateAreaInitPrev(area, city){
    	var xmlhttp = getXMLHTTP();
    	var comboCity = document.getElementById("CityName");
    	xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				document.getElementById("spanArea").innerHTML = xmlhttp.responseText;
				for (var i=0; i<document.getElementById("AreaName").length; i++)
				{
					if(document.getElementById("AreaName").options[i].text == area)
					{
						document.getElementById("AreaName").selectedIndex = i;
						break;
					}
				}	
  			}
		}
		xmlhttp.open("GET","AJAX/populatearea.jsp?City="+ city +"&ReqType=CSCAL&APP_ID=" + _app_id, true);
		xmlhttp.send(null);
    }