//	TITLE:	prop-search.js
//	CREATED:	10/5/2004
//
//	Any page that uses a control in /propertysearch-controls needs to include this file
//	AND atlas.js


//	NAME: preloadHoverImage()
//	DESCRIPTION:
//
//	used by TextButton control
//	trys to ensure the image used to replace DIV:BACKGROUND-IMAGE has been downloaded to the client prior to any
//	onMouseOver events firing, so that in the onMouseOver event the browser should pull the image from 
//	the cache rather than the websitem which should be faster
function preloadHoverImage(url){
	var img=new Image()
	img.src=url;
}

//	NAME: doPriceSearch()
//	DESCRIPTION:
//	
//	function used specifically by SearchCriteriaSelector control, which appears on every page & lets the user
//	search new or resales properties by price range
//	
//	the codebehind for propertysearch.aspx creates & initialises the values of several javascript variables used by 
//	the doPriceSearch() function below
//
//	cboPrices_clientID
//	newButton_clientID
//	resaleButton_clientID
//	searchTypeName
//	searchType
//	priceRangeName
function doPriceSearch(searchUrl){
		var searchType;//new or resales
		var searchCombo=document.getElementById(cboPrices_clientID);
		selectedPriceRange=searchCombo.options[searchCombo.selectedIndex].value;
		if(selectedPriceRange=='0'){
			return;
		}
		if(document.getElementById(newButton_clientID).checked){
			searchType=newSearch;
		}
		if(document.getElementById(resaleButton_clientID).checked){
			searchType=resaleSearch;
		}
		loadUrl(searchUrl + '?' + searchTypeName + '=' + searchType + '&' + priceRangeName + '=' + selectedPriceRange + '&' + language);
	}
	
//	NAME: doSearch()
//	DESCRIPTION:
//
//	function that will load the search page for any type of search where the search criteria are in a single combo
//	currently this covers 100% of atlas search types. 
function doSearch(searchUrl,criteriaComboId,searchTypeName,searchType,criteriaName){

	var searchCombo=document.getElementById(criteriaComboId);
	selectedSearchCriteria=searchCombo.options[searchCombo.selectedIndex].value;
		if(selectedSearchCriteria=='0'){
			return;
		}
		
	loadUrl(searchUrl + '?' + searchTypeName + '=' + searchType + '&' + criteriaName + '=' + selectedSearchCriteria + '&' + language);
}

//	NAME: resetPrice()
//	DESCRIPTION:
//
function resetPrice(){
	document.getElementById(cboPrices_clientID).options[0].selected=true;
}

//	NAME: changeBackground()
//	DESCRIPTION:
//
function changeBackground(thecell,theurl) {
	document.getElementById(thecell).style.background = 'url(' + theurl + ')'
}

//	NAME: loadUrl()
//	DESCRIPTION:
//
function loadUrl(url){
	window.location.href=url;
}

//	NAME: drawMainImage()
//	DESCRIPTION:
//
//	used for swapping in the supplied image into the main image div on the property details screen
function drawMainImage(url){
	
	drawImageInDiv(url,'mainImageDiv',300,248);
	
	//only quicktime currently needs a control panel
	hideControlPanel();
}



//	NAME: showControlPanel()
//	DESCRIPTION:
//
// makes visible the div under the main image if it exists
function showControlPanel(){

	var cp=document.getElementById('mainImageControlPanel');
	if(cp!=null)cp.style.display='block';
	
}

//	NAME: hideControlPanel()
//	DESCRIPTION:
//
// hides the div under the main image if it exists
function hideControlPanel(){

	var cp=document.getElementById('mainImageControlPanel');
	if(cp!=null)cp.style.display='none';
}

//	NAME: drawQuicktime()
//	DESCRIPTION:
//
//	used for displaying any quicktime movies in the main image div on the property details screen
function drawQuicktime(url){

		//show the quicktime instruction
		showControlPanel();
		
	var qtHTML='<OBJECT id=\"mainQt\" codeBase=\"http://www.apple.com/qtactivex/qtplugin.cab\" height=\"240\" width=\"320\" classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" VIEWASTEXT>';
			qtHTML=qtHTML + ' <param name=\"src\" value=\"' + url + '\">';
			qtHTML=qtHTML + ' <param name=\"autoplay\" value=\"true\">';
			qtHTML=qtHTML + ' <param name=\"controller\" value=\"false\">';
			qtHTML=qtHTML + ' <EMBED src=\"' + url + '\" width=\"320\" height=\"240\"';                  
			qtHTML=qtHTML + ' autoplay=\"true\" CONTROLLER=\"false\"';      
			qtHTML=qtHTML + ' PLUGINSPAGE=\"http://www.apple.com/quicktime/download/\">';
			qtHTML=qtHTML + ' </EMBED>';
			qtHTML=qtHTML + ' </OBJECT>';

		document.getElementById('mainImageDiv').innerHTML=qtHTML;

		
		
	}
	