/* ----------------------
   Onload Events
---------------------- */

window.onload = function() {
	sfHover();
	loadBehaviors();
}

/* ----------------------
   Scripts
---------------------- */

function sfHover() {
	if (document.all&&document.getElementById) {
		var sfEls = document.getElementById("tabContent").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" over";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" over\\b"), "");
			}
		}
	}
}


/* Popups */
function popUp(URL, popWidth, popHeight, popLeft, popTop, autoCenter, fullScreen) {
	day = new Date();
	id = day.getTime();
	if (autoCenter == 1) {
		var popLeft = (screen.width - popWidth) / 2;
		var popTop = (screen.height - popHeight) / 2;
	}
	if (fullScreen == 1) {
		// Open in Full Screen window!
		eval("page"+id+" = window.open(URL, '"+id+"', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+(screen.width-10)+",height="+(screen.height-26)+",left=0,top=0');");
	} else {
		// Open in normal window!
		eval("page"+id+" = window.open(URL, '"+id+"', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+popWidth+",height="+popHeight+",left="+popLeft+",top="+popTop+"');");
	}
}


/* Toggle Content */
function toggleDiv( element, showhide ) {
	var e = document.getElementById(element);
	if ( e ) {
		switch ( showhide ) {
			case "true":
				e.style.display = 'inline';
				break;
			case "false":
				e.style.display = 'none';
				break;
			case "default":
				e.style.display = ((e.style.display != 'inline') ? 'inline' : 'none');
				break;
		}
	}
}


/* Tab Code */
function Accordian(target) {
	typeof target == "object" ? this.element = target : this.element = document.getElementById(target); if (!this.element) return false;
	this.ul = this.element.getElementsByTagName("ul")[0];
	this.tabs = this.ul.getElementsByTagName("li");
	this.tabContent = this.getTabContent();
	this.bind();
}

Accordian.prototype.getTabContent = function() {
	var tabContent = new Array();
	this.divs = this.element.getElementsByTagName("div");
	for(var i = 0; i < this.divs.length; i++) {
		if (/tabContent/i.test(this.divs[i].className)) {
			tabContent.push(this.divs[i]);
		}
	}
	return tabContent;
}

Accordian.prototype.bind = function() {
	var o = this;
	for(var i = 0; i < this.tabs.length; i++) {
		//this.tabs[i].onmouseover = function() {
		//this.tabs[i].onclick = function() {
			//if (this.className != 'current') {
				//o.open(this); return false;
				//var a = this.getElementsByTagName("a")[0];
				//if (a) a.onclick = function() {
					return false;
				//}
			//}
		//}
	}
}

Accordian.prototype.open = function(caller) {
	for(var i = 0; i < this.tabs.length; i++) {
		var tab = this.tabs[i];
		if (tab == caller) {
			this.collapse();
			tab.className = "current";
			this.tabContent[i].style.display = "block";
		}
	}
}

Accordian.prototype.collapse = function() {
	for(var i = 0; i < this.tabs.length; i++) {
		this.tabs[i].className = "";
		this.tabContent[i].style.display = "none";
	}
}

function loadBehaviors() {
	new Accordian("article_nav");
}
