//*********************Swap Image************************/
function swapImg ( imgName, imgSrc ){
	document[imgName].src = imgSrc;

}

//******************Writes to Span************************/

function writeEx(id,text){
	document.getElementById(id).innerHTML = text;
}

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 toggleArea(area) {
	if(document.getElementById(area) ) {
		if( document.getElementById(area).className == 'activeDisplay' ) {
			closeArea(area);
		} else {
			openArea(area);
		}
	}
}

function closeArea(area) {
	if(document.getElementById(area) ) {
		document.getElementById(area).className = 'hiddenDisplay';
	}
}

function openArea(area) {
	if(document.getElementById(area) ) {
		document.getElementById(area).className = 'activeDisplay';
	}
}
