
jQuery(document).ready(function(){
	
  //gestion des fonds	
  if(typeof HOMEPAGE == 'undefined'){
    var obj = document.getElementById('main-wrapper');
    var divHeight;
    if(obj.offsetHeight)          {divHeight=obj.offsetHeight;}
    else if(obj.style.pixelHeight){divHeight=obj.style.pixelHeight;}
    
    divHeight +=319;
    h = divHeight+"px";
    jQuery(".page-bkg").each(function(index) {
      jQuery(this).css("height",h);
    });
  }
  //google map
  if(document.getElementById("gmap-localisation")) {
	  initialisation();
  }
});
 
	
	
function initialisation(){
	var centreCarte = new google.maps.LatLng(45.4518648, 6.9744443);
	var optionsCarte = {
		zoom: 15,
		center: centreCarte,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	var maCarte = new google.maps.Map(document.getElementById("gmap-localisation"), optionsCarte);
	
	var myMarker = new google.maps.Marker({
		// Coordonnées du cinéma
		position: centreCarte,
		map: maCarte,
		title: "Hotel Le Savoie"
	});
}	
	

//Slider photo sur pages

var slider = new Object();
var slideProcess = false;
slider["newImage"];
slider["nbImages"];
slider["leftImage"];
slider["rightImage"];
slider["toHide"];
jQuery(document).ready(function(){
	slider["nbImages"] = jQuery("ul#galerie li").size()-1;
	if(slider["nbImages"] > 3){
    	slider["leftImage"] = 0;
    	slider["rightImage"] = 2;
	}
	jQuery('#galerie-fleche-gauche').hide();
});
(function ($) {
	Drupal.behaviors.slider = {
	  attach: function(context) {
	    $('span.fleche-galerie', context).once(function(){
	      $(this).click(function(){
	    	if(!slideProcess) {
	    		slideProcess = true;
		    	if((this.id == "galerie-fleche-gauche") &&  (slideProcess)){
		    		slider["newImage"] = Math.round(jQuery("ul#galerie li:visible:first").attr('id').substr(8,1));
		    		slider["newImage"]--;
		    		slider["toHide"] = Math.round(jQuery("ul#galerie li:visible:last").attr('id').substr(8,1));
			    	if(slider["newImage"]<0) {return false;}
			    	if(slider["newImage"]==0) {jQuery('#galerie-fleche-gauche').hide();}
			    	jQuery('#galerie-fleche-droite').show();
		    	}
		        else {
		        	slider["newImage"] = Math.round(jQuery("ul#galerie li:visible:last").attr('id').substr(8,1));
		        	slider["newImage"]++;
		        	slider["toHide"] = Math.round(jQuery("ul#galerie li:visible:first").attr('id').substr(8,1));
		        	if(slider["newImage"]>slider["nbImages"]) {;return false;}
			    	if(slider["newImage"]==slider["nbImages"]) {jQuery('#galerie-fleche-droite').hide();}
		        	jQuery('#galerie-fleche-gauche').show();
		        }
		    	jQuery("#gal-img-"+slider["toHide"]).hide("slow");
		    	jQuery("#gal-img-"+slider["newImage"]).show("slow",function() {
		    	  slideProcess = false;
		    	});	
		    	slider["leftImage"] = Math.round(jQuery("ul#galerie li:visible:first").attr('id').substr(8,1));
		    	slider["rightImage"] = Math.round(jQuery("ul#galerie li:visible:last").attr('id').substr(8,1));
		    	
		    	return false;
		      }
      		});
	    });
	  }
	}
})(jQuery);




// event listener sur l'input de la newsletter
(function ($) {
	Drupal.behaviors.clear_search = {
	  attach: function(context) {
	    $('#simplenews-block-form-1 #edit-mail', context).once(function(){  
	      this.defaultValue = this.value;
	      $(this).click(function(){
	        if(this.value == this.defaultValue){
	          $(this).val("");
	        }
	        return false;
	      });
	      $(this).blur(function(){
	        if(this.value == ""){
	          $(this).val(this.defaultValue);
	        }
	      });
	    });
	  }
	}
})(jQuery);
	
;

