
function popup(img){
   var src = img.src.replace('/images/thumbs/', '/images/content/');
   window.open('popup_image.php?img='+src, 'wpop', 'width=615,height=415');
}

function popWin(n, u, w, h, x, r, s) {
  str = "width="+w+",height="+h+",resizable="+r+",status=0,scrollbars="+s;
  rem = window.open(u, n, str);
  if(rem != null) {
    if(rem.opener == null)
      rem.opener = self;
  }
  if(x == 1) {
   return rem;
  }
}

function foto(img) {    
	w=window.open(img,"new","left=40,width=415,height=300 resizable=1");
	w.document.write( "<HTML><body TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 ><IMG SRC='" + img + "' width='100%' heigth='100%'></BODY></HTML>");
}

function foto360(img){
	w=window.open('/photo360.php?img='+img,"new","left=40,width=320,height=240 resizable=0");
}
function video(flv){
	w=window.open("/flowplayer/index.php?path="+flv,"new","left=40,width=360,height=240");
}


function tour(url){
	w=window.open(url,"tour","left=40,width=720,height=500,resizable=0");
}

function map(id,restx,resty,zoom) {
	m=window.open("dynamap.php?ref=" + id, "map","width=535,height=395");
}

var xmlHttp;
function createXMLHttpRequest(){
	if(window.XMLHttpRequest){
		xmlHttp = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		try{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
			}
		}
	}
}

function propertySearch() {
	createXMLHttpRequest();
	var loc = document.getElementById('location').value;
	var typ = document.getElementById('type').value;
	var bed = document.getElementById('bedrooms').value;
	var url = "/ajax_search.php?location=" + loc + "&type=" + typ + "&bedrooms=" + bed;
	xmlHttp.onreadystatechange  =  function(){onStateChange();}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function onStateChange(str){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){
			var returntxt=unescape(xmlHttp.responseText);
			document.getElementById("properties").innerHTML = returntxt;
		}
	}
}

function selectProperty(){
	var loc = document.getElementById('location').value;
	var typ = document.getElementById('type').value;
	var bed = document.getElementById('bedrooms').value;
	var property = document.getElementById("property").value;
	if (property == "all") {
		var location = "/properties.php?location=" + loc + "&type=" + typ + "&bedrooms=" + bed +"&property=" + property;
		window.location.href = location;
	} else if (property != "") {
		var location = "/layout.php?location=" + loc + "&type=" + typ + "&bedrooms=" + bed +"&property=" + property;
		window.location.href = location;
	}
	
}

function required() {
	if (document.contact_form.email.value == "") {
		alert("Please fill in your email address");
		return false;
	} else {
		return true;
	}
}