// Make all blocks (divs) on one page the same height as the tallest one (when faux columns can't be used)

function getHeights(){
	//check for standards compliance
	if(!document.getElementById) return;
	if(!document.getElementsByTagName) return;
	var midHolder = document.getElementById("primarycontent");
	var blocks = midHolder.getElementsByTagName("div");
	// loop through all divs
	for(var i = 0; i < blocks.length; i++){
		if(blocks[i].className == 'panel'){ // we only want <div class="block">
			if(!height ||  height < blocks[i].offsetHeight){ // set the height for first div then reset it if the next div is taller and so on.
				var height = blocks[i].offsetHeight; //set the highest height
			}
		}
	}
	
	setBlockHeights(height); // run the setHeights function for the content blocks
}

// make all divs the same height in pixels. must be run on window resize, text increase/decrease. (a ballache basically.)
function setBlockHeights(height){
	var midHolder = document.getElementById("primarycontent");
	var blocks = midHolder.getElementsByTagName("div");	
	for(var i = 0; i < blocks.length; i++){
		// set heights for IE6/Win
		if(blocks[i].className == 'panel' && !blocks[i].getAttribute("class")){
				blocks[i].style.height = height+'px'; // set height
		} 
		// set min-height for sane browsers
		else if(blocks[i].getAttribute("class") == 'panel'){
				blocks[i].style.minHeight = height+'px'; // set min-height
		}
	}
}


//addEvent(window,"load",getHeights);

$(document).ready(
	function() {
		getHeights();
	}
);