function initMenus() {
    $('ul.menu ul').hide();
    $.each($('ul.menu'), function(){
        $('#' + this.id + '.expandfirst ul:first').show();
    });
    $('ul.menu li a').click(
        function() {
            var checkElement = $(this).next();
            var parent = this.parentNode.parentNode.id;
            if($('#' + parent).hasClass('noaccordion')) {
                $(this).next().slideToggle('normal');
                return false;
            }
            if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
                if($('#' + parent).hasClass('collapsible')) {
                    $('#' + parent + ' ul:visible').slideUp('normal');
                }
                return false;
            }
            if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
                $('#' + parent + ' ul:visible').slideUp('normal');
                checkElement.slideDown('normal');
                return false;
            }
        }
    );
}
$(document).ready(function() {
    $("#channels ul li:first").addClass("ntp");
    
    initMenus();

    $("#menu").toggle(
        function () {
            $(this).addClass("on");
            $("#nwrap").animate({height: "500"},"slow");
        }, function () {
            $(this).removeClass("on");
            $("#nwrap").animate({height: "0"},"fast");
        }
    );
    
$("#channels").hover(
          function () {return false;}, 
          function () {
            if ($("#nwrap").css("height") == "500px") {
                window.setTimeout(function(){ $("#menu").click();$("#menu").removeClass("on"); }, 1500);
            }
    });

    if($("#mycarousel").html()!=null) {
        $("#mycarousel").jcarousel({scroll:4});
    }
    
    if($("#tabContent").html()!=null) {
        $("#mycarousel li a").click(function() { $('#tabContent > ul').tabs('select', $("#mycarousel li a").index(this)); });
        $("#tabContent > ul").tabs({ fx:{opacity: 'toggle'} });
    }
    
    if($(".vclips").html()!=null) {
        $("#video li a").fancybox({ 'padding':'5', 'frameWidth': 562, 'frameHeight': 311, 'hideOnContentClick': false });
        $("#fancy_bg").css("background","white");
        $("#fancy_close").css("visibility","hidden");
    }
    
    if($(".jcarousel-skin-tango2").html()!=null) {
        $('#mycarousel li a').fancybox({'padding':0});
    }

});


///////////////////////////////////////////////////////////////////////////////////

function shopTracker2(sku, refcode, category, category_id, UserPageSize)
{
    if (typeof emosLeadEvent=='function'){
         emosLeadEvent('co', sku, refcode, category,category_id);
     msg =location.href = '/website/skript/shopTracker.php?sku=' + sku + '&refcode=' + refcode + '&category=' + category + '&category_id=' + category_id;
    }else{
        msg =location.href = '/website/skript/shopTracker.php?sku=' + sku + '&refcode=' + refcode + '&category=' + category + '&category_id=' + category_id;
    }
}

function popup(pname, width, height, scrollbars)
{
    msg=open(pname,"pname","width=" + width + ",height=" + height + ",toolbar=no,location=no,directories=no,status=no,scrollbars=" + scrollbars + ",resizeable=no,menubar=no");
}
