//alert('matchHeight_categories');

// 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()');

function matchHeights() {
	matchHeight_categories();
	matchHeight_searchpane_and_content();
	}

/* 
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.
*/
matchHeight_categories=function(){
	// initialize maximum height value
	var maxHeight=0;
	
	var divs=getElementsByClassName ('details', 'div', document.getElementById('categories'));
	
	// iterate over specified elements to greatest height
	for(var i=0;i<divs.length;i++){
		//alert(divs[i]);
		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);
		
		// calculate maximum height
		maxHeight=Math.max(maxHeight,divHeight);
		//alert('maxHeight: '+maxHeight);
		} // end for (args)
		
	//alert('final maxHeight for categories: '+maxHeight);
	
	// 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';
			}
		}

	}

matchHeight_searchpane_and_content=function(){
	// initialize maximum height value
	var maxHeight=0;
	
	var divs=new Array(document.getElementById('searchpane'),document.getElementById('content'));
	
	// iterate over specified elements to greatest height
	for(var i=0;i<divs.length;i++){
		//alert(divs[i]);
		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);
		
		// calculate maximum height
		maxHeight=Math.max(maxHeight,divHeight);
		//alert('maxHeight: '+maxHeight);
		} // end for (args)
		
	//alert('final maxHeight for searchpane_and_content: '+maxHeight);
	
	// 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';
			}
		}

	}


