//// Onload Events

var onload_events = new Array();

function set_onload(f)
{
	var i = onload_events.length;
	onload_events[i] = f;
}

function do_onload()
{
	if(onload_events.length == 0) return;

	for(var i=0; i<onload_events.length; i++)
	{
		eval(onload_events[i] + "()");
	}
}

onload=do_onload;

//// Return an Elements Position;

function find_pos(obj)
{
	var cur_left = cur_top = 0;

	if(obj.offsetParent)
	{
		cur_left = obj.offsetLeft;
		cur_top = obj.offsetTop;

		while (obj = obj.offsetParent)
		{
			cur_left += obj.offsetLeft;
			cur_top += obj.offsetTop;
		}
	}
	return [cur_left,cur_top];
}

//// Get A CSS Value

function get_style(el,el_css)
{
	var css_value = el.style[el_css];

	if(!css_value) // If it's not an inline style
	{
		if(el.currentStyle) // IE
		{
			// Firefox wants "padding-top", and IE wants "paddingTop"
			// So we'll pass "padding-top" and convert it for IE
			var ix  = el_css.indexOf("-");

			if(ix > -1)
			{
				var new_css = el_css.split("-");
				for(var i=0; i<new_css.length; i++)
				{
					if(i>0)
					{
						new_css[i] = new_css[i].substring(0,1).toUpperCase() + new_css[i].substring(1,new_css[i].length);
					}
				}

				el_css = new_css.join("");
			}

			css_value = el.currentStyle[el_css];
		}
		else if(window.getComputedStyle)
		{
			css_value = document.defaultView.getComputedStyle(el,null).getPropertyValue(el_css);
		}
		else
		{
			css_value = null;
		}
	}

	return css_value;
}

// CONTENT HEIGHT CHECK
// It's possible that the right menu height to be larger than the content
// The problem is that the left menu is positioned absolutely and doen't "push" the bottom area underneath and
//  	so the left menu "overhangs" the white background
// We need to make the content height at least as large as the left menu height (actually more, some padding would look good)
function content_height()
{

	var left = document.getElementById("p-menu");
	var left_top = parseInt(get_style(left,"top"));

	var content = document.getElementById("p-content");
	var content_top =  parseInt(get_style(content,"padding-top"));

	var difference = left_top - content_top;

	var left_height = left.offsetHeight + difference;
	var content_height = content.offsetHeight - content_top;

	//alert(content_top);

	if(content_height < left_height)
	{
		content.style.height = left_height + "px";
	}
}

set_onload("content_height");