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 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,     \nor use \'Advanced Search\'.");
		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;
		}

	properClose=0;
return true;
}

function applyImageTransition (obj, imgsrc)
{
    obj.filters(0).Apply();
    obj.src=imgsrc;
    obj.filters(0).Play();
}

function setIn(obj, imgsrc)
{
	obj.src = imgsrc;
}

function fadeInOut(obj, imgsrc)
{
if(is_ie5_5up)
	{
	obj.style.filter='progid:DXImageTransform.Microsoft.Fade(duration=1)';
	applyImageTransition(obj,imgsrc)
	}
else
	{
	obj.src = imgsrc;
	}
}

var oInterval = "";

function fadeImages2()
{
	fadeInOut(menu_home,'images/110107/but_home2.jpg')
	fadeInOut(menu_book,'images/110107/but_favourites2.jpg')
	fadeInOut(menu_emeal,'images/110107/but_emeal2.jpg')
	fadeInOut(menu_food,'images/110107/but_food2.jpg')
	fadeInOut(menu_team,'images/110107/but_team2.jpg')
	fadeInOut(menu_contact,'images/110107/but_contact2.jpg')
}

function fadeImages1()
{
	if(menu_contact.complete)
		{
		clearInterval(oInterval);
		setTimeout("fadeImages2()",1500)
		}
}

function loadImages()
{
	menu_home.src='images/110107/but_home_over2.jpg'
	menu_book.src='images/110107/but_favourites_over2.jpg'
	menu_emeal.src='images/110107/but_emeal_over2.jpg'
	menu_food.src='images/110107/but_food_over2.jpg'
	menu_team.src='images/110107/but_team_over2.jpg'
	menu_contact.src='images/110107/but_contact_over2.jpg'

	oInterval = setInterval("fadeImages1()",1500)
}

var slideno = 2;
var slidemax = 21;

function loadnext()
{
	picture_buffer.src='images/050107/intro_bg_play' + slideno + '.jpg'
}

function trans1()
{
if(is_ie5_5up)
	{
	intro_img.style.filter='progid:DXImageTransform.Microsoft.Fade(duration=1)';
	applyImageTransition(intro_img,'images/050107/intro_bg_play' + slideno + '.jpg')
	}
else
	{
	intro_img.src='images/050107/intro_bg_play' + slideno + '.jpg'
	}
	
	slideno = slideno + 1;
	if(slideno == (slidemax+1))
		{
		slideno=2
		}
	
transtime2=setTimeout("loadnext()",1500)
transtime=setTimeout("trans1()",3000)
}


function initHome()
{
	loadImages();
	trans1();
}

function FocusInput(el)
{
	if(el.value == "Enter postcode or town" || el.value=="Enter restaurant name")	el.value = ""
}

var but_path='images/110107/panel_advanced.gif'
var but_path_over='images/110107/panel_advanced_over.gif'
var but_toggle = 0

function loadAdvanced(override)
{
	if(override)
		{
		but_toggle = override
		}
	if(but_toggle==0)
		{
		but_toggle=1
		frames['myIframe'].location ='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 ='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'
		}
}

function openWebsite(web_url,win_id,rst_name)
{
var ct;
var slotFound;
var alreadyAllocated=0;
var strHTML;

	win_ref=window.open(web_url, win_id,'width=800,height=600,scrollbars=1,resizable=1');

	win_ref.focus()
}
