﻿/*

If it bleeds we can kill it ;)

*/
var mouseOutTimeout = 200;

var mouseOverMenu = false;
var mouseOverMenuContent = false;

var timerObj = null;
var menuHoveredObj = null;

$(document).ready(function () {

    // ladujemy plik z zawartoscia menu... jakby sie nie zaladowal to nie ladujemy menu
    $.ajax({
        url: '/aspx/async/home_menu.aspx',
        dataType: 'html',
        success: function (data) {

            var obj = $("<div/>").html(data);
            // usuwamy forma i inputa wrzuconego przez .net...

            $(".katalog_kategorie", obj).appendTo("#mainBoxArtMenuAdvanceCnt");

            //Ustawiamy zdarzenia pokazywania i chowania menu ;)
            $('div.mainBoxArtMenu').mouseover(function () {
                clearTimeout(timerObj);

                // wybieramy ktore menu pokazac...
                $(".katalog_kategorie").hide();
                idx = $(this).index();
                $(".mainBoxArtMenu").removeClass("open");
                $(this).addClass("open");
                menuHoveredObj = this;
                $(".katalog_kategorie:eq(" + idx + ")").show();


                $('#mainBoxArtMenuAdvance').show();
                mouseOverMenuContent = true;
            }).mouseout(function () {
                mouseOverMenuContent = false;
                timerObj = setTimeout("chceHideMenu()", mouseOutTimeout);
            });

            $('#mainBoxArtMenuAdvance').mouseover(function () {
                clearTimeout(timerObj);
                mouseOverMenuContent = true;
            }).mouseout(function () {
                mouseOverMenuContent = false;
                timerObj = setTimeout("chceHideMenu()", mouseOutTimeout);
            })

        }
    });

});


chceHideMenu = function () {
    // sprawdzamy czy uzytkownik nie zjechal myszka na menu...
    if ((!mouseOverMenu) && (!mouseOverMenuContent)) {
        $('#mainBoxArtMenuAdvance').hide();
        $(".mainBoxArtMenu").removeClass("open");
    }
}

/*
#   
#     
#   //Mouseover with animate Effect for Category menu list  :)  
#   $('.boxBody #category li').mouseover(function() {  
#   
#     //Change background color and animate the padding  
#     $(this).css('backgroundColor','#888');  
#     $(this).children().animate({paddingLeft:"20px"}, {queue:false, duration:300});  
#   }).mouseout(function() {  
#       
#     //Change background color and animate the padding  
#     $(this).css('backgroundColor','');  
#     $(this).children().animate({paddingLeft:"0"}, {queue:false, duration:300});  
#   });    
#       
#   //Mouseover effect for Posts, Comments, Famous Posts and Random Posts menu list.  
#   $('.boxBody li').click(function(){  
#     window.location = $(this).find("a").attr("href");  
#   }).mouseover(function() {  
#     $(this).css('backgroundColor','#888');  
#   }).mouseout(function() {  
#     $(this).css('backgroundColor','');  
#   });     
#       
# });  

*/
