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 validate(theForm)
{
	validSearch = /^[ 0-9a-z-'&!,()]+$/i
	
	if (theForm.PCTownID.value.length < 1 || theForm.PCTownID.value == 'Enter postcode or town')
		{
		alert("Please Enter Town or Postcode.");
		theForm.PCTownID.focus();
		return false;
		}

	if (theForm.PCTownID.value.search(validSearch) == -1) 
		{
		alert('Your entry contains invalid characters. Please try again.      ')
		theForm.PCTownID.focus();
		return false;
		}

//	if (theForm.PCTownID.value.toUpperCase() == 'LONDON')
//		{
//		frames['searchIframe'].frames['myIframe'].location ='advanced_town3.asp?sql_flag=1'
//		searchDiv.style.visibility='visible';
//		return false;
//		}
	properClose=0;
return true;
}

function validate_old(theForm)
{
	validSearch = /^[ 0-9a-z-'&!()]+$/i
	
	if (theForm.PCTownID.value.length < 2 || theForm.PCTownID.value == 'Enter postcode or town')
		{
		alert("Please Enter Town, County, Postcode, or Restaurant Name.");
		theForm.PCTownID.focus();
		return false;
		}
	properClose=0;
return true;
}

function inputFocus()
{
	self.focus();
	document.directory.TownID.focus();
	document.directory.TownID.select();
}

function changeCellBG(el, myColor) {
	el.style.background=myColor;
}

function setIn(obj, imgsrc)
{
	obj.src = imgsrc;
}

function fadeInOut(obj, imgsrc)
{
if(is_ie5_5up)
	{
	obj.style.filter='progid:DXImageTransform.Microsoft.Fade(duration=1)';
	parent.applyImageTransition(obj,imgsrc)
	}
else
	{
	obj.src = imgsrc;
	}
}

//var but_path='images/110107/panel_advanced.gif'
//var but_path_over='images/110107/panel_advanced_over.gif'
var but_path='images/110107/map_search.gif'
var but_path_over='images/110107/map_search_over.gif'
var but_toggle = 1

function loadAdvanced(override)
{
	if(override)
		{
		but_toggle = override
		}
	if(but_toggle==0)
		{
		but_toggle=1
		frames['myIframe'].location.replace('advanced_search.asp')
		button_advanced.src='images/110107/map_search_over.gif'
		but_path='images/110107/map_search.gif'
		but_path_over='images/110107/map_search_over.gif'
		map_advanced_text.innerHTML ='<FONT face=Verdana>or use the advanced form below</FONT>'
		button_advanced.title='Click to search for restaurants using a map'
		}
	else
		{
		but_toggle=0
		frames['myIframe'].location.replace('uk_map_2.asp')
		button_advanced.src='images/110107/panel_advanced_over.gif'
		but_path='images/110107/panel_advanced.gif'
		but_path_over='images/110107/panel_advanced_over.gif'
		map_advanced_text.innerHTML ='<FONT face=Verdana>or click on the map</FONT>'
		button_advanced.title='Click for advanced restaurant search'
		}
}
