var topimages = new Array()
topimages[topimages.length] = ["1a_over.jpg", "1a_off.jpg", "/musicdirector.shtml", "Learn more about the symphony leadership"]
topimages[topimages.length] = ["3_over.jpg", "3_off.jpg", "/yac.shtml", "The Competition - Young Artists Competition"]
topimages[topimages.length] = ["10_over.jpg", "10_off.jpg", "/soirees.shtml", "Enjoy the intimacy of FCS Soirees"]
topimages[topimages.length] = ["8_over.jpg", "8_off.jpg", "/bmwraffle.shtml", "Win a 2009 BMW 128i 2-year Lease!"]

var topimages_guild = new Array()
topimages_guild[topimages_guild.length] = ["5b_off.jpg", "5b_over.jpg", "/guild/volunteers.shtml", "Meet the Volunteers of the Guild"]
topimages_guild[topimages_guild.length] = ["3_over.jpg", "3_off.jpg", "/default.shtml", "Visit the Symphony Website"]
topimages_guild[topimages_guild.length] = ["6_off.jpg", "6_over.jpg", "/guild/musicalzoo09.shtml", "Musical Zoo - introducing young children to music"]
topimages_guild[topimages_guild.length] = ["9_off.jpg", "9_over.jpg", "/guild/derby.shtml", "Kentucky Derby Party 2009"]




var support = new Array()
support[support.length] = ["Individual", "/individual.shtml"]
support[support.length] = ["Corporate", "/corporate.shtml"]
support[support.length] = ["Endowment", "/endowment.shtml"]
support[support.length] = ["Volunteer", "/volunteer.shtml"]
support[support.length] = ["Symphony Guild", "http://www.fcsymphonyguild.org/"]

var about = new Array()
about[about.length] = ["FCSO Staff", "/staff.shtml"]
about[about.length] = ["FCSO Leaders", "/leaders.shtml"]

var events = new Array()
events[events.length] = ["Masterworks Series", "/masterworks.shtml"]
events[events.length] = ["Chapter 4", "/chapter4.shtml"]
events[events.length] = ["Chapter 5", "/chapter5.shtml"]
events[events.length] = ["Chapter 6", "/chapter6.shtml"]
events[events.length] = ["Sound of Color", "/soundofcolor.shtml"]
events[events.length] = ["Soirees", "/soirees.shtml"]

var youth = new Array()
youth[youth.length] = ["YES Concerts", "/yesconcerts.shtml"]
youth[youth.length] = ["Young Artist Competition", "/youngartist.shtml"]
youth[youth.length] = ["Colorado Youth Orchestras", "/orchestras.shtml"]

var leftlinks = new Array()
leftlinks[leftlinks.length] = ["Home", "/"]
leftlinks[leftlinks.length] = ["Support the symphony", "/support.shtml", support]
leftlinks[leftlinks.length] = ["About us", "/aboutus.shtml", about]
leftlinks[leftlinks.length] = ["News", "/news.shtml"]
leftlinks[leftlinks.length] = ["Events", "/events.shtml", events]
leftlinks[leftlinks.length] = ["Youth programs", "/youthprograms.shtml", youth]
leftlinks[leftlinks.length] = ["Buy tickets", "/tickets.shtml"]
leftlinks[leftlinks.length] = ["Contact FCSO", "/contact.shtml"]


var graphics = "/graphics/"
var nav
var openmenu

function init() {
	nav = document.getElementById("nav")
	buildtop()
	//buildnav()
	buildcalendar()
}

function init_guild() {
	nav = document.getElementById("nav")
	buildtop_guild()
	//buildnav()
	buildcalendar()
}

function buildtop() {
	var toprow = document.getElementById("toprow")
	for(i in topimages) {
		img = document.createElement("img")
		img.setAttribute("src", graphics + topimages[i][0])
		img.setAttribute("style", "cursor:pointer;")
		img.onmouseover = swaptop
		img.onmouseout = swaptop
		img.onmousedown = toplink
		img.link = topimages[i][2]
		toprow.appendChild(img)
	}
}

function buildtop_guild() {
	var toprow = document.getElementById("toprow")
	for(i in topimages_guild) {
		img = document.createElement("img")
		img.setAttribute("src", graphics + topimages_guild[i][0])
		img.setAttribute("style", "cursor:pointer;")
		img.onmouseover = swaptop_guild
		img.onmouseout = swaptop_guild
		img.onmousedown = toplink
		img.link = topimages_guild[i][2]
		toprow.appendChild(img)
	}
}

function swaptop() {
	text = document.getElementById("rollovertext")
	for(i in topimages) {
		if (this.src.indexOf(topimages[i][0]) > -1) {
			this.src = graphics + topimages[i][1]
			text.innerHTML = topimages[i][3]
		}
		else if (this.src.indexOf(topimages[i][1]) > -1) {
			this.src = graphics + topimages[i][0]
			text.innerHTML = ""
		}
	}
}

function swaptop_guild() {
	text = document.getElementById("rollovertext")
	for(i in topimages_guild) {
		if (this.src.indexOf(topimages_guild[i][0]) > -1) {
			this.src = graphics + topimages_guild[i][1]
			text.innerHTML = topimages_guild[i][3]
		}
		else if (this.src.indexOf(topimages_guild[i][1]) > -1) {
			this.src = graphics + topimages_guild[i][0]
			text.innerHTML = ""
		}
	}
}


function toplink() {
	window.location = this.link
}

function buildnav() {
	for(i in leftlinks) newlink(i, leftlinks[i])
}

function linkover(linknode) {
	row = this.parentNode.parentNode
	row.cells[0].innerHTML = "<img src=\"/graphics/arrows.gif\"/>"
	for(i=0; i < nav.rows.length; i++) {
		if (i == row.rowIndex) continue
		nav.rows[i].cells[0].innerHTML = ""
	}
	
	if (this.kidarray != null && openmenu != this.kidarray) {
		for(j in openmenu) {
			for(m=0; m < nav.rows.length; m++) {
				myrow = nav.rows[m]
				//development stopped here, it wouldnt remove child m
				//alert("row = "+myrow.childNodes[1].firstChild.innerHTML)
				//alert("array = "+openmenu[j][0])
				//alert("index = "+m)
				if (myrow.childNodes[1].firstChild.innerHTML == openmenu[j][0]) nav.removeChild(m)
			}
		}
		
		for(k=0; k < this.kidarray.length; k++) {
			newlink(row.rowIndex+k+1, this.kidarray[k])
			openmenu = this.kidarray
		}
	}
}

function newlink(index, arr) {
	nav.insertRow(index)
	newrow = nav.rows[index]
	newrow.insertCell(0)
	newrow.insertCell(1)
	imagecell = newrow.cells[0]
	linkcell = newrow.cells[1]
	imagecell.setAttribute("width", 17)
	ahref = document.createElement("a")
	ahref.innerHTML = arr[0]
	ahref.setAttribute("href", arr[1])
	ahref.className = "nav"
	ahref.kidarray = arr[2]
	ahref.onmouseover = linkover
	linkcell.appendChild(ahref)
}

function linkon(linknode) {
	linknode.parentNode.parentNode.cells[0].firstChild.src = "/graphics/arrows2.jpg"
}

function linkoff(linknode) {
	linknode.parentNode.parentNode.cells[0].firstChild.src = "/graphics/blank.gif"
}

function buildcalendar() {
	var datecell = document.getElementById("datecell")
	thedate = new Date()
	//here
	//datecell.innerHtml = thedate.getMonth()+1 + "/" + thedate.getDate() + "/" + thedate.getFullYear()
}