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 < 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 validateEmeal(theForm)
{
	validEmail = /^[_\.0-9a-z-]+\@([0-9a-z][0-9a-z-]*\.)+([a-z]{2,4})+$/i
	
	if (theForm.restaurateur_email.value.length > 0)
		{
		if (theForm.restaurateur_email.value.search(validEmail) == -1) 
			{
			alert("Please Enter A Valid Email Address!     ");
			theForm.restaurateur_email.focus();
			return false;
			}
		}
	else
		{
		alert("Please Enter Your Email Address!     ");
		theForm.restaurateur_email.focus();
		return false;
		}

	if (theForm.restaurateur_name.value.length < 1)
		{
		alert("Please Enter Your Name     ");
		theForm.restaurateur_name.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;
}


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;
	}
}

function openWebsite(web_url,win_id,width,height)
{
var ct;
var slotFound;
var alreadyAllocated=0;
var strHTML;

	if(!width) width=800
	if(!height) height=600

//	width = 930
//	height = 730

	win_ref=window.open(web_url, win_id,'width=' + width + ',height=' + height + ',scrollbars=1,resizable=1');

	win_ref.focus()
}

function popoff() {
	searchDiv.style.visibility='hidden';
}

function popon() {
  searchDiv.style.visibility='visible';
}
