$(document).ready(function(){
  // Verification de la hauteur de la hauteur d'affichage
  if($(window).height() < 590) {
    $('#global').removeAttr('id', 'global');
    $('body div:eq(1)').attr('id', 'global2');
    $('#ombre').hide();
  }
  
  // target sur les lien
  $('.target').attr('target','_blank');
  
  // Gestion du clic sur les vignettes
  if ($('#box-diapo').lenght != 0) {
    $('#vignettes a').click(function(){ 
      srcTmp = $('#apercu img').attr('src').substring(0, $('#apercu img').attr('src').length-4);
      vignetteTmp = $(this).find('img').attr('src').substring(0, $(this).find('img').attr('src').length-6);   
      $('#apercu img').attr('src',vignetteTmp+'.jpg');
      $(this).find('img').attr('src',srcTmp+'-m.jpg');
      return false;
    });    
  }
  
  // Gestion des disponibilites manager
  if ($('.change-disponibilite').length != 0){
    $('.change-disponibilite').click(function(){
       idA = $(this).attr('id');
       $.ajax({
         type: 'POST',
         url: 'update-reservation.php',
         data: 'date='+$(this).attr('id'),
         success: function(msg){
          if (msg == 1){
            $('#'+idA).parent().removeClass('ON');  
          }
          if (msg == 2){
            $('#'+idA).parent().addClass('ON');  
          }
         }
       });
      return false;
    });  
  }
  
  // Gestion du click sur le select
  if ($('#chambre_select').length != 0){
    $('#chambre_select').change(function(){
      $(location).attr('href',$(this).val());
    });    
  }
});
