/// eccamenu.js

var ie=document.all
var ns=document.layers
var ns6=document.getElementById && !document.all
var Credit = ""
var Heading = ""

var MenuChoices = new Array()

function Choice(id, text, title, update) {
	var now, y, m, d, then
	this.id = id
	this.linkText = '<a href="../" target="main" onClick="showSelection(\'' + id + '\'); return false;"'
		+ ' onmouseover="return setMsg2(\'' + text + '\')" onmouseout="return setMsg2()">' + text + '</a><br>'
	this.text = text
	this.title = title
	this.locn = "javascript:showSelection('" + id + "')"
	this.mclass = "menuitem"
/*
	if ((typeof update == "string") && (update != "")) {
		now = new Date()
		y = parseInt(update.substr(6))
		if (y < 100) { y = y + 2000 }
		d = parseInt(update.substr(0,2))
		m = parseInt(update.substr(3,2)) - 1
		then = new Date(y, m, d)
//alert(now + '  :  ' + then + '  :  ' + (now - then) + '  :  ' + (10 * 24 * 60 * 60 *1000))
		if (((now-then) / (24 * 3600 *1000)) < 10 ) { //alert('less than 10 days')
			this.title = this.title + ". Last updated on " + update
			this.mclass = "updateitem"
		}
	}
*/
}

function getChoices() {
	MenuChoices = new Array()
	var i = 0
	MenuChoices[i++] = new Choice("news", "News", "ECCA News Items", "28/04/2004")
	MenuChoices[i++] = new Choice("clubs", "Clubs", "List of ECCA Clubs")
	MenuChoices[i++] = new Choice("contacts", "Contacts", "ECCA Contact Details", "25/04/2004")
	MenuChoices[i++] = new Choice("social", "Social News", "ECCA Social Reports")
	MenuChoices[i++] = new Choice("newsletter2", "Newsletter", "ECCA Newsletters")
	MenuChoices[i++] = new Choice("archives2", "Archives", "Samples of ECCA Archive Information")
	MenuChoices[i++] = new Choice("diary", "Diary", "ECCA Diary")
	MenuChoices[i++] = new Choice("racing2", "Racing", "ECCA Racing Information", "02/04/2004")
	MenuChoices[i++] = new Choice("festival2", "Festival", "ECCA Festival Information")
//	MenuChoices[i++] = new Choice("winners","Winners", "ECCA Trophy Winners")
	MenuChoices[i++] = new Choice("ecrra records", "ECRRA", "ECRRA Records")
}

function setMsg2(msg) {
	if ((msg == null) || (msg == "undefined")) { msg = '' }
	window.status = unescape(msg)
	return true
}

function showHighlight(obj, typ) {
	var bgcol
	with (obj.style) {
		if (obj.className == "menuitem") {
			if (color != "blue") {
				color = (((color=="red") || (color=="")) ? "black" : "red")
				backgroundColor = (((backgroundColor=="#ffffcc") || (backgroundColor=="")) ? "white" : "#ffffcc")
			}
		} else {
			if (obj.className == "updateitem") {
				if (color != "blue") {
					color = (((color=="red") || (color=="")) ? "black" : "red")
					backgroundColor = (((backgroundColor=="cyan") || (backgroundColor=="")) ? "white" : "cyan")
				}
			} else {
				backgroundColor = (((backgroundColor=="#ffffcc") || (backgroundColor=="")) ? "white" : "#ffffcc")
			}
		}
	}
	setMsg2(typ)
	return false
}

function isClicked(obj, id) {
	if (document.getElementById) {
		var mn = document.getElementById("masterdiv").getElementsByTagName("span");
		for (var i=0; i<mn.length; i++) {
			if (mn[i].className == "menuitem") {
				mn[i].style.color = "red"
				mn[i].style.backgroundColor = "#ffffcc"
			}
			if (mn[i].className == "updateitem") {
				mn[i].style.color = "red"
				mn[i].style.backgroundColor = "cyan"
			}
		}
	}
	with (obj.style) {
		color = "blue"
		backgroundColor = "yellow"
	}
	showSelection(id)
	return false
}

function setMenu(news) {	/// modifications to Menu Variables - if not listed then default values used
	var cText = '', sText = ''
	var sub
	for (i = 0, y = 0, z = 0, year1 = 0; i < MenuChoices.length; i++ ) {
		sText += '<span class="' + MenuChoices[i].mclass + '" onclick="return isClicked(this, \'' + MenuChoices[i].id + '\')" title="' + MenuChoices[i].title + '"'
			+ ' onmouseover="return showHighlight(this, \'' + MenuChoices[i].title + '\')" onmouseout="return showHighlight(this)"'
			+ '>' + MenuChoices[i].text + '</span>'
//			+ ((i==4) ? '<br>' : '')
	}
	cText = '<div id="masterdiv">' + cText + sText + '</div>'
//alert(cText)
	document.write(cText)
}

getChoices()

function showSelection(id) {
	var x, no = -1 
	if ((id == null) || (id == "") || (id == "undefined")) { 
		if (parent.location.search.length > 1) { 
			id = parent.location.search.substr(1) 
			x = id.indexOf('/')
			if (x != -1) {
				no = parseInt(id.substr(x+1))
				id = id.substring(0,x)
			}
		} else { 
			if (parent.location.href.indexOf("festival") != -1) {
				id = "festival2"
			} else {
				if (parent.location.href.indexOf("newsletter") != -1) { 
					id = "newsletter2" 
				} else { 
					id = "homepage" 
				}
			}
		}
	}
	if (parent.main) {
//alert(id)
		if (parent.main.location.href.indexOf(id + ".html") == -1) { 
			parent.main.location = id + ".html#top" 
		}
	}
	return false
}
