/*** Copy Right Information ***
  * Please do not remove following information.
  * Element Size v1.0
  * Author: John J Kim
  * Email: john@frontendframework.com
  * URL: www.FrontEndFramework.com
  * 
  * You are welcome to modify the codes as long as you include this copyright information.
 *****************************/
 
getWidth = function(elem) {
	function _convertValue(val) {
		if (!val) {return;}
		val = parseInt(val.replace("px",""));
		if (!val || isNaN(val)) {return 0;}
		return val;
	}
	var currentStyle;
	if (elem.currentStyle)	{ currentStyle = elem.currentStyle; }
	else if (window.getComputedStyle) {	currentStyle = document.defaultView.getComputedStyle(elem, null); }
	else { currentStyle = elem.style; }
	
	return (elem.offsetWidth -
			_convertValue(currentStyle.marginLeft) -
			_convertValue(currentStyle.marginRight) -
			_convertValue(currentStyle.borderLeftWidth) -
			_convertValue(currentStyle.borderRightWidth));
}

getHeight = function(elem) {
	function _convertValue(val) {
		if (!val) {return;}
		val = parseInt(val.replace("px",""));
		if (!val || isNaN(val)) {return 0;}
		return val;
	}
	var currentStyle;
	if (elem.currentStyle)	{ currentStyle = elem.currentStyle; }
	else if (window.getComputedStyle) {	currentStyle = document.defaultView.getComputedStyle(elem, null); }
	else { currentStyle = elem.style; }
	return (elem.offsetHeight -
	        _convertValue(currentStyle.marginTop) -
    	    _convertValue(currentStyle.marginBottom) -
        	_convertValue(currentStyle.borderTopWidth) -
        	_convertValue(currentStyle.borderBottomWidth));	
}

// Fa's addition - dynamically size content div according to sidebar's height
function setContentHeight() {
	var sidebarHeight = getHeight(document.getElementById('sidebar'));
	document.getElementById('content').style.minHeight = (sidebarHeight + 225) + 'px';
	//alert('sidebarHeight = ' + sidebarHeight + '\ncontentHeight = ' + (sidebarHeight + 225));
	// For IE7
	var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;
	if (ie7) {
		document.getElementById('content').style.minHeight = (sidebarHeight - 40) + 'px';
		document.getElementById('container').style.minHeight = (sidebarHeight - 40) + 'px';
	}
}
