	//Form Validation
	//-- added the AJAX CODING FOR THE SEND MAIL ENQUIRY IN THE VIEW PAGE
	var httpNew = null;
	var ipSM = new ip_sendmail();
	var currentStr="";
	var mailStatus=null;
	var ipTrack = new ip_tracker();
	function validate_SendMail(frm){
		if(validateEnqForm(frm)) frm.submit();
	}
	function frmchk(frm){
		if(!frm) frm = d.frmenq;
		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.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,"Special characters are not allowed.",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 + " ,.?/;:'!@#$%*()-_+=|\[]{}",numbers + alphabets)) return ip.throwErr(frm.txteqmsg,"Special characters are not allowed.",2);
		return true;
	}
	function validateEnqForm(frm){
		if(!frm) frm = d.frmenq;
		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.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);
		try{if(!IsMandatory(frm.strcountry,"select","Please select a Country",2)) return false;}catch(e){}
		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,"Special characters are not allowed.",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 + " ,.?/;:'!@#$%*()-_+=|\[]{}",numbers + alphabets)) return ip.throwErr(frm.txteqmsg,"Special characters are not allowed.",2);
		return true;
	}
	function validateSMSForm(frm){
		if(!frm) frm = d.frmenq;
		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);
		return true;
	}
	function ajaxenquirySms(frm){
		try{
			currentStr = $ip("smsenquiry").innerHTML;
			if(!frm) frm = d.frmenq;
			if(validateSMSForm(frm)){
				ipSM.strname = frm.strname.value;
				ipSM.strphone = frm.strphone.value;
				ipSM.strmsg = frm.txteqmsg.value;
				///ipSM.username = frm.username.value;
				ipSM.username = 'SRG';
				ipSM.listingid = frm.listingid.value;
				ipSM.listingtype = frm.listingtype.value;
				///ipSM.date = frm.posteddate.value;
				ipSM.date = '';
				///ipSM.toemail  = frm.toemail.value;
				ipSM.toemail  = 'leogopal80@gmail.com';
				ipSM.divObj = $ip("smsenquiry");
				mailStatus=0;
				country="";
				name = frm.strname.value;
				phone = frm.strphone.value;
				msg = frm.txteqmsg.value;
				type = frm.listingtype.value;
				///username = frm.username.value;
				username = "SRG";
				listingid = frm.listingid.value;
				///date = frm.posteddate.value;
				date ='';
				///toemail  = frm.toemail.value;
				toemail  = 'leogopal80@gmail.com';
				sc = frm.security_code.value;
				url = "strname="+name+"&strphone="+phone+"&listingid="+listingid+"&txteqmsg="+msg+"&listingtype="+type+"&security_code="+sc;
				//var urltoget = ip.host() + "/index.php?option=listing&page=sendsms&notemplate=yes&WT.si_n=SENDENQUIRY&WT.si_p=completed&WT.si_sc=1&"+url;
				var urltoget = ip.host() + "/enquiry/sendsmsenquiry.php?"+url;
				httpNew = new getHTTPObject();
				if (httpNew){
					$ip("smsenquiry").innerHTML = getMessage(0,"Click to SMS");
					httpNew.open("GET", urltoget, true);
					httpNew.onreadystatechange = function(){
						if (httpNew.readyState == 4){
							if( parseInt(httpNew.responseText) == 1 ){
								$ip("smsenquiry").innerHTML = getMessage(1,"Click to SMS");
								mailStatus=1;
								ipTrack.ipSMS.trackSent();
							}else {
								$ip("smsenquiry").innerHTML = getMessage(0,"Click to SMS");
								mailStatus=0;
							}
						}
					};
					httpNew.send(null);
					/*After 3o sec, if result not coming then failure message will appear*/
					/*window.setInterval(function(){
							if(mailStatus==0){
								$ip("mailenquiry").innerHTML = getMessage(2,"Click to SMS");
								window.setTimeout(function(){$ip("mailenquiry").innerHTML = currentStr;mailStatus=null;},10000);
							}
						}
					,30000);
					*/
				}
			}
			return false;
		}catch(e){
			//alert(e);return false;
			$ip("smsenquiry").innerHTML = getMessage(2,"Click to SMS");
			window.setTimeout(function(){$ip("smsenquiry").innerHTML = currentStr;mailStatus=null;},5000);
			ip.traceErr(e,"ajaxenquirySms","sendenqvalidate.js");
		}
	}
	function ajaxenquirymail(frm){
		try{
			currentStr = $ip("mailenquiry").innerHTML;
			if(!frm) frm = d.frmenq;
			if(validateEnqForm(frm)){
				ipSM.strname = frm.strname.value;
				ipSM.stremail = frm.stremail.value;
				ipSM.strphone = frm.strphone.value;
				ipSM.strmsg = frm.txteqmsg.value;
				///ipSM.username = frm.username.value;
				ipSM.username = 'SRG';
				ipSM.listingid = frm.listingid.value;
				///ipSM.date = frm.posteddate.value;
				ipSM.date = '';
				///ipSM.toemail  = frm.toemail.value;
				ipSM.toemail  = 'leogopal80@gmail.com';
				ipSM.divObj = $ip("mailenquiry");
				mailStatus=0;
				name = frm.strname.value;
				country = frm.strcountry.value;
				email = frm.stremail.value;
				phone = frm.strphone.value;
				msg = frm.txteqmsg.value;
				///username = frm.username.value;
				username = "SRG";
				listingid = frm.listingid.value;
				///date = frm.posteddate.value;
				date ='';
				///toemail  = frm.toemail.value;
				toemail  = 'leogopal80@gmail.com';
				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){}
				ipSM.country = country;
				url = "strname="+name+"&stremail="+email+"&strphone="+phone+"&listingid="+listingid+"&country="+country+"&txteqmsg="+msg+"&alertme="+alertme+"&security_code="+sc;
				var urltoenq = ip.host() + "/index.php?option=listing&page=enqtoregister&notemplate=yes&WT.si_n=SENDENQUIRY&WT.si_p=completed&WT.si_sc=1&"+url;
				convertEnqToReg(urltoenq);
				//var urltoget = ip.host() + "/index.php?option=listing&page=mailenquiry&notemplate=yes&WT.si_n=SENDENQUIRY&WT.si_p=completed&WT.si_sc=1&"+url;
				var urltoget = ip.host() + "/enquiry/sendemailenquiry.php?"+url;
				httpNew = new getHTTPObject();

				if (httpNew){
					$ip("mailenquiry").innerHTML = getMessage(0,"Click to Email");
					httpNew.open("GET", urltoget, true);
					httpNew.onreadystatechange = function(){
						if (httpNew.readyState == 4){
							//alert(httpNew.responseText);return false;
							if( parseInt(httpNew.responseText) == 1 ){
								$ip("mailenquiry").innerHTML = getMessage(1,"Click to Email");
								mailStatus=1;
							}
							else if( parseInt(httpNew.responseText) == 2 ){
								mailStatus=0;
								ipSM.showMailForm(1);
								return;
							}
							else if( parseInt(httpNew.responseText) == 3 ){
								$ip("mailenquiry").innerHTML = getMessage(3,"Click to Email");
								mailStatus=1;
								//ipSM.showMailForm(1);
							}
							else {
								$ip("mailenquiry").innerHTML = getMessage(0,"Click to Email");
								mailStatus=0;
							}
						}
					};
					httpNew.send(null);
					/*After 3o sec, if result not coming then failure message will appear*/
					/*window.setInterval(function(){
							if(mailStatus==0){
								$ip("mailenquiry").innerHTML = getMessage(2,"Click to Email");
								window.setTimeout(function(){$ip("mailenquiry").innerHTML = currentStr;mailStatus=null;},10000);
							}
						}
					,30000);
					*/
				}
			}
			return false;
		}catch(e){
			$ip("mailenquiry").innerHTML = getMessage(2,"Click to Email");
			window.setTimeout(function(){$ip("mailenquiry").innerHTML = currentStr;mailStatus=null;},5000);
			ip.traceErr(e,"ajaxenquirymail","sendenqvalidate.js");
		}
	}
	function convertEnqToReg(urltoenq){

		httpEnq = new getHTTPObject();
		//alert(httpEnq);
		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 handleHttpResponse(){
		if (httpNew.readyState == 4){
			$ip("mailenquiry").innerHTML = successStr;
		}
	}
	//FOR MAIL ENQUIRY IN THE YAHOO DETAILED PAGE
	function yahooajaxenquirymail(){
		//test = frmchk();
		if(!frm) frm = d.frmenq;
		if(validateEnqForm(frm)){
			name = d.frmenq.strname.value;
			email = d.frmenq.stremail.value;
			phone = d.frmenq.strphone.value;
			msg = d.frmenq.txteqmsg.value;
			username = d.frmenq.username.value;
			listingid = d.frmenq.listingid.value;
			date = d.frmenq.posteddate.value;
			toemail  = d.frmenq.toemail.value;
			url = "strname="+name+"&stremail="+email+"&strphone="+phone+"&txteqmsg="+msg+"& username="+username+"&listingid="+listingid+"&posteddate="+date+"&toemail="+toemail;
			var urltoget = ip.host() + "/index.php?option=yahoo&page=mailenquiry&notemplate=yes&"+url;
			httpNew = new getHTTPObject();
			if (httpNew){
				httpNew.open("GET", urltoget, true);
				httpNew.send(null);
				httpNew.onreadystatechange = handleHttpResponse;
			}
		}
		return false;
	}
	function getMessage(status,Header){
		var msgArr = ["Your enquiry has been sent sucessfully.","Your enquiry has been sent sucessfully.","Your enquiry has been sent sucessfully"];
		var Str = (status==0) ? ip.loadingStr : (status==1) ? msgArr[0] : (status==3) ? msgArr[2] : msgArr[2];
		if(Header.indexOf("SMS")!=-1){Str="Your SMS has been sent Successfully.";}
		return String('<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>' + Str +'</div>');
		/*return String('<div class="mainMenu"><ul><li style="padding:5px 4px;"><div class="collapse" id="div_m1" style="padding:10px 0px;"><span>' + Header + '</span></div><div id="m1_list" class="subMenu gText" style="line-height:17px;">' + Str + '</div></li></ul></div>');*/
	}
	function ip_sendmail(){
		//this.url = ip.host() + "/index.php?option=listing&page=mailenquiry&notemplate=yes";
		this.url = ip.host() + "/enquiry/sendemailenquiry.php?";
		this.ajax = null;
		this.divObj = null;
		this.listingid = "";
		this.strname = "";
		this.stremail = "";
		this.strphone = "";
		this.strmsg = "";
		this.username = "";
		this.listingid = "";
		this.date = "";
		this.toemail  = "";
		this.country="";
	}
	ip_sendmail.prototype.showMailForm = function(scErr){
		this.ajax = new getHTTPObject();
		var qry="";
		if(scErr){
			qry = "&scErr=1&strname="+this.strname+"&stremail="+this.stremail+"&strphone="+this.strphone+"&txteqmsg="+this.strmsg+"&strcountry="+this.country+"&listingid="+this.listingid+"&username="+this.username;
		}
		var thisObj = this;
		var url = this.url + qry;
		this.ajax.open("get",url,true);
		this.ajax.onreadystatechange = function(){
			if(thisObj.ajax.readyState==4){
				thisObj.divObj.innerHTML = thisObj.ajax.responseText;
			}
		}
		this.ajax.send(null);
	}
	function imageLoad(src){
		StartPreLoader(src);
		$ip("ipmedimg").src = src;
	}
	function ImageLoad(src){
		StartPreLoader(src);
		$ip("ipmedimg").src = src;
	}