function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var http = createRequestObject();
function createRequestObject() 
{
	var xmlhttp; 
	if (window.XMLHttpRequest)
	{
 		xmlhttp=new XMLHttpRequest();
  	}
	if (window.ActiveXObject)
  	{
  		// IE6, IE5
  		return new ActiveXObject("Microsoft.XMLHTTP");
 		try 
       		{ 
        		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
        	}
		catch(e) 
        	{
			try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
			catch(f) 
			{ 
				xmlhttp=null; 
			}
		}
		if(!xmlhttp&&typeof XMLHttpRequest!="undefined") 
		{
			xmlhttp=new XMLHttpRequest();
		}
	}
	return  xmlhttp;
}
function getForm(string) 
{
	document.body.style.cursor = 'wait';
	var url = '/ourmenu/ourmenu.numo?' + string
	var dvelement = document.getElementById('right_form');
	dvelement.innerHTML = "<div id='right_content'><h1>Our Menus: </h1><br /><img src='/image/image_epos/37-1.gif'></div>";
	try
	{
		http.open('GET', url);
		http.onreadystatechange = handleResponseText;
		http.send(null);
	}
	catch(e){alert("error saving");}
	finally{document.body.style.cursor = 'default';}
}
function getView(ldiv,idiv,params)
{
	var url = '/ourmenu/ourmenu_ad.numo?o=2&' + params
	var dvelement = document.getElementById(idiv);
	dvelement.innerHTML = "<table width='600' border='0' cellpadding='0' cellspacing='2'><tr><td align=right width='540'><img src='/image/image_epos/37-1.gif'></td><td align='right' width='40'>&nbsp;</td></tr></table>";
	try
 	{
		http.open('GET', url);
		http.onreadystatechange = function(){ handleResponseTextPreFormGet(ldiv,idiv,params)}; 
		http.send(null);
	}
	catch(e){alert('error saving');}
	finally{document.body.style.cursor = 'default';}
}
function getDel(iddel,ldiv,idiv,params) 
{
	document.body.style.cursor = 'wait';
	var url = '/ourmenu/ourmenu_ad.numo?o=3&iddel=' + iddel
	var dvelement = document.getElementById(idiv);
	dvelement.innerHTML = "<table width='600' border='0' cellpadding='0' cellspacing='2'><tr><td align=right width='540'><img src='/image/image_epos/37-1.gif'></td><td align='right' width='40'>&nbsp;</td></tr></table>";
	try
	{
		http.open('GET', url);
		http.onreadystatechange = function(){ handleResponseTextDel(ldiv,idiv,params)}; 
		http.send(null);
	}
	catch(e){alert("error deleting");}
	finally{document.body.style.cursor = 'default';}
}
function closeView(ldiv,idiv,params)
{
	var dvelement = document.getElementById(idiv);
	dvelement.innerHTML = "<table cellspacing='0' cellpadding='0' height='0'><tr><td></td></tr></table>"
	
	//get count for icon			
	var urlc = '/ourmenu/ourmenu_ad.numo?o=4&' + params
	try
 	{
		http.open('GET', urlc);
		http.onreadystatechange = function(){ handleResponseTextCountOpen(ldiv,idiv,params)}; 
		http.send(null);
	}
	catch(e){alert('error changing icon');}
}
function getFormPre(string) 
{
	document.body.style.cursor = 'wait';
	var url = '/ourmenu/ourmenu_pre.numo?' + string
	var dvelement = document.getElementById('preForm');
	dvelement.innerHTML = "<h1>Select Menu: </h1><br /><img src='/image/image_epos/37-1.gif'>";
	try
	{
		http.open('GET', url);
		http.onreadystatechange = handleResponseTextPre;
		http.send(null);
	}
	catch(e){alert("error loading form");}
	finally{document.body.style.cursor = 'default';}
}
function subFormPre(odiv,idiv,i,im,is,it) 
{
	document.body.style.cursor = 'wait';
	var params = 'i=' + i + '&im=' + im + '&is=' + is + '&it=' + it
	var ldiv = is + '_' + it
	var dvelement = document.getElementById(idiv);
	dvelement.innerHTML = "<table width='600' border='0' cellpadding='0' cellspacing='2'><tr><td align=right width='540'><form name='iform' id='iform' style='margin:0px; padding:0px' onsubmit='return false;'><input type='text' name='one' value='guest name' size='40' class='bodystyle' style='margin:0px; padding:0px' onblur=enterGuest('" + odiv + "','" + ldiv + "','"+ idiv +"','" + params + "','" + i + "','" + im + "','" + is + "','" + it + "') onclick=document.iform.one.value=''></form></td><td width='60'>&nbsp;&nbsp;<img src='/image/image_epos/image_icon_add.gif' style='cursor:hand'></td></tr></table>"
	var dvelement = document.getElementById(odiv);
	dvelement.innerHTML = '<a style="cursor:hand" onclick=subFormPreClose("' + odiv + '","' + idiv + '","' + i + '","' + im + '","' + is + '","' + it + '")><img src="/image/image_epos/image_icon_plus_on.gif" border="0"></a>'
	document.body.style.cursor = 'default';
}
function subFormPreClose(odiv,idiv,i,im,is,it) 
{
	document.body.style.cursor = 'wait';
	var dvelement = document.getElementById(idiv);
	dvelement.innerHTML = "<table cellspacing='0' cellpadding='0' height='0'><tr><td></td></tr></table>"
	var dvelement = document.getElementById(odiv);
	dvelement.innerHTML = '<a style="cursor:hand" onclick=subFormPre("' + odiv + '","' + idiv + '","' + i + '","' + im + '","' + is + '","' + it + '")><img src="/image/image_epos/image_icon_plus_on.gif" border="0"></a>'
	document.body.style.cursor = 'default';
}
function sendReq(parameters)
{
	document.body.style.cursor = 'wait';
	var url = '/ourmenu/ourmenu.numo?o=1'
	var dvelement = document.getElementById('right_form');
	dvelement.innerHTML = "<div id='right_content'><h1>Reservation Enquiry:  </h1><br /><img src='/image/image_epos/37-1.gif'></div>";
	try
 	{
		http.open("POST",url); 
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      		http.send(parameters);
		http.onreadystatechange = handleResponseText;
	}
	catch(e){alert("error saving");}
	finally{document.body.style.cursor = 'default';}
}
function postForm(i,im)
{
	if (document.sform.dEnquiryDay.value == "") 
	{
       		alert("Please tell us the date you wish to book.");
            	document.sform.dEnquiryDay.focus();
             	return false;
       	}
	if (document.sform.dEnquiryDay.value == "dd") 
	{
       		alert("Please tell us the date you wish to book.");
		document.sform.dEnquiryDay.value = "";
            	document.sform.dEnquiryDay.focus();
             	return false;
       	}
	if (document.sform.dEnquiryMonth.value == "") 
	{
       		alert("Please tell us the date you wish to book.");
            	document.sform.dEnquiryMonth.focus();
             	return false;
       	}
	if (document.sform.dEnquiryMonth.value == "mm") 
	{
       		alert("Please tell us the date you wish to book.");
		document.sform.dEnquiryMonth.value = "";
            	document.sform.dEnquiryMonth.focus();
             	return false;
       	}
	if (document.sform.dEnquiryYear.value == "") 
	{
       		alert("Please tell us the date you wish to book.");
            	document.sform.dEnquiryYear.focus();
             	return false;
       	}
	if (document.sform.dEnquiryYear.value == "yy") 
	{
       		alert("Please tell us the date you wish to book.");
		document.sform.dEnquiryYear.value = "";
            	document.sform.dEnquiryYear.focus();
             	return false;
       	}
	if (document.sform.iEnquiryNo.value == "") 
	{
       		alert("Please tell us the number of people you are booking for.");
            	document.sform.iEnquiryNo.focus();
             	return false;
       	}
	if (document.sform.tEnquiryContactNo.value == "") 
	{
       		alert("Please tell us your contact number.");
            	document.sform.tEnquiryContactNo.focus();
             	return false;
       	}
	if (document.sform.tEnquiryEmail.value == "") 
	{
       		alert("Please tell us your e-mail address!")
       		document.sform.tEnquiryEmail.focus()
       		return false;
	}
	if (document.sform.tEnquiryEmail.value.indexOf("@")==-1) 
	{
       		alert("Your e-mail address is missing an '@' symbol.");
       		document.sform.tEnquiryEmail.focus()
       		return false;
	}
	if (document.sform.tEnquiryEmail.value.indexOf(".")==-1) 
	{         
       		alert("You are missing a '.' dot in your e-mail address.");
       		document.sform.tEnquiryEmail.focus()
       		return false;
	}
	if (document.sform.tEnquiryEmail.value.length<8) 
	{                 
       		alert("Your e-mail address is not a valid length.");
       		document.sform.tEnquiryEmail.focus()
       		return false;
	}  
	document.body.style.cursor = 'wait';
	var params = 	'dEnquiryDay='+encodeURI( document.sform.dEnquiryDay.value )+
			'&dEnquiryMonth='+encodeURI( document.sform.dEnquiryMonth.value )+
			'&dEnquiryYear='+encodeURI( document.sform.dEnquiryYear.value )+
			'&tEnquiryTime='+encodeURI( document.sform.tEnquiryTime.value )+
			'&iEnquiryNo='+encodeURI( document.sform.iEnquiryNo.value )+
			'&tEnquiryFirstName='+encodeURI( document.sform.tEnquiryFirstName.value )+
			'&tEnquiryGroupName='+encodeURI( document.sform.tEnquiryGroupName.value )+
			'&tEnquiryContactNo='+encodeURI( document.sform.tEnquiryContactNo.value )+
			'&tEnquiryEmail='+encodeURI( document.sform.tEnquiryEmail.value );
	var url = '/ourmenu/ourmenu_ad.numo?o=5&i=' + i + '&im=' + im
	var dvelement = document.getElementById('preForm');
	dvelement.innerHTML = "<h1>Online Prebooking: </h1><br /><img src='/image/image_epos/37-1.gif'>";
	try
 	{
		http.open("POST",url); 
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.send(params);
		http.onreadystatechange = handleResponseTextPost;
	}
	catch(e){alert("error sending");}
	finally{document.body.style.cursor = 'default';}
}
function handleResponseText() 
{
	try
       	{
        	if((http.readyState == 4)&& (http.status == 200))
                {
			var response = http.responseText;
			var dvelement = document.getElementById('right_form');
			dvelement.innerHTML = response.toString();
		}
        }
	catch(e){alert("error displaying line");}
	finally{}
}
function handleResponseTextPre() 
{
	try
       	{
        	if((http.readyState == 4)&& (http.status == 200))
                {
			var response = http.responseText;
			var dvelement = document.getElementById('preForm');
			dvelement.innerHTML = response.toString();
		}
        }
	catch(e){alert("error displaying line");}
	finally{}
}
function handleResponseTextPreForm(ldiv,idiv,params)
{
	try
       	{
        	if((http.readyState == 4)&& (http.status == 200))
                {
			var response = http.responseText;
			var dvelement = document.getElementById(ldiv);
			dvelement.innerHTML = '<a style=cursor:hand onclick=getView("' + ldiv + '","' + idiv + '","' + params + '")><img src="/image/image_epos/image_icon_list_on.gif" border="0"><strong>' + response.toString() + '</strong></a>';
		}
        }
	catch(e){alert("error displaying line");}
	finally{}
}
function handleResponseTextPreFormGet(ldiv,idiv,params)
{
	try
       	{
        	if((http.readyState == 4)&& (http.status == 200))
                {
			var response = http.responseText;
			var dvelement = document.getElementById(idiv);
			dvelement.innerHTML = response.toString();

			//get count for icon			
			var urlc = '/ourmenu/ourmenu_ad.numo?o=4&' + params
			http.open('GET', urlc);
			http.onreadystatechange = function(){ handleResponseTextCount(ldiv,idiv,params)}; 
			http.send(null);
		}
        }
	catch(e){alert("error displaying line");}
	finally{}
}
function handleResponseTextDel(ldiv,idiv,params)
{
	try
       	{
        	if((http.readyState == 4)&& (http.status == 200))
                {
			//get count for icon	
			var url = '/ourmenu/ourmenu_ad.numo?o=2&' + params		
			var urlc = '/ourmenu/ourmenu_ad.numo?o=4&' + params
			http.open('GET', urlc);
			http.onreadystatechange = function(){ handleResponseTextCount(ldiv,idiv,params)}; 
			http.send(null);
			try
 			{
				http.open('GET', url);
				http.onreadystatechange = function(){ handleResponseTextPreFormGet(ldiv,idiv,params)}; 
				http.send(null);
			}
			catch(e){alert('error getting list');}
			finally{document.body.style.cursor = 'default';}
		}
        }
	catch(e){alert("error displaying line");}
	finally{}
}
function handleResponseTextCount(ldiv,idiv,params)
{
	try
       	{
        	if((http.readyState == 4)&& (http.status == 200))
                {
			var response = http.responseText;
			var dvelement = document.getElementById(ldiv);
			dvelement.innerHTML = '<a style=cursor:hand onclick=closeView("' + ldiv + '","' + idiv + '","' + params + '")><img src="/image/image_epos/image_icon_list_on.gif" border="0"><strong>' + response.toString() + '</strong></a>';
		}
        }
	catch(e){alert("error displaying line get");}
	finally{}
}
function handleResponseTextCountOpen(ldiv,idiv,params)
{
	try
       	{
        	if((http.readyState == 4)&& (http.status == 200))
                {
			var response = http.responseText;
			var dvelement = document.getElementById(ldiv);
			dvelement.innerHTML = '<a style=cursor:hand onclick=getView("' + ldiv + '","' + idiv + '","' + params + '")><img src="/image/image_epos/image_icon_list_on.gif" border="0"><strong>' + response.toString() + '</strong></a>';
		}
        }
	catch(e){alert("error displaying line get");}
	finally{}
}
function handleResponseTextPost()
{
	try
       	{
        	if((http.readyState == 4)&& (http.status == 200))
                {
			var response = http.responseText;
			var dvelement = document.getElementById('preForm');
			dvelement.innerHTML = "<h1>Online Prebooking: </h1><br />" + response.toString();
		}
        }
	catch(e){alert("error displaying send");}
	finally{}
}
function get(obj) 
{
	var str = 	'dEnquiryDay='+encodeURI( document.rform.dEnquiryDay.value )+
			'&dEnquiryMonth='+encodeURI( document.rform.dEnquiryMonth.value )+
			'&dEnquiryYear='+encodeURI( document.rform.dEnquiryYear.value )+
			'&tEnquiryTime='+encodeURI( document.rform.tEnquiryTime.value )+
			'&iEnquiryNo='+encodeURI( document.rform.iEnquiryNo.value )+
			'&tEnquiryTitle='+encodeURI( document.rform.tEnquiryTitle.value )+
			'&tEnquiryFirstName='+encodeURI( document.rform.tEnquiryFirstName.value )+
			'&tEnquiryGroupName='+encodeURI( document.rform.tEnquiryGroupName.value )+
			'&tEnquiryContactNo='+encodeURI( document.rform.tEnquiryContactNo.value )+
			'&tEnquiryEmail='+encodeURI( document.rform.tEnquiryEmail.value )+
			'&tEnquiryAddress='+encodeURI( document.rform.tEnquiryAddress.value )+
			'&tEnquiryTown='+encodeURI( document.rform.tEnquiryTown.value )+
			'&tEnquiryCounty='+encodeURI( document.rform.tEnquiryCounty.value )+
			'&tEnquiryPostcode='+encodeURI( document.rform.tEnquiryPostcode.value );
	sendReq(str);
}
function enterGuest(odiv,ldiv,idiv,params,i,im,is,it)
{
	document.body.style.cursor = 'wait';
	try
 	{
		var val = document.iform.one.value
		var url = '/ourmenu/ourmenu_ad.numo?o=1&val=' + val + '&' + params
		var dvelement = document.getElementById(idiv);
		dvelement.innerHTML = "<table width='600' border='0' cellpadding='0' cellspacing='2'><tr><td align=right width='540'><img src='/image/image_epos/37-1.gif'></td><td align='right' width='40'>&nbsp;</td></tr></table>";
		try
 		{
			http.open('GET', url);
			http.onreadystatechange = function(){ handleResponseTextPreForm(ldiv,idiv,params)}; 
			http.send(null);
		}
		catch(e){alert('error saving');}
		finally{document.body.style.cursor = 'default';}
	}
	catch(e){alert("more than one textbox open");}
	finally{document.body.style.cursor = 'default';}

	var dvelement = document.getElementById(idiv);
	dvelement.innerHTML = "<table cellspacing='0' cellpadding='0' height='0'><tr><td></td></tr></table>"
	var dvelement = document.getElementById(odiv);
	dvelement.innerHTML = '<a style="cursor:hand" onclick=subFormPre("' + odiv + '","' + idiv + '","' + i + '","' + im + '","' + is + '","' + it + '")><img src="/image/image_epos/image_icon_plus_on.gif" border="0"></a>'
}
function clickclear(thisfield, defaulttext) 
{
	if (thisfield.value == defaulttext) 
	{
		thisfield.value = "";
	}
}
function clickrecall(thisfield, defaulttext) 
	{
	if (thisfield.value == "") 
	{
		thisfield.value = defaulttext;
	}
}
function getKeyd(keyStroke) 
{
	var keyCode = event.keyCode;
	if (keyCode == 9)
	{
		document.sform.dEnquiryMonth.value = "";
	}
}
function getKeym(keyStroke) 
{
	var keyCode = event.keyCode;
	if (keyCode == 9)
	{
		document.sform.dEnquiryYear.value = "";
	}
}
function nextbox(o,nbox)
{
	if(o.value.length>1)
	{
		document.forms[0].elements[nbox].value = ""
		document.forms[0].elements[nbox].focus()
	}
}

function checkform(form)
{
	if (form.dEnquiryDay.value == "") 
	{
       		alert("Please tell us the date you wish to book.");
            	form.dEnquiryDay.focus();
             	return false;
       	}
	if (form.dEnquiryDay.value == "dd") 
	{
       		alert("Please tell us the date you wish to book.");
		form.dEnquiryDay.value = "";
            	form.dEnquiryDay.focus();
             	return false;
       	}
	if (form.dEnquiryMonth.value == "") 
	{
       		alert("Please tell us the date you wish to book.");
            	form.dEnquiryMonth.focus();
             	return false;
       	}
	if (form.dEnquiryMonth.value == "mm") 
	{
       		alert("Please tell us the date you wish to book.");
		form.dEnquiryMonth.value = "";
            	form.dEnquiryMonth.focus();
             	return false;
       	}
	if (form.dEnquiryYear.value == "") 
	{
       		alert("Please tell us the date you wish to book.");
            	form.dEnquiryYear.focus();
             	return false;
       	}
	if (form.dEnquiryYear.value == "yy") 
	{
       		alert("Please tell us the date you wish to book.");
		form.dEnquiryYear.value = "";
            	form.dEnquiryYear.focus();
             	return false;
       	}
	if (form.iEnquiryNo.value == "") 
	{
       		alert("Please tell us the number of people you are booking for.");
            	form.iEnquiryNo.focus();
             	return false;
       	}
	if (form.tEnquiryContactNo.value == "") 
	{
       		alert("Please tell us your contact number.");
            	form.tEnquiryContactNo.focus();
             	return false;
       	}
	if (form.tEnquiryEmail.value == "") 
	{
       		alert("Please tell us your e-mail address!")
       		form.tEnquiryEmail.focus()
       		return false;
	}
	if (form.tEnquiryEmail.value.indexOf("@")==-1) 
	{
       		alert("Your e-mail address is missing an '@' symbol.");
       		form.tEnquiryEmail.focus()
       		return false;
	}
	if (form.tEnquiryEmail.value.indexOf(".")==-1) 
	{         
       		alert("You are missing a '.' dot in your e-mail address.");
       		form.tEnquiryEmail.focus()
       		return false;
	}
	if (form.tEnquiryEmail.value.length<8) 
	{                 
       		alert("Your e-mail address is not a valid length.");
       		form.tEnquiryEmail.focus()
       		return false;
	}  
return true;
}