function over_button(image) {
	if (document.images) {
		document.getElementById("mainpicture").src = image;
	}
}

function rental_or_sale_select(rental_or_sale,maxprice,minprice) {
	if (document.getElementById('maxprice')) {
		document.getElementById('maxprice').options.length=0;
		if (rental_or_sale=="rental")
		{
			if ( $("#quicksearchform").length > 0 ) {
				document.getElementById("quicksearchform").setAttribute("action","/lettings-and-management/property-search.htm");
			}
			var pricesArray=new Array(10)
			for (i=0; i <11; i++)
			pricesArray[i]=new Array(2)

			pricesArray[0][0] = "Maximum";
			pricesArray[0][1] = 0;
			pricesArray[1][0] = "£350 PCM";
			pricesArray[1][1] = 350;
			pricesArray[2][0] = "£500 PCM";
			pricesArray[2][1] = 500;
			pricesArray[3][0] = "£625 PCM";
			pricesArray[3][1] = 625;
			pricesArray[4][0] = "£750 PCM";
			pricesArray[4][1] = 750;
			pricesArray[5][0] = "£1,000 PCM";
			pricesArray[5][1] = 1000;
			pricesArray[6][0] = "£2,000 PCM";
			pricesArray[6][1] = 2000;
			pricesArray[7][0] = "£3,000 PCM";
			pricesArray[7][1] = 3000;
			pricesArray[8][0] = "£4,000 PCM";
			pricesArray[8][1] = 4000;
			pricesArray[9][0] = "£5,000 PCM";
			pricesArray[9][1] = 5000;

		} else {

			if ( $("#quicksearchform").length > 0 ) {
				document.getElementById("quicksearchform").setAttribute("action","/buying/property-search.htm");
				if (rental_or_sale=="new-build") document.getElementById("quicksearchform").setAttribute("action","/buying/new-builds.htm");
				if (rental_or_sale=="land") document.getElementById("quicksearchform").setAttribute("action","//information-for-developers.htm");
			}

			var pricesArray=new Array(13)
			for (i=0; i <14; i++)
			pricesArray[i]=new Array(2)

			pricesArray[0][0] = "Maximum";
			pricesArray[0][1] = 0;
			pricesArray[1][0] = "£100,000";
			pricesArray[1][1] = 100000;
			pricesArray[2][0] = "£125,000";
			pricesArray[2][1] = 125000;
			pricesArray[3][0] = "£150,000";
			pricesArray[3][1] = 150000;
			pricesArray[4][0] = "£175,000";
			pricesArray[4][1] = 175000;
			pricesArray[5][0] = "£200,000";
			pricesArray[5][1] = 200000;
			pricesArray[6][0] = "£250,000";
			pricesArray[6][1] = 250000;
			pricesArray[7][0] = "£300,000";
			pricesArray[7][1] = 300000;
			pricesArray[8][0] = "£400,000";
			pricesArray[8][1] = 400000;
			pricesArray[9][0] = "£500,000";
			pricesArray[9][1] = 500000;
			pricesArray[10][0] = "£1,000,000";
			pricesArray[10][1] = 1000000;
			pricesArray[11][0] = "£2,000,000";
			pricesArray[11][1] = 2000000;
		}

		var selected = false;
		for ( var i=0, len=pricesArray.length-1; i<len; ++i ){
			document.getElementById('maxprice').options[i]=new Option(pricesArray[i][0], pricesArray[i][1], selected, false)
			if ((maxprice==pricesArray[i][1]) && maxprice!='' && maxprice!=0)
			{
				document.getElementById('maxprice').options[i].selected = true;
			}
		}

		if (document.getElementById('minprice')) {
			document.getElementById('minprice').options.length=0;
			pricesArray[0][0] = "Minimum";
			for ( var i=0, len=pricesArray.length-1; i<len; ++i ){
				document.getElementById('minprice').options[i]=new Option(pricesArray[i][0], pricesArray[i][1], selected, false)
				if ((minprice==pricesArray[i][1]) && minprice!=''  && minprice!=0)
				{
					document.getElementById('minprice').options[i].selected = true;
				}
			}
		}
	}
}


var num = 1;

function lastest_property() {
	setInterval("update()", 10000);
}

function update() {
	display("latestproperty_header_padded", latestProperties[num][0]);
	display("latestproperty_photo", latestProperties[num][1]);
	display("latestproperty_footer_padded", latestProperties[num][2]);
	num++;
	if (num == latestProperties.length) num = 0;
}

function display(id, str) {
	if ( $("#"+id).length > 0 ) {
		document.getElementById(id).innerHTML = str;
	}
}


function EvalSound(soundobj) {
	var thissound= eval("document."+soundobj);
	thissound.Play();
}


var the_timeout;
function moveDiv()
{
	// get the stylesheet
	//
	var the_style = getStyleObject("mini");
	var miniimage_style = getStyleObject("mini_image");
	if (the_style)
	{
		// get the current coordinate and add movement
		//
		var current_left = parseInt(the_style.left);
		var new_left = current_left + 5;

		var current_top = parseInt(the_style.top);
		var new_top = current_top + 1;
		
		var current_width = parseInt(miniimage_style.width);
		var new_width = Math.round(current_width*0.99);

		var current_height = parseInt(miniimage_style.height);
		var new_height = Math.round(current_height*0.99);

		// set the left property of the DIV, add px at the
		// end unless this is NN4
		//
		if (document.layers) 
		{
			the_style.left = new_left;
			the_style.top = new_top;
			miniimage_style.width = new_width;
			miniimage_style.height = new_height;
		}
		else 
		{
			the_style.left = new_left + "px";
			the_style.top = new_top + "px";
			miniimage_style.width = new_width + "px";
			miniimage_style.height = new_height + "px";
		}

		// if we haven't gone to far, call moveDiv() again in a bit
		// 

		if (new_left < 900)
		{
			the_timeout = setTimeout('moveDiv();',20);
		} else if (new_left >= 900) {
			the_style.visibility = 'hidden';
		}
	}
}

function resetMini()
{
	var the_style = getStyleObject("mini");
	var miniimage_style = getStyleObject("mini_image");
	if (document.layers) 
	{
		the_style.left = -70;
		the_style.top = 550;
		miniimage_style.width = 160;
		miniimage_style.height = 78;
	}
	else 
	{
		the_style.left = -70 + "px";
		the_style.top = 550 + "px";
		miniimage_style.width = 160 + "px";
		miniimage_style.height = 78 + "px";
	}
	the_style.visibility = 'visible';
}

function getStyleObject(objectId) {
	// cross-browser function to get an object's style object given its
	if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
		return document.getElementById(objectId).style;
	} else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
		return document.all(objectId).style;
	} else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
		return document.layers[objectId];
	} else {
		return false;
	}
} // getStyleObject


function xmlhttpPost(strURL,propertiesString) {
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			display('display_area_padding',self.xmlHttpReq.responseText);
		}
	}
	self.xmlHttpReq.send(propertiesString);
}

/*
function getquerystring() {
	var form = document.forms['f1'];
	var word = form.word.value;
	qstr = 'w=' + escape(word);  // NOTE: no '?' before querystring
	return qstr;
}
*/