var numOfItems = 8;
var rn = 0;
	
//menu constructor
function menu(allitems,thisitem,startstate){ 
  callname= "nbtxt"+thisitem;
  divname="navbardesc"+thisitem;  
  this.numberOfNavbarItems = numOfItems;
  this.caller = document.getElementById(callname);
  this.thediv = document.getElementById(divname);
  this.thediv.style.visibility = startstate;
}

//menu methods
function ehandler(event,theobj){
  for (var i=1; i<= theobj.numberOfNavbarItems; i++){
    var shutdiv =eval( "navbaritem"+i+".thediv");
    shutdiv.style.visibility="hidden";
  }
  theobj.thediv.style.visibility="visible";
}
				
function closenavbardesc(event){ 
  if (event.clientY > 295){
    for (var i=1; i<= numOfItems; i++){
      var shutdiv =eval('navbaritem'+i+'.thediv');
      shutdiv.style.visibility='hidden';
    }
  }
}

function rand(num) {
	return Math.floor(Math.random() * num) + 1;
}	


function playcards(count,last) {
		i = (count==4) ? 0 : count;
		lc = last;
		if (i==0) {
			document.getElementById('card1').src= "./images/0.jpg";
			document.getElementById('card2').src= "./images/0.jpg";
			document.getElementById('card3').src= "./images/0.jpg";
		}
		else {
			rn = rand(26);
			while (rn == lc){
				rn = rand(26);
			}
			cardID = "card"+i;
			document.getElementById(cardID).src= "./images/" + rn +".jpg";
		}
		i++;
		setTimeout("playcards(i,rn)", 2000);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_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_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];}
}


function numcheckloop(num, maxnum)
{
	if (num > (maxnum - 1))
		{
		num = num - maxnum;
		}
	return num;
}

function chgC4(index, NoOfPics, count)
{
	cellfour(index, count);
	NumPics = NoOfPics;
	newindex = index;
	newcount = count + 1;
	newindex = numcheckloop(index + 1, NumPics);
	setTimeout("chgC4(newindex, NumPics, newcount)", 12000);
}

function cellfour(i, c)
{
	var picscr = new Array()
	var htxt = new Array()
	var ptxt = new Array()

	picscr[0] = "./images/dining.jpg"
	picscr[1] = "./images/diets.jpg"
	picscr[2] = "./images/functions.jpg"

	htxt[0] = "A warm welcome awaits you"
	htxt[1] = "Gluten or Lactose intolerant?"
	htxt[2] = "Having a Party?"
	

	ptxt[0] = "The Golcar Lily is wholly owned by Darryl, who personally supervises all aspects of the operation, purchasing and cooking all the dishes and organising the service. Together with the rest of his team, Darryl is able to provide a unique and very flexible personal service and is keen to ensure that everyone wishes to make a speedy return to the Golcar Lily!"
	ptxt[1] = "At the Golcar Lily we pride ourselves in making your visit as enjoyable as possible, and for those guests who must adhere to a special diet, our chef will be happy to talk to you and recommend suitable menu choices. Coeliac (Gluten Free) and Lactose Intolerant diets are amongst those that we are able to accommodate."
	ptxt[2] = "Our downstairs Function Room will seat up to 40 diners or hold up to 75 guests for a buffet or hot supper.<br><br>A range of dining or buffet menus are available, along with our tasty hot supper menu. Please see the Functions section of our menu page for full details."



	document.getElementById('c4pic').style.filter="blendTrans(duration=0.5)";
	if (document.all) document.getElementById('c4pic').filters.blendTrans.Apply();
	
	document.getElementById('c4pic').src= picscr[numcheckloop(i, picscr.length)];
	if (document.all) document.getElementById('c4pic').filters.blendTrans.Play();
	document.getElementById('c4h').innerHTML= htxt[numcheckloop(i, htxt.length)];
	document.getElementById('c4txt').innerHTML= ptxt[numcheckloop(i, ptxt.length)];
}
