// Code to toggle panels

//######################################################################################
// Copyright (c) 2010 - Ken Drysdale - www.kendrysdale.net - Unauthorised use prohibited
//######################################################################################

function hidePanels() {
//Hide all panels
	// detect browser features
	
	//NS6, FF 1.5, 2.0, 3.0, Safari 1.3,2.0, 3.0, Opera 9.0, 9.5 - but buggy in IE 5.5, 6 & 7
	var br1 = (document.getElementById) ? true:false; // -->document.getElementById('[Div]').style.visibility = "hidden"
	
	//IE4
	var br2 = (document.all) ? true:false; // -->[Div].style.visibility ="hidden" 
	
	//Netscape 4
	var br3 = (document.layers) ? true:false; // -->document.[Div].visibility = "hide" 
	
	var pDiv = document.getElementsByTagName('div');
	var i = 0
	var elm
	
	while (elm = pDiv.item(i++)) {
		if (elm.id.substr(0,5) == 'panel') { //looking for Divs begining with ID of "panel"
			
			if (br1) { 
				elm.style.visibility = "hidden";
			} else if (br2) { 
				elm.style.visibility ="hidden";
			} else if (br3) {  
				elm.visibility = "hide";
			}
		}
	}
}

function hidejoin() {
//hide all the little bars between link tabs and main panel
	
	// ENTER TOTAL NUMBER OF TABS (loop not needed & will slow down - surplus items not a problem)
	changecss('#link1','border-right-style','none');
	changecss('#link2','border-right-style','none');
	changecss('#link3','border-right-style','none');
	changecss('#link4','border-right-style','none');
	changecss('#link5','border-right-style','none');
	changecss('#link6','border-right-style','none');
	changecss('#link7','border-right-style','none');
	changecss('#link8','border-right-style','none');
	changecss('#link9','border-right-style','none');
}

function crumb(t)  {
	//populate crumbtrail
	
	var txt=document.getElementById("crumb")
	var cr=document.getElementById("topicheading").innerHTML
	txt.innerHTML= '<span class="darken crumblinks">' + cr + '</span>' + ' &raquo; ' + '<span class="darken crumblinks">' + t + '</span>';
}

function showPanel(n, col, tx) {
	//show the selected panel
	
	//hide all the others	
	hidePanels(); 
	hidejoin();

//set property depending on browser
	if (document.getElementById) { //IE 5, 6, Firefox, Safari, Opera, NS7 etc
		document.getElementById('panel' + n).style.visibility = "visible";
	}
	else {
		if (document.layers) { //NS 4
			document.layers["panel" + n].visibility = "show"; 
		}
		else { //IE4
			document.all["panel" + n].style.visibility = "visible";
		}
	}
	
	
	//focus will move down to top of the panel so move it back to top of page
	document.getElementById('wrapper').focus();
	
	//match the colour of the tab
	changecss('.contentwrapper','border-color',col);
	changecss('.colourblock','background-color',col);
	changecss('#link' + n,'border-right-style','solid');
	
	//fill in the crumbtrail
	crumb(tx);
}

