/******************************************************************************************
* Name         : menu.js
* Description : javascript for simple menu
* Author        : Shane Larkin 
* Date           : 16/05/2004
* Copyright    : Blue Hexagon Ltd 2004
* Modifications
* --------------
* Version    Date    Who
*
* Change
*
******************************************************************************************/
var menuTitles = new Array(); 
var menuURLs = new Array(); 
/******************************************************************************************
* Name       : makeScroll()
* Action      : Makes the menu move up/down so it's allways on screen
* Arguments : 1) offset of menu from top of page
* Returns     : Nothing
* Calls         : makeScroll()
******************************************************************************************/
function makeScroll(offsettop,refresh) 
{
	if(IE4||IE5||IE6)
	{
		menuObject.style.pixelTop=document.body.scrollTop+offsettop;
	} 
	else 
	{ 
		if(NS6)
		{
			document.getElementById("menuObject").style.top=window.pageYOffset+offsettop;
		} 
		else 
		{ 
			if(NS4) 
			{ 
				eval(document.menuObject.top=eval(window.pageYOffset+offsettop)); 
			} 
		} 
	} 
	/* continually call yourself to make any changes to the menu location if scroll occurred */
	setTimeout("makeScroll(" + offsettop + "," + refresh +")",refresh); 
} 
/******************************************************************************************
* Name       : makeMenu()
* Action      : Puts menu on the screen
* Arguments : 1) Flag to make menu scroll with page or not "scroll"/"noscroll"
*                   2) Role of Agent menu is appropriate for "admin"/"user"/"casual"
*                   3) Width of menu
*                   4) Left offset of menu
*                   5) Offset down from top of page for menu
* Returns     : Nothing
* Calls         : makeScroll() - optional on arguments
******************************************************************************************/
function makeMenu(scroll,role,menuwidth,offsetleft,offsettop,refresh)
{
	scroll = scroll.toUpperCase();
	// initially, three roles - admin, user, casual
	role = role.toUpperCase();
	switch(role)
	{
		case "2":
		// Menu items on the screen. Must be corresponding entry in menuURLs array
		// for each one here
			menuTitles[0]="Welcome";
			menuTitles[1]="About Us";
			menuTitles[2]="Add Piece";
			menuTitles[3]="Amend Piece";
			menuTitles[4]="Add User";
			menuTitles[5]="Browse Customers";
			menuTitles[6]="Browse Pieces";
			menuTitles[7]="Advanced Search";
			menuTitles[8]="Read Articles";
			menuTitles[9]="General Information";
			menuTitles[10]="Add Article Title";
			menuTitles[11]="Add Paragraph";
			menuTitles[12]="Sign Out"
			
			// URLs that are associated with each title
			menuURLs[0]="getpage.php?targetPage=1&imageLayout=R&dispLang=Eng";
			menuURLs[1]="getpage.php?targetPage=2&imageLayout=LR&dispLang=Eng";
			menuURLs[2]="uploadphoto.php";
			menuURLs[3]="findproduct01.php";
			menuURLs[4]="registercustomer.php";
			menuURLs[5]="do_findusers.php?browseAll=Y";
			menuURLs[6]="do_findproducts.php?browseAll=Y";
			menuURLs[7]="findproducts.php";
			menuURLs[8]="listarticles.php";
			menuURLs[9]="getpage.php?targetPage=4&imageLayout=LR&dispLang=Eng";
			menuURLs[10]="addarttitle.php";
			menuURLs[11]="addartpara.php";
			menuURLs[12]="do_adminsignout.php";
				
		break;
		case "1":
			menuTitles[0]="Welcome";
			menuTitles[1]="About Us";
			menuTitles[2]="Browse Pieces";
			menuTitles[3]="Advanced Search";
			menuTitles[4]="Read Articles";
			menuTitles[5]="Enquiry";
			menuTitles[6]="View Your Details";
			menuTitles[7]="General Information";
			menuTitles[8]="300 Years";
			menuTitles[9]="Sign Out";
			
			// URLs that are associated with each title
			menuURLs[0]="getpage.php?targetPage=1&imageLayout=R&dispLang=Eng";
			menuURLs[1]="getpage.php?targetPage=2&imageLayout=LR&dispLang=Eng";
			menuURLs[2]="do_findproducts.php?browseAll=Y";
			menuURLs[3]="findproducts.php";
			menuURLs[4]="listarticles.php";
			menuURLs[5]="email.php";
			menuURLs[6]="viewowndetails.php";
			menuURLs[7]="getpage.php?targetPage=4&imageLayout=LR&dispLang=Eng";
			menuURLs[8]="300years.html";
			menuURLs[9]="do_custsignout.php";			
		break;
		case "0":
		 	menuTitles[0]="Welcome";
			menuTitles[1]="About Us";
			menuTitles[2]="Browse Pieces";
			menuTitles[3]="Advanced Search";
			menuTitles[4]="Read Articles";
			menuTitles[5]="E-mail Us";
			menuTitles[6]="Register";
			menuTitles[7]="Why Register?";
			menuTitles[8]="General Information";
			menuTitles[9]="300 Years";
			menuTitles[10]="Sign In";								
			// URLs that are associated with each title
			menuURLs[0]="getpage.php?targetPage=1&imageLayout=R&dispLang=Eng";
			menuURLs[1]="getpage.php?targetPage=2&imageLayout=LR&dispLang=Eng";
			menuURLs[2]="do_findproducts.php?browseAll=Y";
			menuURLs[3]="findproducts.php";
			menuURLs[4]="listarticles.php";
			menuURLs[5]="email.php";
			menuURLs[6]="registercustomer.php";
			menuURLs[7]="getpage.php?targetPage=3&imageLayout=LR&dispLang=Eng";
			menuURLs[8]="getpage.php?targetPage=4&imageLayout=LR&dispLang=Eng";
			menuURLs[9]="300years.html";
			menuURLs[10]="custsignin.php";			
		break;	
		return;		
	}

	if (IE4||NS6||IE6) 
	{ 
		document.write('<SPAN class="menu" ID="menuObject" STYLE="margin-left:'+offsetleft+';');
		document.write(' margin-top:'+offsettop+'" width="'+menuwidth+'">');
		document.write('<TABLE class="menu" width="'+menuwidth+'">');
		if(NS6)
		{
			document.write('<col width="'+menuwidth+'">');
		}
	} 
	else 
	{ 
		if (NS4) 
		{  
			document.write('<LAYER class = "menu" name="menuObject" left="'+offsetleft+'">');
			document.write('<TABLE class="menu" width="'+menuwidth+'">');
			document.write('col width="'+menuwidth+'">');
		}	 
	} 
 
	if (IE4||NS6||NS4||IE6) 
	{ 
		document.write('<TR class="menu"><TD class="menuheader">MENU</TD></TR>');
	} 

	for (i=0;i<=menuTitles.length-1;i++) 
	{ 
		if(IE4||NS6||IE6) 
		{ 
			document.write('<TR class ="menu"><TD class="menuitem"  STYLE="cursor:hand"');
			document.write('onclick="location=\''+menuURLs[i]+'\'" onmouseover="className=\'menuh\'"'); 
			document.write('onMouseout="className=\'menu\'">'+menuTitles[i]+' </TD></TR>'); 
		} 
		else 
		{ 
			if (NS4) 
			{ 
				document.write('<TR class ="menu"><TD class="menuitem"><ILAYER>');
				document.write('<LAYER width="'+menuwidth+'" onmouseover="bgColor=\'yellow\'"'); 
				document.write('onmouseout="bgColor=\'white\'"><A HREF="'+menuURLs[i]+'"'); 
				document.write('class=menuURLsinks>'+menuTitles[i]+'</A></LAYER></ILAYER></TD></TR>'); 
			}
		}
	}	
	if(IE4||NS6||IE6) 
	{ 
		document.write('</TABLE></SPAN>'); 
	} 
	else 
	{ 
		if (NS4) 
		{ 
			document.write('</TABLE></TD></TR></TABLE></LAYER>');
		} 
	}

	/* make the menu scroll if required */ 
	if(scroll == "SCROLL")
	{
		makeScroll(offsettop,refresh);
	}
} 
/************************************************* End of file *************************************/
