var agt=navigator.userAgent.toLowerCase();

var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

function highlight()
{
	self.focus();
	document.directory.TownID.focus();
	document.directory.TownID.select();
}

function taLimit() {
	var taObj=event.srcElement;
	if (taObj.value.length==taObj.maxLength*1) return false;
}

var ie5 = (document.getElementById&&document.all); 
if (ie5) document.attachEvent("oncontextmenu",RefreshDisplay); 

function RefreshDisplay(event) {

	window.location.reload();
}

function bookmarkhome(jplace)
{

	if(is_ie4up)
		{
		if (document.all)
			window.external.AddFavorite("http://www.restaurantuk.com",document.title);
		}
	else
		{
		alert('Not Supported By This Browser. Please Try Pressing (CTRL+D)\n\nThis site is best viewed using MSIE5+')
		}
}


function changeCellBG(el, myColor) {
	el.style.background=myColor;
}

function validateAdvanced(theForm)
{
var anyCount=0;
	
	if (theForm.TownID.value == 'Any' || theForm.TownID.value.length < 1)
		{
		anyCount = anyCount + 1
		}
	if (theForm.NameID.value.length < 1 || theForm.NameID.value == 'Any')
		{
		anyCount = anyCount + 1
		}
	if (theForm.AddressID.value.length < 1 || theForm.AddressID.value == 'Any')
		{
		anyCount = anyCount + 1
		}
	if (theForm.PostcodeID.value.length < 1 || theForm.PostcodeID.value == 'Any')
		{
		anyCount = anyCount + 1
		}
	if (theForm.CountyID.value.length < 1 || theForm.CountyID.value == 'Any')
		{
		anyCount = anyCount + 1
		}
	if (anyCount==5)
		{
		alert('Please enter a town, county, postcode or restaurant name     ')
		return false;
		}
return true;
}

function validateEmeal(theForm)
{
	validEmail = /^[_\.0-9a-z-]+\@([0-9a-z][0-9a-z-]*\.)+([a-z]{2,4})+$/i
	
	if (theForm.eCust.value.length > 0)
		{
		if (theForm.eCust.value.search(validEmail) == -1) 
			{
			alert("Please Enter A Valid Email Address!     ");
			theForm.eCust.focus();
			return false;
			}
		}
	else
		{
		alert("Please Enter Your Email Address!     ");
		theForm.eCust.focus();
		return false;
		}

	if (theForm.eArea.value.length < 1)
		{
		alert("Please Enter Your Area!     ");
		theForm.eArea.focus();
		return false;
		}
		
return true;
}

function inputFocus()
{
	self.focus();
	document.directory.TownID.focus();
	document.directory.TownID.select();
}

function changeCellBG(el, myColor) {
	el.style.background=myColor;
}
