

//Global jquery.ready() functionality
$(document).ready(function() {

    resetForms();

    $('#emailFooter').watermark('your email address', { className: 'waterMarkClass' });

    $("ul.sf-menu").superfish({
        delay: 0,                            // one second delay on mouseout        
        speed: 'fast',                          // faster animation speed 
        autoArrows: true,                           // disable generation of arrow mark-up 
        dropShadows: true                            // disable drop shadows 
    });

    $('#coin-slider-product').coinslider({ spw: 1, sph: 1, effect: 'straight', sDelay: 100, delay: 5000, height: 200, width: 440, links: false });
    $('#coin-slider-test').coinslider({ spw: 1, sph: 1, effect: 'straight', sDelay: 100, delay: 5000, height: 276, width: 456 });


    //Mini Basket slide down    
    $("#miniBasketItemList").hide();
    $(".showItemsLink").click(function() {


        if ($("#miniBasketItemList").is(":visible") == false) {
            $("#miniBasketItemList").load("Ajax/cartItems.aspx", function() {

                $("#miniBasketItemList").slideDown();
            });
        }
        else {
            $("#miniBasketItemList").fadeOut();
        }
    });


    //Tabs
    $(".tab_content").hide(); //Hide all content
    $("ul.ticketTabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content

    //On Click Event
    $("ul.ticketTabs li").click(function() {

        if ($(this).hasClass("active"))
            return false;

        var activeTab = $(this).find("a").attr("id"); //Find the href attribute value to identify the active tab + content
        $("ul.ticketTabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab        
        $(".tab_content").hide(); //Hide all tab content
        $("#cont" + activeTab).show(); //Fade in the active ID content
        return false;
    });

    //On click that opens ticket tab
    $(".openTicketTab").click(function() {
        $("ul.ticketTabs li").removeClass("active"); //Remove any "active" class
        $(".tab_content").hide(); //Hide all tab content
        $("#availableTicketsTab").addClass("active");
        $("#conttab0").show();
    });


    //On click that opens ticket tab
    $(".openReviews").click(function() {
        $("ul.ticketTabs li").removeClass("active"); //Remove any "active" class
        $(".tab_content").hide(); //Hide all tab content
        $(".customerReviewsTab").addClass("active");
        $(".reviewTab").fadeIn(200);
    });


    /*Customer testamonials */
    $("#customerTestamonials").load("Ajax/testamonials.aspx?batch=1", function() {
        $("#customerTestamonials").hide().fadeIn(700);
        $("#customerTestamonials").click(function() {
            var currentImageNo = $("#testamonialBatch").val();
            $("#testamonialBatch").val(parseInt(currentImageNo) + 1);
            $("#customerTestamonials").load("Ajax/testamonials.aspx?batch=" + currentImageNo, function() { $("#customerTestamonials").hide().fadeIn(700) });
        });
    });


    $("#mainContentWrapper .planRow div").hoverIntent(
            function() {
                $(this).find("img").animate({ borderTopColor: '#8cc9ff', borderLeftColor: '#8cc9ff', borderRightColor: '#8cc9ff', borderBottomColor: '#8cc9ff' }, 500);
                $(this).find("h2").animate({ backgroundColor: '#8cc9ff' }, 500);
            },
            function() {
                $(this).find("img").animate({ borderTopColor: '#CCE7FF', borderLeftColor: '#CCE7FF', borderRightColor: '#CCE7FF', borderBottomColor: '#CCE7FF' }, 500);
                $(this).find("h2").animate({ backgroundColor: '#CCE7FF' }, 500);
            });

    $("#mainContentWrapper .planRow div").click(function() {
        var ref = $(this).find("a").attr("href");
        window.location.href = ref;
    });


    function showMiniBasket() {

        if ($("#basketDropDown").hasClass("beenHoveredRecently")) {
            return;
        }

        $("#basketDropDown").addClass("beenHoveredRecently");

        $.ajax({
            url: 'ajax/MiniBasketTable.aspx',
            cache: false,
            success: function(data) {
                $("#basketMiniSummary").html(data);
            }
        });

        $("#basketMiniSummary").delay(100).slideDown("fast");
    }

    function hideMiniBasket() {
        if (!$('#basketMiniSummary').hasClass('being_hovered')) {
            $("#basketMiniSummary").fadeOut("fast",
                function() {
                    $("#basketDropDown").removeClass("beenHoveredRecently")
                });
        }
    }

    var config = {
        over: showMiniBasket,
        timeout: 1000,
        out: hideMiniBasket
    };

    $("#basketDropDown").hoverIntent(config);

    $('#basketMiniSummary').hover(function() {
        //hover in
        $(this).addClass('being_hovered');
        $("#basketMiniSummary").show();
    }, function() {
        //hover out
        $(this).removeClass('being_hovered');
        $("#basketMiniSummary").delay(3000).fadeOut("fast",
                function() {
                    $("#basketDropDown").removeClass("beenHoveredRecently")
                });
    });

});
