﻿
$(document).ready
(
function() 
{

    // Format nav menu
    FormatNavMenuLinks();


    //-- HOVER event handler for TOP LEVEL Links (upper right hand corner)
    //$("#Header .content #LinksLevelOne a").hover
    $("#Header .content .linksLevelOneRow 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 "RegisterDesc":
                    $("#Header .content #LinksLevelOne #LinksLevelOneDesc #RegisterDesc").show();
                    break;
                case "MakePaymentDesc":
                    $("#Header .content #LinksLevelOne #LinksLevelOneDesc #MakePaymentDesc").show();
                    break;
                case "HomeMakePaymentDesc":
                    $("#Header .content #LinksLevelOne #LinksLevelOneDesc #HomeMakePaymentDesc").show();
                    break;
                case "SubmissionDesc":
                    $("#Header .content #LinksLevelOne #LinksLevelOneDesc #SubmissionDesc").show();
                    break;
                case "HomeSubmissionDesc":
                    $("#Header .content #LinksLevelOne #LinksLevelOneDesc #HomeSubmissionDesc").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;
        }
    );

    /// Event handler for the a.showUpload link button on the UploadForm.ascx user control
    $(".showUpload").click(
        function()
        {
            $(this).addClass("showUploadSelected").removeClass("showUpload").removeClass("showUploadLiHover");
            
            if ( $.browser.msie )
            {
                $(this).parent().siblings(".uploadFormContainer").addClass("uploadFormContainerIE");
            }
            $(this).parent().siblings(".uploadFormContainer").show("fast");
            
            return false;
        }
    );

    /// Event handler for the input.$cancel button on the UploadForm.ascx user control
    $(".uploadForm input[id$=cancel]").click(
        function()
        {
            $(this).parent().parent().parent().hide("fast");
            $(this).parent().parent().parent().siblings(".submitItemLinks").children(".showUploadSelected").addClass("showUpload").removeClass("showUploadSelected");
        
            return false;
        }
    );
    
    /// Event handler for the .submitItems li hover event
    $(".pageContent ol.submitItems li").hover(
        function()
        {
            $(this).addClass("listItemHover");
            $(this).children(".submitItemLinks").children(".showUpload").addClass("showUploadLiHover");
        },
        function()
        {
            $(this).removeClass("listItemHover");
            $(this).children(".submitItemLinks").children(".showUpload").removeClass("showUploadLiHover");
        }
    );
    
    /// Event handler for the .soonCome click event
    $(".soonCome").click(
        function()
        {
            alert("Coming soon...");
            return false;
        }
    );
    
    /// If the hidden#keepOpen field value is not "", then show the .uploadForm div
    if ($(".uploadForm input[id$=keepOpen]").length)
    {
        $(".uploadForm input[id$=keepOpen]").each(
            function()
            {
                if ( $(this).val() != "" )
                {
                    $(this).parent().parent().siblings(".submitItemLinks").children(".showUpload").addClass("showUploadSelected").removeClass("showUpload").removeClass("showUploadLiHover");
                    if ( $.browser.msie )
                    {
                        $(this).parent().parent().addClass("uploadFormContainerIE");
                    }
                    $(this).parent().parent().show();
                }
            }
        );
//        if ($(".uploadForm input[id$=keepOpen]").val() != "")
//        {
//            $(".uploadForm input[id$=keepOpen]").parent().parent().siblings(".submitItemLinks").children(".showUpload").addClass("showUploadSelected").removeClass("showUpload");
//            if ( $.browser.msie )
//            {
//                $(".uploadForm input[id$=keepOpen]").parent().parent().addClass("uploadFormContainerIE");
//            }
//            $(".uploadForm input[id$=keepOpen]").parent().parent().show();
//        }
    }

    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;
        }
    }

        



    }
);

