$(document).ready(function(){

//Larger thumbnail preview 

$("ul.thumb li#thumb_1").hover(function() {

	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-138px', 
			marginLeft: '0', 
			top: '50%', 
			left: '0', 
			width: '206px', 
			height: '277px',
			padding: '0px' 
		}, 200);
	
	} , function() {

	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '165px', 
			height: '222px', 
			padding: '0px'
		}, 400);
});



$("ul.thumb li#thumb_2").hover(function() {

	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-161px', 
			marginLeft: '0', 
			top: '50%', 
			left: '0', 
			width: '174px', 
			height: '313px',
			padding: '0px' 
		}, 200);
	
	} , function() {

	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '139px', 
			height: '250px', 
			padding: '0px'
		}, 400);
});


$("ul.thumb li#thumb_3").hover(function() {
	/*$('#det_3 a').css('color','#db0075');*/
	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-178px', 
			marginLeft: '0', 
			top: '50%', 
			left: '0', 
			width: '198px', 
			height: '356px',
			padding: '0px' 
		}, 200);
	
	} , function() {
	/*$('#det_3 a').css(('color',''));*/
	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '158px', 
			height: '285px', 
			padding: '0px'
		}, 400);
});


$("ul.thumb li#thumb_4").hover(function() {

	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-178px', 
			marginLeft: '0', 
			top: '50%', 
			left: '0', 
			width: '198px', 
			height: '356px',
			padding: '0px' 
		}, 200);
	
	} , function() {

	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '158px', 
			height: '285px', 
			padding: '0px'
		}, 400);
});

$("ul.thumb li#thumb_5").hover(function() {

	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-156px', 
			marginLeft: '0', 
			top: '50%', 
			left: '0', 
			width: '174px', 
			height: '313px',
			padding: '0px' 
		}, 200);
	
	} , function() {

	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '139px', 
			height: '250px', 
			padding: '0px'
		}, 400);
});

$("ul.thumb li#thumb_6").hover(function() {

	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-138px', 
			marginLeft: '0', 
			top: '50%', 
			left: '0', 
			width: '154px', 
			height: '277px',
			padding: '0px' 
		}, 200);
	
	} , function() {

	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '123px', 
			height: '222px', 
			padding: '0px'
		}, 400);
});

 
});





(function($){
	
	$.fn.tzSelect = function(options){
		options = $.extend({
			render : function(option){
				return $('<li>',{
					html : option.text()
				});
			},
			className : ''
		},options);
		
		return this.each(function(){
			
			// The "this" points to the current select element:
			
			var select = $(this);
		
			var selectBoxContainer = $('<div>',{
				width		: select.outerWidth(),
				className	: 'tzSelect',
				html		: '<div class="selectBox"></div>'
			});
		
			var dropDown = $('<ul>',{className:'dropDown'});
			var selectBox = selectBoxContainer.find('.selectBox');
			
			// Looping though the options of the original select element

			if(options.className){
				dropDown.addClass(options.className);
			}
			
			select.find('option').each(function(i){
				var option = $(this);
		
				if(i==select.attr('selectedIndex')){
					selectBox.html(option.text());
				}
				
				// As of jQuery 1.4.3 we can access HTML5 
				// data attributes with the data() method.
				
				if(option.data('skip')){
					return true;
				}
				
				// Creating a dropdown item according to the
				// data-icon and data-html-text HTML5 attributes:
				
				var li = options.render(option);

				li.click(function(){
					
					selectBox.html(option.text());
					dropDown.trigger('hide');

					affiche_bloc("bloc_"+select.attr("id"),option.val());
					// When a click occurs, we are also reflecting
					// the change on the original select element:
					select.val(option.val());
					
					return false;
				});
		
				dropDown.append(li);
			});
			
			selectBoxContainer.append(dropDown.hide());
			select.hide().after(selectBoxContainer);
			
			// Binding custom show and hide events on the dropDown:
			
			dropDown.bind('show',function(){
				
				if(dropDown.is(':animated')){
					return false;
				}
				
				selectBox.addClass('expanded');
				dropDown.slideDown();
				
			}).bind('hide',function(){
				
				if(dropDown.is(':animated')){
					return false;
				}
				
				selectBox.removeClass('expanded');
				dropDown.slideUp();
				
			}).bind('toggle',function(){
				if(selectBox.hasClass('expanded')){
					dropDown.trigger('hide');
				}
				else dropDown.trigger('show');
			});
			
			selectBox.click(function(){
				dropDown.trigger('toggle');
				return false;
			});
		
			// If we click anywhere on the page, while the
			// dropdown is shown, it is going to be hidden:
			
			$(document).click(function(){
				dropDown.trigger('hide');
			});

		});
	}
	
})(jQuery);











/* scripts ajax qui vérifient les champs et envoie le mail*/

var xhr = null;
 
/* Fonction de creation de l'objet XMLHttpRequest qui resservira pour chaques fonctions AJAX*/
function getXhr()
 {
  if(window.XMLHttpRequest) xhr = new XMLHttpRequest(); 
  else if(window.ActiveXObject)
   {  
    try
     {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
     }
    catch (e)
     {
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
     }
   }
  else 
   { 
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest, veuillez le mettre ŕ jour"); 
    xhr = false; 
   } 
 }
 
 
 
	/* Pour afficher le contenu d'un bloc, page d'accueil */
	function affiche_bloc(bloc, idbloc){
	
		getXhr();
		xhr.onreadystatechange = function()
		   {
			if(xhr.readyState == 4 && xhr.status == 200)
			 {
				$("#"+bloc).fadeOut(300, function(){
					document.getElementById(bloc).innerHTML=xhr.responseText;
				});
				$("#"+bloc).delay(300).fadeIn(300);	
			  
			 }
		   }
		  // On envoie la requete 

		  xhr.open("POST",'./inc/javascript/recup_contenu_accueil.php',true);
		  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		  xhr.send("id_page_accueil="+idbloc);
	}
