<!--


	/*
/////////////////////////////////////////////////////////////////////
	  Created on 3/27/06 by Jeremiah T La Bresh
	  
	  DEPT				:	FLEX || CHANNEL
	  
	  DESCRIPTION		:	Group of functions to adjust page width according to content, and to 
	  						compensate for legacy code
							
	  INSTRUCTIONS		:	To make this work, simply adjust the settings in the modSquad function
	  						or make a similar mod quad function and call in any page to adjust widths
	*/


	
	/*
/////////////////////////////////////////////////////////////////////
	  FUNCTION			:	modFit
	
	  DESCRIPTION		:	Calls all functions needed to adjust page settings accordingly
	
	  ATTRIBUTES		:	NONE				
	*/
	function modFit(){
		
		// strip out no wraps
		//modNowraps(); 
		
		// modify width of these elements to 570px wide
		var tempArr = Array("p");
		//modEleWidths(tempArr);
		
		// adjust these elements to 500px wide because of their offset
		var tempArr = Array("ul","ol"); 
		//modEleWidths(tempArr, "500px");
		
		// stretch the div layers to the proper widths
		//modWidth();
	}
	
	
	
	/*
/////////////////////////////////////////////////////////////////////
	  FUNCTION		:	modNowraps
	
	  DESCRIPTION		:	Strips out nowrap from TDs then updates page to show changes
	
	  ATTRIBUTES		:	NONE				
	*/
	function modNowraps(){
		var holdTableArea = document.getElementById("holdTable");
		if(holdTableArea){
			//Nowrap causes tables to stretch past the width of 570px
			//This will remove no wrap from any table cell
			var allTDs = holdTableArea.getElementsByTagName("td");
			for(var i=0; i < allTDs.length; i++){
				var tdAttrs = allTDs[i].attributes;
				if(tdAttrs){
					if(tdAttrs.length > 0){
						for(var k=0; k < tdAttrs.length; k++){
							var tempAttr = tdAttrs[k];
							if(tempAttr.nodeName.toLowerCase() == "nowrap"){
								var tempTry = allTDs[i].removeAttribute(tempAttr.nodeName);
							}
							if(tempAttr.nodeName.toLowerCase() == "nowrap"){
								//alert("issue"); 
							}
						}
					}
				}
			}
			
			// Adjust table widths from 100% to a pixel width equivelent of a percentage of 570
			var allTables = holdTableArea.getElementsByTagName("table");
			var desiredWidth = 570;
			for(var H=0; H < allTables.length; H++){
				//if(allTables[H].parentNode.parentNode == holdTableArea)alert(allTables[H].id + " == " + allTables[H].parentNode.parentNode.nodeName);
				if((allTables[H].parentNode.parentNode == holdTableArea)){
					var curWidth 		= allTables[H].width;
					var curStyleWidth 	= allTables[H].style.width;
					if(curWidth){
						var curWidthP = curWidth.indexOf('%');
						if(curWidthP >= 0){
							//we have a percentage lets make this happen with pixels instead
							var p 			= curWidth.substring(0,curWidth.length-1); // this is our percentage number
							var newP		= parseInt(p);
							var newWidth 	= ((p/100) * desiredWidth);
							var rndWidth	= Math.round(newWidth);
							allTables[H].width = rndWidth;
							allTables[H].style.width = rndWidth + "px";
						} else {
							// we have a number in width -- do NOTHING
						}
					} else if(curStyleWidth) {
						var curWidthP = curStyleWidth.indexOf('%');
						if(curWidthP >= 0){
							//we have a percentage lets make this happen with pixels instead
							var p 			= curWidth.substring(0,curWidth.length-1); // this is our percentage number
							var newP		= parseInt(p); // make our string a number
							var newWidth 	= ((p/100) * desiredWidth); // change our percentage to a decimal
							var rndWidth	= Math.round(newWidth); // change our dcimal to a whole number
							allTables[H].width = rndWidth; // set the width
							allTables[H].style.width = rndWidth + "px"; // set the style
						} else {
							// we have a number in width -- do NOTHING
						}
					} else {
						// we have nothing setting the width
						// do nothing
						allTables[H].width = desiredWidth; // set the width
						allTables[H].style.width = desiredWidth + "px"; // set the style
					}
				}
			}
		}
	}
	
	
	
	/*
/////////////////////////////////////////////////////////////////////
	  FUNCTION		:	modEleWidths
	
	  DESCRIPTION	:	Takes an array of elements, and a target width, this will check for an 
	  					id from 1-3 levels above the current HTML node type based on the array values
	  					If the elements above the selected node match the chosen node Id, then the width 
	  					will be adjusted accordingly
	
	  ATTRIBUTES	:	eleArray 		:: Array 	| i.e. Array("p", "ul", "ol")
	  				:	targetWidth		:: String	| i.e. "570px"					
	*/
	function modEleWidths(eleArray, targetWidth){
		// make sure we have an array - or this wont work
		if(eleArray == undefined){
			return false;
		}
		
		// make sure we have a target width, or set the default
		if(targetWidth == undefined){
			var targetWd = "570px";
		} else {
			var targetWd = targetWidth;
		}
		
		var targetID = "holdTable"; // the target we are aiming for
		var holdTableArea = document.getElementById("holdTable");
		// make sure our target area exits, or dont do anything
		if(holdTableArea){
			// loop through our array of html elements
			for(var m=0; m<eleArray.length; m++){
				var allEles = holdTableArea.getElementsByTagName(eleArray[m]);
				// if there are any of the selected element, then lets do this
				if(allEles){
					for(var i=0; i < allEles.length; i++){
						if(allEles[i].parentNode.parentNode.parentNode.id == targetID){
							allEles[i].style.width = targetWd;
						}
						if(allEles[i].parentNode.parentNode.id == targetID){
							allEles[i].style.width = targetWd;
						}
						if(allEles[i].parentNode.id == targetID){
							allEles[i].style.width = targetWd;
						}
					}
				}
			}
		}
	}
	
	
	
	
	/*
/////////////////////////////////////////////////////////////////////
	  FUNCTION		:	modWidth
	
	  DESCRIPTION	:	Gets the correct width for holdTable and associated tables and corrects the width
	  					for the div layers as well as adjusts properly for the wSpots
	
	  ATTRIBUTES	:	NONE			
	*/
	function modWidth(){
		
		var hTable 			= document.getElementById("holdTable");
		var rPayne  		= document.getElementById("right");	
		var bHolder  		= document.getElementById("bigHolder");
		
		if(!hTable){
			//alert("missing hTable");
		}
		if(!rPayne){
			//alert("missing rPayne");
		}
		if(!bHolder){
			//alert("missing bHolder");
		}
		
		var defaultWidthIn 	= 572;
		var defaultWidthOut	= 583;
		var defaultWidthOutr= 762;
		var bufferWidth  	= 50;
		
		if(hTable){
			var hTableW = hTable.offsetWidth;
			var wSpots  = document.getElementById("wspots");
			if(wSpots){
				var wSpotsW = wSpots.offsetWidth;
			}
			
			if(hTableW > defaultWidthIn){
				bHolder.style.width   = (bufferWidth + hTableW) + "px";
				if(wSpots){
					wSpots.style.right    = (0-wSpotsW) + "px";
					wSpots.style.position = "absolute";
				}
			} else {
				rPayne.style.width 	= defaultWidthOut + "px";
				bHolder.style.width = defaultWidthOutr + "px";
			}
		}
	}

//-->