
var addtolist_2="<div class='p-f-link'><div class='p-f-links-icon'><img src='../images/icon_saved_to_list.gif'></div><div class='p-f-links-text red8'>Saved to list</div></div>";
var addtolist_1="<div class='p-f-link'><div class='p-f-links-icon'><img src='../images/icon_saved_to_list.gif'></div><div class='p-f-links-text red8'>Saved to list</div></div>";
var removetolist_2="<div class='p-f-link'><div class='p-f-links-icon'><img src='../images/icon_saved_to_list.gif'></div><div class='p-f-links-text red8'>Saved to list</div></div>";
var removetolist_1="<div class='p-f-link'><div class='p-f-links-icon'><img src='../images/icon_saved_to_list.gif'></div><div class='p-f-links-text red8'>Saved to list</div></div>";


var availableRadius = null;
var addtolist_0="";
var oldV = "";
var places = new Array();
var loggedIn = false;

var buttonMouseY=0;
var running=false;

var errorColour='yellow';
var dd= null;
var highlighted=0;
var showing=0;
var matches=0;
var done = new Array();

var slideIds = new Array();
var slideCounter=0;
var slideTimer=null;
var propertyIds = null;

var minLat=0;
var maxLat=0;
var minLng=0;
var maxLng=0;
var lat=0;
var lng=0;
var windowHeight=0;
var windowWidth=0;
var keepAliveTime = 60000;
var tabToGoTo = "";

var isLonResi = false;


function checkAllOffices(val)
{
	for (i=0; i<document.forms.search.offices.length; i++)
	{
		document.forms.search.offices[i].checked=val;
	}
	init(1);
}

function launchEPC(grap)
{
	window.open ("../assets/photos/"+grap,"epc","height=467,width=1057");
}

function launchEPC_lets(url)
{
	window.open (url,"epc","height=467,width=1057");
}

function alterUrl()
{
	var newUrl = escape("../search/map.php?"+flattenForm());
	alert (newUrl);
}

function showDiv(el){
$(el).style.display='block';
}

function showPassword(val)
{
	$("msg").style.display='none';
	if (val) $("msg").innerHTML= "Your password has been emailed to you";
	else{
	$("msg").innerHTML="Couldn't send an email. Please try again";
	$("msg").style.display='block';
	}
}

function forgottenPassword(email)
{
	$("msg").style.display='none';
	if (email==""){
	$('msg').innerHTML="Sorry, please enter an email address"; $('msg').style.display='block'; return false;
	}
	rm2.doRequest ("handleRequestGeneric","../xml/forgottenpassword.php?email="+email,"showPassword");
	//$('msg').innerHTML="An email with your password has been sent to your email address.";
	document.getElementById('msg2').innerHTML="An email with your password has been sent to your email address.";
	//$('msg').style.display='block';
	return true;
}

function getFlashMovie(movieName) {
		var isIE = navigator.appName.indexOf("Microsoft") != -1;
		return (isIE) ? window[movieName] : document[movieName];
	}
	
	function flashOffice() {
		
		var f = document.forms.flashForm;		
		for (o=0; o<f.offices.length; o++)
		{
			if ( f.offices[o].checked )
			{
				getFlashMovie("searchByOffice").active( f.offices[o].value );
			}
			else
			{
				getFlashMovie("searchByOffice").inactive( f.offices[o].value );
			}
		}
	}
function feedbackLogin(val)
{
	var htmlout ='<div style="width:150px;height:42px;"><div style="position:absolute;z-index:1000;margin-top:23px;margin-left:12px;display:inline;float:left"><a href="javascript:void(logoutLink(\'false\',\'\'))"><img id="logout" width="57" height="11" src="../images/mysanp_logout.png" alt="logout"/></a></div><div style="position:absolute;z-index:1000;margin-top:23px;margin-left:72px;display:inline;float:left"><a href="javascript:void(mysiteLink(\'false\',\'\'))"><img id="mysanp_visit" width="55" height="11" src="../images/mysanp_visit.png" alt="mysite"/></a></div><img width="150" height="60" src="../images/bg_mysanp_top.png" style="position:relative;top:0;left:0;z-index:100;"></div>';
	$("msg").style.display='none';
	if (val=="true")
	{
		hideDiv("registerorlogin");
		document.getElementById("mysite").innerHTML=htmlout;
		loggedIn=true;
		hidePic("registerorloginBackground");
	}
	else{
	$("msg").innerHTML='Sorry, could not log in';
	$("msg").style.display='block';
	}
}

function hideDiv(el){
	document.getElementById(el).style.display='none';
}

function keepAlive()
{
//	rm2.div="keepalive";
 //       rm2.doRequest ("handleHTMLRequest", "../xml/keepalive.php");
//	setTimeout("keepAlive()", keepAliveTime);
	if (document.getElementById("keepalive"))
	{
	document.getElementById("keepalive").src="../xml/keepalive.php";
	setTimeout("keepAlive()",60000);
	}
}
var displayOfficeMapLinkTmp="";
function displayOfficeMap(id,dir_location,type)
{
	if(type=="") type="b";
	if($("officemap").innerHTML==""){
		document.getElementById("officemap").innerHTML="<iframe src='http://www.struttandparker.co.uk/"+dir_location+"/php/veofficemap.php?type="+type+"&office="+id+"' height=200 width=350 frameborder=0 border=0></iframe>";
		displayOfficeMapLinkTmp=$("displayOfficeMapLink").href;
		
		pngfix();
	}else{
		$("officemap").innerHTML="";
		$("displayOfficeMapLink").href=displayOfficeMapLinkTmp;
	}
	
}

function pngfix() {

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1]);

if ((version >= 5.5) && (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
        //var imgID = (img.id) ? "id='" + img.id + "' " : ""
        var imgID = (img.id) ? "id='" + img.id + "' " : "id='randId_" + Math.round( Math.random()*100000000000 ) + "' "
        var imgClass = (img.className) ? "class='" + img.className + "' " : ""
        var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
        var imgStyle = "display:inline-block;" + img.style.cssText 
        var scaleMethod = 'scale';
        if (img.align == "left") imgStyle = "float:left;" + imgStyle
        if (img.align == "right") imgStyle = "float:right;" + imgStyle
        if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
        if (img.className == 'scaleImage') scaleMethod='image';
        var strNewHTML = "<span " + imgID + imgClass + imgTitle
        + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
        + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
        + "(src=\'" + img.src + "\', sizingMethod='"+scaleMethod+"');\"></span>";
        img.outerHTML = strNewHTML;
        i = i-1;
      }
   }

}

/*
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
var isIE = navigator.appName.indexOf("Microsoft") != -1;

if ( isIE && version < 7 && (version >= 5.5) && (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         var scaleMethod = 'scale';
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         if (img.className == 'scaleImage') scaleMethod='image';
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='"+scaleMethod+"');\"></span>"         
	 img.outerHTML = strNewHTML;
         i = i-1;
      }
   }
}*/

}

function hideOfficeMap(id)
{
	
	$("officemap").style.height="10px";
}

function submitEmailFriend(type,runlive,reposition)
{

	if (reposition==true)
        {
                var top = document.all ? document.body.scrollTop : 0;

                document.getElementById("enquire").style.top= (top+buttonMouseY)+"px";
        }

	var url="../forms/email_friend2.php?type="+type;
	var f = document.forms.emailFriend;

	var msg=0;


	highlightBox ("name2","white");	
	highlightBox ("surname","white");	
	highlightBox ("fromemail","white");	
	highlightBox ("toemail","white");	
	highlightBox ("comments2","white");	

	if (f.name2.value=='')	msg+=highlightBox("name2",errorColour); 
	if (f.surname.value=='') msg+=highlightBox("surname",errorColour); 
	if (f.fromemail.value=='') msg+=highlightBox("fromemail",errorColour);
	if (f.toemail.value=='') msg+=highlightBox("toemail",errorColour); 
	if (f.comments2.value=='') msg+=highlightBox("comments2",errorColour);

	if (!check_email(f.toemail.value))
	msg+=highlightBox("toemail","red");

	if (!check_email(f.fromemail.value))
	msg+=highlightBox("fromemail","red");

	url+="&name2="+escape(f.name2.value);
	url+="&surname="+escape(f.surname.value);
	url+="&comments2="+escape(f.comments2.value);
	url+="&toemail="+escape(f.toemail.value);
	url+="&fromemail="+escape(f.fromemail.value);
	url+="&marketing="+escape(f.marketing.checked);
	url+="&cc="+escape(f.cc.checked);
	url+="&preview="+!runlive;
	url+="&id="+escape(f.id.value);

	if (runlive)
	rm2.div = "enquire";
	else
	rm2.div = "emailpreview";


	if (msg)
	return document.getElementById("errors").innerHTML="You must enter the highlighted fields. ";
	else
        rm2.doRequest ("handleHTMLRequest", url);
	urchinTracker("/ajax/email_friend_submitted" );
	document.getElementById(rm2.div).innerHTML="";
	return false;
}


function highlightBox (field,colour)
{
	document.getElementById(field).style.backgroundColor=colour;
	return 1;
}
function submitEnquiry(type)
{
	urchinTracker("/ajax/enquire_form_submitted" );
	var url="../forms/enquire_form2.php?type="+type;
	var f = document.forms.enquiryForm;
	var msg=0;

	highlightBox ("name","white");	
	highlightBox ("email","white");	
	highlightBox ("phone","white");	
	highlightBox ("mobile","white");	
	highlightBox ("surname","white");	

	if (f.name.value=='') msg+=highlightBox("name",errorColour);
	if (f.email.value=='') msg+=highlightBox("email",errorColour);
	if (f.surname.value=='') msg+=highlightBox("surname",errorColour); 
	if (f.phone.value=='' && f.mobile.value=='') 
	{
		msg+=highlightBox("phone",errorColour);
		highlightBox("mobile",errorColour)		
	}

  var mailMsg = '';
  var phoneMsg = '';
  if (!check_email(f.email.value))
  {
    msg+=highlightBox("email","red");
    mailMsg = "Please enter valid email<BR>";
  }

  var number_regex = /[^(0-9\s)]/g;
  //f.phone.value = f.phone.value.replace( number_regex, "" );
  if( number_regex.test(f.phone.value) && f.phone.value != '' ) {
    msg+=highlightBox("phone","red");
    phoneMsg = "Please enter valid phone number<BR>";
  }
  if( number_regex.test(f.mobile.value) && f.mobile.value != '' ) {
    msg+=highlightBox("mobile","red");
    phoneMsg += "Please enter valid mobile number<BR>";  
  }  

	url+="&name="+escape(f.name.value);
	url+="&surname="+escape(f.surname.value);
	url+="&id="+escape(f.id.value);
	url+="&address="+escape(f.address.value);
	url+="&postcode="+escape(f.postcode.value);
	url+="&email="+escape(f.email.value);
	url+="&phone="+escape(f.phone.value);
	url+="&mobile="+escape(f.mobile.value);
	url+="&comments="+escape(f.comments.value);
	url+="&senddetails="+escape(f.sendDetails.checked);
	url+="&viewproperty="+escape(f.viewProperty.checked);
	url+="&marketing="+escape(f.marketing.value);

	rm2.div = "enquire";
//	window.open (url);

	if (msg)
	{
		return document.getElementById("errors").innerHTML=mailMsg + phoneMsg + "Please fill in the highlighted fields";
	}
	
	else
        rm2.doRequest ("handleHTMLRequest", url);

	document.getElementById(rm2.div).innerHTML="";
	return false;
}

function launchEmailFriend(id,type,reposition,adjTop,adjLeft)
{
	
	urchinTracker("/ajax/email_friend_launched" );
	rm2.div = "enquire";
	setVisibleTop("enquire",adjTop,adjLeft);
	//setTimeout('document.getElementById("enquire").style.display=\'block\'',1250);
	
    rm2.doRequest ("handleHTMLRequest","../forms/email_friend.php?id="+id+"&type="+type, "pngfix");
	
	var dv="p_"+id;
	/*
  if($(dv)){
		$(rm2.div).style.top=(($(dv).offsetTop-150)+"px");
	}
	*/
  /*
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	if ((version >= 5.5) && (document.body.filters) && (version <7)) {
		setTimeout("pngfix()",1250);
	}
	*/
}

function launchEnquire(id,type,reposition,adjTop,adjLeft){
	
		
	urchinTracker("/ajax/enquire_form_launched" );
	if (reposition=='map'){
		document.getElementById("enquire").style.top= (-50)+"px";
	}
	if(BrowserDetect.browser!="Explorer"){

//		adjTop=250;
	}
	if (reposition==true)
	{
		//MyElem = 'p_'+id;
		//MyTop = ($(MyElem).offsetTop);
		//MyTop = MyTop+parseInt(window.pageYOffset)-50;
		
		var top = document.all ? document.body.scrollTop : 0;
		
		//document.getElementById("enquire").style.top= (top+buttonMouseY-400)+"px";
		//document.getElementById("enquire").style.top= (posY-600)+"px";
		//document.getElementById("enquire").style.top= MyTop+"px";
		//document.getElementById("enquire").style.marginTop= "-80px";
	}
	setVisibleTop("enquire",adjTop,adjLeft);
	rm2.div = "enquire";

	document.getElementById("enquire").style.display='block';
  rm2.doRequest ("handleHTMLRequest","../forms/enquire_form.php?id="+id+"&type="+type, "pngfix");

	//pngfix();

	/*var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	if ((version >= 5.5) && (document.body.filters) && (version <7)) {
		setTimeout("pngFix()",1250);
	}*/
}

function testCallback() {
  alert("Who you gonna call...back");
}

function populateLatLngUpdates(val)
{

	var f = document.forms.search;
	
	if (val=="Pimlico & West")
	{
		f.Latitude.value = lat = "51.490629272781184";
		f.Longitude.value = lng = "-00.13887405395507812";
	} 
	else if (val=="Sloane Square") 
	{
		f.Latitude.value = lat = "51.49260657816879";
		f.Longitude.value = lng = "-00.15719890594482422";
	}
	else if (val=="St James") 
	{
		f.Latitude.value = lat = "51.507593901214925";
		f.Longitude.value = lng = "-00.13591289520263672";
	}
	else if (val=="Knightsbridge") 
	{
		f.Latitude.value = lat = "51.49928602967096";
		f.Longitude.value = lng = "-00.17380714416503906";
	}
	else if (val=="Belgravia") 
	{
		f.Latitude.value = lat = "51.49498457510481";
		f.Longitude.value = lng = "-00.1520705223083496";
	}
	else if (val=="Kensington") 
	{
		f.Latitude.value = lat = "51.50185067895931";
		f.Longitude.value = lng = "-00.19084453582763672";
	}
	else if (val=="Chelsea") 
	{
		f.Latitude.value = lat = "51.48934665045721";
		f.Longitude.value = lng = "-00.1650524139404297";
	}
	else if (val=="Mayfair") 
	{
		f.Latitude.value = lat = "51.51138670225366";
		f.Longitude.value = lng = "-00.14745712280273437";
	}
	else if (val=="Marylebone") 
	{
		f.Latitude.value = lat = "51.51779635241522";
		f.Longitude.value = lng = "-00.16028881072998047";
	}
	else if (val=="Regents Park") 
	{
		f.Latitude.value = lat = "51.53063964456957";
		f.Longitude.value = lng = "-00.1540660858154297";
	}
	else if (val=="West End") 
	{
		f.Latitude.value = lat = "51.509383501611595";
		f.Longitude.value = lng = "-0.13535499572753906";
	}
	else if (val=="Paddington") 
	{
		f.Latitude.value = lat = "51.51584684593611";
		f.Longitude.value = lng = "-00.1750946044921875";
	}
	else if (val=="Marble Arch") 
	{
		f.Latitude.value = lat = "51.51365688983539";
		f.Longitude.value = lng = "-00.15852928161621094";
	}
	else if (val=="South Kensington") 
	{
		f.Latitude.value = lat = "51.49431661096613";
		f.Longitude.value = lng = "-0.17706871032714844";
	}
	else if (val=="Notting Hill Gate") 
	{
		f.Latitude.value = lat = "51.50900956106959";
		f.Longitude.value = lng = "-00.19689559936523437";
	}
	else if (val=="Holland Park") 
	{
		f.Latitude.value = lat = "51.503453511475826";
		f.Longitude.value = lng = "-00.2028179168701172";
	}
	else if (val=="West Kensington") 
	{
		f.Latitude.value = lat = "51.4978433510224";
		f.Longitude.value = lng = "-0.21577835083007812";
	}
	else if (val=="North Kensington") 
	{
		f.Latitude.value = lat = "51.52241608253253";
		f.Longitude.value = lng = "-00.21843910217285156";
	}
	else if (val=="Fulham") 
	{
		f.Latitude.value = lat = "51.480741459392426";
		f.Longitude.value = lng = "-00.19629478454589844";
	}
	else if (val=="Barons Court") 
	{
		f.Latitude.value = lat = "51.489987966129696";
		f.Longitude.value = lng = "-00.21363258361816406";
	}
	else if (val=="Hammersmith") 
	{
		f.Latitude.value = lat = "51.49308753137669";
		f.Longitude.value = lng = "-00.22556304931640625";
	}
	//updatedipa();
}

function populateLatLng(val,f)
{
	if (val=="Pimlico & West")
	{
		document.forms.myform.lat.value = lat = "51.490629272781184";
		document.forms.myform.lng.value = lng = "-00.13887405395507812";
	} 
	else if (val=="Sloane Square") 
	{
		document.forms.myform.lat.value = lat = "51.49260657816879";
		document.forms.myform.lng.value = lng = "-00.15719890594482422";
	}
	else if (val=="St James") 
	{
		document.forms.myform.lat.value = lat = "51.507593901214925";
		document.forms.myform.lng.value = lng = "-00.13591289520263672";
	}
	else if (val=="Knightsbridge") 
	{
		document.forms.myform.lat.value = lat = "51.49928602967096";
		document.forms.myform.lng.value = lng = "-00.17380714416503906";
	}
	else if (val=="Belgravia") 
	{
		document.forms.myform.lat.value = lat = "51.49498457510481";
		document.forms.myform.lng.value = lng = "-00.1520705223083496";
	}
	else if (val=="Kensington") 
	{
		document.forms.myform.lat.value = lat = "51.50185067895931";
		document.forms.myform.lng.value = lng = "-00.19084453582763672";
	}
	else if (val=="Chelsea") 
	{
		document.forms.myform.lat.value = lat = "51.48934665045721";
		document.forms.myform.lng.value = lng = "-00.1650524139404297";
	}
	else if (val=="Mayfair") 
	{
		document.forms.myform.lat.value = lat = "51.51138670225366";
		document.forms.myform.lng.value = lng = "-00.14745712280273437";
	}
	else if (val=="Marylebone") 
	{
		document.forms.myform.lat.value = lat = "51.51779635241522";
		document.forms.myform.lng.value = lng = "-00.16028881072998047";
	}
	else if (val=="Regents Park") 
	{
		document.forms.myform.lat.value = lat = "51.53063964456957";
		document.forms.myform.lng.value = lng = "-00.1540660858154297";
	}
	else if (val=="West End") 
	{
		document.forms.myform.lat.value = lat = "51.509383501611595";
		document.forms.myform.lng.value = lng = "-0.13535499572753906";
	}
	else if (val=="Paddington") 
	{
		document.forms.myform.lat.value = lat = "51.51584684593611";
		document.forms.myform.lng.value = lng = "-00.1750946044921875";
	}
	else if (val=="Marble Arch") 
	{
		document.forms.myform.lat.value = lat = "51.51365688983539";
		document.forms.myform.lng.value = lng = "-00.15852928161621094";
	}
	else if (val=="South Kensington") 
	{
		document.forms.myform.lat.value = lat = "51.49431661096613";
		document.forms.myform.lng.value = lng = "-0.17706871032714844";
	}
	else if (val=="Notting Hill Gate") 
	{
		document.forms.myform.lat.value = lat = "51.50900956106959";
		document.forms.myform.lng.value = lng = "-00.19689559936523437";
	}
	else if (val=="Holland Park") 
	{
		document.forms.myform.lat.value = lat = "51.503453511475826";
		document.forms.myform.lng.value = lng = "-00.2028179168701172";
	}
	else if (val=="West Kensington") 
	{
		document.forms.myform.lat.value = lat = "51.4978433510224";
		document.forms.myform.lng.value = lng = "-0.21577835083007812";
	}
	else if (val=="North Kensington") 
	{
		document.forms.myform.lat.value = lat = "51.52241608253253";
		document.forms.myform.lng.value = lng = "-00.21843910217285156";
	}
	else if (val=="Fulham") 
	{
		document.forms.myform.lat.value = lat = "51.480741459392426";
		document.forms.myform.lng.value = lng = "-00.19629478454589844";
	}
	else if (val=="Barons Court") 
	{
		document.forms.myform.lat.value = lat = "51.489987966129696";
		document.forms.myform.lng.value = lng = "-00.21363258361816406";
	}
	else if (val=="Hammersmith") 
	{
		document.forms.myform.lat.value = lat = "51.49308753137669";
		document.forms.myform.lng.value = lng = "-00.22556304931640625";
	}
	//updatedipa();
}
function showlocations (loc,div,url)
{
        layermanager.divStatus(div,"block");
}

function quickSearch (val,type,stype) {	
  quickSearchGeneric( val,type,stype, ".." );
} 

function quickSearchGeneric( val,type,stype, path ) {
	//window.open ("../xml/lookup.php?t="+val+'&type='+type,'qs');
	rm2.div = "lookforresults";
	var extra = "";
	if (stype=="farms") extra="&farms=true&stype=farms";
	if (stype=="lonresi") extra="&lonresi=true&stype=lonresi";
	
	//document.getElementById("debugger").innerHTML = "../xml/lookup.php?t="+val+'&type='+flatType(type)+extra;
    rm2.doRequest ("handleHTMLRequest",path+"/xml/lookup.php?t="+val+'&type='+flatType(type)+extra,"pngfix");
}

function recordPtype(val)
{
	//document.forms.myform.houses.value="true";
	document.forms.myform.houses.value="false";
	//document.forms.myform.flats.value="true";
	document.forms.myform.flats.value="false";
	if (val=="house" || val=="HouseandFlat") document.forms.myform.flats.value="true";
	if (val=="flat" || val=="HouseandFlat") document.forms.myform.houses.value="true";	
}
function layerAlter (id, style)
{
	document.getElementById("div"+id).style.display=style;
	if (style=="none")
	document.getElementById("div"+id+"onoff").innerHTML = "<a href='javascript:layerAlter(\""+id+"\",\"block\")'><img src='../images/btn_list_plus_off.gif' alt='display properties'/></a>";
	else
	document.getElementById("div"+id+"onoff").innerHTML = "<a href='javascript:layerAlter(\""+id+"\",\"none\")'><img src='../images/btn_list_minus_off.gif' alt='hide properties'/></a>";
}

function jp(id,type)
{
	document.location.href='../php/property.php?id='+id+'&type='+type+flattenForm().replace("&id=","&id2=");
}

function jpmap(id,type,ids)
{
	var jform = document.forms.jumpproperty.id2;
	var ids="";

	var comma="";
	for (i=1; i<jform.options.length; i++)
	{
		ids+=comma+jform.options[i].value;
		comma=",";
	}
	
	document.location.href='../php/property.php?id='+id+'&type='+type+"&ids="+ids;
}

function _populateBubbleInner(x)
{
	alert (x);
}
/*
function alterFormElement(name,checked)
{
	var f = document.forms.myform;
	
	eval ("f."+name+".value=" + checked);
	document.getElementById("debugger").innerHTML="f."+name+".value=" + checked;
	if (name=="houses" || name=="flats")
	{
		if (f.houses.value=="true" && f.flats.value=="true")
		f.ptype.value="House & Flat";
		else
		if (f.flats.value=="true")
		f.ptype.value="Flat";
		else
		f.ptype.value="House";
	}
	
	var typeTmp = document.getElementById("type").value;
		document.getElementById("type").value= flatType(typeTmp);
		var minPricetmp = flatPrice(document.getElementById("minprice").value);
		document.getElementById("minprice").value=  minPricetmp;
		var maxPricetmp = flatPrice(document.getElementById("maxprice").value);
		document.getElementById("maxprice").value=  maxPricetmp;
		
		mapmanager.populate();
		document.getElementById("minprice").value = fancyPrice(minPricetmp);
		document.getElementById("maxprice").value = fancyPrice(maxPricetmp);
		document.getElementById("type").value=typeTmp;
}

function alterFormElementPrice(name,checked,fancy)
{
	var f = document.forms.myform;
	
	if (fancy=='true'){
		eval ("f."+name+".value='" + fancyPrice(checked)+"'");
	}else{
		eval ("f."+name+".value=" + flatPrice(checked));
	}
		document.getElementById("debugger").innerHTML="f."+name+".value=" + checked;
}
*/
function windowSize() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    windowWidth = window.innerWidth;
    windowHeight = window.scrollHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.scrollHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  }

}

function doOverlaySize()
{
	windowSize();
	if($("overlay")) document.getElementById("overlay").style.height=windowHeight+"px";
	if($("overlay")) document.getElementById("overlay").style.width=windowWidth+"px";
}

function _setMapSize() {}

function _initExtra() {zoom.hide();}
function _registerEvents() {}
function _doDefaults() {}

function init3() { dd= document.getElementById('dropdown'); keepAlive()}

function showhideform(action) //hideshowpanel'><a href='javascript:void(showhideform(\"none\"
{
	document.getElementById("searchpane").style.display=action;
	if (action=="none")
	document.getElementById("hideshowpanel").innerHTML="<a href='javascript:void(showhideform(\"block\"))' class='red8'>+ SHOW SEARCH PANEL</a>";
	else
	document.getElementById("hideshowpanel").innerHTML="<a href='javascript:void(showhideform(\"none\"))' class='red8'>X HIDE SEARCH PANEL</a>";

}

function alterZoomLevel(radius)
{
	var level =8;
	if (radius==0.25) level=1;
	if (radius==0.5) level=2;
	if (radius==0.75) level=3;
	if (radius==5) level=10;
	if (radius==10) level=7;
	if (radius==25) level=10;
	doZoom(level);
}

function toggleSlideshow()
{
	if (!slideTimer)
	{
	document.getElementById('pausestart').innerHTML='PAUSE';
	nextSlide();
	}
	else
	{
	document.getElementById('pausestart').innerHTML='START';
	clearTimeout(slideTimer);
	slideTimer=null;
	}
	
}

function changeMainImage(id, src)
{
	eval("document."+id+".src='"+src+"'");
	
}

function flattenForm ()
{
	var f = document.forms.myform;
  
  //for newhomes page
  if(!f) return false;
  
  var url = "&minprice="+flatPrice(f.minprice.value);
	var houses=f.houses.value;
	var flats=f.flats.value;
	var ptype=f.ptype.value;
	
	if (propertyid) url+="&id="+propertyid;
	url += "&maxprice="+flatPrice(f.maxprice.value);
	url += "&houses="+f.houses.value;
	url += "&flats="+f.flats.value;
	url += "&ptype="+f.ptype.value;
  
  if( f.area2 ) {
    if (f.area2.value == "Enter a Town, City, Area or Postcode") f.area2.value="";
    if (f.area2.value == "Enter a Town, City or Postcode") f.area2.value="";
    if (f.area2.value) url += "&postcodes="+escape(f.area2.value);
  }
  
	url += "&minbeds="+f.minbeds.value;

//	if (document.location.href.match("london-residential"))
	 if(isLonResi)
	url += "&radius=0.75";
	else
	url += "&radius="+(1*f.radius.value);
	url += "&type="+f.type.value;
	if (f.developments.value) url += "&developments="+f.developments.value;
	if (f.plots.value) url += "&plots="+f.plots.value;
	if (f.devid.value) url += "&devid="+f.devid.value;
	if (f.min_acreage) url += "&min_acreage="+f.min_acreage.value;
	if (f.max_acreage) url += "&max_acreage="+f.max_acreage.value;
	if (f.farms.value) url += "&farms="+f.farms.value;
	if (f.farms2) url += "&farms2="+f.farms2.value;
	if (f.lonresi.value) url += "&lonresi="+f.lonresi.value;
	if (f.stype.value) url += "&stype="+f.stype.value;
  
  if( f.resdev )
    if (f.resdev.value) url += "&resdev="+f.resdev.value;
  if( f.rdsite )
    if (f.rdsite.value) url += "&rdsite="+f.rdsite.value;


	if (PAGE!="map" && param2("ids")) url +="&ids="+param2("ids");

	if (param2("developments")=="true" || param2("resdev")=="true"  || param2("farms2")=="true") { }
	else
	if (f.lat.value)
	{
	url += "&lat="+f.lat.value;
	url += "&lng="+f.lng.value;
	
	}
	else
	if (typeof settings=="undefined")
	{
		//SK, 13.11.2009: cause search not work with empty lat and  lng
		if (f.stype.value=="resi"){
			url += "&county="+escape(f.area2.value);
		} else {
			url += "&lat="+lat;
			url += "&lng="+lng;
		}
	}
	else
	{
	url += "&lat="+settings.lat;
	url += "&lng="+settings.lng;
	}


	if (PAGE=="list" && tabToGoTo=="list")
	url += "&levels="+param2("levels");

	if (PAGE=="list" && tabToGoTo=="slideshow" && param2("devid")!="")
	{
	url += "&levels="+param2("levels") + "&lat="+param2("lat")+"&lng="+param2("lng")+"&radius="+param2("radius");
	}

	url = url.replace("lng= ","lng=");

	tabToGoTo="";
	//url += "&ids="+propertyIds;


	return url;
}

function showSlide(theHtml)
{
	document.getElementById("slideshowpanel").innerHTML=theHtml;
}

function formAlterSpeed()
{
	if (!slideTimer) return;
	clearTimeout(slideTimer);
	nextSlide();	
}

function getSlideshowInner(id)
{	
	
	rm2.doRequest ("handleRequestGeneric","../php/slideshowinner.php?type=b&id="+id+"&count="+slideCounter+"&total=" + slideIds.length,"showSlide");
//	window.open ("../php/slideshowinner.php?type=b&id="+id+"&count="+slideCounter+"&total=" + slideIds.length,dipa);
}

function startSlideshow()
{
	getSlideshowInner (slideIds[slideCounter]);
	slideCounter++;
//	slideTimer=setTimeout("nextSlide()", document.forms.slidecontrol.speed.value);
}

function nextSlide()
{
	getSlideshowInner (slideIds[slideCounter]);
	slideCounter++;
	if (slideCounter==slideIds.length) slideCounter=0;
	slideTimer=setTimeout("nextSlide()", document.forms.slidecontrol.speed.value);
}

function changeUrl(url)
{
	document.location = url;
}

function slideshowLink()
{
  return slideshowLinkGeneric("..");
}

function slideshowLinkGeneric(path) {
	if (currentResultsInRadius==0) return showDiv("pop_swaptabs"); 
	tabToGoTo="slideshow";
	//window.open ("../search/slideshow.php?cpage=1&a=slideshow" + flattenForm() + "&office="+document.forms.myform.office.value);

	if (param2("farms2")=="true")
        {
        if (PAGE=="map")
	return changeUrl(path+"/search/slideshow.php?cpage=1&a=slideshow" + flattenForm() + "&office="+document.forms.myform.office.value + mapboundary.flatten() + "&z=" + settings.zoomlevel);
        else
        {
        extra="&x1="+param2("x1")+"&x2="+param2("x2")+"&y1="+param2("y1")+"&y2="+param2("y2")+"&z="+param2("z");
	return changeUrl(path+"/search/slideshow.php?cpage=1&a=slideshow" + flattenForm() + "&office="+document.forms.myform.office.value + extra);
        }
        }


	return changeUrl(path+"/search/slideshow.php?cpage=1&a=slideshow" + flattenForm() + "&office="+document.forms.myform.office.value);
}

function mysiteLink(flatten,page) {
  mysiteLinkPath(flatten,page,"..")
}

function mysiteLinkPath(flatten,page,path) {
	var searchform = "";
	if (!flatten)
    searchform = flattenForm() + "&su=true";
	changeUrl(path+"/mysite/mydetails.php?" + searchform + "&page="+page);
}

function logoutLink(flatten,page) {	
  logoutLinkPath(flatten,page,"..");
}

function logoutLinkPath(flatten,page,path) {	
	var searchform = "";
	if (!flatten)
    searchform = flattenForm() + "&su=true";
	changeUrl(path+"/mysite/homepage.php?logout=true&" + searchform  + "&page="+page);
}

function emailupdatesLink(flatten,page)
{
	var searchform = "";
	if (!flatten)
	searchform = flattenForm() + "&su=true";
	changeUrl("../mysite/emailupdates.php?" + searchform + "&page="+page);
}

function savedLink(flatten,page)
{
	var searchform = "";
//	if (!flatten) searchform = flattenForm() + "&su=true";
	changeUrl("../mysite/savedproperties.php?" + searchform  + "&page="+page);
}



function registerLink(flatten,page)
{
	var searchform = "";
	if (!flatten)
	searchform = flattenForm() + "&su=true";
	changeUrl("../mysite/register.php?" + searchform  + "&page="+page);
}

function loginLink(flatten,page)
{
	var searchform = "";
	if (!flatten)
	searchform = flattenForm() + "&su=true";
	changeUrl("../mysite/login.php?" + searchform  + "&page="+page);
}

function alterHouses(val)
{
	alert (val);
}

function isSafari()
{
	
	var ua = navigator.userAgent;

	if (ua.indexOf("Safari")>0 || param2("safari")=="true") 
	return true;

	return false;
}

function mapLink() {
  return mapLinkGeneric("..");
}

function mapLinkGeneric(path) {
	if (isSafari()) {
		//document.getElementById("dipa_info").style.display='block';
		document.getElementById("dipa_info").innerHTML='Sorry, but the map currently doesn\'t work in safari';
		return;
	}
	var extra="";

	if (currentResultsInRadius>=40 && !param2("z")) {
    $("popLocationText").innerHTML='<p>Sorry!</p><p>There are too many properties to show on map, please refine your search.</p>';
    showDiv("pop_nolocation");
    return;
  }

	if (currentResultsInRadius==0) return showDiv("pop_swaptabs");

	if ( param2("developments")=="true" || param2("resdev")=="true" || param2("farms2")=="true") {

		var maxLat = param2("y2");
		var minLat = param2("y1");
		var maxLng = param2("x1");
		var minLng = param2("x2");
		var lat = ((maxLat - minLat)/2) + 1*minLat;
    var lng = ((minLng - maxLng)/2) + 1*maxLng;

		if (isNaN(lat))
		{
			alert ('You cannot view the map for more than 1 area');
			return;
		}

		extra="&lat="+lat+"&lng="+lng+"&z="+param2("z"); //"&action=fitmap&ids="+ propertyIds;
	}

	return changeUrl(path+"/search/map.php?" + flattenForm() + "&office="+document.forms.myform.office.value+extra);
}

function param2(w) { var p= location.search; if (p.length==0) return ""; p= p.substring(1, p.length); var pairs = p.split("&"); for (var i=0; i<pairs.length; i++) { var pv = pairs[i].split("="); if (pv[0] == w) return pv[1]; } return ""; }


function listLink(page) {
  return listLinkGeneric( page, ".." );
}

function listLinkGeneric(page, path) {
	tabToGoTo = "list";

	if (param2("county")) dipacounty=param2("county");
	if (currentResultsInRadius==0) return showDiv("pop_swaptabs"); 
	if (typeof(page)=="undefined") page=1;
	if (param2("developments")=="true" || param2("resdev")=="true"  || param2("farms2")=="true")
	{
	if (PAGE=="map")
	return changeUrl(path+"/search/?a=list_view" + flattenForm() + "&p="+page + "&office="+document.forms.myform.office.value + mapboundary.flatten() + "&z=" + settings.zoomlevel);
	else
	{
	extra="&x1="+param2("x1")+"&x2="+param2("x2")+"&y1="+param2("y1")+"&y2="+param2("y2")+"&z="+param2("z");
	return changeUrl(path+"/search/?a=list_view" + flattenForm() + "&p="+page + "&office="+document.forms.myform.office.value + extra);
	}
	}
	else if (dipacounty=="off5" || dipacounty=="LKN" || dipacounty=="LCD" || dipacounty=="FLH" || dipacounty=="SLN" || dipacounty=="off1" || dipacounty=="off2" || dipacounty=="off3" || dipacounty=="off4" || dipacounty=="off5")
	return changeUrl(path+"/search/?a=main_search" + flattenForm() + "&p="+page + "&from=lonresihome&office=" + dipacounty.replace("off","")) + "&";
	else
	return changeUrl(path+"/search/?a=main_search" + flattenForm() + "&p="+page + "&office="+document.forms.myform.office.value + "&county=" + dipacounty);
}

function sortByLink(sort)
{
	var extra = "";
	var al = "main_search";
	if (param2("developments")=="true"  || param2("farms2")=="true")
	{
	extra="&x1="+param2("x1")+"&x2="+param2("x2")+"&y1="+param2("y1")+"&y2="+param2("y2")+"&z="+param2("z");
	al = "list_view";
	}
	add='';
	if( promotionPage == true )
	{
		add = "&promotion=true";
	}
	changeUrl("../search/?a="+al + flattenForm() + "&orderby="+sort + "&office="+document.forms.myform.office.value + "&levels=" + param2("levels") + extra + "&county=" + param2("county")+add);
}

function perPageLink(sort)
{
	var extra = "";
	var al = "main_search";
	if (param2("developments")=="true"  || param2("farms2")=="true")
	{
	extra="&x1="+param2("x1")+"&x2="+param2("x2")+"&y1="+param2("y1")+"&y2="+param2("y2")+"&z="+param2("z");
	al = "list_view";
	}
	
	add='';
	if( promotionPage == true )
	{
		add = "&promotion=true";
	}
	changeUrl("../search/?a="+al + flattenForm() + "&ppp="+sort + "&office="+document.forms.myform.office.value + "&levels=" + param2("levels") + extra + "&county=" + param2("county")+add);
}

//Open House Day Edit
function sortByLinkOpenHouse(sort)
{
	var extra = "";
	var al = "main_search";
	if (param2("developments")=="true"  || param2("farms2")=="true")
	{
	extra="&x1="+param2("x1")+"&x2="+param2("x2")+"&y1="+param2("y1")+"&y2="+param2("y2")+"&z="+param2("z");
	al = "list_view";
	}
	changeUrl("../search_openday/?a="+al + flattenForm() + "&orderby="+sort + "&office="+document.forms.myform.office.value + "&levels=" + param2("levels") + extra + "&county=" + param2("county")) + "&promotion=true";
}

function perPageLinkOpenHouse(sort)
{
	var extra = "";
	var al = "main_search";
	if (param2("developments")=="true"  || param2("farms2")=="true")
	{
	extra="&x1="+param2("x1")+"&x2="+param2("x2")+"&y1="+param2("y1")+"&y2="+param2("y2")+"&z="+param2("z");
	al = "list_view";
	}
	
	changeUrl("../search_openday/?a="+al + flattenForm() + "&ppp="+sort + "&office="+document.forms.myform.office.value + "&levels=" + param2("levels") + extra + "&county=" + param2("county")) + "&promotion=true";
}

// Open House Day Edit End

function doArea()
{
	var ar = document.forms[0].area2.value;
	if (ar.length<1) return;

	for (var i=0;i<places.length;i++)
	{
		var bits = places[i].split(",");
		if (bits[0]==ar) 
		{
		presearch(bits[1],bits[2])
		return;
		}
	}
}

//var miles = new Array(5,10,25); this is now being generated from PHP because it's different for farms, lonresi etc

function sClass(el){
if(el.className=='teal') el.className='red';else el.className='teal';
}

function resetArrowButtons() {
  var btn_arr = document.getElementsByClassName('imgLeftArrowButton');
  for( var i=0; i<btn_arr.length; i++ ) {
    var el = btn_arr[i];
    if( el ) {    
      //el.src = el.src.replace("btn_mysite_props", "red_ofice_icon");
      PNGswitch2(el.id, "btn_mysite_props", "red_ofice_icon");
      el.style.borderLeft = "none";
    }  
  }
  var link_arr = document.getElementsByClassName('tealGeneric');
  for( var i=0; i<link_arr.length; i++ ) {
    var el = link_arr[i];
    if( el ) {   
      if( el.id.indexOf('linkMilesRed') > -1 )
      el.className = "redGeneric";
    }  
  }  
}

function freeLinks(number,radius)
{
  for (i=0; i<availableRadius.length; i++) {
    if (document.getElementById("radius" + availableRadius[i]))
      document.getElementById("radius" + availableRadius[i]).checked=false;
  
    if(document.getElementById("linkMiles"+availableRadius[i])) {
      document.getElementById("linkMiles"+availableRadius[i]).className="teal";
      document.getElementById("linkMiles"+availableRadius[i]).style.color="#85875D";
    }
  }
  
  if(document.getElementById("linkMiles"+radius)) {
    document.getElementById("linkMiles"+radius).className="red";
    document.getElementById("linkMiles"+radius).style.color="#CA001A";
  }

  if( document.getElementById("radius" + radius) )
    document.getElementById("radius" + radius).checked=true;
  
  
  if( document.getElementById("btnArrow_"+radius) ) {
    resetArrowButtons();
    //document.getElementById("btnArrow_"+radius).src = document.getElementById("btnArrow_"+radius).src.replace("red_ofice_icon", "btn_mysite_props");
    PNGswitch2( "btnArrow_"+radius, "red_ofice_icon", "btn_mysite_props" );
    document.getElementById("btnArrow_"+radius).style.borderLeft = "2px solid #ffffff";
    document.getElementById("linkMilesRed"+radius).className = "tealGeneric";
  }
  
  	if (document.getElementById("map_overlay_link")){
		document.getElementById("map_overlay_link").href="javascript:void(listLink());";
	}
  
	if($("home-page-search-button")){
		$("home-page-search-button").disabled = false;
		$("home-page-search-button").className='';
	}
	
	if($("london-residental-search-buttom")){
		 $("london-residental-search-buttom").disabled = false;
		 $("london-residental-search-buttom").className='';
		}
  
  
	var lat = document.forms.myform.lat.value;
	var lng = document.forms.myform.lng.value;
	//alert ('b4');
  
  if(showingMap==true){

    //alert($('mapradimage').src);
    
        //map.src="tile.php?height=205&width=205&lat="+lat+"&lng="+lng+"&style=strutt&radius="+radius;
	//$("map_overlay")
  //document.img_map.src="tile.php?height=205&width=205&lat="+lat+"&lng="+lng+"&style=strutt&radius="+radius;
	var z=1;

	if (radius=="0.25") z=16;
	if (radius=="0.5") z=15;
	if (radius=="0.75") z=14;
	if (radius==1) z=13;
	if (radius==5) z=11;
	if (radius==10) z=10;
	if (radius==25) z=9;
	if (radius==40) z=8;
  
  if(mymap) {
    mymap.SetCenterAndZoom(new VELatLong(lat, lng), z);
  }

	//window.open ("tile.php?height=205&width=205&lat="+lat+"&lng="+lng+"&style=strutt&radius="+radius);
	/* 
  if( $('mapradimage').src != "undefined" && $('mapradimage').src != undefined ) {
    $('mapradimage').src='../images/home_map_radius_'+ radius + '.png'; 
  } else {
    $('map_overlay_link').innerHTML = PNGswitch( $('map_overlay_link').innerHTML, '../images/home_map_radius_'+ radius + '.png' );
  }  
  */
  
  /*
  alert(document.mapradimage.src);
	document.mapradimage.src='../images/home_map_radius_'+ radius + '.png';
	alert(document.mapradimage.src);
  */
	$('map_overlay').style.visibility='visible';
 	}
	

	document.forms.myform.radius.value = radius;
	
	if(document.getElementById(listMask)){
		document.getElementById(listMask).style.display='none';
		document.getElementById(slideshowMask).style.display='none';
		
		document.getElementById(listButton).style.display='block';
		document.getElementById(slideshowButton).style.display='block';  
	}

	if(document.getElementById(listMask)){
		//document.getElementById(listMask).style.display='none';
		//document.getElementById(slideshowMask).style.display='none';
	
		if (number<=40 && !isSafari()){
			document.getElementById(mapMask).style.display='none';
			document.getElementById(mapButton).style.display='block';
		}
		if (number>40){
			document.getElementById(mapButton).style.display='none';
		}
		//$("london-residental-search-buttom").disabled = false;
		//$("london-residental-search-buttom").className='';
	}
	
	currentResultsInRadius=number;
  //pngfix();
}

var initialLoad=true;
var showingMap=true;
var mapMask='map_mask';
var listMask='list_mask';
var slideshowMask='slideshow_mask';
var mapButton='button_map';
var listButton='button_list';
var slideshowButton='button_slideshow';
var txtSelectSearchRadius="<div class='home-radius-title'><img src='../images/txt_select_radius.gif' alt='select your radius'/></div>";
var noPropertiesText="<b>Sorry, no relevant properties found.<b/>";
var dipacounty="";
var selectedLonresi="";

function numProps (num,extra,mylat,mylng)
{
	document.getElementById("indicator1").style.display="none";
	dipacounty="";
	var theOtherText="";
  	var num_temp = num;
  
  	if( selectedLonresi == "officeSearch" ) 
	{
		var arg_arr = extra.split("=");
		if(typeof(init_lonresi_search)=="function")
		{	
			init_lonresi_search();
		}	
    		num_temp = arg_arr[1];
		theOtherText="&nbsp; ";    
	
		if(typeof(num_temp)!="string")
		{
			num_temp="0";
		}
		
    		var msg_obj = document.getElementById("searchMessageOffice");

			if($("london-residental-search-buttom")){
				$("london-residental-search-buttom").disabled = true;
				$("london-residental-search-buttom").className='london-residental-search-button-disabled';
			}
		

		
		
		if(num_temp==0)
                {
			if($("london-residental-search-buttom")){
				$("london-residental-search-buttom").disabled = true;
				$("london-residental-search-buttom").className='london-residental-search-button-disabled';
			}
             	}
                else
                {
                			if($("london-residental-search-buttom")){
						$("london-residental-search-buttom").disabled = false;
						$("london-residental-search-buttom").className='';
					}
                }		

		if(num_temp==0)
		{
			theOtherText="no properties available";
		}
		if(num_temp==1)
		{
			theOtherText="1 property available";
		}
		if(num_temp>1)
		{
			 theOtherText=num_temp+" properties available";
		}
		document.getElementById("searchMessageOffice").innerHTML= theOtherText;   
		dipacounty=num;
    		currentResultsInRadius=num_temp;;
		var word="county";
		var regx = /\d/;
    		if (num.match(regx))
		{
		      word="postcode area";
		}
		var url =  "../search/index.php?a=main_search" + flattenForm() + "&county=" + num;
		//console.log("url: "+url);

		return;
	}

	if (isNaN(num) && 1)
	{
		//alert("Sorry test!");
    		if(selectedLonresi=="areas") 
		{

			if(extra==0)
			{
				$("london-residental-search-buttom").disabled = true;
				$("london-residental-search-buttom").className='london-residental-search-button-disabled';
			}
			else
			{
				$("london-residental-search-buttom").disabled = false;
				$("london-residental-search-buttom").className='';

			}

			theOtherText="Sorry, there are no properties available";
			if(extra==1)
			{
				
				theOtherText="1 property available";
			}
      			if(extra>1)
			{
				theOtherText=extra+" properties available";
			}
			if(document.getElementById("lonresiInfo")) 
			{
				document.getElementById("lonresiInfo").innerHTML= theOtherText;
				document.getElementById("lonresiInfo").style.display='block';
      			}
    			currentResultsInRadius=extra;
			dipacounty=num;
	                currentResultsInRadius=num_temp;;
	                var word="county";
        	        var regx = /\d/;
                	if (num.match(regx))
	                {
        	              word="postcode area";
	                }
        	        var url =  "../search/index.php?a=main_search" + flattenForm() + "&county=" + num;
                	//console.log("url: "+url);

			return;
    		}
		dipacounty=num;
    		currentResultsInRadius=extra;
    
		var word="county";
    		var regx = /\d/;
    		if (num.match(regx))
		{
			word="postcode area";
		}
    
		var url =  "../search/index.php?a=main_search" + flattenForm() + "&county=" + num;
    
		if(document.getElementById("dipa_info"))
		{
			document.getElementById("dipa_info").innerHTML = extra + " properties found for this "+word+".<br>&nbsp;<br>To view results on a map or slideshow please<br>narrow your search criteria to a town, city or <br>postcode";
		}
  
    	//document.getElementById(mapButton).style.display='none';
		//document.getElementById(mapMask).style.display='none';
		//document.getElementById(slideshowMask).style.display='none';
		//document.getElementById(slideshowButton).style.display='none';
		//document.getElementById(listButton).style.display='block';
		//document.getElementById(listMask).style.display='none';
		
				
		if (document.getElementById(listButton)) {
			className = document.getElementById('london-residental-search-buttom').className 
			className = className.replace('-disabled','');
			document.getElementById('london-residental-search-buttom').className = className;
			document.getElementById('london-residental-search-buttom').disabled = "";
			//london-residental-search-button
		}
    
		if (extra==0)
		{
			document.getElementById(listMask).style.display='block';
		}
  
    //document.location=url;
		return;
	}
	if(selectedLonresi=="locationSearch" || selectedLonresi == "officeSearch" )
	{
		// section working ok	
    		theOtherText="&nbsp; ";    
		if(num==0)
		{
			theOtherText="Sorry, there are no properties available";
		}
		if(num==1)
		{
			theOtherText="1 property available";
		}
		if(num>1)
		{
			theOtherText=num+" properties available";
		}
		document.getElementById("searchMessage").innerHTML= theOtherText;
	} 
  
	var theform = document.forms.myform;

	theform.lat.value = mylat;
	theform.lng.value = mylng;
	
	if($("london-residental-search-buttom")){		
		$("london-residental-search-buttom").disabled = false;
		$("london-residental-search-buttom").className='';
	}
	if(document.getElementById(mapMask)){
		
		
		if (!isSafari()){
			document.getElementById(mapMask).style.display='block';
		}
		document.getElementById(listMask).style.display='block';
		document.getElementById(slideshowMask).style.display='block';
	  
		document.getElementById(mapButton).style.display='none';
		document.getElementById(listButton).style.display='none';
		document.getElementById(slideshowButton).style.display='none';
		
	}
	
  	var theText = "<a href=''>"+num + " properties found</a> within " + document.forms.myform.radius.value + " miles";

	availableRadius = miles; //new Array();

	match=0;
	if (1) //num==0 || 1)
	{
		theText = txtSelectSearchRadius; 
		for (i=0; i<extra.length;i++) 
		{
			if (extra[i]>0) 
			{
    //	availableRadius[availableRadius.length] = miles[i];
				theText+="<div class='home-radius-box'><input type='radio' name='radius"+miles[i]+"' id='radius"+miles[i]+"' onclick='freeLinks(\""+extra[i]+"\",\""+miles[i]+"\");'><a class='teal' id='linkMiles"+miles[i]+"'  style='font-weight:400;' href='javascript:void(freeLinks(\""+extra[i]+"\",\""+miles[i]+"\"));'>" + extra[i] + " properties within " + miles[i] + " mile radius</a></div>";
  				match++;
      			}
    		}
		var loc = document.location.href;
    		if(isLonResi && num>0)
		{
			// && (!loc.match("london-residential"))) {
			freeLinks(extra[extra.length-2], miles[extra.length-2]);
    		}
	 }

	if (match==0)
	{
		theText =noPropertiesText;
	}
	if (num>0 && isLonResi)
	{
		freeLinks(extra[extra.length-2], miles[extra.length-2]);
	}
  
	if(document.getElementById("dipa_info"))
	{
		document.getElementById("dipa_info").innerHTML = theText;
	}
}
var ttt='';
function numPropsGeneric (num,extra,mylat,mylng)
{
        //document.getElementById("dipa_loading").style.display="none";
        document.getElementById("indicator1").style.display="none";
        var theform = document.forms.myform;

        theform.lat.value = mylat;
        theform.lng.value = mylng;
	
	$("london-residental-search-buttom").disabled = true;
	$("london-residental-search-buttom").className='london-residental-search-button-disabled';
				
        var theText = "<a href=''>"+num + " properties found</a> within " + document.forms.myform.radius.value + " miles";

        availableRadius = miles; //new Array();

        match=0;
        if (1) //num==0 || 1)
        {
        theText = "<div class='home-radius-title'></div>";
        for (i=0; i<extra.length;i++)
        if (extra[i]>0)
        {
//      availableRadius[availableRadius.length] = miles[i];
         theText+="<div class='home-radius-box'><input type='radio' name='radius"+miles[i]+"' id='radius"+miles[i]+"' onclick='freeLinks(\""+extra[i]+"\",\""+miles[i]+"\");'><a class='teal' id='linkMiles"+miles[i]+"'  style='font-weight:400;' href='javascript:void(freeLinks(\""+extra[i]+"\",\""+miles[i]+"\"));'>" + extra[i] + " properties within " + miles[i] + " mile radius</a></div>";
        match++;
        }

        }

        if (match==0)
        theText = "<span class='red'>Sorry, no relevant properties found.</span>";

        document.getElementById("dipa_info").innerHTML = theText;
}

function updatevisualizer()
{
        document.getElementById("radius_mask").style.display="none";
        var theform = document.forms.myform;

        if (theform.radius.value==560)
        theform.radius.value=5;
	//window.open("tile.php?height=170&width=170&lat="+lat+"&lng="+lng+"&style=strutt&radius="+theform.radius.value);

       // document.img_map.src="tile.php?height=170&width=170&lat="+lat+"&lng="+lng+"&style=strutt&radius="+theform.radius.value;

        updatedipa();
}


var previousurl = "";


function updateGenericDipa()
{
                var flats=true;
                var houses=true;
                var ptype ="";
                var url="";

        if(document.getElementById("auto_complete")) document.getElementById("auto_complete").style.display="none";
        var theform = document.forms.myform;
        var radius = "0.000000001";//theform.radius.value;
        var minprice = flatPrice(theform.minprice.value);
        var maxprice = flatPrice(theform.maxprice.value);

        /*minprice=minprice.substring(1);
        maxprice=maxprice.substring(1);

        maxprice=maxprice.replace(",","");
        minprice=minprice.replace(",","");*/

        if (theform.ptype.value=="All") {houses=true;flats=true;ptype="HouseandFlat";}

        if (theform.ptype.value=="House") {flats=false;ptype="house";}
        if (theform.ptype.value=="Flat") {houses=false;ptype="flat";}
        var minbeds = theform.minbeds.value;
        var area = escape(theform.area2.value);


        var farms = theform.farms.value;
        var lonresi = theform.lonresi.value;
    if (theform.type.value=="Buy" || theform.type.value=="buy") type="b";
    else if (theform.type.value=="Rent" || theform.type.value=="rent") type="r";
    else if(theform.type.value=="b" || theform.type.value=='r') type=theform.type.value;

                var stype = document.getElementById("stype").value;

//      alert ('update');
        if (area=="" || area.match ("Postcode")) return;


        //document.getElementById("dipa_loading").style.display="block";
        document.getElementById("indicator1").style.display="block";
        var url = "/html2/xml/searchnumber.php?a=slideshow&postcodes="+area+"&minbeds="+minbeds+"&minprice="+minprice+"&maxprice="+maxprice+"&radius="+radius+"&otherradius="+miles.join(",")+"&houses="+houses+"&flats="+flats+"&farms="+farms+"&lonresi="+lonresi+"&stype="+stype+"&type="+type+"&ptype="+ptype+"&lat="+lat+"&lng="+lng;//+"&lat="+lat+"&lng="+lng;
//      window.open(url);
        //alert (url);
        //document.getElementById('debugger').innerHTML = url;
        if (url==previousurl)
        {
        //document.getElementById("dipa_loading").style.display="none";
        document.getElementById("indicator1").style.display="none";
                return; // alert ('done already' + url);
        }
        previousurl=url;
      //window.open (url,'dipawindow');

        rm2.doRequest ("handleRequestGeneric",url,"numProps");

}

function updateOfficesOnLonResi(a)
{
	selectedLonresi="officeSearch";
	numProps(rm2.ocode,a);
}
function updatedipa(field)
{
		var flats=true;
		var houses=true;
		var ptype ="";
		var url="";
		
	if(document.getElementById("auto_complete")) document.getElementById("auto_complete").style.display="none";
        var theform = document.forms.myform;
        var radius = "0.000000001";//theform.radius.value;
	 var loc = document.location.href;
//    	if(isLonResi) radius = "0.75";
        var minprice = flatPrice(theform.minprice.value);
        var maxprice = flatPrice(theform.maxprice.value);
		
	/*minprice=minprice.substring(1);
	maxprice=maxprice.substring(1);
	
	maxprice=maxprice.replace(",","");
	minprice=minprice.replace(",","");*/
	
	if (theform.ptype.value=="House") {flats=false;ptype="house";}
	if (theform.ptype.value=="Flat") {houses=false;ptype="flat";}
	if (theform.ptype.value=="All") {houses=true;flats=true;ptype="HouseandFlat";}
        var minbeds = theform.minbeds.value;
        var area = escape(theform.area2.value);
        if (area=="" || area.match ("Postcode")) return;

	if (field=="area3"){
		if($("searchMessage")) $("searchMessage").innerHTML="";
                if($("lonresiInfo")) $("lonresiInfo").innerHTML="";
	        area = theform.area3.value;
	}
        var farms = theform.farms.value;
        var lonresi = theform.lonresi.value;
    if (theform.type.value=="Buy" || theform.type.value=="buy") type="b";
    else if (theform.type.value=="Rent" || theform.type.value=="rent") type="r";
    else if(theform.type.value=="b" || theform.type.value=='r') type=theform.type.value;
		
		var stype = document.getElementById("stype").value;
		
//	alert ('update');


        //document.getElementById("dipa_loading").style.display="block";
        document.getElementById("indicator1").style.display="block";
        var url = "../xml/searchnumber.php?a=slideshow&postcodes="+area+"&minbeds="+minbeds+"&minprice="+minprice+"&maxprice="+maxprice+"&radius="+radius+"&otherradius="+miles.join(",")+"&houses="+houses+"&flats="+flats+"&farms="+farms+"&lonresi="+lonresi+"&stype="+stype+"&type="+type+"&ptype="+ptype+"&lat="+lat+"&lng="+lng;//+"&lat="+lat+"&lng="+lng;

	if (isLonResi)
	url+="&highlightradius=0.75";

	if (field=="area3")
	{
		var val = document.forms.myform.area3.value;
		var code="";
		if (type=="b")
		{
		if (val=="Kensington") code="LKN";
		if (val=="Fulham") code="FLH";
		if (val=="Chelsea") code="LCD";
		if (val=="Knightsbridge") code="SLN";
		}
		else
		{
		if (val=="Kensington") code="off3";
		if (val=="Fulham") code="off4";
		if (val=="Chelsea") code="off5";
		if (val=="Knightsbridge") code="off2";
		}
		
		url = "../xml/propertiesperoffice.php?type="+type+"&minprice="+minprice+"&maxprice="+maxprice+"&minbeds="+minbeds+"&offices="+code.replace("off","");
		rm2.id="updateOfficesOnLonResi";
		rm2.ocode=code;
		   rm2.doRequest("handleRequestGeneric", url, "updateOfficesOnLonResi");
		return;
	}
//	window.open(url);
	//alert (url);
	//document.getElementById('debugger').innerHTML = url;
	if (url==previousurl) 
	{
        //document.getElementById("dipa_loading").style.display="none";
        document.getElementById("indicator1").style.display="none";
		return; // alert ('done already' + url);
	}
	previousurl=url;
//	window.open (url,'dipawindow');

        rm2.doRequest ("handleRequestGeneric",url,"numProps");

}

function updatedipa_lonresi(field) {

  var flats=true;
  var houses=true;
  var ptype ="";
  var url="";
		
	if(document.getElementById("auto_complete")) 
    document.getElementById("auto_complete").style.display="none";
    
  var theform = document.forms.myform;
  var radius = "0.000000001";//theform.radius.value;
  var minprice = flatPrice(theform.minprice.value);
  var maxprice = flatPrice(theform.maxprice.value);
	
	if (theform.ptype.value=="House") {flats=false;ptype="house";}
	if (theform.ptype.value=="Flat") {houses=false;ptype="flat";}
	if (theform.ptype.value=="All") {
    houses=true;flats=true;ptype="HouseandFlat";
  }
  
  var minbeds = theform.minbeds.value;
  var area = theform.area2.value;

	if (field=="area1")
	{
//	alert ("ar1=" + theform.area1.value);
	area = $('area1').value;//theform.area3.value;
	}

  var farms = theform.farms.value;
  var lonresi = theform.lonresi.value;
  
  if (theform.type.value=="Buy" || theform.type.value=="buy") type="b";
  else if (theform.type.value=="Rent" || theform.type.value=="rent") type="r";
  else if(theform.type.value=="b" || theform.type.value=='r') type=theform.type.value;
		
  var stype = document.getElementById("stype").value;

  if ((area=="" || area.match ("Postcode")) && field!="area1") return;

  document.getElementById("indicator1").style.display="block";
  var url = "../xml/searchnumber.php?a=main_search&postcodeintact=true&postcodes="+area+"&minbeds="+minbeds+"&minprice="+minprice+"&maxprice="+maxprice+"&radius="+radius+"&otherradius="+miles.join(",")+"&houses="+houses+"&flats="+flats+"&farms="+farms+"&lonresi="+lonresi+"&stype="+stype+"&type="+type+"&ptype="+ptype+"&lat="+lat+"&lng="+lng;

	if (url==previousurl) {
    document.getElementById("indicator1").style.display="none";
		return;
	}
	previousurl=url;
  rm2.doRequest ("handleRequestGeneric",url,"numProps");
}

function parsePlaces(num,ps)
{
places = ps;
doMatch2();
}

function presearch(lt,lg)
{
	dd.style.display='none';
	lat = lt;
	lng = lg;
//	alert (lat + "," + lng);
	if (document.forms.myform)
	{
	document.forms.myform.lat.value=lat;
	document.forms.myform.lng.value=lng;
	}
	if (document.getElementById("radius_mask"))
	updatevisualizer();
	else
	document.img_map.src="../php/tile.php?height=100&width=100&lat="+lat+"&lng="+lng+"&style=strutt&radius=40";
}

function doMatch()
{
	//if (running) return;
        running=true;

	if (document.forms[0].area2.value.length<1) return;
	var url = "../xml/searchplaces.php?place=" +  document.forms[0].area2.value;
//window.open(url);
	rm2.doRequest ("handleRequestGeneric", url, "parsePlaces");	
}

function doMatch2()
{
	oldV = document.forms[0].area2.value;
	var newV="";
	var regExp = new RegExp ("^"+oldV,"i");
	var inner="";
	var high="on";
	var c=0;
	var done=new Array();
	matches=0;

	for (var i=0;i<places.length;i++)
	{
		//places[i] = places[i].replace ("'","");
		//if (places[i].match (regExp) && !done[places[i]]) { if (++c==1) newV = places[i]; inner+="<div id='dd"+c+"' class='"+high+"' onKeyUp='checkEnter(event)' onmouseover='this.className=\"on\";' onmouseout='this.className=\"off\";' onclick=\"document.forms[0].area2.value='"+places[i]+"';highlighted="+c+";\">"+places[i]+"</div>"; high="off"; matches++; done[places[i]]=true; }
		var bits = places[i].split(",");
		if (++c==1) newV = bits[0]; 
		inner+="<div id='dd"+c+"' class='"+high+"' onKeyUp='checkEnter(event)' onmouseover='this.className=\"on\";' onmouseout='this.className=\"off\";' onclick='document.forms[0].area2.value=\""+bits[0]+"\";highlighted="+c+";presearch(\""+bits[1]+"\",\""+bits[2]+"\");'>"+bits[0]+"</div>"; high="off"; matches++; done[bits[0]]=true;
	}
	highlighted=1;
	dd.innerHTML=inner;
	dd.style.height=(matches*12)+"px";

	if (matches==0) highlight();

	if(newV != oldV && document.forms[0].area2.createTextRange && newV)
	{
		document.forms[0].area2.value = newV;
		var rNew = document.forms[0].area2.createTextRange();
		rNew.moveStart('character', oldV.length) ;
		rNew.select();
	}
	if (newV!= oldV &&  document.forms[0].area2.setSelectionRange && newV)
	{
		document.forms[0].area2.value = newV;
		document.forms[0].area2.setSelectionRange(oldV.length, newV.length);
	}

	if (places.length==1 && 0)
	{
		var bits = places[0].split(",");
		presearch(bits[1],bits[2]);
	}
	running=false;
}

function alterDiv (name, newContent)
{
	var d = document.getElementById(name);
	d.innerHTML=newContent;
	d.style.display='block';
}
function stopRKey(evt) {
	var evt  = (evt) ? evt : ((event) ? event : null);
	var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	if ((evt.keyCode == 13) && (node.type=="text")) { return false; }
}

document.onkeypress = stopRKey;

function checkEnter(e)
{
	var unicode=e.keyCode? e.keyCode : e.charCode;

	if (unicode==13)
	return doArea();	
	
	if (unicode==40)
	{
		if (highlighted==matches) return;

		if (highlighted>0)
		document.getElementById('dd'+highlighted).className='off';
		highlighted++;
		
		document.getElementById('dd'+highlighted).className='on';
		document.forms[0].area2.value=document.getElementById('dd'+highlighted).innerHTML;
	}
	else	
	if (unicode==38)
	{
		if (highlighted==1) return highlight();

		document.getElementById('dd'+highlighted).className='off';
		highlighted--;
		if (highlighted>0)
		{
		document.getElementById('dd'+highlighted).className='on';
		document.forms[0].area2.value=document.getElementById('dd'+highlighted).innerHTML;
		}
	}
	else if (!";8;46;37;38;39;40;33;34;35;36;45;".match(";"+unicode+";"))
	doMatch();

	dd.style.display='block';
}	

function highlight()
{
if (!dd) return;
highlighted=0;
dd.style.display='none';
return true;
}
function clearForm() {
	for(i=document.forms.myform.maxpriceInput.options.length;i>=0;i--){
			document.forms.myform.maxpriceInput.options[i]=null;
		}
	for(i=document.forms.myform.minpriceInput.options.length;i>=0;i--){
			document.forms.myform.minpriceInput.options[i]=null;
		}
}
//----Search Functions ----//
function sptype(t){
	if(t=="house"){
		document.forms.myform.houses.value=='true';
		document.forms.myform.flats.value=='false';
	}else{
		if(t=="flat"){
			document.forms.myform.houses.value=='false';
			document.forms.myform.flats.value=='true';
		}else{
			document.forms.myform.houses.value=='true';
			document.forms.myform.flats.value=='true';
		}
	}
}
function srad(rad){
	var tmp = parseInt(rad);
	if(tmp!=0){
		$('radius').value=tmp;
	}		
}
function $(el){
	return document.getElementById(el);
}
function combotext_onkeydown(e,oText,oSelect,zindex){
	if(zindex == "") zindex = "9999";
	blurAll(oSelect.id);
	keyCode = e.keyCode;  
  
	if (keyCode == 40 || keyCode == 38) {  
		$(oSelect.id).style.display = 'block';  
		oSelect.focus();  
		comboselect_onchange(oSelect, oText);  
	}  
	else if (keyCode == 13) {  
		e.cancelBubble = true;  
		if (e.returnValue) e.returnValue = false;  
		if (e.stopPropagation) e.stopPropagation();  
		comboselect_onchange(oSelect, oText);  
		$(oSelect.id).style.display='none';  
		oText.focus();  
	return false;  
	}  else if(keyCode == 9) return true;  
	else { 
		$(oSelect.id).style.display = 'block';  
		$(oSelect.id).focus();
  
		$(oSelect.id).style.zIndex=zindex;  
		var c = String.fromCharCode(keyCode);  
		c = c.toUpperCase();   
		toFind = oText.value.toUpperCase() + c;  
	
		for (i=0; i < oSelect.options.length; i++){  
			//oSelect.options[i].onmouseover= function() {alert('mouseover');}
			nextOptionText = oSelect.options[i].text.toUpperCase();  
			if(toFind == nextOptionText){  
				oSelect.selectedIndex = i;  
			break;  
			}  
  
			if(i < oSelect.options.length-1){  
				lookAheadOptionText = oSelect.options[i+1].text.toUpperCase() ;  
				if( (toFind > nextOptionText) &&   (toFind < lookAheadOptionText) ){  
					oSelect.selectedIndex = i;  
				break;  
				}  
			} else {  
				if(toFind > nextOptionText){  
					oSelect.selectedIndex = oSelect.options.length-1; // stick it at the end  
				break;  
				}  
			}  
		}  
	}  
}  

function comboselect_show(el,zindex){
	//alert('el='+el);
	if(zindex == "") zindex = "9999";
	blurAll(el.id);
  document.getElementById(el).style.display = 'block';
  document.getElementById(el).style.zIndex=zindex; 
  document.getElementById(el).focus();
}  

function comboselect_onchange(oSelect,oText) {  

	if(oSelect.selectedIndex != -1) {
		var tmpTmp = oText.value = oSelect.options[oSelect.selectedIndex].text; 
  }
  
  if( oSelect.name == "TypeType_G" ) {  
    $('type').value = ( oSelect.options[oSelect.selectedIndex].text == 'Buy' ) ? 'b' : 'r';
    
    if(PAGE=="map") {      
      updateMapForm("maxprice","Maximum",'myform');
      updateMapForm("maxprice","Maximum",'cpform');
      updateMapForm("minprice","Minimum",'myform');
      updateMapForm("minprice","Minimum",'cpform');
      mapmanager.populate();
    } /*else {
      updateForm("rPriceTo","Max","myform");
      updateForm("rPriceFrom","Min","myform");      
    }*/
    
  } else if( oSelect.name == "rTyperType_G" ) {
    $('type').value = ( oSelect.options[oSelect.selectedIndex].text == 'Buy' ) ? 'b' : 'r';
    updateForm("rPriceTo","Maximum","myform");
    updateForm("rPriceFrom","Minimum","myform");
  } 
  window.focus();
  //alert( oSelect.name+" "+oText.name +" "+ oText.value );
}  

function comboselect_onkeyup(keyCode,oSelect,oText){  
	if (keyCode == 13) {  
		comboselect_onchange(oSelect, oText);  
		$(oSelect.id).style.display='none';  
		oText.focus();  
	 }  
}  


function blurAll(el){
if (typeof boxes!="undefined")
	for(i=0;i<boxes.length;i++){
		if(el!=boxes[i] && $(boxes[i])){
			$(boxes[i]).style.display='none';	
			//alert($(boxes[i])+'.style.display='+$(boxes[i]).style.display);
		}
	}	
}


function mo(el) {
  img_el = el.firstChild;
  img_el = el.childNodes[0];
  var node;
  if( img_el.tagName == "SPAN" ) {
    if( img_el.id ) {
      PNGmo(img_el.id);
    } else {
      node = el.innerHTML;
      if(node.match("_over")) {
        el.innerHTML = node.replace("_over","_off");
      } else {
        el.innerHTML = node.replace("_off","_over");
      }
    }
  } else {
    node = el.childNodes[0].src;
    if(img_el.src.match("_over")) {
      img_el.src = img_el.src.replace("_over","_off");
    } else {
      img_el.src = img_el.src.replace("_off","_over");
    }
  }
}


function mo2(el) {
  if(el.firstChild.src.match("_over"))
    el.firstChild.src=el.firstChild.src.replace("_over","_off");
  else
    el.firstChild.src=el.firstChild.src.replace("_off","_over");
}

function PNGmo(myID)
{
   var strOver  = "_over"
   var strOff = "_off"
   var oSpan = document.getElementById(myID);
   var currentAlphaImg = oSpan.filters(0).src;
   if (currentAlphaImg.indexOf(strOver) != -1)
      oSpan.filters(0).src = currentAlphaImg.replace(strOver,strOff)
   else
      oSpan.filters(0).src = currentAlphaImg.replace(strOff,strOver)
}

function PNGswitch2(myID, over, off) {
  if( document.getElementById(myID).src != "undefined" && document.getElementById(myID).src != undefined ) {
    if( document.getElementById(myID).src.indexOf( off ) < 0 )
      document.getElementById(myID).src = document.getElementById(myID).src.replace(over,off);
  } else {  
    var oSpan = document.getElementById(myID);    
    if( oSpan.filters ) {
      var currentAlphaImg = oSpan.filters(0).src;
      if( currentAlphaImg.indexOf( off ) < 0 )
        oSpan.filters(0).src = currentAlphaImg.replace(over, off);
    }
  }
}

function PNGswitch( str, img ) {
  var prefixSplit_str = "AlphaImageLoader(src='";
  var suffixSplit_str = "', sizing";
  var temp_arr = str.split( prefixSplit_str );
  var prefix = temp_arr[0] + prefixSplit_str;
  temp_arr = str.split( suffixSplit_str );
  var suffix = suffixSplit_str + temp_arr[1]; 
  var ret_str = prefix + img + suffix;
  return ret_str;
}

function check_email(emailStr)
{
	if (emailStr == "") {return true;}
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	//alert("Email address seems incorrect (check @ and .'s)")
	return false
}
var user=matchArray[1]

var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    //alert("The username doesn't seem to be valid.")
    return false
}

var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        //alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	//alert("The domain name doesn't seem to be valid.")
    return false
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   //alert("The address must end in a three-letter domain, or two letter country.")
   return false
}

if (len<2) {
   var errStr="This address is missing a hostname!"
   //alert(errStr)
   return false
}

return true;
}

var pound=String.fromCharCode(163);

function flatType(type){
	if(type.toLowerCase()=='buy' || type.toLowerCase()=='b'){
		return 'b';
	}
	
	if(type.toLowerCase()=='rent' || type.toLowerCase()=='r'){
		return 'r';
	}
}

function flatPrice(price) {
  if(price.match(",")) price=price.replace(",","");

  if(price.match("Minimum")||price=="0K") {
    return "0";
  }

  if(price.match("Maximum")) {
    price="999999999";
    return price;
  }

  if(price.match(/M|m/)) {
    price=price.replace(/M|m/,"");
    price=price.replace(/\D*/,"");
    price=price*1000000;
  } else if(price.match(/K|k/)) {
    price=price.replace(/K|k/,"000");
    price=price.replace(/\D*/,"");
  }

  //if (price) price=price.replace(pound,"");

  if( typeof price == "string" ) {
    myregexp = new RegExp(pound);
    price=price.replace(myregexp,"");
  }
  //document.getElementById("debugger").innerHTML=price;

  return price;
}


function getMaxPrice(price){
	var maxprice = new Array();
	maxprice['b']='9999999';
	maxprice['r']='9999999';
	type = flatType(type);
	return maxprice[type];
}

function fancyPrice(price){

	price = parseInt(price);
	if(price==999999999) {
		price=getMaxPrice(document.getElementById("type").value);
	} 
  
  if(price>=1000000){
		price=price/1000000;
		price=price+"M";
	}else if(price>10000){
		price=price/1000;
		price=price+"K";
	}else if(price>1000){
		price=price.replace(price.substr((price.length-3)),"")+","+price.substr((price.length-3))
	}else if (price==0){
		//price = 'No minimum';
		price = 'Minimum';
	}
	
	if (price != 'No minimum' && !price.match(/over/) && price != 'Minimum' && price != 'Maximum' ) {
		price=pound+price;
	}
	return price;
}
	

function toohigh()
{
	//alert ('toohigh!!!');
	el='controlpanel';
	loginOffsetTop=0;
	loginOffsetLeft=0;
	$('toohigh').style.top=($(el).offsetTop+ loginOffsetTop) + 'px';
        if(loginOffsetLeft==null){ var left="250px"; }else{ var left=($(el).offsetLeft + loginOffsetLeft)+ 'px';}
		$('toohigh').style.left=left;
        $('toohigh').style.display='block';
}
//----------------------------------------------------------//

function isNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   }

var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
if (param2("minbeds"))
document.onmousemove = getMouseXY;
var tempX = 0
var tempY = 0

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  if (document.Show)
  {
  document.Show.MouseX.value = tempX
  document.Show.MouseY.value = tempY
  }
  return true
}

function checkform()
{
  var myform = document.forms.mydetails;
  var msg = "";
  if (myform.Password.value != myform.Password2.value) {msg += "\n    * Passwords do not match";} 
  if (msg)
  {
    alert (msg);
    return false;
  }
  return true;
}

function showMapOverlay(){
	$("map_overlay").style.visibility='visible';
}

function refresh_boxes() {}

function setFocus(Element){
	document.getElementById(Element).focus();
}
/*
function pngfix(){

var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])

	if ((version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
	      var img = document.images[i]
	      var imgName = img.src.toUpperCase()
	      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	      {
	         var imgID = (img.id) ? "id='" + img.id + "' " : ""
	         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	         var imgStyle = "display:inline-block;" + img.style.cssText 
	         if (img.align == "left") imgStyle = "float:left;" + imgStyle
	         if (img.align == "right") imgStyle = "float:right;" + imgStyle
	         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	         var strNewHTML = "<span " + imgID + imgClass + imgTitle
	         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
	         img.outerHTML = strNewHTML
	         i = i-1
	      }
	   }
	}
}
*/
/*function fixPNG(myImage) 
{
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}*/

function hidePic(el){
		document.getElementById(el).style.visibility='hidden';
}

var divMenu;
var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isNS = navigator.appName == "Netscape";

function getRef(id) {
if (isDOM) return document.getElementById(id);
if (isIE4) return document.all[id];
if (isNS4) return document.layers[id];
}

function moveRightEdge() {
if(divMenu != undefined) {

} else {
  divMenu = getRef('divMenu');
}

var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;

if (isNS4) {
yMenuFrom = divMenu.top;
yMenuTo = windows.pageYOffset + 137;
} else if (isDOM) {
yMenuFrom = parseInt (divMenu.style.top, 10);
yMenuTo = (isNS ? window.pageYOffset : document.body.scrollTop) + 30; //Specify the distance of the Floating Object from top.
}
timeoutNextCheck = 50;
if (yMenuFrom != yMenuTo) {
yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);//Specify the floating Speed high=0,slow=500. etc
if (yMenuTo < yMenuFrom)
yOffset = -yOffset;
if (isNS4)
divMenu.top += yOffset;
else if (isDOM)
//divMenu.style.left = 120;//Specifies the distance of the floating object from left.
divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
return parseInt (divMenu.style.top, 10) + yOffset;
timeoutNextCheck = 0; //Specifies the speed of reaction .
}
//setTimeout ("moveRightEdge()", timeoutNextCheck);
}

function setVisibleTop(id,adjTop,adjLeft){
if (isNS4) {
var divMenu = document["divMenu"];
divMenu.top = top.pageYOffset + 0;
divMenu.visibility = "visible";
tmp = moveRightEdge();
} else if (isDOM) {

var divMenu = getRef('divMenu');
divMenu.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + 0;
//divMenu.style.visibility = "visible";
tmp = moveRightEdge();

}
if (adjTop) {tmp=parseInt(tmp)+parseInt(adjTop);}
document.getElementById(id).style.top=tmp-70;//changed from -150 as popups were appearing below nav
if (adjLeft) {document.getElementById(id).style.marginLeft=adjLeft;}
//document.getElementById(id).style.marginLeft=50;
}


function displayMessage(str) {
  if(str != undefined && str != "") {
    alert(str);
  }
}









