// JavaScript Document


//function updatefrmPostcode(value, position){
//	if (position == 1) {document.locationFinder.frm_postcode.value = value + "," + document.locationFinder.county.value; }
//	if (position == 2) {document.locationFinder.frm_postcode.value = document.locationFinder.town.value + "," + value; }
//	if (position == 3) {document.locationFinder.frm_postcode.value = value; } }


function combineSearchFields()
{
	document.locationFinder.frm_postcode.value = "";
	document.locationFinder.frm_postcode.value += document.locationFinder.street.value+", ";
	document.locationFinder.frm_postcode.value += document.locationFinder.town.value+", ";
	document.locationFinder.frm_postcode.value += document.locationFinder.county.value+", ";
	document.locationFinder.frm_postcode.value += document.locationFinder.postcode.value;
}






function usePointFromPostcode(postcode, page) { 

	isValid = true

	if (page == "search") { //Search page volidation
		if (document.locationFinder.frm_postcode.value == ", , , ")
		{
			alert("Please enter at least one line in the address fields");
			isValid = false;
		}
		if ((document.locationFinder.length.value == "") || (document.locationFinder.width.value == "") || (document.locationFinder.thickness.value == ""))
		{
			alert("Please enter a length, width and thickness");
			isValid = false;
		}
		
		
		
		
		
	}
	else  //Contact page volidation
	{
		
		if (document.locationFinder.frm_postcode.value == ", , , ") 
		{
			alert("Please enter at least one line in the address fields");
			isValid = false;
		}
	}
	
	
	if (isValid == true) 
	{
	//postcode += ", GB";

	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';
	document.getElementById('SearchButton').src = '/Images/Layout/ButtonGoDisabled.png';
	
	
	
}





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);
}




function Show(tagId){
	document.getElementById(tagId).style.visibility='visible';
}


function Hide(tagId){
	document.getElementById(tagId).style.visibility='hidden';
}




function ValidateForm(){

	var Fail = false ;
	var message = '';
	
	if ( document.forms[1].name.value == '' ) {
		message += 'Please enter your name\n';
		Fail = true
	}
	
	if (( document.forms[1].tel.value == '' ) &&  ( document.forms[1].email.value == '' )) {
		message += 'Please enter your telephone number or your email address';
		Fail = true
	}
	
	if (Fail == false) {
		return true;
		
	}
	else {
		alert(message);
		return false;
	}
	
}




function ValidateVolumeForm() {
	
	if(document.ProductQuote.postcode.value==''){
		alert("Please enter a postcode");
	} else {
	document.ProductQuote.submit();
	}
}

















