// Functions Created by Dominion Digital (c) 2007
// info@dominiondigital.com

window.onload = init;

function init() {
	traverseTree(document.getElementById("mainmenuContainer"));
	viewLink (document.getElementById("seasons"));
}

function traverseTree(whatTree){	
	version=0
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		temp=navigator.appVersion.split("MSIE")
		version=parseFloat(temp[1])
	}
	
	if (version==6) {	
		if (whatTree.hasChildNodes()) {
			for(var i=0;i<whatTree.childNodes.length;i++) {
				var node_str = whatTree.childNodes[i]
				if (node_str.nodeName=="UL") {
					for(var j=0;j<node_str.childNodes.length;j++) {
						var subnode_str = node_str.childNodes[j]
						if (subnode_str.nodeName=="LI") {
							setItAndForgetIt(subnode_str);
							traverseTree(subnode_str);
						}
					}
				}
			}		
		} 
	} 
}

function setItAndForgetIt(whichNode) {
//	alert(whichNode.className)
	whichNode.onmouseover=function() {
	  this.className+=" over";
//	  alert(this.className)
	}
	whichNode.onmouseout=function() {
	  this.className=this.className.replace(" over", "");
//	  alert(this.className)
	}
}

function toggleDiv(whichID) {
	var divObject = document.getElementById(whichID)
	if (divObject.style.display == "block") {
		  divObject.style.display = "none";
	} else {
		  divObject.style.display = "block";
	}
}	

function hideDiv(whichID) {
  document.getElementById(whichID).style.display = "none";
}	
function showDiv(whichID) {
  document.getElementById(whichID).style.display = "block";
}	

function viewLink (whichSection){	
	if (whichSection.hasChildNodes()) {
		for(var i=0;i<whichSection.childNodes.length;i++) {
			var node_str = whichSection.childNodes[i]
			if (node_str.nodeName=="LI") {
				for(var j=0;j<node_str.childNodes.length;j++) {
					var subnode_str = node_str.childNodes[j]
					if (subnode_str.nodeName=="A") {
						if (subnode_str.href == "http://www.osagebioenergy.com/#") {
							subnode_str.style.cursor = "default";
						} else if (subnode_str.href == "http://www.osagebioenergy.com/default.shtml#") {
							subnode_str.style.cursor = "default";
						}
					}
				}
			}
		}		
	}
}


function extractPageName(hrefString)
{
	var arr = hrefString.split('/');
	return  (arr.length<2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase();		
}

function setActiveMenu(arr, crtPage)
{
	for (var i=0; i<arr.length; i++)
	{
		if(extractPageName(arr[i].href) == crtPage)
		{
			if (arr[i].parentNode.tagName != "DIV")
			{
				var listItem = arr[i].parentNode;
				var topListItem = listItem.parentNode;
				var topTopListItem = topListItem.parentNode;				
				var topTopTopListItem = topTopListItem.parentNode;
				arr[i].className = "current";
				listItem.className = "currentList";
				listItem.parentNode.className = "listOpen";			
				topListItem.parentNode.className = "topListOpen";
				//topTopListItem.parentNode.className = "listOpen";			
				//topTopTopListItem.parentNode.className = "topListOpen";
			}
		}
	}
}

function setPage()
{
	hrefString = document.location.href ? document.location.href : document.location;
	if (document.getElementById("submenu")!=null) 
		setActiveMenu(document.getElementById("submenu").getElementsByTagName("a"), extractPageName(hrefString));
}

