﻿function tgl(node,tag){
    var div=node.parentNode.getElementsByTagName(tag)[0];
    var style=div.style.display;
    if(style=="" || style=="auto" || style=="block"){
        div.style.display="none";
        node.setAttribute("class","collapsed");
        node.setAttribute("className","collapsed");
    }
    else{
        div.style.display="block";
        node.setAttribute("class","expanded");
        node.setAttribute("className","expanded");
    }
    return false;
}

function changeAll(open){
    var div=document.getElementById("contacts");
    h2s=div.getElementsByTagName("H2");
    var childDiv;
    var css = open===true?"expanded":"collapsed";
    var styleText = open===true?"display:block;":"display:none;";
    for(var i=0;i<h2s.length-1;i++){
        h2s[i].setAttribute("class",css);
        h2s[i].setAttribute("className",css);
        childDiv=h2s[i].parentNode.getElementsByTagName("DIV")[0];
        childDiv.setAttribute("style",styleText);
        childDiv.style.cssText=styleText;
    }
    return false;   
}

// enables suckerfish dropwdowns in IE
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

sfTree = function() {
    var tree = document.getElementById("tree");
    if(tree){	
        var sfEls = tree.getElementsByTagName("DIV");
	    for (var i=0; i<sfEls.length; i++) {
	        if(sfEls[i].getAttribute("className")!="noexpand" && sfEls[i].getAttribute("class")!="noexpand"){
	            sfEls[i].onclick=function(){return tgl(this,"UL");
	            }
	        }
	    }
	}
}

sfContact = function() {
    var contacts = document.getElementById("contacts");
    if(contacts){
        var sfEls = contacts.getElementsByTagName("H2");
        for (var i=0; i<sfEls.length; i++) {
            if(sfEls[i].getAttribute("className")!="noexpand" && sfEls[i].getAttribute("class")!="noexpand"){
                sfEls[i].onclick=function(){return tgl(this,"DIV");
                }
            }
        }
	}
}

function sf(){
    sfContact();
    sfHover();
    sfTree();
}

// attach the hover event to anything with a class of collapsed or expanded
if (window.attachEvent) window.attachEvent("onload", sf);
if (window.addEventListener) window.addEventListener("load", sf, false);

function CreateBookmarkLink(title,url) {
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, url,"");
    } else if( window.external ) { // IE Favorite
        window.external.AddFavorite( url, title); }
    else if(window.opera && window.print) { // Opera Hotlist
        return true; }
}