﻿GoodNites.Menu = function(serverVars) {
    this.ServerVars = serverVars;
    this.Initialize();
};
GoodNites.Menu.prototype = {
    Initialize: function() {
        $(serverVars.menuSelector).superfish();

        // Remove all the title tags from the menu item links so they
        // don't get in the way of the graphic interface
        $("a", serverVars.menuSelector).attr("title", "");

        // Prepare the search box for watermark capability  
        $(".Search input[@type=text]").focus(function() {
            if ($(this).val() != "Search") {
                $(this).select();
            } else {
                $(this).val("");
            }
        }).blur(function() {
            if ($(this).val().length == 0) {
                $(this).val("Search");
            }
        });

        /*
        // Prevent the search form from stealing the default button behavior for the page
        $("form input").keypress(function(e) {
            var isEnterKey = (e.which && e.which == 13) || (e.keyCode && e.keyCode == 13);
            if (isEnterKey) {
                $("form input[type=submit]:not(.PreventDefault), form input[type=image]:not(.PreventDefault)").click();
                e.preventDefault();
                return false;
            } else {
                return true;
            }
        });
        */
        
        // Find all links to the contest official rules and enable setup popup window behavior for them
        $("a.ContestOfficialRules").click(function(event) {
            openPopupWindow(this.href, "rules", "width=600,height=480,scrollbars=1,resizable=0,location=no,directories=no");
            event.preventDefault();
            event.returnValue = false;
        });
    }
};
GoodNites.Extend(GoodNites.Menu, GoodNites.Core);