// JavaScript Document

function usePointFromPostcode(postcode, page) { 

	//if ((document.locationFinder.frm_product.value == "") || (document.locationFinder.frm_postcode.value == "")){
	if (document.locationFinder.frm_product.value == "" ){
		alert("Please select a product before submitting a search.");
	}
	else {
	//postcode += ", GB";

	if (page=="print"){

		document.locationFinder.action="/print-map.asp"
		document.getElementById('printButton').innerHTML = 'Loading';

		setTimeout("document.getElementById('printButton').innerHTML = 'Print';" ,2500);
		
	} else {
		document.locationFinder.action="/default.asp"
		document.locationFinder.target="_self"
		activateSearch();
	}	
	
	var localSearch = new GlocalSearch();
	localSearch.setSearchCompleteCallback(null, 
	function() {
	if (localSearch.results[0])
		{
		var resultLat = localSearch.results[0].lat;
		var resultLng = localSearch.results[0].lng;
		var point = new GLatLng(resultLat,resultLng); 
		document.locationFinder.property_lon.value = resultLng;
		document.locationFinder.property_lat.value = resultLat;
		}else{
		document.locationFinder.property_lon.value = "";
		document.locationFinder.property_lat.value = "";
		
		}
	});	
	localSearch.execute(postcode + ", UK");
	
	setTimeout("document.locationFinder.submit();" ,2000);
	
	}
}



function activateSearch(){
	document.locationFinder.SearchButton.disabled=true;
	document.getElementById('SearchButton').value = 'Processing';
}





function EnablePostcode(value){
	if(value==""){
		alert("Please select a product");
		document.locationFinder.frm_postcode.value="";
	}else{
		document.locationFinder.frm_postcode.disabled=false;
	}
}





function showlocation(area){
	document.getElementById('GoogleMapsLocation').style.display='block';
	document.getElementById('GoogleMapsSalesOffice').style.display='none';
}






function showsales(area){
	document.getElementById('GoogleMapsLocation').style.display='none';
	document.getElementById('GoogleMapsSalesOffice').style.display='block';
}



function updateSelectedProduct(selected_value, selected_name){
	document.getElementById('drop').style.display='none';
	//document.getElementById('frm_product').value=selected_value;
	document.locationFinder.frm_product.value=selected_value;
	document.getElementById('selectLabel').innerHTML=selected_name;
}



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}




























