//-- ### Javascript for Suckerfish Dropdown Navigation ### -- //
sfHover = function() {
	if(document.getElementById("navigation")){
		var sfEls = document.getElementById("navigation").getElementsByTagName("li");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
	
				// Hide from Opera
				if(navigator.userAgent.indexOf("Opera") == -1){
					var ieUL = this.getElementsByTagName('ul')[0];
					if (ieUL) {
						var ieMat = document.createElement('iframe');
						ieUL.insertBefore(ieMat,ieUL.firstChild);
					} 
				}
			
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
// ----------------------------------------------------------//

/* grab Elements from the DOM by className */
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

/* window 'load' attachment */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

if (document.images) { 
	image1 = new Image 
	image1.src = '../img/map-dn.gif'
}



/*------------------------------------------------------------------------------

This code is used to create a list of external links on the printed version of the page.

Filename:       jsUtilities Library
Author:         Aaron Gustafson (aaron at easy-designs dot net)
                unless otherwise noted
Creation Date:  4 June 2005
Version:        2.1
Homepage:       http://www.easy-designs.net/code/jsUtilities/
License:        Creative Commons Attribution-ShareAlike 2.0 License
                http://creativecommons.org/licenses/by-sa/2.0/
Note:           If you change or improve on this script, please let us know by 
                emailing the author (above) with a link to your demo page.
------------------------------------------------------------------------------*/
if(Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }; };if (!Function.prototype.apply) { Function.prototype.apply = function(oScope, args) { var sarg = []; var rtrn, call; if (!oScope) oScope = window; if (!args) args = []; for (var i = 0; i < args.length; i++) { sarg[i] = "args["+i+"]";}; call = "oScope.__applyTemp__(" + sarg.join(",") + ");"; oScope.__applyTemp__ = this; rtrn = eval(call); oScope.__applyTemp__ = null; return rtrn;};};
function inArray(needle) { for (var i=0; i < this.length; i++) { if (this[i] === needle) { return i; } } return false; } Array.prototype.inArray = inArray;
function addClass(theClass) { if (this.className != '') { this.className += ' ' + theClass; } else { this.className = theClass; } } Object.prototype.addClass = addClass;
/*------------------------------------------------------------------------------
Function:       footnoteLinks()
Author:         Aaron Gustafson (aaron at easy-designs dot net)
Creation Date:  8 May 2005
Version:        1.3
Homepage:       http://www.easy-designs.net/code/footnoteLinks/
License:        Creative Commons Attribution-ShareAlike 2.0 License
                http://creativecommons.org/licenses/by-sa/2.0/
Note:           If you change or improve on this script, please let us know by 
                emailing the author (above) with a link to your demo page.
------------------------------------------------------------------------------*/
function footnoteLinks() {
	var containerID="wrapper";
	if (!document.getElementById || !document.getElementsByTagName || !document.createElement) return false;
	if (!document.getElementById(containerID)) return false;
	var container = document.getElementById(containerID);
	var oDiv = document.createElement('div');
	oDiv.id = "links";
	addClass.apply(oDiv,['printOnly']);
	var h2        = document.createElement('h2');
	var h2_txt    = document.createTextNode('External Links');
	h2.appendChild(h2_txt);
	var coll = container.getElementsByTagName('a');
	var ol   = document.createElement('ol');
	var myArr = [];
	var thisLink;
	var num = 1;
	for (var i=0; i<coll.length; i++) {
	  var thisClass = coll[i].className;
	  if ((coll[i].getAttribute('target')) && (thisClass == '' || thisClass.indexOf('ignore') == -1)) { 
	    thisLink = coll[i].href;
	    var note = document.createElement('sup');
	    addClass.apply(note,['printOnly']);
	    var note_txt;
	    var j = inArray.apply(myArr,[thisLink]);
	    if ( j || j===0 ) {
	      note_txt = document.createTextNode(j+1);
	    } else {
	      var li     = document.createElement('li');
	      var li_txt = document.createTextNode(thisLink);
	      li.appendChild(li_txt);
	      ol.appendChild(li);
	      myArr.push(thisLink);
	      note_txt = document.createTextNode(num);
	      num++;
	    }
	    note.appendChild(note_txt);
	    if (coll[i].tagName.toLowerCase() == 'blockquote') {
	      var lastChild = lastChildContainingText.apply(coll[i]);
	      lastChild.appendChild(note);
	    } else {
	      coll[i].parentNode.insertBefore(note, coll[i].nextSibling);
	    }
	  }
	}
	if(num>1){
		container.appendChild(oDiv);
		oDiv.appendChild(h2);
		oDiv.appendChild(ol);
		addClass.apply(document.getElementsByTagName('body')[0],['noted']);
	}
	return true;
}

addLoadEvent(footnoteLinks);

//////////////////////////



// === hide and show div's  === //

function toggleDiv(divID, divState) // 1 visible, 0 hidden
{
	//alert(divID + ":" + divState);
	var obj = document.getElementById(divID);
	
	if (obj) {
		obj.style.display = divState ? "" : "none";
	} else {
		//alert("unable to find element with id: " + divID);
	}
}

// === changing classes for tabs === //

function changeElementClass(element,classname)
{
  document.getElementById(element).className = classname;
}