/*
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
*/

// 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
$(function() {
    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'] = 'Places_To_Visit/Aberglasney-P2-6.aspx';
	links['cs2'] = 'Places_To_Visit/Clyne_Gardens-P2-2.aspx';
	links['cs3'] = 'Places_To_Visit/Colby_Woodland_Gardens_(National_Trust)-P2-15.aspx';
	links['cs4'] = 'Places_To_Visit/Margam_Country_Park-P2-4.aspx';
	links['cs5'] = 'Places_To_Visit/Picton_Castle_and_Woodland_Gardens-P2-18.aspx';
	links['cs6'] = 'Places_To_Visit/Pembrokeshire_Coast_National_Park-P2-20.aspx';
	links['cs7'] = 'Places_To_Visit/National_Botanic_Garden_of_Wales-P2-10.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';
	document.getElementById("cs6").style.display = 'none';
	document.getElementById("cs7").style.display = 'none';
}

function jump(s) {
	var id = s.href.match(/#(\w.+)/)[1];
	window.location = links[id];
}