	var AjaxFile = SitePath+'ajax/ajax.php';
	
	var loader_img    = "<p style='height:405px; text-align:center' align='center'><img style='margin:20px 0 0 0' src=\"images/ajax-loader.gif\"></p>";	

	function sendMail(listingID,clientID){
		//document.getElementById('content').innerHTML = loader_img;
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
		var name		=	document.getElementById('frmName').value;
		var email		=	document.getElementById('frmEmail').value;
		var phone		=	document.getElementById('frmPhone').value;
		var comments	=	document.getElementById('frmComments').value;
		var url="sendmail.php?name="+name+"&email="+email+"&phone="+phone+"&comments="+comments+"&listingID="+listingID+"&clientID="+clientID;
		xmlhttp.onreadystatechange=getstate;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
		} else {
		alert("Your browser doesn't support xmlhttp");
		return;
		}
	}
	function getstate(){
	//	alert(xmlhttp.responseText)
		if(xmlhttp.readyState==4 && xmlhttp.status==200) {
			document.getElementById('content').innerHTML	=	xmlhttp.responseText;
		}
	}
	function GetXmlHttpObject() {
		if (window.XMLHttpRequest) {
	  // code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
		}
		if (window.ActiveXObject) {
	  // code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
		}
		return null;
	}
	
	function showVideoSlider(listingID){
		//document.getElementById('slideshow-right').innerHTML = loader_img;
		document.getElementById('slideshow-bar').innerHTML = loader_img;	

		document.getElementById('slideshow-left-photos1').className = "photoInactive";
		document.getElementById('slideshow-left-photos2').className = "VideoActive";
		//document.getElementById('slideshow-left-photos3').className = "slideshow-left-photos3";	
		
		document.getElementById('slideshow-right1').style.display = 'none';
		document.getElementById('slideshow-right2').style.display = 'block';
		document.getElementById('slideshow-right3').style.display = 'none';

		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?PageAction=video_slider&listingID="+listingID;
			xmlhttp.onreadystatechange=getVideo_sliderState;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
			//setTimeout('showVideoMain('+listingID+')',2000);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}

	function getVideo_sliderState() {
		if(xmlhttp.readyState==4 && xmlhttp.status==200) {
			var str = xmlhttp.responseText;
			//alert(str);
			document.getElementById('slideshow-bar').innerHTML = str;
			$(function() {
				$(".sliderImages").jCarouselLite({
					btnNext: ".next",
					btnPrev: ".prev",
					visible: 3,
					easing: "easeInOutExpo",
					auto: 4100,
					speed: 1000
				});
				
			});
		}
	}
	
	function showVideoMain(listingID){
		//document.getElementById('slideshow-right').innerHTML = loader_img;
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?PageAction=video_main&listingID="+listingID;
			xmlhttp.onreadystatechange=getVideo_MainState;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
	function getVideo_MainState() {
		if(xmlhttp.readyState==4 && xmlhttp.status==200) {
			var str = xmlhttp.responseText;
			document.getElementById('slideshow-right').innerHTML = str;
			var so = new SWFObject(AjaxFile+'format/flash/player.swf','ply1','540','480','9');
		}
	}
	
	function showPhotoSlider(listingID){
		//document.getElementById('slideshow-right').innerHTML = loader_img;
		document.getElementById('slideshow-bar').innerHTML = loader_img;

		document.getElementById('slideshow-left-photos1').className = "slideshow-left-photos1";
		document.getElementById('slideshow-left-photos2').className = "slideshow-left-photos2";
		document.getElementById('slideshow-left-photos3').className = "slideshow-left-photos3";	
		
		document.getElementById('slideshow-right1').style.display = 'block';

		document.getElementById('slideshow-right2').style.display = 'none';
		document.getElementById('slideshow-right3').style.display = 'none';
		
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?PageAction=photo_slider&listingID="+listingID;
			xmlhttp.onreadystatechange=getPhoto_sliderState;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
			//setTimeout('showPhotoMain('+listingID+')',2000);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
	function getPhoto_sliderState() {
		if(xmlhttp.readyState==4 && xmlhttp.status==200) {
			var strres = xmlhttp.responseText;
			document.getElementById('slideshow-bar').innerHTML = strres;
			$(function() {
				$(".sliderImages").jCarouselLite({
					btnNext: ".next",
					btnPrev: ".prev",
					visible: 3,
					easing: "easeInOutExpo",
					auto: 4100,
					speed: 1000
				});
				
			});
		}
	}
	function showPhotoMain(listingID){
		//document.getElementById('slideshow-right').innerHTML = loader_img;
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?PageAction=photo_main&listingID="+listingID;
			xmlhttp.onreadystatechange=getPhoto_MainState;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
	function getPhoto_MainState() {
		if(xmlhttp.readyState==4 && xmlhttp.status==200) {
			var str2 = xmlhttp.responseText;
			document.getElementById('slideshow-right').innerHTML = str2;
		}
	}
	function showQtvrSlider(listingID){
		//document.getElementById('slideshow-right').innerHTML = loader_img;
		document.getElementById('slideshow-bar').innerHTML = loader_img;
		
		document.getElementById('slideshow-left-photos1').className = "photoInactive";
		document.getElementById('slideshow-left-photos2').className = "slideshow-left-photos2";
		document.getElementById('slideshow-left-photos3').className = "QtvrActive";	
		
		document.getElementById('slideshow-right1').style.display = 'none';
		document.getElementById('slideshow-right2').style.display = 'none';
		document.getElementById('slideshow-right3').style.display = 'block';
		
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?PageAction=qtvr_slider&listingID="+listingID;
			xmlhttp.onreadystatechange=getQtvr_sliderState;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
			//setTimeout('showQtvrMain('+listingID+')',2000);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
	function getQtvr_sliderState() {
		if(xmlhttp.readyState==4 && xmlhttp.status==200) {
			var str2 = xmlhttp.responseText;
			document.getElementById('slideshow-bar').innerHTML = str2;
			$(function() {
				$(".sliderImages").jCarouselLite({
					btnNext: ".next",
					btnPrev: ".prev",
					visible: 3,
					easing: "easeInOutExpo",
					auto: 4100,
					speed: 1000
				});
				
			});
		}
	}
	function changeQtvrs(qtvrID){
		//document.getElementById('slideshow-right').innerHTML = loader_img;
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?PageAction=changeQtvrs&qtvrID="+qtvrID;
			xmlhttp.onreadystatechange=getQtvr_MainState;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
	function getQtvr_MainState() {
		if(xmlhttp.readyState==4 && xmlhttp.status==200) {
			var str2 = xmlhttp.responseText;
			document.getElementById('slideshow-right3').innerHTML = '<div id="slideshow-photo"><OBJECT classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="545" height="360" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="https://www.agentcontrol.com'+str2+'"><param name="autoplay" value="true"><param name="controller" value="false"><param name="loop" value="false"><EMBED src="https://www.agentcontrol.com'+str2+'" width="545" height="360" autoplay="true" controller="false" loop="false" bgcolor="#000000" pluginspage="http://www.apple.com/quicktime/download/"></EMBED></OBJECT></div>';
		}
	}
	function changeVideo(videoID){
		//document.getElementById('slideshow-right').innerHTML = loader_img;
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?PageAction=video_main&videoID="+videoID;
			xmlhttp.onreadystatechange=getVideo_MainState;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
	function getVideo_MainState() {
		if(xmlhttp.readyState==4 && xmlhttp.status==200) {
			var str = xmlhttp.responseText;
			document.getElementById('player1').innerHTML = '<embed height="360" width="545" flashvars="file='+str+'&amp;autostart=true" allowscriptaccess="always" allowfullscreen="true" quality="high" name="ply1" id="ply1" style="" src="'+SitePath+'format/flash/player.swf" type="application/x-shockwave-flash">';
		}
	}
function getCityByStateId(Id){
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?Id="+Id+"&PageAction=getCity";
			xmlhttp.onreadystatechange=getcity;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
	
function getcity() {
	
  if(xmlhttp.readyState==4 && xmlhttp.status==200) {
		 document.getElementById('frmProperty_City').innerHTML=xmlhttp.responseText ;
	}	
}


function getCityByStateId1(Id){
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?Id="+Id+"&PageAction=getCity";
			xmlhttp.onreadystatechange=getcity1;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
	
function getcity1() {
  if(xmlhttp.readyState==4 && xmlhttp.status==200) {
		 document.getElementById('frmProperty_City1').innerHTML=xmlhttp.responseText ;
	}	
}

function getCityByStateId2(Id){
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?Id="+Id+"&PageAction=getCity";
			xmlhttp.onreadystatechange=getcity2;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
	
function getcity2() {
  if(xmlhttp.readyState==4 && xmlhttp.status==200) {
		 document.getElementById('frmProperty_City2').innerHTML=xmlhttp.responseText ;
	}	
}

function getCityByStateId3(Id){
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?Id="+Id+"&PageAction=getCity";
			xmlhttp.onreadystatechange=getcity3;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
	
function getcity3() {
  if(xmlhttp.readyState==4 && xmlhttp.status==200) {
		 document.getElementById('frmProperty_City3').innerHTML=xmlhttp.responseText ;
	}	
}
	
	
	
function getCityByStateIdFromFeed(Id){
	xmlhttp=GetXmlHttpObject();
	if(xmlhttp!=null) {
		var url=AjaxFile+"?Id="+Id+"&PageAction=getCityFromFeed";
		xmlhttp.onreadystatechange=getstates;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	} else {
	alert("Your browser doesn't support xmlhttp");
	return;
	}
}

function getstates() {
	
  if(xmlhttp.readyState==4 && xmlhttp.status==200) {
		 document.getElementById('frmProperty_City').innerHTML=xmlhttp.responseText ;
	}	
}




function showUser(Id,txtPlace)
{
	var url=AjaxFile+"?Id="+Id+"&PageAction=getCity";
if (Id=="")
  {
  document.getElementById("frmBasicTab_City").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function(txtPlace)
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(txtPlace).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET",url,true);
xmlhttp.send();
}

function showUserForFeed(Id,txtPlace)
{
	var url=AjaxFile+"?Id="+Id+"&PageAction=getCityFromFeed";
if (Id=="")
  {
  document.getElementById("frmBasicTab_City").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(txtPlace).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET",url,true);
xmlhttp.send();
}

function getCityByStateIdFromFeed1(Id){
	xmlhttp=GetXmlHttpObject();
	if(xmlhttp!=null) {
		var url=AjaxFile+"?Id="+Id+"&PageAction=getCityFromFeed";
		xmlhttp.onreadystatechange=getstates1;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	} else {
	alert("Your browser doesn't support xmlhttp");
	return;
	}
}


function getstates1() {
	//alert(xmlhttp.readyState);
	//alert(xmlhttp.status);
	if(xmlhttp.readyState==4 && xmlhttp.status==200) {
		 document.getElementById('frmProperty_City1').innerHTML=xmlhttp.responseText ;
	}
}


function getCityByStateIdFromFeed2(Id){
	xmlhttp=GetXmlHttpObject();
	if(xmlhttp!=null) {
		var url=AjaxFile+"?Id="+Id+"&PageAction=getCityFromFeed";
		xmlhttp.onreadystatechange=getstates2;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	} else {
	alert("Your browser doesn't support xmlhttp");
	return;
	}
}


function getstates2() {
	//alert(xmlhttp.readyState);
	//alert(xmlhttp.status);
	if(xmlhttp.readyState==4 && xmlhttp.status==200) {
		 document.getElementById('frmProperty_City2').innerHTML=xmlhttp.responseText ;
	}
}

function getCityByStateIdFromFeed3(Id){
	xmlhttp=GetXmlHttpObject();
	if(xmlhttp!=null) {
		var url=AjaxFile+"?Id="+Id+"&PageAction=getCityFromFeed";
		xmlhttp.onreadystatechange=getstates3;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	} else {
	alert("Your browser doesn't support xmlhttp");
	return;
	}
}


function getstates3() {
	//alert(xmlhttp.readyState);
	//alert(xmlhttp.status);
	if(xmlhttp.readyState==4 && xmlhttp.status==200) {
		 document.getElementById('frmProperty_City3').innerHTML=xmlhttp.responseText ;
	}
}
function showSavedSearch(displayId){
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?PageAction=saved_search&displayId="+displayId;
			
			xmlhttp.onreadystatechange=showSavedSearchBox;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
			//setTimeout('showVideoMain('+listingID+')',2000);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
function showSavedSearchBox() {
	//alert(xmlhttp.readyState);
	//alert(xmlhttp.status);
	if(xmlhttp.readyState==4 && xmlhttp.status==200) {
		 document.getElementById('tiptip_holder').innerHTML=xmlhttp.responseText ;
	}
}	
function changename(Id, displayId,displayName){
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?PageAction=changename&Id="+Id+"&displayId="+displayId+"&displayName="+displayName;
			xmlhttp.onreadystatechange=changenameBox;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
			//setTimeout('showVideoMain('+listingID+')',2000);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
function changenameBox() {
	var response =	xmlhttp.responseText;
	responseArray	=	response.split("|");
    document.getElementById('changename'+responseArray[0]).innerHTML=responseArray[1];
}
function showSuggestion(value){
	if(value.length<3){
		doHideAutoSuggestionBox();
		return false;
	}
	xmlhttp=GetXmlHttpObject();	
	if(xmlhttp!=null) {
			var url=AjaxFile+"?PageAction=autosuggestion&key="+value;
			
			xmlhttp.onreadystatechange=showAutoSuggestionBox;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
			//setTimeout('showVideoMain('+listingID+')',2000);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
}
function showAutoSuggestionBox() {
	//alert(xmlhttp.responseText);suggestion-box
	document.getElementById('suggestion-box').style.display="block";
	document.getElementById('suggestion-box').innerHTML=loader_img ;
	if(xmlhttp.readyState==4 && xmlhttp.status==200) {
		document.getElementById('suggestion-box').innerHTML=xmlhttp.responseText ;
	}
}
function assignAddress(value){
		document.getElementById('suggestion-box').style.display	=	"none";
		var id	=	'con'+value;
		htmlString	=	document.getElementById(id).innerHTML;
		document.getElementById('frmProperty_address').value	=	htmlString.replace(/<.*?>/g, '');
}
function doHideAutoSuggestionBox() {
	if(document.getElementById('suggestion-box')){
		document.getElementById('suggestion-box').style.display="none";
	}
}

// send text messge 

function validatemobileMsg(){
	var count=0;
	if(document.getElementById('frmMobile').value==""){
			document.getElementById('frmMobile').className	=  "error-box";
			 count++;
	} else if(isNaN(document.getElementById('frmMobile').value)){
			document.getElementById('frmMobile').className	=  "error-box";
			 count++;
	} else {
			document.getElementById('frmMobile').className = "textbox";
	}
	 if(document.getElementById('frmMessage').value==""){
			document.getElementById('frmMessage').className	=  "error-box-big";
			 count++;
	} else {
			document.getElementById('frmMessage').className = "textarea";
	}
	if(count!=0){
			return false;
	} else {
			// after validation 
				var mobile_no = document.getElementById('frmMobile').value;
				var message   = document.getElementById('frmMessage').value;
				xmlhttp=GetXmlHttpObject();
				if(xmlhttp!=null) {
					var url=AjaxFile+"?PageAction=sendSMS&mobile="+mobile_no+'&msg='+message;
					xmlhttp.onreadystatechange=MsgNotificationsResult;
					xmlhttp.open("GET",url,true);
					xmlhttp.send(null);
					//setTimeout('showVideoMain('+listingID+')',2000);
				} else {
					alert("Your browser doesn't support xmlhttp");
					return;
				}
	}
}

function MsgNotificationsResult(){
	var response =	xmlhttp.responseText;
}
function updateEmailNotifications(Id){
	    var notification_status = document.getElementById('email_notification_'+Id).value;
		document.getElementById('notification_ack_'+Id).style.display='block';
		xmlhttp=GetXmlHttpObject();
		if(xmlhttp!=null) {
			var url=AjaxFile+"?PageAction=SearchEmailNotifications&Id="+Id+'&status='+notification_status;
			xmlhttp.onreadystatechange=EmailNotificationsResult;
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
			//setTimeout('showVideoMain('+listingID+')',2000);
		} else {
			alert("Your browser doesn't support xmlhttp");
			return;
		}
	}
function EmailNotificationsResult() {
	var response =	xmlhttp.responseText;
	if(response){
	 	 document.getElementById('notification_ack_'+response).style.display='none';	
	}
}

