﻿
$(document).ready
(
    function() 
    {
        
        // Format nav menu
        FormatNavMenuLinks();
        
        
        //-- HOVER event handler for TOP LEVEL Links (upper right hand corner)
        $("#Header .content #LinksLevelOne a").hover
        (
            function() 
            {
                // Show the correct description
                switch ($(this).attr("class"))
                {
                    case "RequestDesc": 
                        $("#Header .content #LinksLevelOne #LinksLevelOneDesc #RequestDesc").show();
                        break;
                    case "RegisterDesc": 
                        $("#Header .content #LinksLevelOne #LinksLevelOneDesc #RegisterDesc").show();
                        break;
                    case "CoachesCornerDesc": 
                        $("#Header .content #LinksLevelOne #LinksLevelOneDesc #CoachesCornerDesc").show();
                        break;
                    case "InfoMeetingDesc": 
                        $("#Header .content #LinksLevelOne #LinksLevelOneDesc #InfoMeetingDesc").show();
                        break;
                    case "MakePaymentDesc":
                        $("#Header .content #LinksLevelOne #LinksLevelOneDesc #MakePaymentDesc").show();
                        break;
                    case "NominateAthlete":
                        $("#Header .content #LinksLevelOne #LinksLevelOneDesc #NominateAthlete").show();
                        break;
                    case "AdNominateAthlete":
                        $("#Header .content #LinksLevelOne #LinksLevelOneDesc #AdNominateAthlete").show();
                        break;    
                    case "NominateCoach":
                        $("#Header .content #LinksLevelOne #LinksLevelOneDesc #NominateCoach").show();
                        break;
                }
                
            },
            function()
            {
                // Hide all descriptions the correct description
                $("#Header .content #LinksLevelOne #LinksLevelOneDesc p").hide();
                 
            }
        );
        
        
        //-- HOVER event handler for NAV MENU
        $("#MenuBar ul li").hover
        (
            function() 
            {
                if( $(this).children("a").attr("class") != "thisMenuLink" ) 
                {
                    $(this).addClass("navMenuHover");
                    $(this).children("a").css("color", "#1a4395");
                    //alert($(this).children("a").attr("class"));
                }
           },
            function()
            {
                $(this).removeClass("navMenuHover");
                $(this).children("a").css("color", "#fff");
            }
        );
        
        //-- Click event for the NAV MENU LI
        $("#MenuBar ul li").click
        (
            function()
            {
                //-- Get the child A HREF value and redirect to that
                window.location.href = $(this).children("a").attr("href");
            }
        );
        
        //-- Hover event handler for LOGIN button
        $("#Login input:submit").hover
        (
            function()
            {
                $(this).addClass("buttonHover");
            },
            function()
            {
                $(this).removeClass("buttonHover");
            }
        );
        
        
        //***************** LOGIN DISPLAY SCRIPT **************************************************************
        var $initialVal = "Login ID";
        
        if ($("#Login input.lefttext").val() != $initialVal)
        {
            $("#Login input.lefttext").css("color", "#000");
        }

        $("#Login input.text").focus
        (
            function() 
            {
                if (($(this).val() == 'Login ID') || ($(this).val() == 'Password')) 
                {
                    //$initialVal = $(this).val()
                    //alert($initialVal);

                    // If this is the password textbox, then show the "real"(masked) password textbox
                    if ($("#Login input[@id$=loginPasswordDisplay]").attr("id") == $(this).attr("id")) 
                    {
                        //$(this).attr("type", "password");
                        $(this).hide();
                        $("#Login input[@id$=loginPassword]").show();
                        $("#Login input[@id$=loginPassword]").focus();
                    }
                    else 
                    {
                        $(this).val("").css("color", "#000");
                    }
                }
            }
        );

        $("#Login input.text").blur
        (
            function() {
                if ($(this).val() == "") {
                    $(this).val($initialVal).css("color", "#9A9A9A");
                }
            }
        );


        $("#Login input.password").blur
        (
            function() {
                // If this is the password textbox, then show the "display" (unmasked) password textbox, if no pw was entered
                if ($(this).val() == "") {
                    $(this).hide();
                    $("#Login input[@id$=loginPasswordDisplay]").show();
                }
            }
        );
        //*****************************************************************************************************

        
        
        //***************** ITINERARY Calender Hover event ****************************************************
        $(".itineraryGrid tr .4").hover
        (
            function()
            {
                $(".kangaroo .pic, .waikiki .pic").css("background-position", "0px -130px");
            },
            function()
            {
                $(".kangaroo .pic, .waikiki .pic").css("background-position", "0px 0px");
            }
        );
        $(".itineraryGrid tr .6").hover
        (
            function()
            {
                $(".activity .pic").css("background-position", "0px -130px");
            },
            function()
            {
                $(".activity .pic").css("background-position", "0px 0px");
            }
        );
        $(".itineraryGrid tr .7").hover
        (
            function()
            {
                $(".itinPic .coaster").css("background-position", "0px -132px");
            },
            function()
            {
                $(".itinPic .coaster").css("background-position", "0px 0px");
            }
        );
        $(".itineraryGrid tr .8").hover
        (
            function()
            {
                $(".itinPic .tournament").css("background-position", "0px -130px");
            },
            function()
            {
                $(".itinPic .tournament").css("background-position", "0px 0px");
            }
        );
        $(".itineraryGrid tr .9").hover
        (
            function()
            {
                $(".teamPic .pic").css("background-position", "0px -130px");
            },
            function()
            {
                $(".teamPic .pic").css("background-position", "0px 0px");
            }
        );
        $(".itineraryGrid tr .10").hover
        (
            function()
            {
                $(".itinPic .luau, .itinPic .ussAz").css("background-position", "0px -130px");
            },
            function()
            {
                $(".itinPic .luau, .itinPic .ussAz").css("background-position", "0px 0px");
            }
        );
        //*****************************************************************************************************
        
        
        
        $(".meetingDetail").hover
        (
            function()
            {
                $(this).addClass("meetingDetailOver");
            },
            function()
            {
                $(this).removeClass("meetingDetailOver");
            }
        );
        
        
        
       $(".newsletter a").hover
       (
            function()
            {
                $(this).children(".pdfIcon").css("background-position", "0 -20px");
                //alert($(this).children("a").children(".pdfIcon").attr("class"));
            },
            function()
            {
                $(this).children(".pdfIcon").css("background-position", "0 0");
            }
       );
       
       $(".embeddedMediaLink").click(
            function()
            {
                if ($(this).next().attr("class") === "embeddedMedia")
                {
                    if ($(this).next().css("display") != "none")
                    {
                        $(this).next().hide();
                        $(this).removeClass("openEmbeddedMedia");
                    }
                    else
                    {
                        $(this).addClass("openEmbeddedMedia");
                        $(this).next().show();
                    }
                }
                
                return false;
            }
       );


        function FormatNavMenuLinks()
        {
            var thisPage = GetThisPage(window.location.href);
            SetLinkForThisPage(thisPage);
        }

        /// Gets the page name only out of a full url;
        function GetThisPage(s)
        {
            // Remove any querystring stuff
            if (s.lastIndexOf("?") > 0)
            {
                s = s.substring(0, s.lastIndexOf("?"))
            }
            if (s.length > (s.lastIndexOf(".aspx") + 5))
            {
                s = s.substring(0, s.lastIndexOf(".aspx") + 5)
            }
            // Get the page name
            s = s.substring(s.lastIndexOf("/") + 1, s.length);
            // Make sure the page is not just the root of a folder
            if (s.indexOf(".aspx") < 0)
            {
                s = "default.aspx";
            }
            //alert(s);
            return s;
        }
        
        
        /// Sets the CSS CLASS for the link, to highlight the current page
        function SetLinkForThisPage(thisPage)
        {
            switch (thisPage.toLowerCase())
            {
                case "defaultathlete.aspx":
                    $("#MenuBar #NavMenu li a[@id$=defaultAthlete]").addClass("thisMenuLink");
                    $("#MenuBar #NavMenu li a[@id$=defaultAthlete]").parent().addClass("thisMenuLinkBg");
                    break;
                case "sampleitinerary.aspx":
                    $("#MenuBar #NavMenu li a[@id$=sampleItinerary]").addClass("thisMenuLink");
                    $("#MenuBar #NavMenu li a[@id$=sampleItinerary]").parent().addClass("thisMenuLinkBg");
                    break;
                case "package.aspx":
                    $("#MenuBar #NavMenu li a[@id$=package]").addClass("thisMenuLink");
                    $("#MenuBar #NavMenu li a[@id$=package]").parent().addClass("thisMenuLinkBg");
                    break;
                case "payforthistrip.aspx":
                    $("#MenuBar #NavMenu li a[@id$=payForThisTrip]").addClass("thisMenuLink");
                    $("#MenuBar #NavMenu li a[@id$=payForThisTrip]").parent().addClass("thisMenuLinkBg");
                    break;
                case "travelprotection.aspx":
                    $("#MenuBar #NavMenu li a[@id$=travelProtection]").addClass("thisMenuLink");
                    $("#MenuBar #NavMenu li a[@id$=travelProtection]").parent().addClass("thisMenuLinkBg");
                    break;
                case "faq.aspx":
                    $("#MenuBar #NavMenu li a[@id$=faq]").addClass("thisMenuLink");
                    $("#MenuBar #NavMenu li a[@id$=faq]").parent().addClass("thisMenuLinkBg");
                    break;
                case "newsletter.aspx":
                    $("#MenuBar #NavMenu li a[@id$=newsletter]").addClass("thisMenuLink");
                    $("#MenuBar #NavMenu li a[@id$=newsletter]").parent().addClass("thisMenuLinkBg");
                    break;
                case "video.aspx":
                    $("#MenuBar #NavMenu li a[@id$=video]").addClass("thisMenuLink");
                    $("#MenuBar #NavMenu li a[@id$=video]").parent().addClass("thisMenuLinkBg");
                    break;
                case "media.aspx":
                    $("#MenuBar #NavMenu li a[@id$=media]").addClass("thisMenuLink");
                    $("#MenuBar #NavMenu li a[@id$=media]").parent().addClass("thisMenuLinkBg");
                    break;
                case "basketball.aspx":
                    $("#SportsLinks a[@id$=basketball]").addClass("thisSportsLink");
                    $("#SportsLinks a[@id$=basketball]").removeClass("sportsLink");
                    break;
                case "cheerdance.aspx":
                    $("#SportsLinks a[@id$=cheerDance]").addClass("thisSportsLink");
                    $("#SportsLinks a[@id$=cheerDance]").removeClass("sportsLink");
                    break;
                case "crosscountry.aspx":
                    $("#SportsLinks a[@id$=crossCountry]").addClass("thisSportsLink");
                    $("#SportsLinks a[@id$=crossCountry]").removeClass("sportsLink");
                    break;
                case "football.aspx":
                    $("#SportsLinks a[@id$=football]").addClass("thisSportsLink");
                    $("#SportsLinks a[@id$=football]").removeClass("sportsLink");
                    break;
                case "golf.aspx":
                    $("#SportsLinks a[@id$=golf]").addClass("thisSportsLink");
                    $("#SportsLinks a[@id$=golf]").removeClass("sportsLink");
                    break;
                case "track.aspx":
                    $("#SportsLinks a[@id$=track]").addClass("thisSportsLink");
                    $("#SportsLinks a[@id$=track]").removeClass("sportsLink");
                    break;
                case "volleyball.aspx":
                    $("#SportsLinks a[@id$=volleyball]").addClass("thisSportsLink");
                    $("#SportsLinks a[@id$=volleyball]").removeClass("sportsLink");
                    break;
                case "wrestling.aspx":
                    $("#SportsLinks a[@id$=wrestling]").addClass("thisSportsLink");
                    $("#SportsLinks a[@id$=wrestling]").removeClass("sportsLink");
                    break;
            }
        }
        
        
        
        



    }
);

