// v1.2 Copyright (c) 2006 TJKDesign - Thierry Koblentz
// Significantly modified by RPI.
function swap(){this.className="msieFix"; ToggleSelects('hidden');}
function swapBack(){this.className="trigger"; ToggleSelects('visible');}
function swapBackPause(){var t; t=setTimeout("swapBack()",2000); alert('hello1');}
function toggle(){(this.parentNode.className=="trigger")?this.parentNode.className="msieFix":this.parentNode.className="trigger";return false;}
function reveal(){
    this.parentNode.parentNode.parentNode.className="msieFix";
}

function ToggleSelects(status){
	var MySelect;
	if (document.all) //Z-Index issues appear to be restricted to IE. Firefox is fine.
	{
		// IE browsers.
		var aSelectCollection = document.all.tags("select");

		//var aiFrameCollection = document.all.tags("iframe");
	}
	else
	{
		//Mozilla browsers.
		//var aiFrameCollection = document.getElementsByTagName("iframe");
	}

	//Find and hide all select tags on the page.
	if (aSelectCollection!=null) {
		for (i=0; i<aSelectCollection.length; i++) 
		{
			if (aSelectCollection[i].id) {
				if (document.getElementById(aSelectCollection[i].id)) {
					MySelect = document.getElementById(aSelectCollection[i].id);
					MySelect.style.visibility = status;
				}
			}
		}
	}
	/*
	if (aiFrameCollection!=null) {
		for (i=0; i<aiFrameCollection.length; i++) 
		{
			if (aiFrameCollection[i].id) {
				if (document.getElementById(aiFrameCollection[i].id)) {
					MyFrame = document.getElementById(aiFrameCollection[i].id);
					MyFrame.style.visibility = status;
				}
			}
		}
	}
	*/
}


function cleanUp(){
	var zA;
	var LI = document.getElementsByTagName("li");
	var zLI= LI.length;
		for(var k=0;k<zLI;k++){
		if(LI[k]!=this.parentNode){
		LI[k].className="trigger";
		}
	}	
}

function TJK_keyBoardDropDown(){
	var LI;
	var dvNavArea = document.getElementById('divNavarea');
	if (dvNavArea){
		//alert('Found divNavarea');
		LI = dvNavArea.getElementsByTagName("li");
	}

	//if (document.all) //Z-Index issues appear to be restricted to IE. Firefox is fine.
	//{
		// IE browsers.
	//	LI = document.all.tags("select");
	//}
	//else {
	//	LI = document.getElementsByTagName("li");
	//}

	
	var zLI= LI.length;
	//alert('LI Length: ' + zLI);
	
	var bAllowMenusToDropDown;

	//alert(location.href.indexOf("/content/"));
	//bAllowMenusToDropDown = true;
	//if (document.all) {
	//	if (location.href.indexOf("/content/") != -1) { //If "/content/" is not part of the URL, it's ok to show menu.
	//		bAllowMenusToDropDown = false;
	//	}
	//}

	//if (bAllowMenusToDropDown) {
		if (document.getElementById){
			//alert('Here');
			for(var k=0;k<zLI;k++){
				
				if ((LI[k].id) || (LI[k].className)) {
					//return;
					//alert('Checking...' + LI[k].id);
					if(LI[k].id){
						LI[k].className="trigger";
						//LI[k].firstChild.onclick=toggle; //RS - commented this out 21/09/07, as it prevents <a href> links from working on root menu items, like "Home", "News", etc.
						//LI[k].firstChild.title="show/hide the sub-menu";
						
						if (LI[k].firstChild) { //Just check to make sure there's a value. Menus with no submenus may throw an error.
						    LI[k].firstChild.onfocus = cleanUp;
						}
						//alert('Alert 1...');
					}
					if(LI[k].className=="trigger"){
						LI[k].onmouseover=swap;
						LI[k].onmouseout=swapBack;
						//alert('Alert 2...');
					}

					if(!LI[k].id){
						/* RS 16/01/08 - commented this out as it was causing a JS error on menu items 
						that did not have a link yet. May need to reactivate this when the site is finished!!! */
						
					    if (LI[k].firstChild) { //Just check to make sure there's a value. Menus with no submenus may throw an error.
					        LI[k].firstChild.onfocus = reveal;
					    }
						//alert('Alert 3...');
					}
				}
			}
		}
	//}
}
//document.write('<style type="text/css" media="screen">@import "TJK_keyBoardDropDownModernBrowsersWithScriptSupport.css";</style>')
document.write("<link rel='stylesheet' media='all' type='text/css' href='/styles/TJK_keyBoardDropDownModernBrowsersWithScriptSupport.css' />")
/*window.onload=function(){TJK_keyBoardDropDown();}*/
