/*
This code is based on a code example from the article "Javascript navigation - cleaner, not meaner" by Christian Heilmann
URL: http://www.evolt.org/article/Javascript_navigation_cleaner_not_meaner/17/60273/index.html
*/
$(function() {
    initShowHide();
});
// If there is enough W3C DOM support for all our show/hide behavior:
// 1. Call the stylesheet that by default hides all toggleable sections 
// 2. Apply the show/hide behavior by calling the initialization function
if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
	document.write('');
	window.onload = initShowHide;
}

var links;
function initShowHide() {
	// Hide all toggleable sections with JavaScript for the highly improbable case that CSS is disabled
	// Note that in this case the 'flash of visible content' still will occur
	// For testing purposes you can add the following code to disable CSS: document.getElementsByTagName('link')[0].disabled = true;			
	hide();
	var toggle = document.getElementById('toggle');
	var as = toggle.getElementsByTagName('a');
	links = new Array();
	links['cs1'] = 'Be_Inspired/Sense_Of_Place-I1-1.aspx';
	links['cs2'] = 'Be_Inspired/Museums_And_Galleries-I1-2.aspx';
	links['cs3'] = 'Be_Inspired/Performing_Arts-I1-3.aspx';
	links['cs4'] = 'Be_Inspired/Arts_And_Crafts-I1-4.aspx';
	links['cs5'] = 'Be_Inspired/Food_And_Drink-I1-5.aspx';
	for (var i = 0; i < as.length; i++) {
		
		// onmouseover, regular browsers see new related paragraph
		// onmouseover, screenreaders get no feedback
		as[i].onmouseover = function() {
			show(this);
			return false;
		}
		// onclick, regular browsers get redirected to page using javascript
		// onclick, screenreaders get archored to related paragraph (which contains a link to page)
		as[i].onclick = function() {
			jump(this);
		}

		as[i].onmouseout = function() {
			hide();
		}

	}
}

function show(s) {
	hide();
	document.getElementById("cs0").style.display = 'none';
	var id = s.id.match(/#(\w.+)/)[1];
	document.getElementById(id).style.display = 'block';
}

function hide() {
	document.getElementById("cs0").style.display = 'block';
	document.getElementById("cs1").style.display = 'none';
	document.getElementById("cs2").style.display = 'none';
	document.getElementById("cs3").style.display = 'none';
	document.getElementById("cs4").style.display = 'none';
	document.getElementById("cs5").style.display = 'none';
}

function jump(s) {
	var id = s.href.match(/#(\w.+)/)[1];
	window.location = links[id];
}