/**
  * Define the base History Channel namespace
 **/
HC = {
};

$(document).ready(function(){
	
    //hover functionality for the main nav all shows drop down arrow
    //change the appearance of the tv shows arrow when hovering on the tv shows li item
    $("#tvShows a").hover(
        function () {
            $("#triggerShowsDrop").addClass("hoverReady");

        },function () {
            $("#triggerShowsDrop").removeClass("hoverReady");
        });

    //change the appearance of the tv shows arrow when hovering on the arrow itself
    $("#triggerShowsDrop").hover(
        function () {
            $(this).addClass("hoverOn");

        },function () {
            $(this).removeClass("hoverOn");
        });

        $("li#tvShows a").mouseleave(function () {
            $("#triggerShowsDrop").removeClass("hoverOn");
        });

    //trigger shows dropdown when clicking the tv shows arrow
    $("#triggerShowsDrop").click(function () {

        if ($("#showsDrop").hasClass("hidden")) {
        		$("#showsDrop").fadeIn(200);
            }
        $("li#tvShows").addClass("activeSub");
        $("#showSeriesDropdown").hide(100);
        return false;
    });

    //hide the shows drop down when the mouse leaves the dropdown area
    $("#showsDrop").mouseleave(function () {
        $(this).fadeOut(200);
        $(this).addClass("hidden");

        $("li#tvShows").removeClass("activeSub");
        	$("#showSeriesDropdown").show(100);
    });


    //reveal terms & conditions content on the newsletter page
    $("#nlTermsTrigger").click(function () {

      if ($("#termsConditionsFull").is(":hidden")) {

        $("#termsConditionsFull").slideDown("slow");
      } else {
        $("#termsConditionsFull").hide();
      }
    });

    //common reveal more
    $('.fullText').hide();
    
    $("a.showFullText").click(function () {


        $('p.summaryText').removeClass('hidden');

        $(this).parent().addClass('hidden');

        $('div.fullText').hide();


        if(document.getElementById('aboutDayCopy')) {

            $("#aboutDayCopy").removeClass("setHeight");
        }

        $(this).parent().next($('div.fullText')).fadeIn(400);

    });
    //bio eventlist reveal more
    $("a.revealFullText").click(function () {

        $('.fullText').hide();
        $(this).parent().children(".fullText").fadeIn(400);

    });

	try
    {
        //initiate tabs
	    $("#tabs").tabs();
    }
    catch (e) { }

    //clear our specific inputs with specific copy
    //so we don't clear inputs once the user has entered their own copy
    $("#headerSearchInput,#promNewsSignupFName,#promNewsSignupEmail,#newsletterEmail,#newsletterFname").click(function () {

        if ($(this).val().match(/^[Ss]earch/)) { $(this).val(''); }

        if ($(this).val() == 'First Name') { $(this).val(''); }

        if ($(this).val() == 'E-mail') { $(this).val(''); }
    });

    try
    {
        // init jQModal redirect Lightbox
        $('#lightboxRedirect').jqm();
        $('#lightboxRedirect').jqmShow();
    }
    catch (e) { }

    try
    {
        // init jQModal info Lightbox
        // $('#lightboxInfo').jqm({trigger: 'a.infoLightbox'});
        // $('#lightboxInfo').jqm({trigger: 'a.infoLightbox'});
        
        $('#lightboxInfo').jqm({ajax:'@href',trigger:'a.infoLightbox'});
    }
    catch (e) { }

    try
    {
        if(document.getElementById('carousel')){
            // init homepage carousel
            HC.carousel.init("items","featureShow",3);
        }
    }
    catch (e) { }

    try
    {
        if(document.getElementById('content-scroll')){
            // init shows carousel
            HC.carousel.init("items","subpanel",4);
        }
    }
    catch (e) { }


});
