$(document).ready(function(){

	// Make sure the two columns of feature tables stay the same length
	$("ul.Features").equalizeCols();
	
	// Do the rollovers for the menu pages
	$("div.Menu a.MenuOption").hover(
		function() {
		    $(this).find("span > img").attr("src", $(this).find("span > img").attr("src").replace("_off", "_on"));
			$(this).addClass("Hover");
		},
		function() {
			$(this).find("span > img").attr("src", $(this).find("span > img").attr("src").replace("_on", "_off"));
			$(this).removeClass("Hover");
		}
	);


	// Make the overhead navigation work
	$("ul#OverheadNav li.PrimaryNav").hover(
		function() {
            $("#OverheadNav").removeClass(OriginalNavSection);
			$(this).removeClass("PrimaryNavMouseOff");
			$(this).addClass("PrimaryNavMouseOn");
			$(this).find(".SecNavInner > .Section:first").addClass("FirstSection");
		},
		function() {
			$(this).removeClass("PrimaryNavMouseOn");
			$(this).addClass("PrimaryNavMouseOff");
            $("#OverheadNav").addClass(OriginalNavSection);
		}
	);

	// Make the overhead navigation work
	/*$("input.Button").hover(
		function() {
			$(this).addClass("ButtonHover");
		},
		function() {
			$(this).removeClass("ButtonHover");
		}
	);*/
	
	$("div.SubSection.DisplayedSubSection h4").addClass("NonExpand");
 
    $("div.SubSection h4:not(h4.NonExpand)").click(
        function(){
            $(this).siblings("div.PageList").hide("fast");
            if (this.className.indexOf("Selected") > -1) {
                $(this).removeClass("Selected");
                return false;
            }
            $(this).removeClass("Selected");
            $(this).addClass("Selected").siblings("div.PageList").show("fast");
            return false;
        });
        
    $("input.NumbersOnly").keypress(function(evt) {
        var charCode = (evt.which) ? evt.which : event.keyCode
        if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

        return true;
    });
});

function PopCenterWindow(Url, Height, Width, FromTop)
{

    var WindowHeight = 0;
    var WindowWidth = 0;
    var PosLeft = 0;
    var PosTop = 0;
	
	ScreenHeight = screen.height;
	ScreenWidth = screen.width;

    var WindowName = "PopUp";

    WindowFeatures ="menubar=no,scrollbars=no,location=no,favorites=no,resizable=no,status=no,toolbar=no,directories=no";

    PosLeft = (ScreenWidth - Width) / 2;
    PosTop = (ScreenHeight - Height) / 2;
    
    if(FromTop > 0)
    {
        PosTop = FromTop;
    }
    
    NewWindow = open(Url, WindowName,"width=" + Width +",height=" + Height + ",left=" + PosLeft + ",top=" + PosTop + ',' + WindowFeatures);

}


function PopDown(url)
{
    if(window.opener.opener != null)
    {
        parentWindow = window.opener.opener;
        parentWindow.location = url;
        window.opener.close();
        window.close();
    }
    else
    {
        parentWindow = window.opener;
        parentWindow.location = url;
        window.close();
    }
}