
function subWrapperHeight() {
	if(document.getElementById) {
   
		var currHeight = 0;
		var maxHeight = 0;
		pageColumns = new Array('position2', 'position3', 'position4', 'subWrapper');
		
		
		for (i = 0; i < pageColumns.length; i++) {
			if (document.getElementById(pageColumns[i])) {
				document.getElementById(pageColumns[i]).style.height = "";
				currHeight = document.getElementById(pageColumns[i]).offsetHeight;
				if (currHeight > maxHeight) {
					maxHeight = currHeight;
				}
			}
		}
		
		for (i = 0; i < pageColumns.length; i++) {
			if (document.getElementById(pageColumns[i])) {
				if (document.getElementById(pageColumns[i]).offsetHeight < maxHeight) {
					document.getElementById(pageColumns[i]).style.height = maxHeight+"px";
					/*alert(document.getElementById(pageColumns[i]).style.height);*/
				}
			}
		}
	}
}


/* this shows and hides table rows in the search results table. it receives the id of the table row to be hidden as an argument */
function toggle(which) {
	if(document.getElementById) {	
		 var thisOne = document.getElementById(which) // assign row to a varaiable for easy reference
		 if(thisOne.style.display=='none' ){ // check if row is currently hidden
		   thisOne.style.display = ''; // if so, unhide
		 }else{
		   thisOne.style.display = 'none'; // if not, hide it
		 }
		 subWrapperHeight(); // run subWrapperHeight to update page height & accomodate expanding/contracting table rows
	}
}


/* this swaps out the plus/minus signs to visually indicate if a row can be expanded or contracted */
function plusMinus(moreLess) {  // receives self-reference from cell that needs to be changed
	if (moreLess.innerHTML == '+') { // check if plus is displayed
		moreLess.innerHTML = '-' // if so, change to minus
	}
	else if (moreLess.innerHTML == 'Show Additional Photos') {
		moreLess.innerHTML = 'Hide Additional Photos'
	}
	else if (moreLess.innerHTML == 'Hide Additional Photos') {
		moreLess.innerHTML = 'Show Additional Photos'
	}
	else if (moreLess.innerHTML == '-') {
		moreLess.innerHTML = '+'
	}
}
	

/* hlRow swaps the styles on table rows (or any other container) to give visual feedback for event handlers
IMPORTANT! Naming conventions must be observed for CSS styles in order for this script to work. 
- off/inactive state can have any class name
- on/active state must have a class name that is identical to off state, followed by _Highlight
*/
function hlRow(what){
	if(document.getElementById) {	
		var highlightThis = document.getElementById(what) // assign item to be highlighted to a var
		if (highlightThis.className.indexOf('Highlight') == -1) { // check to see if the row is highlighted
			highlightThis.className = highlightThis.className+'_Highlight' // if not, concat. _Highlight to the existing class name
		}
	}
}
	
/* hlRowOff swaps the styles on table rows (or any other container) to give visual feedback for event handlers
IMPORTANT! Naming conventions must be observed for CSS styles in order for this script to work. 
- off/inactive state can have any class name
- on/active state must have a class name that is identical to off state, followed by _Highlight

EXAMPLE ON STATE: foo
EXAMPLE OFF STATE: foo_Highlight
*/	
function hlRowOff(what){
	if(document.getElementById) {	
		if (document.getElementById(what).className.indexOf('Highlight') != -1) { //check to see if the row is highlighted
			var b = document.getElementById(what).className // if so, save the class name to a var
			var temp = new Array(); // set up an array to split the class name into
			temp = b.split('_'); // split the array at the underscore (only used on the classes that end in _Highlight!)
			document.getElementById(what).className = temp[0] // apply the first element in the array as the new class name (which corresponds to the on state without _Highlight)
		}
	}
}


/* hide all rows containing additional content */
function hideAllAdditional(whichTable) { // specify table to hide rows in as argument
	if(document.getElementById) {	
		for (var whichTable, a = 0; a < arguments.length; ++a) { // grab the rows in all tables to modify
			whichTable = document.getElementById(arguments[a]); 
					var r = 0, row, rows = whichTable.rows; // set up to cycle through table rows
					while (row = rows.item(r++)) // cycle through rows
					/*alert(row.className)*/
					if (row.style.display != 'none' && row.className.indexOf('additional') != -1) {  // check to see if the row is visible AND contains additional content
						row.style.display = 'none'; // if so, unhide
					}
		}
		
		var allTDs = document.getElementsByTagName("td"); // grab all table cells
		noOfCells = allTDs.length; // set var equal to number of table cells
			for (var q = 0; q < noOfCells; q++) { //move through all cells
				if (allTDs.item(q).className == 'plusMinus') { // if the cell is classed to contain a plus/minus symbol
					allTDs.item(q).innerHTML = '+' // change the content to a plus, since we're hiding every row
				}
			}
			
		subWrapperHeight();  // run subWrapperHeight to update page height & accomodate expanding/contracting table rows
	}
}



/* show all rows containing additional content */
function showAllAdditional(whichTable) { // specify table to hide rows in as argument
for (var whichTable, a = 0; a < arguments.length; ++a) // grab the rows in all tables to modify
	{
		whichTable = document.getElementById(arguments[a]);
     		var r = 0, row, rows = whichTable.rows; // set up to cycle through table rows
     		while (row = rows.item(r++)) // cycle through rows
			/*alert(row.className)*/
			if (row.style.display == 'none' && row.className.indexOf('additional') != -1) { // check to see if the row is hidden AND contains additional content
				row.style.display = '' // if so, show the row
			}
			
	}
	
	var allTDs = document.getElementsByTagName("td"); // grab all table cells
	noOfCells = allTDs.length; // set var equal to number of table cells
	for (var q = 0; q < noOfCells; q++) { //move through all cells
		if (allTDs.item(q).className == 'plusMinus') { // if the cell is classed to contain a plus/minus symbol
			allTDs.item(q).innerHTML = '-' // change the content to a minus, since we're showing every row
		}
	}
	
  subWrapperHeight(); // run subWrapperHeight to update page height & accomodate expanding/contracting table rows
}

var detailSections = new Array('section1', 'section2', 'section3', 'section4', 'section5', 'section6', 'section7');
      var selectedTab = null;
      function showSection(tab, name) {
	  var whichTab = document.getElementById(tab)
        if (selectedTab) {
          selectedTab.className = 'tabOff'
		}
		
        selectedTab = whichTab;
		selectedTab.className = 'tabOn'
        
        
		for(i = 0; i < detailSections.length; i++)
        {
          if (document.getElementById(detailSections[i])) document.getElementById(detailSections[i]).style.display = (name == detailSections[i]) ? 'block':'none';
        }
        subWrapperHeight(); // run subWrapperHeight to update page height & accomodate expanding/contracting table rows
		return false;
      }
	  
<!--
function openEdmundsRec() { //v2.0
  window.open('/engineering/case_studies/popup.php','caseStudy','scrollbars=0,toolbar=no,menubar=no,width=660');
}
//-->

function showDiv(whichDiv) {
if(document.getElementById(whichDiv).style.display == 'none') {
	document.getElementById(whichDiv).style.display = 'block';
	if(whichDiv == 'bStyleMore') {
		document.getElementById('bStyleLast').innerHTML = '<strong>-&nbsp;</strong><a onclick="showDiv(\'bStyleMore\');">[LESS BODY STYLES]</a>'
	}
}

else if(document.getElementById(whichDiv).style.display == 'block') {
	document.getElementById(whichDiv).style.display = 'none';
	if(whichDiv == 'bStyleMore') {
		document.getElementById('bStyleLast').innerHTML = '<strong>+&nbsp;</strong><a onclick="showDiv(\'bStyleMore\');">[MORE BODY STYLES]</a>'
	}
}


subWrapperHeight();
}