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 taLimit() {
	var taObj=event.srcElement;
	if (taObj.value.length==taObj.maxLength*1) return false;
}

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.");
		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 validateEmeal(theForm)
{
	validSearch = /^[ 0-9a-z-'&!£()]+$/i
	validEmail = /^[_\.0-9a-z-]+\@([0-9a-z][0-9a-z-]*\.)+([a-z]{2,4})+$/i
	
	if (theForm.emeal_name.value.length < 1)
		{
		alert("Please enter your name.     ");
		theForm.emeal_name.focus();
		return false;
		}

	if (theForm.emeal_name.value.search(validSearch) == -1) 
		{
		alert("Your name contains illegal characters!     ");
		theForm.emeal_name.focus();
		return false;
		}


	if (theForm.emeal_email.value.length > 0)
		{
		if (theForm.emeal_email.value.search(validEmail) == -1) 
			{
			alert("Please Enter A Valid Email Address!     ");
			theForm.emeal_email.focus();
			return false;
			}
		}
	else
		{
		alert("Please enter your e-mail address.     ");
		theForm.emeal_email.focus();
		return false;
		}

	if (theForm.emeal_postcode.value.length < 2)
		{
		alert("Please enter your postcode.     ");
		theForm.emeal_postcode.focus();
		return false;
		}

	if (theForm.emeal_postcode.value.search(validSearch) == -1) 
		{
		alert("Your postcode contains illegal characters!     ");
		theForm.emeal_postcode.focus();
		return false;
		}


	if (theForm.emeal_password.value.length < 6)
		{
		alert("Your password must be at least 6 characters long.     ");
		theForm.emeal_password.focus();
		return false;
		}	

	if (theForm.emeal_password.value.search(validSearch) == -1) 
		{
		alert("Your password contains illegal characters!     ");
		theForm.emeal_password.focus();
		return false;
		}

return true;
}

var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=yes,directories=no,status=yes,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings); win.focus();}

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 popoff() {
	searchDiv.style.visibility='hidden';
}

function popon() {
  searchDiv.style.visibility='visible';
}
