	var SMSForm = new Array();
	var C2CForm = new Array();
	var ipTrack = new ip_tracker();
	function contactForm(ListID,fromObj){
		navigateTabs(1,ListID, (!fromObj) ? 'basic' : 'sponsored');
		if(fromObj) $ip("HdivContact"+ListID).style.display = ""; else $ip("divContact"+ListID).style.display = "";
		showMailForm(ListID,fromObj);
	}
	function contactFormPL(ListID){
		navigateTabs(1,ListID,'basic');
		$ip("divContact"+ListID).style.display = "";
		showMailForm(ListID);
	}
	function contactFormAgent(UName){
		navigateTabs(1,UName,'basic');
		$ip("divContact"+UName).style.display = "";
		showMailForm(UName);
	}
	function contactFormBuilder(UName){
		navigateTabs(1,UName,'basic');
		$ip("divContact"+UName).style.display = "";
		showBuilderMailForm(UName);
	}
	/* Start Send Email*/
	function validateSendSMS(frm){
		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,"Special characters are not allowed. Please use only alphabets.",2);

		if(!IsMandatory(frm.strphone,"text","Please enter a mobile number.",2)) return false;
		if(!IsValidCharacters(frm.strphone.value, numbers , numbers)) return ip.throwErr(frm.strphone,"Please use only numerals.",2);
		if( String(frm.strphone.value).substr(0,1)!="9" || String(frm.strphone.value).substr(0,2)=="91") return ip.throwErr(frm.strphone,"Your mobile number should start with digit '9'. Do not Prefix '+', '0', '91'. ",2);
		if(String(frm.strphone.value).length!=10) return ip.throwErr(frm.strphone,"Your mobile number should be 10 digits.",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);
		SMSForm[frm.arrIndex.value].sendESMS(frm);
		return false;
	}
	function showSMSForm(ListID,fromObj){
		var index = SMSForm.length;
		SMSForm[index] = new sendSMS(ListID,fromObj);
		SMSForm[index].callAjax();
	}
	function sendSMS(ListID,fromObj){
		this.ListID = ListID;
		this.SMSStatus = null;
		this.ajax = null;
		this.sAjax = null;
		this.url  = "";
		this.popupURL = "/index.php?option=site&page=sendenquiry&notemplate=yes&listingid=";
		this.SMSformURL ="/index.php?option=search&page=ajaxsearchsms&notemplate=yes&listingid=";
		this.successMsg = "&nbsp;Your enquiry has been sent sucessfully.";
		this.errorMsg = "&nbsp;Unable to access this service currently, Please try again later.";
		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) ? "HdivSMS" : "divSMS") +ListID);
		this.errName ="";
		this.errEmail ="";
		this.errPhone ="";
		this.errMsg ="";
		this.errCountry ="";
		this.resultFrom =  (fromObj) ? "sponsored" : "basic";
	}
	sendSMS.prototype.callAjax = function(scErr){
		this.divObj = $ip( ((this.resultFrom=="sponsored") ? "HdivSMS" : "divSMS") +this.ListID);
		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,"sendSMS");return;}
		}
		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;
		}
		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() + this.SMSformURL +this.ListID+"&resultFrom="+this.resultFrom+"&arrIndex="+parseInt(SMSForm.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="&nbsp;Unable to access this service currently, Please try again later.";
					window.setTimeout(function(){
						closeThis(thisObj.ListID);
					},5000);
				}
				$ip( ((thisObj.resultFrom=='sponsored') ? "HdivSMS" : "divSMS") +thisObj.ListID).innerHTML = res;
				var frm = $ip( ((thisObj.resultFrom=='sponsored') ? "Hfrm_" : "frm_") +thisObj.ListID);
				thisObj.frm = frm;
				window.setTimeout(function(){
					try{
						frm.txteqmsg.focus();
						ip.changeCount(frm.txteqmsg,140, ((thisObj.resultFrom=='sponsored') ? 'HdivCount_' : 'divCount_') +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,"sendSMS");}
				},2000);
			}
		}
		this.sAjax.send(null);
	};
	sendSMS.prototype.sendESMS = function(frm){
		if(!this.divObj){return;}
		this.errName = frm.strname.value;
		this.errPhone = frm.strphone.value;
		this.errMsg=frm.txteqmsg.value;
		var charValue = (frm.charpage) ? frm.charpage.value : "";
		/*
		//agent/sendsms
		var f2L = String(this.ListID).substr(0,2);
		if(String(f2L).indexOf("IP")!=-1 || String(f2L).indexOf("PL")!=-1){
			var urlPage="/index.php?option=listing&page=sendsms";
		}else{
			var urlPage="/index.php?option=agent&page=sendsms";
		}*/
		var temp_params;
		if(frm.listingid.value==frm.username.value)
		{//in agent search both the fields has the same value 
			temp_params="&username="+frm.username.value;
		}
		else
		{
			temp_params="&username="+frm.username.value+"&listingid="+frm.listingid.value;
		}
		var urlPage="/enquiry/sendsmsenquiry.php?";
		this.url = ip.host() + urlPage + "&notemplate=yes&strname="+frm.strname.value +
			"&strphone="+frm.strphone.value+"&listingtype="+frm.listingtype.value+
			"&txteqmsg="+frm.txteqmsg.value+"&security_code="+frm.security_code.value+"&charpage="+charValue+temp_params;
		this.divObj.innerHTML = ip.loading("&nbsp;Sending SMS... 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 ){
					var res =thisObj.successMsg;
					ipTrack.ipSMS.trackSent();
				}
				else if( parseInt(thisObj.ajax.responseText) == 2 ){
					var res =thisObj.ver_errorMsg;
					thisObj.mailStatus=null;
					thisObj.callAjax(1);
					return;
				}
				else {
					var res =thisObj.errorMsg;
				}
				/* divObj.innerHTML = '<div style="padding:5px 10px 0px; color:rgb(255,100,0);">' + res + '</div>'; */
				//res = '<table border="0"><tr class="rowSpecial"><td>'+ res +'</td></tr></table>';
				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 */

	function	sendMultipleEnq(scErr){
		var listingCnt = 0;
		if(!checkSelected()){return false;}
		var chkArr = checkSelected(1);
		var arrListingID="";
		for (var i=0; i<chkArr.length; i++) {if(chkArr[i].checked){listingCnt++;arrListingID+=chkArr[i].value + "|";}}
		if(listingCnt>10) listingCnt=10;
		var qry="";
		if(scErr){
			qry = "&scErr=1&strname="+errName+"&stremail="+errEmail+"&strphone="+errPhone+"&strmsg="+errMsg+"&strcountry="+errCountry;
		}
		var url = "/index.php?option=search&page=ajaxsearchenquiry_multiple&notemplate=yes&listingid=123456&arrIndex=1&arrListingID=" + arrListingID + qry;
		ip.startLB(null,"",225 + (listingCnt*15),"aJax",null,url,"$ip('frm_multipleEnq').strname");
		return false;
	};
	function hide_multipleEnq(){
		$ip("divPageLayer").style.display = "none";
		$ip("divMultipleEnq").style.display = "none";
		lb.exit();
	}
	function convertEnqToRegSearch(urltoenq){
		httpEnq = new getHTTPObject();
		if (httpEnq){
			//$ip("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);
		}
	}
	function sendMultipleEnq_SendMail(frm){
		successMsg = "&nbsp;Your enquiry has been sent sucessfully.";
		errorMsg = "&nbsp;Unable to access this service currently, Please try again later.";
		ver_errorMsg = "Your code is wrong, Re-enter the verification code.";
		if(!frm) return;
		var divObj=$ip("div_multipleEnqSendMail");
		if(typeof frm.strcountry == "object"){
			var strcountry =frm.strcountry.options[frm.strcountry.selectedIndex].value;
		}else{var strcountry="";}
		/*url = ip.host() + "/index.php?option=search&page=ajaxenquirymail&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;*/
		url = ip.host() + "/enquiry/sendmultipleemailenquiry.php?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;
		divObj.innerHTML = ip.loading("&nbsp;Sending mail enquiry... Please wait...");
		mailStatus=0;
		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);
		var thisObj = this;
		var ajax = new getHTTPObject();
		ajax.open("GET",url,true);
		ajax.onreadystatechange = function(){
			if(ajax.readyState==4){
				if( parseInt(ajax.responseText) == 1 ){
					var res = successMsg;
				}else if( parseInt(ajax.responseText) == 2 ){
					var res ="";
					mailStatus=null;
					callAjax(1);
					return;
				}else if( parseInt(ajax.responseText) == 3 ){
					var res ="The given text seems to be a spam text.";
					return;
				}
				else {
					var res =errorMsg;
				}
				/* divObj.innerHTML = '<div style="padding:5px 10px 0px; color:rgb(255,100,0);">' + res + '</div>'; */
				//res = '<table border="0"><tr class="rowSpecial"><td>'+ res +'</td></tr></table>';
				divObj.innerHTML = "<b>" + res + "</b>";
				mailStatus=1;
				/*window.setTimeout(function(){
					closeThis(ListID);
					mailStatus=null;
				},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);
			*/
		}
		ajax.send(null);
	}
	function navigateTabs(Opt,ListID,resultFrom){
		if(resultFrom=="basic"){
			if(!$ip( "divEmail"+ListID) || !ListID) return;/* if not already opend then no need to continue*/
			var divArr = [ $ip("divEmail"+ListID), $ip("divC2C"+ListID), $ip("divSMS"+ListID) ];
		}else{
			if(!$ip( "HdivEmail"+ListID) || !ListID) return;
			var divArr = [ $ip("HdivEmail"+ListID), $ip("HdivC2C"+ListID), $ip("HdivSMS"+ListID) ];
		}
		/*
		switch(Opt){
			case "2":

				break;
			case "3":
				break;
			default:

				break;
		}*/
		for (var i=0; i<divArr.length; i++){
			divArr[i].style.display ="none";
		}
		try{divArr[Opt-1].style.display = "";}catch(e){traceErr(e,"navTab");}
		var tabs = $ip( ((resultFrom=="sponsored") ? "HdivContact" : "divContact") +ListID).getElementsByTagName("li");
		for (var i=0; i<tabs.length; i++) {tabs[i].className = "inactive";}
		try{
			if(Opt==3 && String(divArr[1].innerHTML).length<15 && tabs.length==2){
				tabs[1].className = "active";
			}else{
				tabs[Opt-1].className = "active";
			}
		}catch(e){traceErr(e);}
	}
	function getZoom(ID,fromObj){
		var actionState = String(fromObj.src).indexOf("zoom.gif");
		fromObj.src =  (actionState!=-1) ? "http://imgs.indiaproperty.com/icons/zoomout.gif" : "http://imgs.indiaproperty.com/icons/zoom.gif";
		if($ip("divPhotoZoomer"+ID) == null){
			var imgObj = $ip("photo_"+ID);
			var imgSrc = imgObj.src;
			var imgNewSrc = imgSrc.replace("/tmp_","/med_");
			StartPreLoader(imgNewSrc);
			//var objBody = d.getElementsByTagName("body").item(0);
			if($ip("SearchResultsLoad") != null){
				var toAppObj=$ip("SearchResultsLoad");
			}else{
				var toAppObj=d.getElementsByTagName("body").item(0);
			}
			var doc = d.createElement("div");//+ ip.randomN()
			doc.setAttribute("id","divPhotoZoomer"+ID);
			doc.onclick = function(){
				doc.style.display='none';
				fromObj.src ="http://imgs.indiaproperty.com/icons/zoom.gif";
				return false;
			}
			doc.className="imgBorder";
			with(doc.style){
				position = "absolute";
				padding = "1px";
				background = "#fff url('http://imgs.indiaproperty.com/loading.gif') no-repeat 50% 50%";
				left = ((ip.getPos(imgObj).x + 76) - 204) + "px";
				top = ((ip.getPos(imgObj).y + 76) - 141) + "px";
				width = "203px";
				height= "140px";
				zIndex = "999";
			}
			//background:url(\'' + imgNewSrc + '\') no-repeat 0 0;
			doc.innerHTML = '<div style="text-align:right; position:relative;"><img src="'+imgNewSrc+'" width="203" height="140" alt="" style="background:url(\'http://imgs.indiaproperty.com/buttons/closex.gif\') no-repeat 0 0;" /></div>';
			//<img src="http://imgs.indiaproperty.com/trans.gif" width="1" height="125" alt=""/><br />
			//objBody.appendChild(doc);
			toAppObj.appendChild(doc);
			return false;
		}
		$ip("divPhotoZoomer"+ID).style.display=  (actionState!=-1) ? "" : "none";
	}

	function createLB(){
		lb.init();
	}
	function closeThis(ListID,resultFrom){
		try {
			$ip( ( (resultFrom=="basic") ? "divContact" : "HdivContact") +ListID).style.display="none";
		} catch(e) {
			$ip("divContact"+ListID).style.display="none";
		}
	}

	function traceErr(e,func){ip.traceErr(e,func,"ip_emailsmsc2c.js");}

	function callMailForm(divID,ListID,scErr){
		var isTop = (divID.indexOf("top")==-1) ? 0 : 1;
		navTabs(divID,ListID,isTop);
		var divObj = $ip(divID);
		if(divObj.innerHTML!=""){
			divObj.style.display ="";
			return false;
		}
		/*if(this.divObj.style.display!="none" && !scErr){	 //If Already Opend
			try{
				this.frm.focus();
				if(this.frm.strname.value=="")this.frm.strname.focus(); else this.frm.txteqmsg.focus();
				return;
			}catch(e){traceErr(e,"sendMail");return;}
		}*/
		var sAjax = new getHTTPObject();
		if(!divObj || !sAjax){/*If Ajax not loaded then the Popup Window will open*/
			return;
		}
		divObj.style.display="";
		divObj.innerHTML = ip.loading("Loading enquiry form... Please wait...");
		var qry="";
		if(scErr){
			qry = "&scErr=1&strname="+this.errName+"&stremail="+this.errEmail+"&strphone="+this.errPhone+"&strmsg="+this.errMsg+"&strcountry="+this.errCountry;
		}
		var pageName = (ListID.indexOf("PL")!=-1) ? "option=upcoming&page=mailform_listing" : "option=listing&page=mailform";
		this.url = ip.host() + "/index.php?" + pageName + "&notemplate=yes&listingid="+ListID+"&fromobject="+divID+"&arrIndex=0"+qry;
		sAjax.open("GET",url,true);
		sAjax.onreadystatechange = function(){
			if(sAjax.readyState==4){
				var res = sAjax.responseText;
				if(res==""){
					res="&nbsp;Unable to access this service currently, Please try again later.";
					window.setTimeout(function(){
						closeThis(divID);
					},5000);
				}
				divObj.innerHTML = res;
				var frm = $ip("frmenq_"+ListID);
				window.setTimeout(function(){
					try{
						if(typeof frm.strcountry == "object"){
							/*$ip("TD_STRMSG_"+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,'divCount_'+ListID);*/
						if(frm.strname.value=="") frm.strname.focus(); else if(frm.txteqmsg.value=="") frm.txteqmsg.focus(); else frm.security_code.focus();
						sAjax.abort();
					}catch(e){traceErr(e,"sendMail");}
				},2000);
			}
		}
		sAjax.send(null);
	}
	function convertEnqToRegister(urltoenq){

		httpEnq = new getHTTPObject();
		//alert(httpEnq);
		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);
		}
	}
	function ListingsendMail(frm){
		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);
		var divObj = $ip(frm.fromObject.value);
		if(typeof frm.strcountry == "object"){
			var strcountry =frm.strcountry.options[frm.strcountry.selectedIndex].value;
			this.errCountry=strcountry;
		}else{var strcountry="";}
		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;
		convertEnqToRegister(urltoenq);
		//var url ="/index.php?option=search&page=ajaxenquirymail&notemplate=yes";
		var url ="/enquiry/sendemailenquiry.php?";
		this.url = ip.host() + url + "&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);
		divObj.innerHTML = ip.loading("&nbsp;Sending mail enquiry... Please wait...");
		mailStatus=0;
		ajax = new getHTTPObject();
		ajax.open("GET",this.url,true);
		ajax.onreadystatechange = function(){
			if(ajax.readyState==4){
				/*res = (ajax.responseText==1) ? successMsg : errorMsg;*/
				if( parseInt(ajax.responseText) == 1 ){
					var res = "Your enquiry has been sent successfully.";
					ipTrack.ipMail.trackSent();
				}else if( parseInt(ajax.responseText) == 2 ){
					var res ="Your code is wrong. Please try again.";
					mailStatus=null;
					callMailForm(divObj.id,frm.listingID.value,1);
					return;
				}
				else if( parseInt(ajax.responseText) == 3 ){
					var res ="The given text seems to be a spam text.";
					return;
				}
				else {
					var res ="Unable to access this service currently, Please try again later.";
				}
				/* divObj.innerHTML = '<div style="padding:5px 10px 0px; color:rgb(255,100,0);">' + res + '</div>'; */
				//res = '<table border="0"><tr class="rowSpecial"><td>'+ res +'</td></tr></table>';
				divObj.innerHTML = "<b>" + res + "</b>";
				mailStatus=1;
				/*window.setTimeout(function(){
					closeThis(ListID);
				},10000);
				*/
			}
		}
		ajax.send(null);
		return false;
	}
	function closeListingAjx(ID){
		$ip(ID).style.display="none";
		$ip(ID).innerHTML = "";
		var botCurve = ( ID.indexOf("top")!=-1 ) ? "top_"+ ID.substr((ID.length)-8,ID.length)+"_bc" : "bot_"+ID.substr((ID.length)-8,ID.length)+"_bc";
		navBetweenTabs(null, (( ID.indexOf("top")!=-1 ) ? 1 : 0));
		$ip(botCurve).style.display = "none";
	}
	function callSMSForm(divID,ListID,scErr){
		var isTop = (divID.indexOf("top")==-1) ? 0 : 1;
		navTabs(divID,ListID,isTop);
		divObj = $ip(divID);
		if(divObj.innerHTML!=""){
			divObj.style.display ="";
			return false;
		}
		sAjax = new getHTTPObject();
		if(!divObj || !sAjax){/*If Ajax not loaded then the Popup Window will open*/
			url = ip.host() + popupURL + ListID;
			ip.OpenPopUp(url,100,100,500,400);
			return;
		}
		divObj.style.display="";
		var thisObj = this;
		divObj.innerHTML = ip.loadingStr;
		var qry="";
		if(scErr){
			qry = "&scErr=1&strname="+errName+"&stremail="+errEmail+"&strphone="+errPhone+"&strmsg="+errMsg+"&strcountry="+errCountry;
		}
		url = ip.host() + "/index.php?option=listing&page=smsform&notemplate=yes&listingid=" +ListID+"&arrIndex=0&fromobject="+divID+qry;
		sAjax.open("GET",url,true);
		sAjax.onreadystatechange = function(){
			if(sAjax.readyState==4){
				var res = sAjax.responseText;
				if(res==""){
					res="&nbsp;Unable to access this service currently, Please try again later.";
					window.setTimeout(function(){
						closeThis(ListID);
					},5000);
				}
				divObj.innerHTML = res;
				var frm = $ip("frm_"+ListID);
				window.setTimeout(function(){
					try{
						frm.txteqmsg.focus();
						ip.changeCount(frm.txteqmsg,140,'divCount_'+ListID);
						if(frm.strname.value=="") frm.strname.focus(); else if(frm.txteqmsg.value=="") frm.txteqmsg.focus(); else frm.security_code.focus();
						sAjax.abort();
					}catch(e){traceErr(e,"sendSMS");}
				},2000);
			}
		}
		sAjax.send(null);
	};
	function ListingSendSMS(frm){
		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,"Special characters are not allowed in name field.",2);
		if(!IsMandatory(frm.strphone,"text","Please enter a mobile number.",2)) return false;
		if(!IsValidCharacters(frm.strphone.value, numbers , numbers)) return ip.throwErr(frm.strphone,"Please use only numerals.",2);
		if( String(frm.strphone.value).substr(0,1)!="9" || String(frm.strphone.value).substr(0,2)=="91") return ip.throwErr(frm.strphone,"Your mobile number should start with digit '9'. Do not Prefix '+', '0', '91'. ",2);
		if(String(frm.strphone.value).length!=10) return ip.throwErr(frm.strphone,"Your mobile number should be 10 digits.",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 + " ,.?/;:'!@#$%*()-_+=|\[]{}",numbers + alphabets)) return ip.throwErr(frm.txteqmsg,"Special characters are not allowed.",2);
		//var urlPage="/index.php?option=listing&page=sendsms";
		var urlPage="/enquiry/sendsmsenquiry.php?";
		var charValue = (frm.charpage) ? frm.charpage.value : "";
		url = ip.host() + urlPage + "&notemplate=yes&username="+frm.username.value+"&strname="+frm.strname.value +
			"&strphone="+frm.strphone.value+"&listingtype="+frm.listingtype.value+
			"&listingid="+frm.listingid.value+"&txteqmsg="+frm.txteqmsg.value+"&security_code="+frm.security_code.value+"&charpage="+charValue;
		divObj.innerHTML = ip.loading("&nbsp;Sending SMS... Please wait...");
		mailStatus=0;
		ajax = new getHTTPObject();
		ajax.open("GET",url,true);
		ajax.onreadystatechange = function(){
			if(ajax.readyState==4){
				/*res = (ajax.responseText==1) ? successMsg : errorMsg;*/
				if( parseInt(ajax.responseText) == 1 ){
					var res ="Your enquiry has been sent successfully.";
					ipTrack.ipSMS.trackSent();
				}
				else if( parseInt(ajax.responseText) == 2 ){
					var res ="Your code is wrong.";
					mailStatus=null;
					callSMSForm(frm.fromObject.value,frm.listingid.value,1);
					return;
				}
				else {
					var res ="Unable to access this service currently, Please try again later.";
				}
				/* divObj.innerHTML = '<div style="padding:5px 10px 0px; color:rgb(255,100,0);">' + res + '</div>'; */
				//res = '<table border="0"><tr class="rowSpecial"><td>'+ res +'</td></tr></table>';
				divObj.innerHTML = "<b>"+ res + "</b>";
				mailStatus=1;
				/*
				window.setTimeout(function(){
					closeThis(ListID);
				},10000);*/
			}
		}
		ajax.send(null);
	};

	function navTabs(divID,ListID,isTop){
		if(isTop==1){
			var arr = ["email_top_"+ListID,"sms_top_"+ListID,"c2c_top_"+ListID];
		}else {
			var arr = ["email_bot_"+ListID,"sms_bot_"+ListID,"c2c_bot_"+ListID];
		}
		for (var i=0; i<arr.length; i++) {
			try{$ip(arr[i]).style.display ="none";}catch(e){ip.traceErr(e,"navTabs","ip_emailsmsc2c");}
		}
		try{
			$ip(divID).style.display = "";
			var botCurve = (isTop) ? "top_"+ListID+"_bc" : "bot_"+ListID+"_bc";
			$ip(botCurve).style.display = "";
		}catch(e){ip.traceErr(e,"navTabs","ip_emailsmsc2c");}
	}
	function navBetweenTabs(fromE,isTop){
		var arr =(isTop==1) ? ["href_email_top","href_sms_top","href_c2c_top"] : ["href_email_bot","href_sms_bot","href_c2c_bot"];
		for (var i=0; i<arr.length; i++){
			try{
				if(arr[i]==fromE){
					$ip(fromE).className="active";
				}else{
					$ip(arr[i]).className="inactive";
				}
			}catch(e){ip.traceErr(e,"navTabs","ip_emailsmsc2c");}
		}
	}

	function sendUpcomingEnq(frm){
		if(!validateEnqForm(frm)) return false;
		sc = frm.security_code.value;
		try{var alertme = (frm.stralertme.checked) ? 1 : 0;}catch(e){var alertme=0;}
		try{country  = frm.strcountry.options[frm.strcountry.selectedIndex].value;}catch(e){country="";}
		url = "strname="+frm.strname.value+"&stremail="+frm.stremail.value+"&strphone="+frm.strphone.value+"&listingid="+frm.listingid.value+"&id="+frm.listingid.value+"&strcountry="+country+"&txteqmsg="+frm.txteqmsg.value+"&alertme="+alertme+"&security_code="+sc;

		var urltoget = ip.host() + "/enquiry/sendemailenquiry.php?"+url;
		ip.print("NEW EMAIL SEND URL = " + urltoget);

		urltoenq = ip.host() + "/index.php?option=listing&page=enqtoregister&notemplate=yes&WT.si_n=SENDENQUIRY&WT.si_p=completed&WT.si_sc=1&"+url;
		convertEnqToRegister(urltoenq);
		var httpNew = new getHTTPObject();
		if (httpNew){
			$ip("mailenquiry").innerHTML = ip.loading("Sending mail enquiry...");
			httpNew.open("GET", urltoget, true);
			httpNew.onreadystatechange = function(){
				if (httpNew.readyState == 4){
					if( parseInt(httpNew.responseText) == 1 ){
						res = "Your enquiry has been sent successfully.";
						mailStatus=1;
						ipTrack.ipMail.trackSent();
					}else if( parseInt(httpNew.responseText) == 2 ){
						mailStatus=0;
						ipSM.showMailForm(1);
						return;
					}else if( parseInt(httpNew.responseText) == 3 ){
						mailStatus=0;
						res ="spam err";
						//ipSM.showMailForm(1);
					}else {
						res = "Unable to access this service currently, Please try again later.";
						mailStatus=0;
					}
					$ip("mailenquiry").innerHTML = '<div style="padding:0px 10px 10px;"><div style="background:url(\'http://imgs.indiaproperty.com/dots/dot_999999.gif\') repeat-x bottom; padding:10px 0px 5px 0px;"><h2 style="font-size:11px;">Send Email Enquiry</h2></div>' + res +'</div>';
				}
			};
			httpNew.send(null);
		}
		return false;
	}