//==============================================================================
// na_height.js 1.5
// by NavigationArts: navarts.com
//==============================================================================
// This function is built to take X elements, compare the actual browser  
// rendered heigths, and then makes the shorter ones taller. Useful when trying 
// to emulate a table based design grid.
//==============================================================================

//alert(window.getComputedStyle != undefined);                      // IE false, FF true,  Opera true,  Safari false
//alert(document.defaultView != undefined);                         // IE false, FF true,  Opera true,  Safari true
//alert(document.getElementById(els[0]).currentStyle != undefined); // IE true,  FF false, Opera false, Safari false
	
// px could be % or em

function NA_height(elements) {
	els = NA_height.arguments;
	css = document.defaultView != undefined ? "padding-top,padding-bottom,border-top-width,border-bottom-width" :
	                                          "paddingTop,paddingBottom,borderTopWidth,borderBottomWidth";
	css = css.split(",");
	for(i=0; i<els.length; i++) {
		if(document.getElementById(els[i])) {
			obj = document.getElementById(els[i]); // object we are manipulating
			eval("pHeight" + i + "=" + 0); // creating the var that stores the height of padding/borders
			if (navigator.userAgent.toLowerCase().indexOf("msie 5") == -1) { // MSIE5 Check
				for(j=0; j < css.length; j++) {
					val = document.defaultView != undefined ? (parseInt(document.defaultView.getComputedStyle(obj, "").getPropertyValue(css[j]))) : // W3C model
					                                          (parseInt(obj.currentStyle[css[j]])); // IE Model
					if (! isNaN(val)) {
						eval("pHeight" + i + "=" + eval(eval("pHeight" + i) + val)); // build padding/border var for this object
					}
				}
			}
			obj.style.height = obj.offsetHeight - eval("pHeight" + i) + "px"; // so we no longer have to deal with offsetHeight (it won't be right the 2nd loop through)
		}
	}
	for(x=0; x<2; x++) { // loop throught twice because it's incremental
		for(i=0; i<els.length; i++) {
			j = i == els.length-1 ? 0 : i+1; // if last compare with first
			iHeight = eval(document.getElementById(els[i]).style.height.replace("px", "")) + eval("pHeight" + i);
			jHeight = eval(document.getElementById(els[j]).style.height.replace("px", "")) + eval("pHeight" + j);
			dHeight = iHeight - jHeight;
			if (dHeight < 0) {
				dHeight = dHeight * -1; // make the difference addable to either obj
			}
			if (dHeight > 0) {
				k = iHeight < jHeight ? "i" : "j"; // determine with obj to add to
				dHeight = eval(k + "Height") - eval("pHeight" + eval(k)) + dHeight;
				document.getElementById(els[eval(k)]).style.height = dHeight + "px";
			}
		}
	}
}

		function NA_height_init() {
			NA_height("recent-news", "calendar", "support-community");
		}
		
		window.onload=function(){
				NA_height_init();
			}