//alert('matchHeight.js');

// need to match the searchpane and content heights AFTER matching the category heights
// it appears that addListenerToEvent adds to the FRONT of the listener's stack in FF and the reverse in IE. or the other way round. Whatever, I need to make sure they happen in the correct order therefore add ONE function to body's onload and have it call the two in the correct order
addListenerToEvent(window,'onload','matchHeights()');

/* 
div-height equalizer from 
http://www.devarticles.com/c/a/Web-Design-Standards/Matching-div-heights-with-CSS-and-JavaScript/3/
note that it didn't work in FF because it wasn't setting the heights in pixels, just a number.
*/

matchHeights=function(){
	// initialize maximum height value
	var maxHeight=0;
	
	var divs=new Array();
	if (document.getElementById('cc')) divs.push(document.getElementById('cc'));
	else if (document.getElementById('content')) divs.push(document.getElementById('content'));
	if (document.getElementById('menu')) divs.push(document.getElementById('menu'));
	
	//var alerttext='';
	
	if (divs.length>1) {
		// iterate over specified elements to greatest height
		for(var i=0;i<divs.length;i++){
			//alert(divs[i].id);
			d=divs[i];
			
			// determine height for <div> element
			if(d.style.height){
				//alert('style.height');
				divHeight=d.style.height;
				} // end else if
			else if(d.offsetHeight){
				//alert('offsetHeight');
				divHeight=d.offsetHeight;
				} // end if
			else if(d.style.pixelHeight){
				//alert('style.pixelHeight');
				divHeight=d.style.pixelHeight;
				} // end else if
			//alert('divHeight: '+divHeight);
			//alerttext+='divHeight: '+divHeight+';';
			
			// calculate maximum height
			maxHeight=Math.max(maxHeight,divHeight);
			//alert('maxHeight: '+maxHeight);
			//alerttext+='maxHeight: '+maxHeight+';';
			} // end for (args)
			
		//alert('final maxHeight: '+maxHeight);
		//alerttext+='final maxHeight: '+maxHeight+';';
		
		//alert (alerttext);
		
		// assign maximum height value to all specified elements
		for(var i=0;i<divs.length;i++){
			//alert(divs[i]);
			d=divs[i];		
			d.style.height=maxHeight+'px';
			d.style.marginLeft='0px';
			d.style.height=maxHeight+'px';
			if (d.offsetHeight > maxHeight) { // fix for the difference between height and offsetHeight in standards-compliant mode (see http://www.paulbellows.com/getsmart/balance_columns/column.js)
					d.style.height = (maxHeight - (d.offsetHeight - maxHeight)) + 'px';
				}
			}
		} // end if (divvs.length>1)

	}


