function findElementById(id) {
	if (document.getElementById) {
		return document.getElementById(id);
	}else if (document.layers) {
		return document[id];
	}else{
		return document.all[id];
	}		
};

function findElementStyleById(id) {
	var ele = findElementById(id);
	if (document.layers) {
		return ele;
	}else{
		return ele.style;
	}
};

function setDisplay (id,value) {
	findElementStyleById(id).display = value;
};

function setVisibility (id,value) {
	if (value == "visible" || value == true) {
		value = "visible";
	}else{
		value = "hidden";
	}
	findElementStyleById(id).visibility = value;
	
}


//This will draw out a tab dynamically...it will ensure that the content will stay xhtml(ish)
var allTabStrips = new Array();

function drawDynamicTabs(tabArray,styleClass,tabLabels) {		
	allTabStrips.push(tabArray);
	tabId = allTabStrips.length-1;	
	document.write("<style type='text/css'>");
	for (a=1; a<tabArray.length; a++) {
		document.write("#" + tabArray[a] + " { display: none; }");
	}
	document.write("</style>");
	if (tabLabels.length != tabArray.length) {
		tabLabels = tabArray;
	}
	
	document.write("<ul class='" + styleClass + "'>");
	for (a=0; a<tabArray.length; a++) {
		ele = tabArray[a];
		if (a == 0) {
			style = "class=\"tabSelected\"";
		}else{
			style = "";
		}
		
		document.write("<li id=\"" + ele + "Tab\" " + style + "><a href=\"javascript:turnOnSectionTab('" + ele + "','" + tabId + "');\">" + tabLabels[a] + "</a></li>");
		
	}
	
	document.write("");
	document.write("</ul>");
	
}


function turnOnSectionTab(id,tabId) {
	allTabs = allTabStrips[tabId];
	for (a=0; a<allTabs.length; a++) {
		ele = allTabs[a];
		setDisplay(ele,"none");
		findElementById(ele + "Tab").className = "";
	}
	setDisplay(id,"inline");
	findElementById(id + "Tab").className = "tabSelected";				
}

function toggleDiv(numOfbranches) {
	if(isNaN(numOfbranches)){
	} else {
		for (a=1; a<=10; a++){
			if(numOfbranches > (a-1))
			{ 
				show="1";
			} else {
				show="0";
			}
			id = ("div" + a).toString();
		if (show=="1"){
			if (document.layers) 
				document.layers[''+id+''].display = "inline"
			else if (document.all) 
				document.all[''+id+''].style.display = "inline"
			else if (document.getElementById) 
				document.getElementById(''+id+'').style.display = "inline"
		}
		else
			if (show=="0"){
				if (document.layers) 
					document.layers[''+id+''].display = "none"
				else if (document.all) 
					document.all[''+id+''].style.display = "none"
				else if (document.getElementById) 
					document.getElementById(''+id+'').style.display = "none"
			}
		}
	}

}
