﻿var Lhf = {

    init: function() {

        //        $('#promoIMG').dialog({
        //            height: 500,
        //            modal: true
        //        });

        $('.image-gallery-slides').cycle({
            fx: 'fade',
            speed: 'fast',
            timeout: 0,
            next: '#nextSlide',
            prev: '#prevSlide',
            pager: '#galleryNav'
        });

        $('.image-flash-gallery-slides').cycle({
            fx: 'fade',
            speed: 'fast',
            timeout: 10000,
            pager: '#galleryNav'
        });



        $('.lunch-cycle').cycle({
            fx: 'fade',
            timeout: 4000
        });

        $('#QuoteContainer').cycle({
            fx: 'fade',
            timeout: 6000
        });


        //		$("table").tablesorter();



        // remove border bottom for submenu items
        $("ul#nav li ul").each(function(i, item) {
            $("li:last a", this).css({ borderBottom: 0 });
        });

        if (document.all) {
            $("#nav li").hoverClass("sfHover");
        }

        // Init tabs
        if ($(".tabbed-container")) {
            $(".tabbed-container > ul").tabs();
        }


        //  // Init tabs
        //        if ($("#lunchtabs"))
        //        {
        //			 $("#lunchtabs > ul").tabs();
        //        }


        // $(".accordion").accordion();
        //        $(".accordion").accordion({
        //			header: 'a.accordion-title'
        //        });



        $(".cycle")
        //.after('<div id="pager"></div>')
			.cycle({
			    pager: "#pager",
			    pagerEvent: 'click',
			    timeout: 5000,
			    pause: 1,
			    next: "#nextslide",
			    after: function() {
			        var next = $(this).next();

			        if (next.length == 0)
			            next = $(this.parentNode).children().eq(0);

			        $("#nextslide").html($("h2", next).text());

			    }
			});


        $('a.lightbox').lightBox(); // Select all links that contains lightbox in the attribute class


        var currentDate = new Date();
        var stopDate = new Date(2011, 02, 24, 19, 0, 0, 0);

        if (currentDate < stopDate) {

            $('.meerkat3').meerkat({
            background: 'transparent url(http://www.luleahockey.se/images/meerkatbg.png)',
                height: '100%',
                width: '100%',
                position: 'bottom',
                dontShowAgain: '.meerkat3',
                animationIn: 'fade',
                animationOut: 'fade',
                animationSpeed: 300,
                removeCookie: '.reset'
            });
        }
    }
}; 


$.fn.hoverClass = function(c) {
    return this.each(function() {
        $(this).hover(
            function() { $(this).addClass(c); },
            function() { $(this).removeClass(c); }
        );
    });
};

/**
* OnDomContentReady functions
*/
$(document).ready(function() {

    // Append class to body if IE < 7
    // Do this so we don't need conditional comments
    if ($.browser.msie === true && parseInt($.browser.version) <= 6) {
        // Add png8 to body... 
        $("body").addClass("png8");
        document.execCommand('BackgroundImageCache', false, true);
    }

    if ($.browser.msie === true) {
        $("#nav li ul").mouseout(function() {
            // console.log(this);
            $(this).css("left", "-999em");
        });

        $("#nav li").mouseover(function() {
            $("#nav li ul").css("left", "-999em");
            $("ul", this).css("left", "auto");
        });
    }

    Lhf.init();

    //sfHover();	
});
