	var agentMailArr = new Array();
	var ipTrack = new ip_tracker();
	function showMailForm(userName){
		var index = agentMailArr.length;
		agentMailArr[index] = new ip_agent();
		agentMailArr[index].userName = userName;
		agentMailArr[index].contactAgentForm(userName);
	}
	function validateForm(frm){
		var index = frm.arrIndex.value;
		if(agentMailArr[index].validateForm(frm)) return false;
		return false;
	}
	function showAgentResults(frm,alphabet,offset){
		var strCity= frm.city.options[frm.city.selectedIndex].value;
		localteAgent.showResults(strCity,alphabet,offset);
	}
	function showAgentResultsLimit(frm,alphabet,offset,limit){
		var strCity= frm.city.options[frm.city.selectedIndex].value;
		localteAgent.showResultsLimit(strCity,alphabet,offset,limit);
	}
	function changeRHS(city){
		var cityname = d.locateagent.city.options[d.locateagent.city.selectedIndex].text;
		cityname = cityname.replace(/All/,"");
		cityname = cityname.replace("(","");
		cityname = cityname.replace(")","");
		cityname = cityname.replace(/ /g,"");
		/*cityname = cityname + "Agent160x450";*/
		var newurl="";
		newurl = ip.host() + "/index.php?option=site&page=ip_ads&addpage=locateagent_rhs&notemplate=yes&cityname="+cityname;
		$ip("locateAgentIFrame").src = newurl;
		changeFA(city);
		newurl = ip.host() + "/index.php?option=site&page=ip_ads&addpage=locateagent_top&notemplate=yes&cityname="+cityname;
		var src = '<iframe src="http://www.indiaproperty.com/index.php?option=site&page=ip_ads&addpage=locateagent_top&notemplate=yes&cityname='+cityname+'" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" allowTransparency="true" width="468" height="60"></iframe>';
		$ip("div_ip_topbanner").innerHTML = src;
	}
	function changeFA(city){
		var cityVal = d.locateagent.city.options[d.locateagent.city.selectedIndex].value;
		var ajax = new getHTTPObject();
		url=ip.host() + "/index.php?option=agent&page=locateagent&city="+cityVal+"&notemplate=yes&FA=1";
		//alert(url);return false;
		ajax.open("GET",url,true);
		ajax.onreadystatechange = function(){
			if(ajax.readyState==4){
				$ip("Div_featuredAgents").innerHTML = ajax.responseText;
			}
		};
		ajax.send(null);
	}
	function ip_agent(){
		this.mailAjax = null;
		this.mailStatus = null;
		this.successStr = "Your message has been sent ";
		this.errorStr = "Unable to access this service currently, Please try again later.";
		this.ver_errorStr = "Your code is wrong, Re-enter the verification code.";
		try{this.currentHTML = $ip("div_agentMailForm").innerHTML;}catch(e){}
		//this.agentmailURL = ip.host() + "/index.php?option=agent&page=agentemailsend&notemplate=yes";
		this.agentmailURL = ip.host() + "/enquiry/sendemailenquiry.php?";
		this.agentinfoForm = ip.host() + "/index.php?option=agent&page=agentinfo_form&notemplate=yes";
		this.agentresultURL = ip.host() + "/index.php?option=agent&page=locateagent_results&notemplate=yes";
		this.agentmailFormURL = ip.host() + "/index.php?option=agent&page=contactagentform&notemplate=yes";
		this.agentName = "";
		this.userName = "";
		this.agentID = "";
		this.pageFrom="";
		this.errName ="";
		this.errEmail ="";
		this.errPhone ="";
		this.errMsg ="";
		this.rowID = "";
	}
	ip_agent.prototype.validateForm = function(frm){
		if(!frm){return false;}
		if(!IsMandatory(frm.strname,"text","Please enter a name.",2)) return false;
		if(IsMin(frm.strname.value,4)) return ip.throwErr(frm.strname,"Name must contain a minimum of 4 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(this.pageFrom=="results") this.searchSendMail(frm); else this.sendMail(frm);
		return false;
	};
	/*Agent Profile Page -Send Mail*/
	ip_agent.prototype.sendMail = function(frm){
		var thisObj = this;
		this.mailAjax = new getHTTPObject();
		if(!this.mailAjax)return;
		this.errName = frm.strname.value;
		this.errEmail =frm.stremail.value;
		this.errPhone = frm.strphone.value;
		this.errMsg=frm.txteqmsg.value;
		this.agentID = frm.agentid.value;
		this.userName = frm.username.value;
		this.agentName = frm.agentname.value;
		var strcountry = ( ip.isObject(frm.strcountry)) ? frm.strcountry.options[frm.strcountry.selectedIndex].value : "India";
		var params = "&rowID="+frm.username.value+"&strname="+frm.strname.value +
			"&stremail="+frm.stremail.value +
			"&strphone="+frm.strphone.value +
			"&strcountry="+strcountry+
			"&userid="+frm.agentid.value+
			"&agentname="+frm.agentname.value+
			"&txteqmsg="+frm.txteqmsg.value +
			"&security_code="+frm.security_code.value;
		//"&agentid="+frm.agentid.value+
		this.agentName = frm.agentname.value;
		this.url = this.agentmailURL + params;
		enqurl = ip.host() + "/index.php?option=listing&page=enqtoregister&notemplate=yes" +params;
		var formHTML = $ip("div_agentMailForm").innerHTML;
		/* Enquiry Registration */
		this.convertEnqAgentToRegister(enqurl);
		this.mailAjax.open("GET",this.url,true);
		this.mailAjax.onreadystatechange = function(){
			$ip("div_agentMailForm").innerHTML = ip.loading("Sending mail... Please wait...");
			if(thisObj.mailAjax.readyState==4){
				if( parseInt(thisObj.mailAjax.responseText) == 1 ){
					var res =thisObj.successStr + " successfully";
					ipTrack.ipMail.trackSent();
				}else if( parseInt(thisObj.mailAjax.responseText) == 2 ){
					var res =thisObj.ver_errorStr;
					thisObj.mailStatus=null;
					thisObj.mailAjax.abort();
					thisObj.showAgentInfoForm(1);
					return;
				}else{
					var res =thisObj.errorStr;
				}
				$ip("div_agentMailForm").innerHTML = res;
				thisObj.mailStatus=1;
			}
		};
		this.mailAjax.send(null);
	};
	ip_agent.prototype.convertEnqAgentToRegister = function (urltoenq){
		httpEnq = new getHTTPObject();
		if (httpEnq){
			//document.getElementById("mailenquiry").innerHTML = getMessage(0,"Click to Email");
			httpEnq.open("GET", urltoenq, true);
			httpEnq.onreadystatechange = function(){
				//alert(httpEnq.readyState);
				if (httpEnq.readyState == 4){
					//alert(httpEnq.responseText);return false;
					if( httpEnq.responseText != 0){
						$ip("iframeLoginWrapper").src= ip.host()+"/login_wrapper.php";
						//$ip("div_ip_username").innerHTML ='<font class="bText">Welcome '+httpEnq.responseText+' !</font>&nbsp;|&nbsp;<a href="index.php?option=member&amp;page=mypropertyhome">My Properties</a>&nbsp;| <a href="index.php?option=logout" class="Arw" title="Logout from IndiaProperty">Logout</a>';

					}
				}
			};
			httpEnq.send(null);
		}
	}
	ip_agent.prototype.showAgentInfoForm = function(scErr){
		var divObj = $ip("div_agentMailForm");
		this.pageFrom = "agentinfo";
		var thisObj = this;
		this.mailAjax = new getHTTPObject();
		if(!this.mailAjax)return;
		var qry="";
		if(scErr){
			qry = "&scErr=1&agentid="+this.agentID+"&strcompanyname="+this.agentName+"&strname="+this.errName+"&stremail="+this.errEmail+"&strphone="+this.errPhone+"&strmsg="+this.errMsg;
		}
		this.url = this.agentinfoForm + "&username="+this.userName+qry;
		this.mailAjax.open("GET",this.url,true);
		this.mailAjax.onreadystatechange = function(){
			divObj.style.display="";
			divObj.innerHTML = ip.loading("Loading mail Form... Please wait...");
			if(thisObj.mailAjax.readyState==4){
				var res = thisObj.mailAjax.responseText;
				divObj.innerHTML = res;
				thisObj.mailStatus=0;
				window.setTimeout(function(){
					try{
						var frm = d.frmAgent;
						frm.security_code.focus();
						ip.changeCount(d.frmAgent.txteqmsg,140,"divCount");
					}catch(e){}
				},2000);
			}
		};
		this.mailAjax.send(null);
	};
	/*Agent Search*/
	ip_agent.prototype.contactAgentForm = function(userName,scErr){
		/*if(this.mailStatus){return;}*/
		/*if($ip(rowID).style.display!="none"  && !scErr){
			var frm = eval("d.frmAgent_"+this.rowID);
			try{frm.strname.focus();}catch(e){}
			return;
		}*/
		this.pageFrom = "results";
		var thisObj = this;
		divObj =  $ip("divEmail"+thisObj.userName);
		if(!scErr && String(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,"sendSMS");return;}
		}
		this.mailAjax = new getHTTPObject();
		if(!this.mailAjax)return;
		var qry="";
		if(scErr){
			qry = "&scErr=1&strname="+this.errName+"&stremail="+this.errEmail+"&strphone="+this.errPhone+"&strmsg="+this.errMsg;
		}
		this.url = this.agentmailFormURL + "&username="+userName+"&arrIndex="+ parseInt(agentMailArr.length - 1) + qry;
		this.mailAjax.open("GET",this.url,true);
		this.mailAjax.onreadystatechange = function(){
			divObj.style.display="";
			divObj.innerHTML = ip.loading("Loading mail Form... Please wait...");
			if(thisObj.mailAjax.readyState==4){
				var res = thisObj.mailAjax.responseText;
				divObj.innerHTML = res;
				thisObj.mailStatus=0;
				window.setTimeout(function(){
					try{
						var frm = eval("d.frmAgent_"+thisObj.userName);
						frm.strname.focus();
						ip.changeCount(frm.txteqmsg,140,"divCount"+thisObj.userName)
					}catch(e){}
				},2000);
			}
		};
		this.mailAjax.send(null);
	};
	ip_agent.prototype.searchSendMail = function(frm){
		var thisObj = this;
		this.mailAjax = new getHTTPObject();
		if(!this.mailAjax)return;
		this.errName = frm.strname.value;
		this.errEmail =frm.stremail.value;
		this.errPhone = frm.strphone.value;
		this.errMsg=frm.txteqmsg.value;
		var strname = frm.strname.value;
		var strcountry = frm.strcountry.options[frm.strcountry.selectedIndex].value;
		var stremail = frm.stremail.value;
		var strphone=frm.strphone.value;
		var agentid=frm.agentid.value;
		var agentname=frm.agentname.value;
		var txteqmsg=frm.txteqmsg.value;
		var security_code=frm.security_code.value;
		var params = "&rowID="+this.rowID+"&strname="+strname+
			"&strcountry="+strcountry+
			"&stremail="+stremail+
			"&strphone="+strphone+
			"&userid="+agentid+
			"&agentname="+agentname+
			"&txteqmsg="+txteqmsg+
			"&security_code="+security_code;
		//			"&agentid="+frm.agentid.value+
		this.url = this.agentmailURL + params;
		this.agentName = agentname;
		/* Enquiry Registration */
		enqurl = ip.host() + "/index.php?option=listing&page=enqtoregister&notemplate=yes" + params;
		//&rowID=" + this.rowID + "&strname=" + strname+ "&stremail=" + stremail + "&strphone="+strphone.value +	"&agentid="+frm.agentid.value + "&agentname=" + frm.agentname.value + "&txteqmsg=" + frm.txteqmsg.value + "&security_code=" + frm.security_code.value;
		this.convertEnqAgentToRegister(enqurl);
		/* End Enquiry Registration */
		//ip.print(url);
		this.mailAjax.open("GET",this.url,true);
		var divObj = $ip("divEmail"+this.userName);
		this.mailAjax.onreadystatechange = function(){
			divObj.innerHTML = ip.loading("Sending mail... Please wait");
			if(thisObj.mailAjax.readyState==4){
				if( parseInt(thisObj.mailAjax.responseText) == 1 ){
					var res =thisObj.successStr + " successfully";
					ipTrack.ipMail.trackSent();
				}else if( parseInt(thisObj.mailAjax.responseText) == 2 ){
					var res =thisObj.ver_errorStr;
					thisObj.mailStatus=null;
					thisObj.contactAgentForm("divEmail"+thisObj.userName,1);
					return;
				}else{
					var res =thisObj.errorStr;
				}
				divObj.innerHTML = "<b>" + res + "</b>";
				thisObj.mailStatus=1;
				/*window.setTimeout(function(){
					closeThis(thisObj.userName);
					thisObj.mailStatus=null;
				},5000);*/
			}
		};
		this.mailAjax.send(null);
		return false;
	};
	ip_agent.prototype.showResults = function(city,alphabet,offset){
		this.mailAjax = new getHTTPObject();
		this.url = this.agentresultURL + "&city="+city;
		//alert(this.url);
		if( (typeof alphabet !="undefined") && alphabet!=""){this.url = this.url + "&char="+String(alphabet);}
		if(typeof offset !="undefined" && offset!=""){this.url = this.url + "&offset="+offset;}
		var ipCookie = new ip_cookie();
		ipCookie.setCookie("agent_city",city);
		$ip("Div_locateAgent").innerHTML = ip.loading("Loading contents... Please wait...");
		$ip("Div_featuredAgents").innerHTML = ip.loading("Loading contents... Please wait...");
		/*$ip("Div_locateAgent").style.color = "rgb(255,100,0)";*/
		/*$ip("ipDiv").style.display = "";*/
		//alert(this.url);
		this.mailAjax.open("GET",this.url,true);
		thisObj = this;
		this.mailAjax.onreadystatechange = function(){
			if(thisObj.mailAjax.readyState==4){
				$ip("Div_locateAgent").innerHTML = thisObj.mailAjax.responseText;
				/*$ip("ipDiv").style.display = "none";*/
			}
		};
		this.mailAjax.send(null);
		changeRHS(city);
	};
	ip_agent.prototype.validateContactForm = function(frm){
		if(!frm){return false;}
		if(IsEmpty(frm.strname,"text") || frm.strname.value=="Name") return ip.throwErr(frm.strname,"Please enter a name.",2);
		if(IsMin(frm.strname.value,4)) return ip.throwErr(frm.strname,"Name must contain a minimum of 4 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(IsEmpty(frm.stremail,"text") || frm.stremail.value=="Email") return ip.throwErr(frm.stremail,"Please enter an e-mail ID.",2);
		if(!ip.IsValidEmail(frm.stremail.value)) return ip.throwErr(frm.stremail,"Please enter a valid e-mail ID.",2);
		if(IsEmpty(frm.strphone,"text") || frm.strphone.value=="Phone") return ip.throwErr(frm.strphone,"Please enter a Phone number.",2);
		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(IsEmpty(frm.txteqmsg,"textarea") || frm.txteqmsg.value=="Message") return ip.throwErr(frm.txteqmsg,"Please enter your message.",2);
		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, alphanumeric,alphabets + numbers)) return ip.throwErr(frm.txteqmsg,"Special characters are not allowed.",2);
		this.ContactSendMail(frm);
		return false;
	};
	ip_agent.prototype.ContactSendMail = function(frm){
		var thisObj = this;
		this.mailAjax = new getHTTPObject();
		if(!this.mailAjax)return;
		this.errName = frm.strname.value;
		this.errEmail =frm.stremail.value;
		this.errPhone = frm.strphone.value;
		this.errMsg=frm.txteqmsg.value;
		var strcountry = ( ip.isObject(frm.strcountry)) ? frm.strcountry.options[frm.strcountry.selectedIndex].value : "India";
		var params = "&rowID="+this.rowID+"&strname="+frm.strname.value +
			"&stremail="+frm.stremail.value +
			"&strphone="+frm.strphone.value +
			"&strcountry="+strcountry+
			"&userid="+frm.agentid.value+
			"&agentname="+frm.agentname.value+
			"&txteqmsg="+frm.txteqmsg.value+
			"&security_code="+frm.security_code.value;
					//"&agentid="+frm.agentid.value+
		this.agentName = frm.agentname.value;
		this.url = this.agentmailURL + params;
		ip.print("this.url  =" +this.url );
		urltoenq = ip.host() + "/index.php?option=listing&page=enqtoregister&notemplate=yes" + params;
		this.convertEnqAgentToRegister(urltoenq);
		this.mailAjax.open("GET",this.url,true);
		var divObj = $ip("divContactForm");
		divObj.style.display ="";
		this.mailAjax.onreadystatechange = function(){
			divObj.innerHTML = ip.loading("Sending email... Please wait");
			if(thisObj.mailAjax.readyState==4){
				if( parseInt(thisObj.mailAjax.responseText) == 1 ){
					var res =thisObj.successStr + " successfully";
					ipTrack.ipMail.trackSent();
				}else if( parseInt(thisObj.mailAjax.responseText) == 2 ){
					var res =thisObj.ver_errorStr;
					thisObj.mailStatus=null;
					/*thisObj.contactAgentForm(thisObj.userName);*/
					return;
				}else{
					var res =thisObj.errorStr;
				}
				divObj.innerHTML = res;
				thisObj.mailStatus=1;
				thisObj.mailStatus=null;
				/*window.setTimeout(function(){
					divObj.style.display ="none";
				},25000);
				*/
				/*
				window.setTimeout(function(){
					closeThis(thisObj.userName);
					thisObj.mailStatus=null;
				},5000);
				*/
			}
		};
		this.mailAjax.send(null);
		return false;
	};
	ip_agent.prototype.showResultsLimit = function(city,alphabet,offset,limit){
		this.mailAjax = new getHTTPObject();
		this.url = this.agentresultURL + "&city="+city;
		if( (typeof alphabet !="undefined") && alphabet!=""){this.url = this.url + "&char="+String(alphabet);}
		if(typeof offset !="undefined" && offset!=""){this.url = this.url + "&offset="+offset;}
		if(limit!='') this.url = this.url + "&limit="+limit;
		var ipCookie = new ip_cookie();
		ipCookie.setCookie("agent_city",city);
		$ip("Div_locateAgent").innerHTML = ip.loading("Loading contents... Please wait...");
		/*$ip("Div_locateAgent").style.color = "rgb(255,100,0)";*/
		/*$ip("ipDiv").style.display = "";*/
		//alert(this.url);return false;
		this.mailAjax.open("GET",this.url,true);
		thisObj = this;
		this.mailAjax.onreadystatechange = function(){
			if(thisObj.mailAjax.readyState==4){
				$ip("Div_locateAgent").innerHTML = thisObj.mailAjax.responseText;
				/*$ip("ipDiv").style.display = "none";*/
			}
		};
		this.mailAjax.send(null);
		changeRHS(city);
	};
	ip.startMouseDetect();
	/* 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 ="";
	}
	/*if(!ie){ if(d.captureEvents && Event.MOUSEMOVE) d.captureEvents(Event.MOUSEMOVE);}
	d.onmousemove = getMouseXY;*/
	var vCardTimer=null;