$(document).ready(function(){
  $('.jmenu ul:not(.jmenu):not(.selected)').hide();
  $('.jmenu ul.selected li').addClass('hover');
  $('.jmenu li').hoverIntent({    
     sensitivity: 3,   
     interval: 10, 
     over: function(){
		$(this).children('ul').stop(true, true);
		$(this).children('ul').slideDown('slow');
		$(this).addClass('hover');
	 }, 
     timeout: 250, 
     out:function(){
		$(this).removeClass('hover');
		if($(this).children('.hover').size() == 0 && !$(this).hasClass('selected')) {
			//$(this).children('ul').hide();
			$(this).children('ul').stop(true, true);
			$(this).children('ul').slideUp('slow');
		}
	 }
  });
  
  // MENU BAS 
  
  //this is not menu lol
  var move;
  $('.bouton_g').hoverIntent({    
     sensitivity: 3,   
     interval:10, 
     over: function(){
		//alert('lol');
		var parentId = $(this).parent('div').attr('id');
		move = setInterval("$('.hor_wrapper', $('#"+parentId+"')).scrollTo('-=10px', {axis: 'x', duration: 10})", 10);
		//$('#img_menub').scrollTo('-=30px', {axis: 'x', duration: 10});
	 }, 
     timeout: 10, 
     out:function(){
		clearInterval(move);
	 }
  });
  $('.bouton_d').hoverIntent({    
     sensitivity: 3,   
     interval:10, 
     over: function(){
		//alert('lol');
		var parentId = $(this).parent('div').attr('id');
		move = setInterval("$('.hor_wrapper', $('#"+parentId+"')).scrollTo('+=10px', {axis: 'x', duration: 10})", 10);
		//$('#img_menub').scrollTo('+=30px', {axis: 'x', duration: 10});
	 }, 
     timeout: 10, 
     out:function(){
		clearInterval(move);
	 }
  });
  
  // BTN TOP ET BOTTOM
  
  $('.btn_top').hoverIntent({
     sensitivity: 3,
     interval:10,
     over: function(){
        var parentId = $(this).parent('div').attr('id');
        move = setInterval("$('.scroller', $('#"+parentId+"')).scrollTo('-=5px', {axis: 'y', duration: 10})", 10);
        //$('#img_menub').scrollTo('-=30px', {axis: 'x', duration: 10});
     },
     timeout: 10,
     out:function(){
        clearInterval(move);
     }
  });
  $('.btn_bottom').hoverIntent({
     sensitivity: 3,
     interval:10,
     over: function(){
        var parentId = $(this).parent('div').attr('id');
        move = setInterval("$('.scroller', $('#"+parentId+"')).scrollTo('+=5px', {axis: 'y', duration: 10})", 10);
        //$('#img_menub').scrollTo('+=30px', {axis: 'x', duration: 10});
     },
     timeout: 10,
     out:function(){
        clearInterval(move);
     }
  });


  // GESTION DES IMAGES DE LA GALERIE 
  
  $('#galerie_chambres .img_menu').click(function(){
	var wrapper = $('#img_content_spe img').get(0);
	//alert(wrapper.getAttribute('src'));
	var img_url = $(this).children('img').attr('src').replace('miniature', 'grande');
	wrapper.setAttribute('src', img_url);
  });

});
