// *** Menu Whizzer. Copyright 2005 Riverside Computer Services Limited, all rights reserved ***
// ** Image Preloader
	var imglist = new Array ("images/trans.gif", "images/nav_news_latest.gif", "images/nav_about_bar.gif", "images/nav_menus_current.gif",
		"images/nav_wines_reds.gif","images/nav_contact_contact.gif","images/sub_nav_cross.gif","images/nav_news_archive.gif",
		"images/nav_about_restaurant.gif","images/nav_menus_bar.gif","images/nav_wines_whites.gif","images/nav_contact_gb.gif",
		"images/nav_news_events.gif","images/nav_about_downstairs.gif","images/nav_menus_sample---.gif","images/nav_wines_sparkling.gif",
		"images/nav_contact_location.gif","images/nav_about_about-.gif","images/nav_menus_buffet-.gif","images/nav_wines_dessert.gif",
		"images/nav_about_people.gif","images/nav_menus_special.gif","images/nav_wines_gone-.gif","images/nav_about_location.gif");
	var imgs = new Array();
	var count;
	for (count=0; count<imglist.length; count++)
		{imgs[count]=new Image(); imgs[count].src=imglist[count];}

// ** Initialise Variables
// * List of the submenu items
	var linklist = new Array(
		'<li><img src="images/trans.gif" width="1" height="15" alt="" border="0"><\/li>',
		'<li><a href="news-latest.htm"><img id="s1" src="images/nav_news_latest.gif" width="79" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="news-archive.htm"><img id="s2" src="images/nav_news_archive.gif" width="91" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="news-events.htm"><img id="s3" src="images/nav_news_events.gif" width="46" height="15" alt="" border="0"><\/a><\/li>',
		'<li><a href="about-bar.htm"><img id="s1" src="images/nav_about_bar.gif" width="55" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="about-restaurant.htm"><img id="s2" src="images/nav_about_restaurant.gif" width="75" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="about-downstairs.htm"><img id="s3" src="images/nav_about_downstairs.gif" width="77" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="about.htm"><img id="s4" src="images/nav_about_about-.gif" width="97" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="about-people.htm"><img id="s5" src="images/nav_about_people.gif" width="49" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="about-location.htm"><img id="s6" src="images/nav_about_location.gif" width="160" height="15" alt="" border="0"><\/a><\/li>',
		'<li><a href="menu-current.htm"><img id="s1" src="images/nav_menus_current.gif" width="91" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="menu-bar.htm"><img id="s2" src="images/nav_menus_bar.gif" width="69" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="menu-sample-set.htm"><img id="s3" src="images/nav_menus_sample---.gif" width="113" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="menu-buffet.htm"><img id="s4" src="images/nav_menus_buffet-.gif" width="82" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="menu-special.htm"><img id="s5" src="images/nav_menus_special.gif" width="96" height="15" alt="" border="0"><\/a><\/li>',
		'<li><\/li>',
		'<li><a href="contact.htm"><img id="s1" src="images/nav_contact_contact.gif" width="101" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="contact-gb.htm"><img id="s2" src="images/nav_contact_gb.gif" width="73" height="15" alt="" border="0"><\/a><img src="images/sub_nav_cross.gif" width="6" height="15" alt="" border="0"><\/li><li><a href="contact-location.htm"><img id="s3" src="images/nav_contact_location.gif" width="58" height="15" alt="" border="0"><\/a><\/li>'
		);
// * Left co-ordinate of where the line starts, one entry for each menu option
	var xpos = new Array (0,112,248,388,498,607);
// * Length of the line, one entry for each menu option
	var itemlen = new Array (89,116,120,90,86,92);
// * Left co-ordinate of where the submenu items start, one entry for each menu option
	var subxpos = new Array (0,60,60,190,315,460);
// * Current position & length of line
	var currentpos=0
	var currentlen=0
// * Desination of where the line should end up & how long
	var targetpos=0
	var targetlen=0
// * Which menu array item we are looking at
	var menuitem=0
// * Which submenu array item we are looking at
	var submenuitem=0
// * Step to take may be plus or minus depending on direction
	var xstep=0
// * Used to repeat the move until the line has reached its destination
	var move_id
// * Which menu to return to
	var sourcemenu=0
// * How many pixels to jump for each movement of the line
	var stepsize=20
// * Interval to wait between each movement of the lines (in milliseconds)
	var speed=1
// * Whether the menu is being hovered over or not
	var stillactive=0
// * Time to wait when the mouse has left the menu before the lines return to the original location
	var returntimeout=2300
// * Timeout used to repeat the move until the line has reached its destination
	var move_id
// * Timeout used to delay the move until after the mouse has left the menu
	var return_id
// ** End Initialise Variables
// ** Do the actual move
	function setupitem() {
		document.getElementById('tophilight').style.left = targetpos+'px';
		document.getElementById('bottomhilight').style.left = targetpos+'px';
		document.getElementById('menu2').style.left = subxpos[menuitem]+'px';
		document.getElementById('list2').innerHTML = linklist[menuitem];
		if (menuitem+1 == sourcemenu) selectsubmenu(submenuitem);
	}
// ** Move each step and then repeat until destination has been reached
	function domove() {
		currentpos=currentpos+xstep;
			document.getElementById('tophilight').style.width = targetlen+'px';
			document.getElementById('bottomhilight').style.width = targetlen+'px';
		if (currentpos < 0) currentpos = 0;
		if (currentpos == targetpos) {
			clearTimeout(move_id);
			setupitem();
			}
		else if (xstep > 0 && currentpos > targetpos) {
			clearTimeout(move_id);
			currentpos=targetpos;
			currentlen=targetlen;
			setupitem();
			}
		else if (xstep < 0 && currentpos < targetpos) {
			clearTimeout(move_id);
			currentpos=targetpos;
			currentlen=targetlen;
			setupitem();
			}
		else {
			document.getElementById('tophilight').style.left = currentpos+'px';
			document.getElementById('bottomhilight').style.left = currentpos+'px';
			move_id=setTimeout("domove()",speed);
			}
	}
// ** Select menu item (returns to source menu if no parameter given), calculate direction and initiate move 
	function changemenu(menuoption) {
		if (!menuoption) {
			menuoption=sourcemenu;
			if (stillactive > 0) {
				clearTimeout(return_id);
				return_id=setTimeout("changemenu()",returntimeout);
				return true;
			}
		}
		else {
			stillactive=1;
		}	
		menuoption --;
		menuitem=menuoption;
		targetpos=xpos[menuoption];
		targetlen=itemlen[menuoption];
		if (targetpos > currentpos)
			xstep=stepsize
		else if (targetpos < currentpos)
			 xstep=-stepsize
		else
			 xstep = 0;
		if (xstep != 0) {
			clearTimeout(move_id);
			move_id=setTimeout("domove()",speed);
		}
		return true;
	}
// ** Initialise the lines to start under the correct menu item
	function initcursor(menuoption){
		sourcemenu=menuoption;
		menuoption --;
		targetpos=xpos[menuoption];
		targetlen=itemlen[menuoption];
		currentpos=xpos[menuoption];
		currentlen=itemlen[menuoption];
		menuitem=menuoption;
		document.getElementById('tophilight').style.left = targetpos+'px';
		document.getElementById('tophilight').style.width = targetlen+'px';
		document.getElementById('bottomhilight').style.left = targetpos+'px';
		document.getElementById('bottomhilight').style.width = targetlen+'px';
		document.getElementById('menu2').style.left = subxpos[menuoption]+'px';
		document.getElementById('list2').innerHTML = linklist[menuitem];
		return true;
	}
// ** Start countdown to return the lines as mouse has left the menu and submenus
	function startcount(){
		stillactive=0;
		clearTimeout(return_id);
		return_id=setTimeout("changemenu()",returntimeout);
	}
// ** Reset the countdown as the mouse has returned to one of the menu options
	function clearcount(){
		stillactive=1;
		clearTimeout(return_id);
	}
// ** Place Hilight under selected sub menu
	function selectsubmenu(submenu) {
		if (submenu && submenu > 0) {
			submenuitem=submenu;
			document.getElementById('s'+submenu).style.borderBottom = '1px solid #C8745C';
			}
		else {
			return true;
			}
	}
// *** End Menu Whizzer ***
