$(document).ready(function(){
    if(!$.data(document.body, 'counter')){
        $.data(document.body, 'counter',0);
        // reset for ie8
        $('#nav > div.item img').css({
            'width'     :'60px',
            'height'    :'60px',
            'top'       :'0px',
            'left'      :'0px',
            'opacity'   :'0'
        });
    }
    $('#nav > div.item').hover(
        function () {
//            alert('hover nav > div.item');
            clearTimeout($.data(document.body, 'timer'));
            count = $.data(document.body, 'counter');
            $.data(document.body, 'counter',count++);
            //console.log($.data(document.body, 'counter',count++));
            $(this).find('a').addClass('hover');
            var $this = $(this);
            var $id = $this.attr('id');
//           console.log('hover sul div '+$id);
            $this.find('img').stop().animate({
                'width'     :'203px',
                'height'    :'203px',
                'top'       :'-25px',
                'left'      :'-25px',
                'opacity'   :'1.0'
            },200,'easeOutBack',function(){
                $(this).parent().find('.label').fadeIn(100);
            });
//            $this.find('a').addClass('hover');
            $('div.photoFrame img.photoImage.visible').toggleClass('visible');
            $('div.photoFrame img.'+$id).addClass('visible');
        },
        function () {
            $.data(document.body,'timer',setTimeout(function(){$('div.photoFrame img.photoImage.s5').addClass('visible')}, 1000, true));
            var $this = $(this);
            $this.find('.label').fadeOut(200);
            $this.find('img').stop().animate({
                'width'     :'60px',
                'height'    :'60px',
                'top'       :'0px',
                'left'      :'0px',
                'opacity'   :'0'
            },1000,'easeOutBack');
            $this.find('a').removeClass('hover');
//            $('div.photoFrame img.photoImage.visible').toggleClass('visible');
        }
    );  
   $('#nav.bubble .item a').hover(
        function() {
            $(this).addClass('hover');
        },
        function() {}
   );     
});
