var propertyForArr = new Object();
propertyForArr['1'] = [
					{value:"1", text:"Buy"},
					{value:"2", text:"Rent"},
					{value:"3", text:"PG"}
				];
propertyForArr['2'] = [
					{value:"1", text:"Buy"},
					{value:"2", text:"Rent"}
				];

var budgetval = new Object();
budgetval['1'] = [
					{value:"1000000", text:"10 Lacs"},
					{value:"1500000", text:"15 Lacs"},
					{value:"2000000", text:"20 Lacs"},
					{value:"3000000", text:"30 Lacs"},
					{value:"4000000", text:"40 Lacs"},
					{value:"5000000", text:"50 Lacs"},
					{value:"6000000", text:"60 Lacs"},
					{value:"7500000", text:"75 Lacs"},
					{value:"10000000", text:"1 Crore"},
					{value:"15000000", text:"1.5 Crore"},
					{value:"20000000", text:"2 Crore"},
					{value:"30000000", text:"3 Crore"},
					{value:"50000000", text:"5 Crore"},
					{value:"100000000", text:"10 Crore"},
					{value:"200000000", text:"20 Crore"}
				];
budgetval['2'] = [
					{value:"5000", text:"5000"},
					{value:"10000", text:"10000"},
					{value:"15000", text:"15000"},
					{value:"20000", text:"20000"},
					{value:"25000", text:"25000"},
					{value:"40000", text:"40000"},
					{value:"70000", text:"70000"},
					{value:"100000", text:"1 Lac"},
					{value:"150000", text:"1.5 Lacs"},
					{value:"200000", text:"2 Lacs"},
					{value:"500000", text:"5 Lacs"},
					{value:"1000000", text:"10 Lacs"}
				];
budgetval['3'] = [
					{value:"4000", text:"4000"},
					{value:"6000", text:"6000"},
					{value:"8000", text:"8000"},
					{value:"10000", text:"10000"},
					{value:"15000", text:"15000"},
					{value:"20000", text:"20000"},
					{value:"25000", text:"25000"},
					{value:"30000", text:"30000"}
				];

var pTypeArr = new Object();
pTypeArr['1'] = [
					{value:"1", text:"Residential Property"},
					{value:"3", text:"Apartment"},
					{value:"4", text:"Plot/Land"},
					{value:"5", text:"Builder Floor"},
					{value:"6", text:"Bungalow/Villa"},
					{value:"7", text:"Farm House"},
					{value:"8", text:"Service/Studio Apartment"},
					{value:"9", text:"Other Residential"}
				];
pTypeArr['2'] = [
					{value:"2", text:"Commercial Property"},
					{value:"10", text:"Land"},
					{value:"11", text:"Office"},
					{value:"12", text:"Business Centre"},
					{value:"13", text:"Warehouse/Godown"},
					{value:"14", text:"Industrial Setup"},
					{value:"15", text:"Shop"},
					{value:"16", text:"Other Commercial"}
				];
// This function is customize for registration and list your property
function createAjaxObject(id)
{
	var xmlObj = new Array();
	xmlObj[id] = false;
	//Check if we are using IE.
	try {
	//If the Javascript version is greater than 5.
		xmlObj[id] = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	//If not, then use the older active x object.
		try {
		//If we are using Internet Explorer.
			xmlObj[id] = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
		//Else we must be using a non-IE browser.
			xmlObj[id] = false;
		}
	}
	//If we are using a non-IE browser, create a javascript instance of the object.
	if (!xmlObj[id] && typeof XMLHttpRequest != 'undefined') {
		xmlObj[id] = new XMLHttpRequest();
	}
	return xmlObj[id];
}

function focusSearchBox(frmObj)
{
	var text = frmObj.q.value;
	if(text == 'Quick Search')
	{
		frmObj.q.value = '';
		frmObj.q.className='iqsearch';
	}
}
function blurSearchBox(frmObj)
{
	var text = frmObj.q.value;
	if(text == '')
	{
		frmObj.q.value = 'Quick Search';
		frmObj.q.className='iqsearchgray';
	}
}

var cityArr = new Array(6);
cityArr['M1'] = new Array(11);
cityArr['M1'][0] = '1|Delhi North';
cityArr['M1'][1] = '2|Delhi South';
cityArr['M1'][2] = '3|Delhi East';
cityArr['M1'][3] = '4|Delhi West';
cityArr['M1'][4] = '5|Delhi Central';
cityArr['M1'][5] = '6|Dwarka';
cityArr['M1'][6] = '7|Noida';
cityArr['M1'][7] = '8|Greater Noida';
cityArr['M1'][8] = '9|Gurgaon';
cityArr['M1'][9] = '10|Ghaziabad';
cityArr['M1'][10] = '11|Faridabad';

cityArr['M2'] = new Array(9);
cityArr['M2'][0] = '283|Mumbai Andheri-Dahisar';
cityArr['M2'][1] = '284|Mumbai Central';
cityArr['M2'][2] = '285|Mumbai Harbour';
cityArr['M2'][3] = '286|Mumbai Navi';
cityArr['M2'][4] = '287|Mumbai South';
cityArr['M2'][5] = '288|Mumbai South West';
cityArr['M2'][6] = '289|Mumbai Thane';
cityArr['M2'][7] = '290|Mumbai Beyond Thane';
cityArr['M2'][8] = '291|Mumbai Mira Road and Beyond';

cityArr['M3'] = new Array(5);
cityArr['M3'][0] = '23|Bangalore North';
cityArr['M3'][1] = '24|Bangalore South';
cityArr['M3'][2] = '25|Bangalore East';
cityArr['M3'][3] = '26|Bangalore West';
cityArr['M3'][4] = '27|Bangalore Central';

cityArr['M5'] = new Array(4);
cityArr['M5'][0] = '35|Chennai North';
cityArr['M5'][1] = '36|Chennai South';
cityArr['M5'][2] = '37|Chennai West';
cityArr['M5'][3] = '38|Chennai Central';

cityArr['M6'] = new Array(3);
cityArr['M6'][0] = '40|Hyderabad';
cityArr['M6'][1] = '41|Secunderabad';
cityArr['M6'][2] = '42|Gr. Hyderabad';

cityArr['S299'] = new Array(1);
cityArr['S299'][0] = '299|Pune';

function fillSubCity(val)
{
	var arr = new Array();
	var a = b = "";
	document.getElementById('iq_subcity').length = 0;
	var selectbox = document.getElementById('iq_subcity');
	//addOption(selectbox,"Select Subcity","")
	for (var row = 0; row < cityArr[val].length; row++) 
	{ 
		arr = cityArr[val][row].split("|");
		a = arr[0];
		b = arr[1];
		addOption(selectbox,b,a)
	}
	var e = document.frm_loc_search.iq_subcity;
	var isc = e.options[e.selectedIndex].value;
	fillIqLocality(isc)
}

function addOption(selectbox,text,value,disabled )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}

function fillIqLocality(val)
{
	if(val != '')
	{
		var obj = document.getElementById('iq_locality');
		var serverPage = "/ssi/ajax/fill-iq-locality.php?s=" + val;
		var xmlhttp = createAjaxObject('1');
		try
		{
			xmlhttp.open("GET",serverPage,true);
			xmlhttp.onreadystatechange = function()
			{
				if (xmlhttp.readyState==4)
				{
					var result = xmlhttp.responseText;
					obj.innerHTML = result;
				}
				else
				{
					obj.innerHTML= 'Processing.....please wait';
				}
			}
			xmlhttp.send(null);
		}
		catch(e)
		{
		}
	}
}

function load_iq_content(val)
{
	var a = "";
	var b = "";
	for (var i=1;i<8;i++)
	{
		var a = 'city_'+i+'_on';
		document.getElementById(a).style.display = 'none';
		var b = 'city_'+i+'_off';
		document.getElementById(b).style.display = '';
		var c = 'newscontent_'+i;
		document.getElementById(c).style.display = 'none';
	}
	var a = 'city_'+val+'_on';
	document.getElementById(a).style.display = '';
	var b = 'city_'+val+'_off';
	document.getElementById(b).style.display = 'none';
	var c = 'newscontent_'+val;
	document.getElementById(c).style.display = '';

	//fillIqContent(val);
}

function setBudgetFinal(chooser,pfFldType,frmName,defSale,defRent,defPG,Changed,priceFrom,priceTo)
{
	var frmObj = eval('document.'+frmName);
	if(!priceFrom) priceFrom=0;
	if(!priceTo) priceTo=0;
	if(pfFldType == 0) {
		chooser = chooser;
	}else if(pfFldType == 1) {
		if(frmObj.property_for['0'].checked==true)
			chooser=1;
		else if(frmObj.property_for['1'].checked==true)
			chooser=2;
		else if(frmObj.property_for['2'].checked==true)
			chooser=3;
		else
			chooser=1;
	}else if(pfFldType == 2 && frmObj.property_for.value != ''){	
		chooser=frmObj.property_for.value;
	}
	var newElem;
	var where = (navigator.appName == 'Microsoft Internet Explorer') ? -1 : null;
	var cityChooser = frmObj.elements['budget_from'];
	if(Changed != 1) {
		while (cityChooser.options.length) {
			cityChooser.remove(0);
		}
		var choice = chooser;
		var db = budgetval[choice];
		newElem = document.createElement('option');
		if(chooser == '3') {
			newElem.text = "<4000";
			newElem.value = "3999";
		}
		else if(chooser == '2') {
			newElem.text = "<5000";
			newElem.value = "4999";
		} else {
			newElem.text = "<10 Lacs";
			newElem.value = "999999";
		}
		cityChooser.add(newElem, where);
		if (choice != '') {
			var selfound = 0;
			for (var i = 0; i < db.length; i++) {
				if(selfound == 0 && chooser == '3' &&  priceFrom == '3999') {
					newElem.selected = true;
					selfound = 1;
				}else if(selfound == 0 && chooser == '2' &&  priceFrom == '4999') {
					newElem.selected = true;
					selfound = 1;
				}else if(selfound == 0 && chooser == '1' &&  priceFrom == '999999') {
					newElem.selected = true;
					selfound = 1;
				}
				newElem = document.createElement('option');
				newElem.text = db[i].text;
				newElem.value = db[i].value;
				if(i == (db.length-1)) {
					newElem.text = ">" + newElem.text;
				}
				cityChooser.add(newElem, where);
				if(selfound == 0 && db[i].value == priceFrom) {
					newElem.selected = true;
					selfound = 1;
				}else if(selfound == 0 && chooser == 1 && db[i].value == '3000000') {
					newElem.selected = true;
				}else if(selfound == 0 && chooser == 2 && db[i].value == '15000'){
					newElem.selected = true;
				}else if(selfound == 0 && chooser == 3 && db[i].value == '6000'){
					newElem.selected = true;
				}
			}
		}
	}

	var cityChooser2 = frmObj.elements['budget_to'];
	while (cityChooser2.options.length) {
		cityChooser2.remove(0);
	}
	var choice = chooser;
	var db = budgetval[choice];
	
	var start = 0;
	if(Changed != 1) {
		if(chooser == 3) {
			start = 2;
		}else if(chooser == 2) {
			start = 3;
		} else {
			start = 4;
		}
	} else {
		start = cityChooser.selectedIndex;
	}
	var maxoptions=cityChooser.options.length-1;
	if(start == 0 || start == maxoptions) {
		newElem = document.createElement('option');
		newElem.text = "Max Price";
		newElem.value = "";
		cityChooser2.add(newElem, where);
		cityChooser2.disabled = true;
	}else if (choice != '') {
		var selfound = 0;
		for (var i = start; i < db.length; i++) {
			newElem = document.createElement('option');
			newElem.text = db[i].text;
			newElem.value = db[i].value;
			cityChooser2.add(newElem, where);
			if(db[i].value == priceTo) {
					newElem.selected = true;
					selfound = 1;
			} else if(selfound == 0 && choice == 1 && db[i].value == defSale) {
				newElem.selected = true;
			}else if(selfound == 0 && choice == 2 && db[i].value == defRent){
				newElem.selected = true;
			}else if(selfound == 0 && choice == 3 && db[i].value == defPG){
				newElem.selected = true;
			}
		}
		cityChooser2.disabled = false;
	}
}

function fillPropertyType(type,frm)
{
	var fldObj = eval('document.'+frm+'.property_type');
	while (fldObj.firstChild) {
		fldObj.removeChild(fldObj.firstChild);
	}
	
	if(type == '1' || type == '2')
	{
		var db = pTypeArr['1'];
		var where = (navigator.appName == 'Microsoft Internet Explorer') ? -1 : null;
		for (var i = 0; i < db.length; i++) {
			newElem = document.createElement('option');
				newElem.text = db[i].text;
				newElem.value = db[i].value;
				if(i == 0) {
					newElem.style.background = '#FDF6B5';
				}
			fldObj.add(newElem, where);
		}

		db = pTypeArr['2'];
		var where = (navigator.appName == 'Microsoft Internet Explorer') ? -1 : null;
		for (var i = 0; i < db.length; i++) {
			newElem = document.createElement('option');
				newElem.text = db[i].text;
				newElem.value = db[i].value;
				if(i == 0) {
					newElem.style.background = '#FDF6B5';
				}
			fldObj.add(newElem, where);
		}
	}
	else if(type == '3')
	{
		var db = pTypeArr['1'];
		var where = (navigator.appName == 'Microsoft Internet Explorer') ? -1 : null;
		for (var i = 0; i < db.length; i++) {
			newElem = document.createElement('option');
				newElem.text = db[i].text;
				newElem.value = db[i].value;
				if(i == 0) {
					newElem.style.background = '#FDF6B5';
				}		
			fldObj.add(newElem, where);
		}
	}
	var bedroomFldObj = eval('document.'+frm+'.bedroom');
		if(bedroomFldObj.disabled == true)
		{
			bedroomFldObj.disabled = false;
		}
}

function manage_property_type()
{
	var selected = document.frm_first.property_type.value;
	if(selected==2 || selected==4 || selected==10 || selected==11 || selected==12 ||  selected==13 || selected==14 || selected==15 || selected==16)
	{
		document.frm_first.bedroom.disabled =true;
	}
	else
	{
		document.frm_first.bedroom.disabled =false;
	}
}
function update_tracker(C){var A=createAjaxObject("1");var B="/ssi/ajax/update-listing-tracker.php?trid=93";try{A.open("GET",B,true);A.onreadystatechange=function(){if(A.readyState==4){}};A.send("null")}catch(D){}}
function fillReltedTopics(serverPage,objID)
{
	var ajaxObj = createAjaxObject('0');
	var obj = document.getElementById(objID);
	try
	{
		ajaxObj.open("GET",serverPage,true);
		ajaxObj.onreadystatechange = function()
		{
			if(ajaxObj.readyState==4)
			{
				getmessage = ajaxObj.responseText;
				obj.innerHTML=getmessage;
			}
			else
			{
				obj.innerHTML = '&nbsp;';
			}
		}
		ajaxObj.send(null);
	}
	catch(e)
	{
	}
}

function changeIqCity(val)
{
	var validCity = "#1#M1#M2#S299#M6#M3#M5#" 
	var re = "#" + val + "#";
	var pageurl = "";
	if(validCity.search(re))
	{
		if(val == "1"){
			pageurl = 'index.php';
		}else if(val == "M1"){
			pageurl = 'delhi.php';
		}else if(val == "M2"){
			pageurl = 'mumbai.php';
		}else if(val == "M3"){
			pageurl = 'bangalore.php';
		}else if(val == "M5"){
			pageurl = 'chennai.php';
		}else if(val == "M6"){
			pageurl = 'hyderabad.php';
		}else if(val == "S299"){
			pageurl = 'pune.php';
		}
	}else{
		pageurl = 'index.php';
	}
	document.location.href=pageurl;
}
