	/*
		Created					:	Feb 20 2007
		Author					:	S.k.v
		Descript					:	All Search related scripts
		Last Modified			:	July 08 2009
	*/
	var ipTrack = new ip_tracker();
	var mailForm = new Array();
	var vCard = new Array();
	ip.pageFrom="searchresults";
	var glbRefineParams=null,glbDefaultVal=null;
	var locality_array=new Array();
	var age_array=new Array();
	var price_array=new Array();
	var bedroom_array=new Array();
	var area_array=new Array();
	var firstVisit=false;
	var pageLoaded = false;
	var needCookie = false;/* find the reference search page (it comes from quicksearch or others )*/
	var othersChkd=false;
	var locothersall="";
	/*Quick Search*/
	function checkBuyerSearch(frm){
		if(!frm) frm =d.buyersearch;
		if(!IsMandatory(frm.city,"select","Please select City",2))  return false;
		if(!IsMandatory(frm.property,"select","Please select Property Category",2)) return false;
		return true;
	}
	/* For localitysearch.php */
	function localityvalidate(frm){
		
		if(!frm) frm = d.localitysearch;
		if(!IsMandatory(frm.property,"select","Please select Property type1234",2)) return false;
		if(!IsMandatory(frm.locality,"select","Please select Locality",2)) return false;
		var strLocality = frm.locality.options[frm.locality.selectedIndex].value;
		if(strLocality.indexOf("-------")!=-1) return ip.throwErr(frm.locality,"Please select Locality",2);
		var ipCookie = new ip_cookie();
		ipCookie.setCookie("fltrprice", "",1990,1,1);
		ipCookie.setCookie("constraint", "",1990,1,1);
		try{
			if(frm.locality.selectedIndex!=0){
				frm.fltrlocality.value=frm.locality.value;
			}
		}catch(e){traceErr(e,"localityvalidate");}
		templocality = frm.locality.options[frm.locality.selectedIndex].text;
		var strDomain = (frm.locality.selectedIndex<=cityLocality.additionalArr.length) ? "http://www.indiaproperty.com" :ip.host();
		try{
			if(cityLocality.additionalArr.length>0){
				if(cityLocality.captionReplaceArr.length>0){
					for (var i=0; i<cityLocality.captionReplaceArr.length; i+=2) {
						if(cityLocality.captionReplaceArr[i]==templocality) templocality=cityLocality.captionReplaceArr[i+1];
					}
				}
			}
		}catch(e){ip.traceErr(e,"localityvalidate");}
		templocality=templocality.replace(" ","+");
		var qry = strDomain +  (( String(location.href).indexOf("affordablehousing")==-1) ? "/search/" : "/affordablesearch/") +  frm.transaction.value + "/" + frm.property.options[frm.property.selectedIndex].value + "-in/";
		try{
			var usertypeArr = frm.elements["strusertype[]"];
			var newpath = "/";
			var propByArr=propertiesByArray(usertypeArr);
			var ipCookie = new ip_cookie();
			ipCookie.setCookie("propertyBy",propByArr,"","","",newpath);
		}catch(e){
			ip.traceErr(e);
		}		
		window.location.href = qry + templocality + ".html";
		return false;
	}
	/* End locality search */

	function CheckEmail(frm){
		if(!IsMandatory(frm.stremail,"text","Please Enter an Email-ID",2)) return false;
		if(!ip.IsValidEmail(frm.stremail.value)) return ip.throwErr(frm.stremail,"Please enter a valid E-mail ID.",2);
		return true;
	}
	function trackListID(intlistid){try{$.get(ip.host()+"/index.php?option=track&page=tracksearchresult&notemplate=yes&listingid="+intlistid);}catch(e){traceErr(e,"trackListID");}}
	/* New Beta Search (solr) Scripts */
	function Hide4PG(Obj,frm){
		if(!frm) frm = d.quicksearch;
		var status=false;
		try{status = (Obj.options[Obj.selectedIndex].value=="accommodation")  ? true : false;}
		catch(e){status = (Obj.value=="accommodation")  ? true : false;}
		var Obj = new Array();
		Obj[0] = $ip("ByAgents");
		Obj[1] = $ip("ByBuilders");
		Obj[2] = $ip("ByInd");
		Obj[3] = $ip("ByAll");
		frm.propertyofage.disabled  = status;
		for(i=0;i<Obj.length;i++){
			Obj[i].disabled =status;
		}
	}

	function ChkPropertiesBy(frm,CurrentObj){
		var Status =CurrentObj.checked;
		var Obj = new Array();
		Obj[0] = $ip("ByAgents");
		Obj[1] = $ip("ByBuilders");
		Obj[2] = $ip("ByInd");
		Obj[3] = $ip("ByAll");
		if(Obj[0].checked && Obj[1].checked && Obj[2].checked) {
			for (var i=0; i<Obj.length-1; i++) {Obj[i].checked=false;}
			Obj[3].checked=true;
		}else if(Obj[3]==CurrentObj){
			for (var i=0; i<Obj.length-1; i++) {Obj[i].checked=false;}
		}else{
			Obj[3].checked=false;
		}
	}
	/* Start Send Email*/
	function validateSendMail(frm,action){
		if(!frm){return false;}
		if(!IsMandatory(frm.strname,"text","Please enter a name.", 2)) return false;
		if(IsMin(frm.strname.value,3)) return ip.throwErr(frm.strname,"Name must contain a minimum of 3 characters.",2);
		if(!IsValidCharacters(frm.strname.value, alphabets + "&.-_ ",alphabets)) return ip.throwErr(frm.strname,"Please use only alphabets.",2);
		if(typeof frm.strcountry=="object") if(!IsMandatory(frm.strcountry,"select","Please select a country.",2)) return false;
		if(!IsMandatory(frm.stremail,"text","Please enter an e-mail ID.",2)) return false;
		if(!ip.IsValidEmail(frm.stremail.value)) return ip.throwErr(frm.stremail,"Please enter a valid e-mail ID.",2);
		if(!IsMandatory(frm.strphone,"text","Please enter a phone number.",2)) return false;
		if(!IsValidCharacters(frm.strphone.value, numbers + "- ",numbers)) return ip.throwErr(frm.strphone,"Please use only numerals.",2);
		if(IsMin(frm.strphone.value,8)) return ip.throwErr(frm.strphone,"Please check the phone number.",2);
		if(!IsMandatory(frm.txteqmsg,"textarea","Please enter your message.",2)) return false;
		if(IsMin(frm.txteqmsg.value,50)) return ip.throwErr(frm.txteqmsg,"Message should not be less than 50 characters.",2);
		if(IsMax(frm.txteqmsg.value,140)) return ip.throwErr(frm.txteqmsg,"Message cannot exceed 140 characters.",2);
		if(!IsValidCharacters(frm.txteqmsg.value, alphabets + numbers + " ,.?/;:'!@#$%*()-_+=|\[]{}",alphabets + numbers)) return ip.throwErr(frm.txteqmsg,"Special characters are not allowed.",2);
		if(action) sendMultipleEnq_SendMail(frm); else mailForm[frm.arrIndex.value].sendEmail(frm);
		return false;
	}
	function showMailForm(ListID,fromObj){
		var index = mailForm.length;
		mailForm[index] = new sendMail(ListID,fromObj);
		mailForm[index].callAjax();
	}
	function sendMail(ListID,fromObj){
		this.ListID = ListID;
		this.mailStatus = null;
		this.ajax = null;
		this.sAjax = null;
		this.url  = "";
		this.popupURL = "/index.php?option=site&page=sendenquiry&notemplate=yes&listingid=";
		//this.mailformURL ="/index.php?option=search&page=ajaxsearchenquiry&notemplate=yes&listingid=";
		this.mailformURL ="/enquiry/sendemailenquiry.php?";
		this.successMsg = "&nbsp;Your enquiry has been sent successfully.";
		this.errorMsg = ip.err.timeOut;
		this.ver_errorMsg = "Your code is wrong, Re-enter the verification code.";
		try{this.frm = $ip( ((fromObj) ? "Hfrm_" : "frm_") +ListID) || new Object;}catch(e){}
		this.divObj = $ip( ((fromObj) ? "HdivEmail" : "divEmail") +ListID);
		this.errName ="";
		this.errEmail ="";
		this.errPhone ="";
		this.errMsg ="";
		this.errCountry ="";
		this.resultFrom =  (fromObj) ? "sponsored" : "basic";
		StartPreLoader(preImgs);
	};
	sendMail.prototype.callAjax = function(scErr){
		if(this.resultFrom=="basic") this.divObj = $ip("divEmail"+this.ListID); else  this.divObj = $ip("HdivEmail"+this.ListID);
		this.sAjax = new getHTTPObject();
		if(!this.divObj || !this.sAjax){/*If Ajax not loaded then the Popup Window will open*/
			this.url = ip.host() + this.popupURL + this.ListID;
			ip.OpenPopUp(this.url,100,100,500,400);
			return;
		}
		if(!scErr && String(this.divObj.innerHTML).length>30){	 //If Already Opend
			try{
				this.frm.focus();
				if(this.frm.strname.value=="")this.frm.strname.focus(); else this.frm.txteqmsg.focus();
				this.divObj.style.display ="";
				return;
			}catch(e){traceErr(e,"sendEmail");return;}
		}
		this.divObj.style.display="";
		var thisObj = this;
		this.divObj.innerHTML = ip.loadingStr;
		var qry="";
		if(scErr){
			qry = "&scErr=1&strname="+this.errName+"&stremail="+this.errEmail+"&strphone="+this.errPhone+"&strmsg="+this.errMsg+"&strcountry="+this.errCountry;
		}
		this.url = ip.host() + "/index.php?option=search&page=ajaxsearchenquiry&notemplate=yes&listingid=" +this.ListID+"&resultFrom="+this.resultFrom+"&arrIndex="+parseInt(mailForm.length-1)+qry;
		this.sAjax.open("GET",this.url,true);
		this.sAjax.onreadystatechange = function(){
			if(thisObj.sAjax.readyState==4){
				var res=thisObj.sAjax.responseText;
				if(res==""){
					res=ip.err.timeOut;
					window.setTimeout(function(){
						closeThis(thisObj.ListID,thisObj.resultFrom);
					},5000);
				}
				var ListID = thisObj.ListID;
				try{
					$ip( ((thisObj.resultFrom=="basic") ? "divEmail" : "HdivEmail")  +ListID).innerHTML=res;
				}catch(e){
					/*var elm = d.createElement("div");
					elm.innerHTML = res;
					$ip("divEmail"+ListID).appendChild(elm);*/
					ip.traceErr(e,"callAjax","search");
				}

				var frm = $ip(  ((thisObj.resultFrom=="basic") ? "frm_" : "Hfrm_") +thisObj.ListID);
				thisObj.frm = frm;
				window.setTimeout(function(){
					try{
						if(typeof frm.strcountry == "object"){
							$ip( ((thisObj.resultFrom=="basic")? "TD_STRMSG_" : "HTD_STRMSG_") +thisObj.ListID).rowSpan="4";
							/*$ip("TD_SUBMIT_"+thisObj.ListID).rowSpan="4";*/
							frm.txteqmsg.style.height = "80px";
							//if(qry=="") frm.txteqmsg.value ="";
							frm.txteqmsg.focus();
						}
						/*ip.changeCount(frm.txteqmsg,140, ( (thisObj.resultFrom=="basic") ? 'divCount_' : 'HdivCount_') +thisObj.ListID);*/
						if(frm.strname.value=="") frm.strname.focus(); else if(frm.txteqmsg.value=="") frm.txteqmsg.focus(); else frm.security_code.focus();
						thisObj.sAjax.abort();
					}catch(e){traceErr(e,"sendMail");}
				},2000);
			}
		}
		this.sAjax.send(null);
	};
	sendMail.prototype.sendEmail = function(frm){
		if(!this.divObj){return;}
		this.errName = frm.strname.value;
		this.errEmail =frm.stremail.value;
		this.errPhone = frm.strphone.value;
		this.errMsg=frm.txteqmsg.value;
		if(typeof frm.strcountry == "object"){
			var strcountry =frm.strcountry.options[frm.strcountry.selectedIndex].value;
			this.errCountry=strcountry;
		}else{var strcountry="";}
		/*this.url = ip.host() + "/index.php?option=search&page=ajaxenquirymail&notemplate=yes&username="+frm.username.value+"&strname="+frm.strname.value +
			"&stremail="+frm.stremail.value+"&strphone="+frm.strphone.value+
			"&posteddate="+frm.posteddate.value +"&toemail="+frm.toemail.value+
			"&strcountry="+strcountry+"&listingid="+frm.listingID.value+"&txteqmsg="+frm.txteqmsg.value+"&security_code="+frm.security_code.value;
		*/
		var urltoenq = ip.host() + "/index.php?option=listing&page=enqtoregister&notemplate=yes&username=&strname="+frm.strname.value + "&stremail="+frm.stremail.value+"&strphone="+frm.strphone.value+
			"&strcountry="+strcountry+"&listingid="+frm.listingID.value+"&txteqmsg="+frm.txteqmsg.value+"&security_code="+frm.security_code.value;
		convertEnqToRegSearch(urltoenq);

		this.url = ip.host() + this.mailformURL + "&username=&strname="+frm.strname.value + "&stremail="+frm.stremail.value+"&strphone="+frm.strphone.value+
			"&strcountry="+strcountry+"&listingid="+frm.listingID.value+"&txteqmsg="+frm.txteqmsg.value+"&security_code="+frm.security_code.value;
		ip.print("NEW EMAIL SEND URL = " + this.url);
		this.divObj.innerHTML = ip.loading("&nbsp;Sending mail enquiry... Please wait...");
		this.mailStatus=0;
		var thisObj = this;
		this.ajax = new getHTTPObject();
		this.ajax.open("GET",this.url,true);
		this.ajax.onreadystatechange = function(){
			if(thisObj.ajax.readyState==4){
				/*res = (thisObj.ajax.responseText==1) ? thisObj.successMsg : thisObj.errorMsg;*/
				if( parseInt(thisObj.ajax.responseText) == 1 || parseInt(thisObj.ajax.responseText)==3){
					var res =thisObj.successMsg;
					ipTrack.ipMail.trackSent();
				}else if( parseInt(thisObj.ajax.responseText) == 2 ){
					var res =thisObj.ver_errorMsg;
					thisObj.mailStatus=null;
					thisObj.callAjax(1);
					return;
				}else if( parseInt(thisObj.ajax.responseText) == 3 ){
					var res ="The given text seems to be a spam text.";
					return;
				}else {
					var res =thisObj.errorMsg;
				}
				/* divObj.innerHTML = '<div style="padding:5px 10px 0px; color:rgb(255,100,0);">' + res + '</div>'; */
				thisObj.divObj.innerHTML = "<b>" + res + "</b>";
				thisObj.mailStatus=1;
				thisObj.mailStatus=null;
				/*window.setTimeout(function(){
					closeThis(thisObj.ListID);
				},10000);
				*/
			}
			/*if No response till 35 seconds it ERR message will throw (Note: Netscape will throw immediately so currently i wont use this method => solution: check browser & apply)*/
			/*var checkInterval = window.setInterval(
				function(){
					if(thisObj.mailStatus==0){
						thisObj.mailStatus=null;
						thisObj.ajax.abort();
						thisObj.divObj.innerHTML = thisObj.errorMsg;
						window.setTimeout(function(){
							$ip(thisObj.ListID).style.display="none";
							clearInterval(checkInterval);
							thisObj.callAjax(thisObj.ListID);
						},10000);
					}
				},35000);
			*/
		}
		this.ajax.send(null);
	};
	/* End Send Email */

	ip.startMouseDetect();

	function showSearchBox(divID){
		try{
			try{showSigUpAlert(1,1);}catch(e){}
			if(!pageLoaded) return;
			if(divID=="propertyid" ||divID=="propertyalert") return;
			var frm = $ip(divID+"search");
			var pageF=0;
			if(divID=="buyer"){pageF=1;}
			focusCity(frm,pageF);
			if(divID=="buyer") return;
			var ipCookie = new ip_cookie();
			var propertyBy = ipCookie.getCookie("propertyBy");
			var resultsByObj = frm.elements["strusertype[]"];
			for (var i=0; i<resultsByObj.length; i++) {resultsByObj[i].checked=false;}
			if(propertyBy.indexOf("individual")!=-1) resultsByObj[0].checked = true;
			if(propertyBy.indexOf("agent")!=-1) resultsByObj[1].checked = true;
			if(propertyBy.indexOf("builder")!=-1) resultsByObj[2].checked = true;
			if(propertyBy.indexOf("all")!=-1 || propertyBy=="") resultsByObj[3].checked = true;
		}catch(e){traceErr(e,"showSearchBox");}
	}
	/* Start VCard */
	function showVcard(uName){
		var Obj = $ip("divVCard");
		with(Obj.style){
			display ="";
			left = ip.mouseX + "px";
			top= ip.mouseY + "px";
			innerHTML = '<span style="color:rgb(255,100,100); padding:6px 10px;">'+ip.loading("loading agent info...")+'</span>';
		}
		if(vCardTimer) clearInterval(vCardTimer);
		var aReq = new getHTTPObject();
		var url = ip.host() + "/index.php?option=agent&page=agentvcard&username="+uName+"&notemplate=yes";
		aReq.open("get",url,true);
		aReq.onreadystatechange = function(){
			if(aReq.readyState==4){
				var res = ((aReq.responseText.toLowerCase()).indexOf("error")!="-1" || "") ? '<span style="color:rgb(255,100,100); padding:6px 10px;">Sorry! Agent not found.</span>' : aReq.responseText;
				Obj.innerHTML = res;
			}
		}
		aReq.send(null);
	}
	function hideVcard(uName){
		var Obj = $ip("divVCard");
		vCardTimer = window.setInterval(
			function(){Obj.style.display="none";Obj.innerHTML ="";},3000
		);
	}
	function forceExit(e){
		clearInterval(vCardTimer);
		$ip("divVCard").style.display = "none";
		$ip("divVCard").innerHTML ="";
	}
	var vCardTimer=null;
	/* End VCard */
	function loadSearchResults(params){
		//loadSearchResultsJSON(params);
		//return;
		var sReq = new getHTTPObject();
		params+= "&refer="+new Date().getTime();
		var url = ip.host() + "/index.php";
		$ip("SearchResultsLoad").innerHTML = ip.loading("Loading Search Results... Please wait...");
		sReq.open("POST",url,true);
		sReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=utf-8');
		sReq.setRequestHeader("Content-length", params.length);
		sReq.setRequestHeader("Connection", "close");
		sReq.onreadystatechange = function(){
			if(sReq.readyState==4){
				$ip("SearchResultsLoad").innerHTML =sReq.responseText;
			}
		}
		sReq.send(params);
	}
	function loadAdvSearchResults(params){
		var sReq = new getHTTPObject();
		params+="&refer="+new Date().getTime();
		var url = ip.host() + "/index.php";
		$ip("SearchResultsLoad").innerHTML = ip.loading("Loading Search Results... Please wait...");
		sReq.open("POST",url,true);
		sReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=utf-8');
		sReq.setRequestHeader("Content-length", params.length);
		sReq.setRequestHeader("Connection", "close");
		sReq.onreadystatechange = function(){
			if(sReq.readyState==4){
				$ip("SearchResultsLoad").innerHTML =sReq.responseText;
			}
		}
		sReq.send(params);
	}
	function loadSearchViewResults(params){
		loadSearchResultsJSON(params);
		return false;
		/*var date = new Date();
		var sReq = new getHTTPObject();
		params+="&notemplate=yes&refer="+new Date().getTime();
		var url = ip.host() + "/index.php";
		$ip("SearchResultsLoad").innerHTML = ip.loading("Loading Search Results... Please wait...");
		sReq.open("POST",url,true);
		sReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=utf-8');
		sReq.setRequestHeader("Content-length", params.length);
		sReq.setRequestHeader("Connection", "close");
		sReq.onreadystatechange = function(){
			if(sReq.readyState==4){
				var res = sReq.responseText;
				if(res=="") res = "Request has been cancelled by the user";
				$ip("SearchResultsLoad").innerHTML = res;
				try{showSigUpAlert(1,1);}catch(e){}
			}
		}
		sReq.send(params);
		*/
	}
	function setRefineFilter(params){
		alert("setRefineFilter Called");
		loadRefineResults(params);

		/*sReq.open("POST",url,true);
		sReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=utf-8');
		sReq.setRequestHeader("Content-length", params.length);
		sReq.setRequestHeader("Connection", "close");
		sReq.onreadystatechange = function(){
			if(sReq.readyState==4){
				$ip("div_refine_filters").innerHTML =(sReq.responseText=="") ? "&nbsp;" : sReq.responseText;
			}
		}
		sReq.send(params);*/
	}
	var RefineViewAllTimer=null;
	function closeLocalityDiv(){
		lb.exit();
		$ip('div_refine_filters_all').style.display='none';
		$ip('div_refine_filters_all').innerHTML='';
		refineResults($ip('refinedummyform'));//comment if you doesn't want to load the results while clicking done
	}
	function minusLocalityDiv(){
		lb.exit();
		$ip('div_refine_filters_all').style.display='none';
		$ip('div_refine_filters_all').innerHTML='';
	}
	function hideRefineViewAll(){}
	function showMulRefineFilter(params){
		//if(!pageLoaded) return ip.throwErr(null,"Unable access your request. Please wait till the page loads.",2);
		var Obj = $ip("div_multiple_refine_filters");
		with(Obj.style){
			display ="";
			left = ip.mouseX + "px";
			top= ip.mouseY + "px";
			innerHTML = '<span style="color:rgb(255,100,100); padding:6px 10px;">'+ip.loading("Loading Refine Filters... Please wait...")+'</span>';
		}
		if(RefineFilterTimer) clearInterval(RefineFilterTimer);
		var aReq = new getHTTPObject();
		var url = ip.host() + "/index.php?"+params;
		aReq.open("get",url,true);
		aReq.onreadystatechange = function(){
			if(aReq.readyState==4){
				var res = ((aReq.responseText.toLowerCase()).indexOf("error")!="-1" || "") ? '<span style="color:rgb(255,100,100); padding:6px 10px;">Sorry! There was a problem.</span>' : aReq.responseText;
				Obj.innerHTML = res;
			}
		}
		aReq.send(null);
	}
	function hideMulRefineFilter(){
		var Obj = $ip("div_multiple_refine_filters");
		RefineFilterTimer = window.setInterval(
			function(){Obj.style.display="none";Obj.innerHTML ="";},300
		);
	}
	function sendMultipleRefineFilter(frmobj){
		var jssearchparams=frmobj.searchparms.value;
		var jsrefineparams=frmobj.refineparms.value;
		var temp_str='';
		if(frmobj.locality.selectedIndex!=0){temp_str+="&fltrlocality="+frmobj.locality.value;}
		if(frmobj.age.selectedIndex!=0){temp_str+="&fltrage="+frmobj.age.value;}
		if(frmobj.area.selectedIndex!=0){temp_str+="&fltrarea="+frmobj.area.value;}
		if(frmobj.bedrooms.selectedIndex!=0){temp_str+="&fltrbedroom="+frmobj.bedrooms.value;}
		if(frmobj.price.selectedIndex!=0){temp_str+="&fltrprice="+frmobj.price.value;}
		jssearchparams+=temp_str;
		jsrefineparams+=temp_str;
		loadSearchViewResults(jssearchparams);
		hideMulRefineFilter();
	}
	function SelectCheck(obj,opt){
		for(var cnt=0;cnt<obj.elements.length;cnt++){
			if(obj.elements[cnt].type=='checkbox'){obj.elements[cnt].checked=opt;}
		}
	}
	function add2Favourites(trans){
		if(!checkSelected()) return false;
		var listValues="";
		var obj = checkSelected(1);
		for(var i=0; i<obj.length; i++){ if(obj[i].checked)listValues+=obj[i].value + ",";}
		var url = "/index.php?option=member&page=favourite&notemplate=yes&listingid="+listValues+"&trans="+trans;
		ip.startLB(null,"",200,"aJax",null,url,null);
		/*window.open(,"","width=350,height=101");*/
	}
	function checkSelected(action){
		if (!d.getElementsByTagName){ return; }
		var Arr = d.getElementsByTagName("input");
		var chkArr = new Array();
		for (var i=0; i<Arr.length; i++) {
			if( String(Arr[i].getAttribute("name")).toLowerCase() == "listingid[]"){
				chkArr[chkArr.length] = Arr[i];
				if(!action){ if(Arr[i].checked) return true;}
			}
		}
		if(action){
			return chkArr;
		}
		/*alert("Please select listing and then proceed.");
		return false;*/
		return ip.throwErr(null,"Please select listing and then proceed.",2);
	}
	function traceErr(e,func){ip.traceErr(e,func,"search.js");}
	function showSigUpAlert(SigUpNo,Flag){
		try{
			if(Flag) $("#divSignUpAlertShow"+SigUpNo).slideDown(300); else $("#divSignUpAlertShow"+SigUpNo).slideUp(300);
		}catch(e){traceErr(e,"showSigUpAlert");}
	}
	function signUpAlert(frm, cnt){
		if(!frm) return false;
		if (frm.stremail.value=='Enter your Email ID'){
			return ip.throwErr(frm.stremail,'Please Enter an Email-ID', 2);
		}
		if (frm.strmobile.value=='Enter your Mobile No'){
			return ip.throwErr(frm.strmobile,"Please enter a mobile number",2);
		}
		if(!IsMandatory(frm.stremail,"text","Please Enter an Email-ID",2)) return false;
		if(!ip.IsValidEmail(frm.stremail.value)) return ip.throwErr(frm.stremail,"Please enter a valid E-mail ID.",2);
		if(!IsMandatory(frm.strmobile,"text","Please enter a mobile number.",2)) return false;
		if(!IsValidCharacters(frm.strmobile.value, numbers , numbers)) return ip.throwErr(frm.strmobile,"Please use only numerals.",2);

		if( (String(frm.strmobile.value).substr(0,1)!="9")){
			if(String(frm.strmobile.value).substr(0,1)!="8")
				return ip.throwErr(frm.strmobile,"Your mobile number should start with digit '9 or 8'. Do not Prefix '+', '0'. ",2);}
		if(String(frm.strmobile.value).length!=10) return ip.throwErr(frm.strmobile,"Your mobile number should be 10 digits.",2);
		url = ip.host() + "/index.php?option=search&page=signupalert&notemplate=yes&transaction="+frm.transaction.value+"&property="+frm.home_prop.value+"&category="+frm.category.value+"&city="+frm.city.value+"&email="+frm.stremail.value+"&mobile="+frm.strmobile.value;
		$ip("divSignUpAlertResponse"+cnt).innerHTML = ip.loading("&nbsp;Loading... Please wait...");
		var ajax = new getHTTPObject();
		ajax.open("GET",url,true);
		ajax.onreadystatechange = function(){
			if(ajax.readyState==4){$ip("divSignUpAlertResponse"+cnt).innerHTML = '<div style="padding-left:20px; color:#006eb1;">'+ajax.responseText +'</div>';}
		}
		ajax.send(null);
		return false;
	}
	function multipleRefineValidate(frm){
		if(!IsMandatory(frm.fltrlocality,"select","Please select locality")) return false;
		return true;
	}
	/*Compare Properties*/
	function compare(){
		var minSelection = 2;
		var maxSelection = 4;
		var arrListingID="",listingCnt = 0, catFlag=true, chkAlt = new Array();
		var chkArr = checkSelected(1);
		for(var i=0; i<chkArr.length; i++){
			if(chkArr[i].checked){
				chkAlt.push(chkArr[i].alt);
				listingCnt++;
				arrListingID+=chkArr[i].value + "|";
			}
		}
		if(d.quicksearch.property.options[d.quicksearch.property.selectedIndex].value=="any"){
			if(isFindMismatch(chkAlt,chkAlt)) catFlag=false;
		}
		if(!catFlag && listingCnt>=minSelection) return ip.throwErr(null,"Please select properties that belong to the same category to Compare.",2);
		if(listingCnt<minSelection) return ip.throwErr(null,"Please select a min of "+ minSelection +" properties to Compare. You can select upto "+ maxSelection +" properties",2);
		if(listingCnt>maxSelection) return ip.throwErr(null,"You can select a max of "+ maxSelection + " properties to Compare",2);
		window.open("http://www.indiaproperty.com/index.php?option=listing&page=compare&listingid="+arrListingID);
	}
	function isFindMismatch(Array1,Array2){
		var checkedLen = Array1.length;
		var residentialArr = [ 'Apartment', 'Independent House/Villa', 'Builder Floor', 'Farm House','Serviced Apartment'];
		var commercialArr = ['Retail Showroom/Shop', 'Commercial Building', 'Office Complex', 'IT/ Software Technology Park', 'Industrial Estate'];
		var landArr = [ 'Residential Land', 'Commercial Land', 'Industrial Land','Agricultural Land','Farm House Land'];
		var tempArr = new Array();
		tempArr = subtractArray(residentialArr,Array1);
		if(tempArr.length>0 && checkedLen!=tempArr.length) return true;
		tempArr = subtractArray(commercialArr,Array1);
		if(tempArr.length>0 && checkedLen!=tempArr.length) return true;
		tempArr = subtractArray(landArr,Array1);
		if(tempArr.length>0 && checkedLen!=tempArr.length) return true;
		return false;
	}
	function subtractArray(Arr1,Arr2){
		var tempArray = Arr2;
		for (var i=0; i<Arr1.length; i++) {
			for (var j=0; j<tempArray.length; j++) {
				if(Arr1[i]==tempArray[j]){
					tempArray.splice(j,1);
					j--;
				}
			}
		}
		return tempArray;
	}
	/*End Compare Properties*/

	/*Refine Search */
	function addintoLocality(locality){
		var temp_array= new Array();
		var found=false;
		for(j=0;j<locality_array.length;j++){
			if(locality_array[j]!=locality){
				temp_array[temp_array.length]=locality_array[j];
			}else{
				if($ip('page_loc_chk_'+locality_array[j])){
					$ip('page_loc_chk_'+locality_array[j]).checked=false;
				}
				found=true;
			}
		}
		locality_array=temp_array;
		if(!found){
			if($ip('page_loc_chk_'+locality)){
				$ip('page_loc_chk_'+locality).checked=true;
			}
			locality_array[locality_array.length]=locality;
		}
		$ip('ref_locality').value=locality_array.join('|');
	}
	function addintoAge(age){
		var temp_array= new Array();
		var found=false;
		for(j=0;j<age_array.length;j++){
			if(age_array[j]!=age){
				temp_array[temp_array.length]=age_array[j];
			}else{
				if($ip('page_age_chk_'+age_array[j])){
					$ip('page_age_chk_'+age_array[j]).checked=false;
				}
				found=true;
			}
		}
		age_array=temp_array;
		if(!found){
			if($ip('page_age_chk_'+age)){
				$ip('page_age_chk_'+age).checked=true;
			}
			age_array[age_array.length]=age;
		}
		$ip('ref_age').value=age_array.join('|');
	}
	function addintoArea(area){
		var temp_array= new Array();
		var found=false;
		for(j=0;j<area_array.length;j++){
			if(area_array[j]!=area){
				temp_array[temp_array.length]=area_array[j];
			}else{
				if($ip('page_area_chk_'+area_array[j])){
					$ip('page_area_chk_'+area_array[j]).checked=false;
				}
				found=true;
			}
		}
		area_array=temp_array;
		if(!found){
			if($ip('page_area_chk_'+area)){
				$ip('page_area_chk_'+area).checked=true;
			}
			area_array[area_array.length]=area;
		}
		$ip('ref_area').value=area_array.join('|');
	}
	function addintoPrice(price){
		var temp_array= new Array();
		var found=false;
		for(j=0;j<price_array.length;j++){
			if(price_array[j]!=price){
				temp_array[temp_array.length]=price_array[j];
			}else{
				if($ip('page_price_chk_'+price_array[j])){
					$ip('page_price_chk_'+price_array[j]).checked=false;
				}
				found=true;
			}
		}
		price_array=temp_array;
		if(!found){
			if($ip('page_price_chk_'+price)){
				$ip('page_price_chk_'+price).checked=true;
			}
			price_array[price_array.length]=price;
		}
		$ip('ref_price').value=price_array.join('|');
	}
	function addintoBedroom(bedroom){
		var temp_array= new Array();
		var found=false;
		for(j=0;j<bedroom_array.length;j++){
			if(bedroom_array[j]!=bedroom){
				temp_array[temp_array.length]=bedroom_array[j];
			}else{
				if($ip('page_bed_chk_'+bedroom_array[j])){
					$ip('page_bed_chk_'+bedroom_array[j]).checked=false;
				}
				found=true;
			}
		}
		bedroom_array=temp_array;
		if(!found){
			if($ip('page_bed_chk_'+bedroom)){
				$ip('page_bed_chk_'+bedroom).checked=true;
			}
			bedroom_array[bedroom_array.length]=bedroom;
		}
		$ip('ref_bedrooms').value=bedroom_array.join('|');
	}
	function showvalues(){
		var localityarr=$ip('ref_locality').value;
		alert(localityarr);
	}
	function refinesubmit(frm){
		var ipCookie = new ip_cookie();
		if(glbDefaultVal==null) glbDefaultVal = frm.other_params.value;
		var refparams="";
		if(frm.other_params.value!="") refparams+=frm.other_params.value;
		if(frm.ref_locality.value!="") refparams+="&fltrlocality="+String(frm.ref_locality.value);
		if(frm.ref_age.value!="") refparams+="&fltrage="+frm.ref_age.value;
		if(frm.ref_bedrooms.value!="") refparams+="&fltrbedroom="+frm.ref_bedrooms.value;
		if(frm.ref_area.value!="") refparams+="&fltrarea="+frm.ref_area.value;
		if(frm.ref_price.value!="") refparams+="&fltrprice="+frm.ref_price.value;
		if(othersChkd) refparams+="&locothers=yes&locothersval="+String(locothersall);
		ipCookie.setCookie("fltrprice", frm.ref_price.value,"","","","/");
		loadSearchViewResults(refparams);
		/*//setRefineFilter("page=refinefilter&"+refparams);*/
	}
	function refineResults(frm){
		refinesubmit(frm);
	}
	function resetRefineResults(frm){
		var ipCookie = new ip_cookie();
		var e = d.reallyadummyform.elements;
		for(var i=0; i<e.length; i++){ if(e[i].type=="checkbox") e[i].checked=false;}
		e = $ip("refinedummyform").elements;
		for(var i=0; i<e.length; i++){
			if(e[i].type=="hidden"){
				if(e[i].name!="other_params") e[i].value="";
			}
		}
		locality_array=new Array();
		age_array=new Array();
		price_array=new Array();
		bedroom_array=new Array();
		area_array=new Array();
		var fltrPrice = (ip.isObject(d.quicksearch.fltrprice)) ? d.quicksearch.fltrprice.options[d.quicksearch.fltrprice.selectedIndex].value : "";
		//ipCookie.setCookie("fltrprice", "",1990,1,1);
		ipCookie.setCookie("fltrprice", ((fltrPrice=="any") ? "" : fltrPrice) ,"","","","/");
		if(glbDefaultVal==null) glbDefaultVal = frm.other_params.value + "&option=search&notemplate=yes";
		loadSearchViewResults("page=ajaxresultsjsn&"+glbDefaultVal);
		//setRefineFilter("page=refinefilter&"+glbDefaultVal);
	}
	function resetCheckBox(frm){
		var e= frm.elements;
		var callFunc=null;
		for (var i=0; i<e.length; i++){
			if(e[i].type=="checkbox" && e[i].checked){
				e[i].checked=false;
				if(!ie){/* for FireFox and other non IE browsers */
					callFunc = e[i].getAttribute("onchange");
					eval(callFunc);
				}else{
					callFunc = (e[i].onchange).toString();
					var tempStr = callFunc.substr( callFunc.indexOf("{") ,callFunc.length-1);
					tempStr=tempStr.replace("{","");
					tempStr=tempStr.replace("}","");
					tempStr=ip.Trim(tempStr);
					//callFunc();
					eval(tempStr);
				}
			}
		}
	}
	function setothers(obj,otherloc){
		if(obj.checked==true){
			othersChkd=true;
			locothersall=otherloc;
		}else{
			othersChkd=false;
			locothersall="";
		}
	}
	function delvalE(obj, val){
		if (val=="Enter your Email ID")
		{
			obj.value="";
		}
	}
	function delvalM(obj, val){
		if (val=="Enter your Mobile No")
		{
			obj.value="";
		}
	}
	
	function retval(obj, val){
		if (obj.value=="")
		{
			obj.value=val;
		}
	}
	/*End Refine Search */