//Javascript file

function addLoadEvent(func) {
  	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
	
		window.onload = function() {
		  oldonload();
		  eval(func);
	
		}
	  }
}

function getElementsByClass(theClass) {
	var gotCollection = new Array();
	var gotAll = new Array();
	gotAll = document.getElementsByTagName("*");
	j=0;
	for (i=0; i<gotAll.length; i++) {
		if ((gotAll[i].className==theClass)||(gotAll[i].className.search(" " + theClass)!=-1)||(gotAll[i].className.search(" " + theClass + " ")!=-1)||(gotAll[i].className.search(theClass + " ")!=-1)) {
			gotCollection[j]=gotAll[i];
			j++;
		}
	}
	return gotCollection;
}

function toggleShowHideDivs(e,a) {
	var theElement = document.getElementById(e);
	var theAnchor = document.getElementById(a);
	if (theElement.style.visibility == "hidden") {
		theElement.style.visibility = "visible";
		theElement.style.position = "static";
		theAnchor.className = "showHideDivLinkOn";
		theAnchor.title = "click to close";
	}
	else {
		theElement.style.visibility = "hidden";
		theElement.style.position = "absolute";
		theAnchor.className = "showHideDivLinkOff";
		theAnchor.title = "click to open";
	}
}

function setShowHideDivs() {
	var anchors = getElementsByClass("showHideDivLinkOff");
	for(var i=0; i < anchors.length; i++) {
		//update links
		var a = anchors[i];
		var href = a.href;
		var index = href.indexOf("#") + 1;
		var divIdValue = href.substring(index);
		var anchorLink = "anchorLink" + i;
		a.setAttribute("id",anchorLink);
		a.setAttribute("title","click to open");
		href = "javascript:toggleShowHideDivs('" + divIdValue + "','" + anchorLink + "');";  //href = "#" + href.substring(index);
		a.setAttribute("href",href);
		//hide DIVs
		document.getElementById(divIdValue).style.visibility = "hidden";
		document.getElementById(divIdValue).style.position = "absolute";
	}
}


function setDynTabs(){
	setDynTabsDefaultAppearance();
	setDynTabsLinks();
}
function setDynTabsDefaultAppearance(){
	for (var i = 0; i < arDynTabContent.length; i++) {
		document.getElementById(arDynTabContent[i]).style.display = "none";
		document.getElementById(arDynTabContent[0]).style.display = "block";
	}
}
function setDynTabsLinks(){
	var anchors = document.getElementsByTagName("a");
	for(var i=0; i < anchors.length; i++) {
		var a = anchors[i];
		var href = a.href;
		if (href.indexOf("#dynTabContentSection") != -1) {
			var index = href.indexOf("#dynTabContentSection") + 1;
			href = "javascript:changeDynTabs('" + href.substring(index) + "');";
			a.setAttribute("href",href);
		}
	}
}
function changeDynTabs(url) {
	var divShow = url;
	for (var i = 0; i < arDynTabContent.length; i++) {
		document.getElementById(arDynTabContent[i]).style.display = "none";
	}
	for (var i = 0; i < arDynTabContent.length; i++) {
		document.getElementById("li_" + arDynTabContent[i]).className = "";
	}
	document.getElementById(divShow).style.display = "block";

	var currentTab = "li_" + divShow;
	document.getElementById(currentTab).className = "tabs1selected";
}



addLoadEvent(setDynTabs);



