function disableEnterKey(e)
{
     var key;     
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox     

     return (key != 13);
}


function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}


function OK()
{
if (document.Form2.geolocation.value == "enter area here")
      {
	alert("Please input your location");
	return false;
	}
	
}



function nongeosearch()
   {
   coordinates();
 
   }
   
function coordinates()
{
	try
	{
	var q = document.Form2.geolocation.value;
	}
	catch(e)
	{
	}

	if (q == "")
	{
	document.Form2.northing.value = "";
	document.Form2.easting.value = "";
	document.Form2.fixeddistance.value = "";
	document.Form2.submit();
	return "";
	}

		var xmlHttpReq = false;
		var northeast = "";
		var distance = "";

	if (window.XMLHttpRequest)
	{
	xmlHttpReq = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
	xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}	
		xmlHttpReq.open('GET', "geo/autocomplete.aspx?type=res&q=" + q,true);
		xmlHttpReq.onreadystatechange = function() 
		{		
			if (xmlHttpReq.readyState == 4) 
			{
				northeast = xmlHttpReq.responseText;
				var nearray = northeast .split("|");
            	document.Form2.northing.value = nearray[0];
            	document.Form2.easting.value = nearray[1];     
								
				distance = nearray[2];
				
					if (nearray[2] == "C")
					{
					distance = "10000";
					}
					if (nearray[2] == "T")
					{
					distance = "4500";
					}
					if (distance == "")
					{
					distance = 1000;
					}				
				document.Form2.fixeddistance.value = distance;
				
				document.Form2.submit();
			}
		}
		
		xmlHttpReq.send(null);	
}
	
	
	

	
$(document).ready(function()
{ 
	$("#geolocation").autocomplete("geo/autocomplete.aspx?type=auto", "delay=400");

	$('div.demo').each(function() {eval($('p', this).text()); });
		 
	$('#main p').wrap("<code></code>");

 	
	
	$("FORM").submit( function() {
	var results = $(this).serialize();
	results = decodeURI(results);
	var ptps = ""; 
	var ars = "";
	var mySplitResult = results.split("&");
	for(i = 0; i < mySplitResult.length; i++)
	{
		if (mySplitResult[i].substr(0,4) == "type")
		{
		ptps = ptps + mySplitResult[i].substr(5) + "|"
		}	
		
		if (mySplitResult[i].substr(0,4) == "area")
		{
		ars = ars + mySplitResult[i].substr(5) + "|"
		}	
	}
	
	if (ars == "|")
	{
	ars = "";
	}
	if (ptps == "|"){ptps = "";}
	if (ars == "|"){ars = "";}
	
	document.Form2.multiareas.value = ars;	
	document.Form2.multitypes.value = ptps;	
	});	
});  



function checkKey(event)
{
var iKeyCode = (window.event) ? event.keyCode : e.keyCode;
if (13 == iKeyCode)
{
return false;
}
return true;
}



