/* Subnavigations for the Top navigation and Tooltips for the Supportfunctions */

//var codes = new Array("YH","RU","AS","KA","PU","ME","YA","VI","PI","YHTEISET");	//end codes of subnav-elements, except Yhteiset
var codes = new Array("YH","AS","KA","PU","ME","YA","VI","PI","YHTEISET");	//these before every world is ready
		
//opens a subnavigation element and hides the rest
function openSubnav(code) {	
	if (document.getElementById('subnav'+code).className.indexOf('display') == -1) {	//if there is something to do
		for (var i=0; i<codes.length; i++) {	//looping the array and changing classname for every other element than the parameter
			//if (codes[i] != code)
			try {
				document.getElementById(('subnav'+codes[i])).className = 'subnavElement';
			} catch (err) {	//could come here when not every world is done
			}
		}
		
		//try {
			if (document.getElementById('topnav'+code).className == 'topNavElementHere') {	//if topnav element was selected
				document.getElementById('topnav'+code).className = 'topNavElementHereOpened';	//hiding the arrow in the background
				document.getElementById('subnav'+code).className = 'subnavElementHere display';	//displaying the requested element with green arrow
			}
			else {	//else just showing normal element
				document.getElementById('topnav'+code).className = 'topNavElementOpened';	//hover for the topnav element
				document.getElementById('subnav'+code).className = 'subnavElement display';	//displaying the requested element
			}
		//} catch (err) {
		//}
	}
}

//hides all subnavigation elements
function closeSubnavs() {			
	for (var i=0; i<codes.length; i++) {	//looping the array and changing classname for every element
		try {
			document.getElementById(('subnav'+codes[i])).className = 'subnavElement';
			
			if (document.getElementById('topnav'+codes[i]).className.indexOf('topNavElementHere') == 0)	//if topnav element is here
				document.getElementById('topnav'+codes[i]).className = 'topNavElementHere';	//showing the arrow in the background
			else
				document.getElementById('topnav'+codes[i]).className = 'topNavElement';		//removing hover
		} catch (err) {		//could come here when not every world is done
		}
	}
}


//opens the print tool tip
function openPrintToolTip() {
	document.getElementById('shareHelp').className = '';		//hiding the other elements
	document.getElementById('emailHelp').className = '';
	document.getElementById('printHelp').className = 'display';	//displaying the requested element
}
//opens the share tool tip
function openShareToolTip() {
	document.getElementById('printHelp').className = '';
	document.getElementById('emailHelp').className = '';
	document.getElementById('shareHelp').className = 'display';
}
//opens the email tool tip
function openEmailToolTip() {
	document.getElementById('printHelp').className = '';
	document.getElementById('shareHelp').className = '';
	document.getElementById('emailHelp').className = 'display';
}
//hides the tool tips
function closeToolTips() {
	document.getElementById('printHelp').className = '';
	document.getElementById('shareHelp').className = '';			
	document.getElementById('emailHelp').className = '';
} 


