/*
@depends prototype_1_5_0.js
@depends ofDomFunctions.js
*/

function switchTab(e){
	theEle = getParent(e,'LI');
	theUL = getParent(theEle,'UL');
	theLIs = theUL.immediateDescendants();
	for (i=0; i<theLIs.length; i++){
		Element.removeClassName(theLIs[i],"ofSelected");
		Element.removeClassName(theLIs[i],"ofSelectedAndOfFirstChild");
	}
	Element.addClassName(theEle,"ofSelected");
	
	if (window.ActiveXObject){
		if (Element.hasClassName(theEle,"ofFirstChild")) {
			Element.addClassName(theEle,"ofSelectedAndOfFirstChild");
		}
	}
				
	sizeTabObjects();
}

function switchTabParent(e){
	childDiv = e.immediateDescendants();
	aTag = childDiv[0].immediateDescendants();
	switchTab(aTag[0]);
}

function sizeTabObjects(){ // Sets the height and width
	theTabObjects = $$(".ofTabRounded");
	for (j=0; j<theTabObjects.length; j++){
		if (Element.hasClassName(theTabObjects[j],"ofLastChild")){ // accommodate ofLastChild spacing on bottom
		offSet = 12;
	}else{
		offSet = 36;
	}
	theUL = theTabObjects[j].immediateDescendants();
	theLIs = theUL[0].immediateDescendants();
	for (i=0; i<theLIs.length; i++){
		if (Element.hasClassName(theLIs[i],"ofSelected")){
			theLIchildren = theLIs[i].immediateDescendants();
			theContentObjects = theLIchildren[1];
			theTabObjects[j].style.height = Element.getHeight(theContentObjects) + offSet + "px"; // sets height
		}
	}
}

setAutoWidthObjectWidths() // only needed to support IE6 - sets width of container
calcHeights() // Needed for interwoven framework
}

function getParentGridWidthSize(e) {
 if(null==e) return null;
 if (e.className!=null && (e.className.indexOf("ofGridWidth") > -1 || e.className.indexOf("iw_component") > -1) && e.className.indexOf("ofGridWidthAuto") == -1){

	//alert(Element.getStyle(e,"width"));
	return Element.getStyle(e,"width").replace("px","");
   
 } else {
   if(e.parentNode!=null) return getParentGridWidthSize(e.parentNode);
   else {
    // since now we're at the top of the DOM and our class wasn't found, assume that we should use the entire screen width
    return Element.getWidth(document.getElementsByTagName("body")[0]);
   }
 }
}


function setAutoWidthObjectWidths(){ // Sets width of anything with an ofGridWidthWidthAuto to width of the containing ofGridWidthWidth# class
	theAutoWidthObjects = $$(".ofGridWidthAuto");
	for (i=0; i<theAutoWidthObjects.length; i++){
		theAutoWidthObjects[i].style.width = getParentGridWidthSize(theAutoWidthObjects[i]) + "px";
	}
}