﻿
$(document).ready(function () {

    //google search form
    $('#search .inputSearch').click(function () {
        var queryString = "http://www.google.com/search?q=";
        queryString = queryString + $('#search .inputBox').val() + "&ie=UTF-8&sitesearch=" + $('#search input[name$="sitesearch"]').val();
        //alert(queryString);
        window.open(queryString, 'mywin');
    });

    /// Remove default search text from search button in IE ///
    $('input.inputSearch').removeAttr("value");

    /// Adding Culture class to French link and replace it with Français -- Top
    $("#search a:last").addClass("Culture");
	$("#search .SocialLinks ").removeClass("Culture");
	
    // Adding Culture to Youth FR link in 3rd and remove Culture from last that add in above coding
    $("body#Youth #search a:nth-child(3)").addClass("Culture");
    $("body#Youth #search a:nth-child(5)").removeClass("Culture");

    var newText = $("#search a.Culture").text().replace("French", "Français");
    $("#search a.Culture").text(newText);
    /// Adding Culture class to French link and replace it with Français -- Footer
    $("#footerControl .FrenchVersion a").addClass("Culture");
    var newText = $("#search a.Culture").text().replace("French", "Français");
    $("#footerControl .FrenchVersion a").text(newText);



    /// Hide link text in Youth ///
    $('body#Youth ul#menuElem li a').empty();
    $('body#Youth ul#snav li a').empty();
    $('body#Youth #footerBtm a.SiteMapToggle').empty();

    /// Footer Sitemap toggle ///

    $(".SiteMapList ul.CMSSiteMapList:last").parent().addClass("CMSSiteMapListItem Last");

    // hide SiteMapList group
    $(".SiteMapList").hide();

    $('.SiteMapToggle span.Sign').text('+');

    // toggles the SiteMapList on clicking the noted link  
    $('.SiteMapToggle').click(function () {
        // Change footerBtm background image to expand (longer) one
        //$("#footerBtm").css("background", "url(/cco/images/footerBtm_bg_expand.png) top left repeat-x");
        //$("body.Youth #footerBtm").css("background", "none");

        // toggle with speed of 200
        $('.SiteMapList').slideToggle(200);
        // switch text
        $('.SiteMapToggle span.Sign').text($('.SiteMapToggle span.Sign').text() == '+' ? '-' : '+');
        // Youth sitemap image switch
        $('body#Youth #footerControl .SiteMapLink a').toggleClass("SiteMapToggle_Close");

        // scroll to bottom of the page after expanding
        $('html, body').animate({
            scrollTop: $(document).height()
        });

        // disable link return
        return false;
    });

    // Adding <h2> to 2nd level list menu individually 
    $(".SiteMapList ul.CMSSiteMapList li.CMSSiteMapListItem ul").parent().addClass("CMSSiteMapListItem FirstLevel");
    $(".SiteMapList ul.CMSSiteMapList li.CMSSiteMapListItem:first").addClass("CMSSiteMapListItem FirstLevel");
    $(".SiteMapList ul.CMSSiteMapList li.FirstLevel a").wrap('<h2>');
    


    //// Accordion ////
    $(".toggle_container").hide();
    // Open up first content
    $('.trigger:first').addClass('active').next().show();
    // Click to toggle
    $("h3.trigger").click(function () {
        $(this).toggleClass("active").next().slideToggle("slow");
        // Window scroll the latest toggle content --- Note: hide it due to jumpping issue
        //        $('html, body').animate({
        //            scrollTop: $(document).height()
        //        });
        // disable link return
        return false;
    });


    /// Resource logo download ///
    $(".LogoDownloadThumb img:first").css("margin-left", "0px");
    //$(".LogoDownloadThumb img:last").css("margin-left", "18px");

    /// Section Photos & Videos photo lightbox ///
    $("a[rel='PVphotos']").colorbox();


    /// Resource logo lightbox ///
    $(".LogoUseGuidelines").colorbox({ iframe: true, width: "65%", height: "920px" });

    /// Youth left col light box ///
    //$(".ctalink").colorbox({ inline: true, href: "#inline_cta" });

    /// Youth - Youth Action ///
    $("a[rel='buttcycle']").colorbox();
    /// Youth - Youth Arts ///
    $("a[rel='youthart']").colorbox();
    /// Youth - Youth Pages ///
    $("a[rel='youthpages']").colorbox();
    /// Youth - Youth Pages ///
    $("a[rel='youthpagesTake']").colorbox();
    /// Youth - Tobacco hurt ///
    $("a[rel='Soccer']").colorbox();
    /// Youth - Why do you care ///
    $("a[rel='whydoyou']").colorbox();


    /// ALWAYS PUT THIS ONE IN THE END///
    /// Resource Event show hide ///
    $('.EventInfo').jTruncate({
        length: 100,
        minTrail: 0,
        moreText: "more >>",
        lessText: "less <<",
        moreAni: "fast"
    });

});




