// site wide javascript

function show_nav() {
	if(!document.getElementById){
		return false;
	}
	else{
		var a = document.getElementById('navigation').getElementsByTagName('A');
		if(window.location.href.substr(location.href.length - 1, 1) == '/'){
			var loc = window.location.href + 'index.php'; 
		}
		else{
			var loc = window.location.href.replace('#','');
		}
		for(var i=0; i < a.length; i++) {
			if(a[i].href == loc){
				a[i].setAttribute("class", "over");
				a[i].setAttribute("className", "over");
			}
		}
	}	
}

function init_ie6_fixes(){
	if (!/MSIE (5\.5|6\.)/.test(navigator.userAgent)) return;
	else if (document.all && document.getElementById && document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule){
		// add hover pseudo class to <li>
		navRoot = document.getElementById("navigation");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					curCname = this.className;
					this.className="over";
				}
				node.onmouseout=function() {
					if(!curCname) {
						this.className=this.className.replace("over","");
					}
					else {
						//alert(curCname);
						this.className=this.className.replace("over",curCname);
					}
				}
			}
		}
		// add hp shades fix
		var shades = getElementsByClassName(document, "h2", "shades");
		for (var i=0; i<shades.length; i++) {
			shades[i].onmouseover = function() {
				this.className=this.className.replace("shades","over");
			}
			shades[i].onmouseout = function() {
				this.className=this.className.replace("over","shades");
			}
		}
		// add png transparency fix
		//document.styleSheets[0].addRule('img', 'behavior: url(../../includes/js/iepngfix.htc)');
		// add fixed position fix
		//include_dom('../../includes/js/ie6.js');
	}
}

function include_dom(script_filename) {
    var html_doc = document.getElementsByTagName('head').item(0);
    var js = document.createElement('script');
    js.setAttribute('language', 'javascript');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', script_filename);
    html_doc.appendChild(js);
    return false;
}

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

function set_plos() {
	window.onload = plos_go;
}
function plos_go() {
	for(var i = 0;i < plos.length;i++)
		eval(plos[i]);
}
function plo_add(jso) {
	plos[plos.length] = jso;
}
var plos = new Array();
plo_add("init_ie6_fixes()");
plo_add("show_nav()");
