  function validate_search() 
  {
   /* if (document.getElementById('maker_F').value=='') 
     {
      alert('Select a Manufacturer');
     } 
    else*/ 
    if ((document.dealer_search.postcode_F.value==''))
     {
      alert('Please enter a postcode');
     } 
    else 
     {
      //document.getElementById('dealerSrch').submit();
      validate_postcode('postcode_F');
     }
  }

  function validateDealerSearch() {
    if (document.dealer_search.dlr_postcode_F.value == '') {
      alert('Please, fill a postcode field.');
      return false;
    } else {
      return true;
    }
  }

// Require ajax to validate postcode via the database!

  function validate_postcode(i_postcode)
  {
    postcode = document.getElementById(i_postcode);
    ajaxpack.getAjaxRequest('/ajax-validate-postcode.php', 'postcode_F='+document.getElementById(i_postcode).value, postcodeCallback, 'txt');
  }


 function postcodeCallback()
  {
    var myajax=ajaxpack.ajaxobj;
    var selected;
    if (myajax.readyState == 4){ //if request of file completed
      if (myajax.status==200 || window.location.href.indexOf("http")==-1){
        //attr = myajax.responseText.split("\n");
        if (myajax.responseText !=  "")
        {
	 alert ("Invalid Postcode");
        }
	else
	{
	 document.getElementById('dealerSrch').submit();
	}
      }
    }
  }
  
  function MapWindow(postcode) {    
	url = "/map.php?postcode="+postcode;
	window.open(url,"MAP","status = 0, resizable = 1, location = 0, toolbar = 0, menubar = 0, width = 600, height = 400");    
  }

  
  function DealerMapWindow(wgs_lan,wgs_lng,postcode) {    
	if(wgs_lan != 0){
		url = "/map.php?lan="+wgs_lan+"&lng="+wgs_lng;		
	} else {
		url = "/map.php?postcode="+postcode;
	}
    window.open(url,"MAP","status = 0, resizable = 1, location = 0, toolbar = 0, menubar = 0, width = 600, height = 400");    
  }


