var arrMenuNames = new Array()
var intMenuCounter = 0
var intMinY = 0
var intMinX = 0
var intMaxX = 10000
var blnIsLoaded = true

function Menu(name, width) {
	//properties
	this.width = width
	this.name = name
	this.menuItems = new Array()
	
	//methods
	this.addMenuItem = addMenuItem
	this.writeMenu = writeMenu
	
	//add to array
	arrMenuNames[intMenuCounter] = name
	intMenuCounter++
}

function addMenuItem(item) {
	this.menuItems[this.menuItems.length] = item
}

function writeMenu() {
	
	if (document.layers) {
		document.write('<layer name=' + this.name + ' top=0 left=0 visibility="hide" onMouseOut="hideMenu(\'' + this.name + '\')">')
		document.write('<table cellpadding=0 cellspacing=0 border=0 width=' + this.width + ' ><tr><td background=images/spacer.gif>')
		for (var i = 0; i < this.menuItems.length; i++) {
			document.write(this.menuItems[i] + '<br>')
			if (i < this.menuItems.length - 1)
				document.write('<img src=images/spacer.gif width=1 height=8><br>')
		}
		document.write('</td></tr></table>')
		document.write('</layer>')
	}
	if (document.all) {
		document.write('<div id=' + this.name + ' style="position:absolute;left:0px;top:0px;width:' + this.width + 'px;visibility:hidden;" onMouseOut="hideMenu(\'' + this.name + '\')">')
		document.write('<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td background=images/spacer.gif>')
			for (var i = 0; i < this.menuItems.length; i++) {
			document.write(this.menuItems[i] + '<br>')
			if (i < this.menuItems.length - 1)
				document.write('<img src=images/spacer.gif width=1 height=8><br>')
		}
		document.write('</td></tr></table>')
		document.write('</div>')
	}
}

var lastMenuName = ""
function showMenu(menuName, imageName, position, overImage) {
	var x, y, objLayer
	var strImgName = ""
	var strImgSrc = ""
	
	if (blnIsLoaded){
	
		if ((navigator.userAgent).indexOf("Mac") == -1 || navigator.appName == "Netscape") {
			//move menu to right place
			objLayer = getLayer(menuName)
			x = getImagePageLeft(getImage(imageName)) + position
			y = getImagePageTop(getImage(imageName)) + 0
			moveLayerTo(objLayer, x, y)
			
			// show menu
			if (document.layers) {
				if (lastMenuName != "")
					hideMenu(lastMenuName)
				document.layers[menuName].visibility = "show"
			}
			if (document.all) {
				if (lastMenuName != "")
					hideMenu(lastMenuName)
				document.all[menuName].style.visibility = "visible"
			}
			lastMenuName = menuName
			
			if (document.images) {
				if (menuName == 'theregionMenu') {
					strImgName = 'theregion'
					strImgSrc = 'images/nav-4/nav-theregion-over.gif' 
				        document.images[strImgName].src=strImgSrc;
				}
				else if (menuName == 'aboutusMenu') {  
					strImgName = 'aboutus'             
					strImgSrc = 'images/nav-4/nav-aboutus-over.gif'
				        document.images[strImgName].src=strImgSrc;
				}
				else if (menuName == 'vineyardsMenu') {  
					strImgName = 'vineyards'             
					strImgSrc = 'images/nav-4/nav-vineyards-over.gif'
				        document.images[strImgName].src=strImgSrc;
				}
				else if (menuName == 'newsMenu') {  
					strImgName = 'news'             
					strImgSrc = 'images/nav-4/nav-news-over.gif'
				        document.images[strImgName].src=strImgSrc;
				}
				else if (menuName == 'eventsMenu') {  
					strImgName = 'events'             
					strImgSrc = 'images/nav-4/nav-events-over.gif'
				        document.images[strImgName].src=strImgSrc;
				}
			}
			
			//change(strImgName, strImgSrc)
		}
	}
}
function hideMenu(menuName) {
	var isIn = false
	var i = 0
	var strImgName, strImgSrc
	
	if (blnIsLoaded) {
	
		if (document.images) {
			if (menuName == 'theregionMenu') {
				strImgName = 'theregion'
				strImgSrc = 'images/nav-4/nav-theregion.gif' 
			        document.images[strImgName].src=strImgSrc;
			}
			else if (menuName == 'aboutusMenu') {  
				strImgName = 'aboutus'             
				strImgSrc = 'images/nav-4/nav-aboutus.gif'
			        document.images[strImgName].src=strImgSrc;
			}
			else if (menuName == 'vineyardsMenu') {  
				strImgName = 'vineyards'             
				strImgSrc = 'images/nav-4/nav-vineyards.gif'
					document.images[strImgName].src=strImgSrc;
			}
			else if (menuName == 'newsMenu') {  
				strImgName = 'news'             
				strImgSrc = 'images/nav-4/nav-news.gif'
					document.images[strImgName].src=strImgSrc;
			}
			else if (menuName == 'eventsMenu') {  
				strImgName = 'events'             
				strImgSrc = 'images/nav-4/nav-events.gif'
					document.images[strImgName].src=strImgSrc;
			}
		}
		
		if (document.layers) {
			document.layers[menuName].visibility = "hide"
			//change(strImgName, strImgSrc)
		}
		if (document.all) {
			while (!isIn && i < document.all[menuName].all.length) {
				if (window.event.toElement == document.all[menuName].all[i])
					isIn = true
				i++
			}
			if (!isIn) {
				document.all[menuName].style.visibility = "hidden"
				//change(strImgName, strImgSrc)
			}
		}
	}
}
function hideAllMenus() {
	for (var i=0; i < arrMenuNames.length; i++) {
		hideMenu(arrMenuNames[i])
	}
}

//create new menu with stated width
var menu1 = new Menu('theregionMenu', 266)
var menu2 = new Menu('aboutusMenu', 266)
var menu3 = new Menu('vineyardsMenu', 266)
var menu4 = new Menu('newsMenu', 266)  
var menu5 = new Menu('eventsMenu', 266)

menu1.addMenuItem('<IMG SRC="images/nav-4/nav-theregion-menu.gif" BORDER="0" name="contentImage1" USEMAP="#theregionmap" onMouseover="imageActive(1);">')

menu2.addMenuItem('')

menu3.addMenuItem('<IMG SRC="images/nav-4/nav-vineyards-menu.gif" BORDER="0" name="contentImage1" USEMAP="#vineyardsmap" onMouseover="imageActive(3);">')

menu4.addMenuItem('<IMG SRC="images/nav-4/nav-news-menu.gif" BORDER="0" name="contentImage1" USEMAP="#newsmap" onMouseover="imageActive(4);">')

menu5.addMenuItem('<IMG SRC="images/nav-4/nav-events-menu.gif" BORDER="0" name="contentImage1" USEMAP="#eventsmap" onMouseover="imageActive(5);">')

if (document.all || document.layers) {
	menu1.writeMenu()
	menu2.writeMenu()
	menu3.writeMenu()
	menu4.writeMenu()
	menu5.writeMenu()
}