// JavaScript Document                
$(document).ready( function() {
    var ID_menu = 1;
    var time_menu;
function timer_menu(IDset) {
                    $("#tipsBox img").removeClass("hover_small");
                    $("#tipsBox #tip"+ IDset +" img").addClass("hover_small");
                    $('#tipsBox .mainImage img').attr('src', $("#tipsBox #tip" + IDset + " .hidden_img_big").html());
                    $("#tipsBox #content_timeM").html($("#tipsBox #tip" + IDset + " .content").html());                    
                    clearInterval(time_menu);                    
                    time_menu = setInterval(function(){
                    $("#tipsBox #tip"+ IDset +" img").removeClass("hover_small");
                    if (IDset<5) {timer_menu((IDset+1));}
                    else if (IDset==5) {timer_menu((IDset-4));}
                    }, 6000)
                    }

        
        timer_menu(ID_menu);
        
       
        $("#tipsBox #tip1").hover(
          function(){
                    $("#tipsBox img").removeClass("hover_small");
                    $("#tipsBox #tip1 img").addClass("hover_small");
                    $('#tipsBox .mainImage img').attr('src', $("#tipsBox #tip1 .hidden_img_big").html());
                    $('#tipsBox .mainImage a').attr('href', $("#tipsBox #tip1 a").attr('href'));
                    $("#tipsBox #content_timeM").html($("#tipsBox #tip1 .content").html());
                    },
          function(){
                    ID_menu = 1;
                    }      
          );

          $("#tipsBox #tip2").hover(
          function(){
                    $("#tipsBox img").removeClass("hover_small");
                    $("#tipsBox #tip2 img").addClass("hover_small");
                    $('#tipsBox .mainImage img').attr('src', $("#tipsBox #tip2 .hidden_img_big").html());
                    $('#tipsBox .mainImage a').attr('href', $("#tipsBox #tip2 a").attr('href'));
                    $("#tipsBox #content_timeM").html($("#tipsBox #tip2 .content").html());
                    },
          function(){
                    ID_menu = 2;
                    }
          );
          $("#tipsBox #tip3").hover(
          function(){
                    $("#tipsBox img").removeClass("hover_small");
                    $("#tipsBox #tip3 img").addClass("hover_small");
                    $('#tipsBox .mainImage img').attr('src', $("#tipsBox #tip3 .hidden_img_big").html());
                    $('#tipsBox .mainImage a').attr('href', $("#tipsBox #tip3 a").attr('href'));
                    $("#tipsBox #content_timeM").html($("#tipsBox #tip3 .content").html());
                    },
          function(){
                    ID_menu = 3;
                    }   
          );
          $("#tipsBox #tip4").hover(
          function(){
                    $("#tipsBox img").removeClass("hover_small");
                    $("#tipsBox #tip4 img").addClass("hover_small");
                    $('#tipsBox .mainImage img').attr('src', $("#tipsBox #tip4 .hidden_img_big").html());
                    $('#tipsBox .mainImage a').attr('href', $("#tipsBox #tip4 a").attr('href'));
                    $("#tipsBox #content_timeM").html($("#tipsBox #tip4 .content").html());
                    },
          function(){
                    ID_menu = 4;
                    }
          );          
          $("#tipsBox #tip5").hover(
          function(){
                    $("#tipsBox img").removeClass("hover_small");
                    $("#tipsBox #tip5 img").addClass("hover_small");
                    $('#tipsBox .mainImage img').attr('src', $("#tipsBox #tip5 .hidden_img_big").html());
                    $('#tipsBox .mainImage a').attr('href', $("#tipsBox #tip5 a").attr('href'));
                    $("#tipsBox #content_timeM").html($("#tipsBox #tip5 .content").html());
                    },
          function(){
                    ID_menu = 5;
                    }
          );

        $("#tipsBox").mouseleave(
              function(){
              timer_menu(ID_menu);
              }
              )
                                    
        $("#tipsBox").mouseover(function(){
        clearInterval(time_menu);
        });                     

});
