// JavaScript Document

//$(function() { //Initialization function, runs when the DOM has loaded
//	createSubMenu();
//	equalHeight(columnsList1);
//	equalHeight(columnsList2);
//	equalHeight(columnsList3);
//	$(window).load(function() {
//		equalHeight(columnsList1);
//		equalHeight(columnsList2);
//		equalHeight(columnsList3);
//	});
//});

function createSubMenu(){
	newHeight = findPos(document.getElementById($("#MainNav").attr("id"))).y+$("#MainNav").height()-2;
	$("#MainNav li").hover(
		function(){	$("#subnav" + $(this).attr("id")).css("top",newHeight+"px");	},
		function(){ $("#subnav" + $(this).attr("id")).css("top","-990em"); 		}
	);
	$(".subnav").hover(
		function(){
			$(this).css("top",newHeight+"px");
			$("#"+$(this).attr("id").substring(6)+" a").addClass("MainNav_hover");
		},
		function(){
			$(this).css("top","-990em");
			$("#"+$(this).attr("id").substring(6)+" a").removeClass("MainNav_hover");
		}
	);
}
function findPos(obj) { //returns the x & y coordinates of an element
	var curleft = obj.offsetLeft || 0;
	var curtop = obj.offsetTop || 0;
	while (obj = obj.offsetParent) {
		curleft += obj.offsetLeft
		curtop += obj.offsetTop
	}
	return {x:curleft,y:curtop};
}


function equalHeight(colList) {
        $(colList).each(function() {$(this).height("auto");});
        var topHeight = 0;
        var staticTop = -1;
        $(colList).each(function() {
                if ($(this).height() >= topHeight) {
                        topHeight = $(this).height();
                }
                if ($(this).css("position") == "static") {
                        staticTop = findPos(document.getElementById($(this).attr("id"))).y;
                }
        });
        topHeight = topHeight + "px";
        staticTop = staticTop + "px"
        $(colList).each(function() {
                $(this).height(topHeight);
                if (staticTop != -1) $(this).css("top",staticTop);
        });
};




function show_hide(id){
	if (document.getElementById){
		var obj = document.getElementById(id);
		if(obj){
			if (obj.style.display == "none"){
				obj.style.display = "";
			}else{
				obj.style.display = "none";
			}
		}
	}
}




