(function ($) {
$(document).ready(function(){
	//ZoomShowcase
	$('.fleche_suiv').click(function(){ 
								if(!jQuery.zoomShowcase.isReady()) jQuery.zoomShowcase.goRight()
							});
	$('.fleche_prec').click(function(){ 
								if(!jQuery.zoomShowcase.isReady()) jQuery.zoomShowcase.goLeft()
							});
	
	
	
	$("#voir-collections").click(function(){
		$("#zoom-gallery").fadeOut(300);
		$("#zoomShowcase-navigation").fadeOut(300);
		$('.toutes-les-collections').fadeIn(1000);
		}
	);
	
	$("#affichage-classique").click(function(){
		$('.toutes-les-collections').hide();
		$("#zoom-gallery").fadeIn(300);
		$("#zoomShowcase-navigation").fadeIn(500);
		}
	);	
	
	
	
	//Supression des dimensions des images pour les pages collections
	$('.node-type-collection .field-name-field-photo-ambiance .field-item img').removeAttr('width');
    $('.node-type-collection .field-name-field-photo-ambiance .field-item img').removeAttr('height');



    // People Grid Hovers
    var listItem = $('.view-produit-par-collection .view-content .views-row'),
        title = listItem.find('.views-field-title'),
        hoverDur = 150;
        
    //listItem.bind('click', function (e) { e.preventDefault(); });
    listItem.hover(function () {
      $(this).find('.views-field-title').animate({
        'marginTop' : -30
      }, hoverDur + 200);
      
    
    }, function () {
        $(this).find('.views-field-title').animate({
          'marginTop' : 0
        }, hoverDur);
    }); 
 
 	/*
 	//Etiquette produits page produits
    var listItem = $('.view-cat-gories  .view-content .views-row'),
        title = listItem.find('.views-field-name'),
        hoverDur = 150;
        
    //listItem.bind('click', function (e) { e.preventDefault(); });
    listItem.hover(function () {
      $(this).find('.views-field-name').animate({
        'marginTop' : -35
      }, hoverDur + 200);
      
    
    }, function () {
        $(this).find('.views-field-name').animate({
          'marginTop' : 0
        }, hoverDur);
    });   
    */


	//Affichage des produits
	$("#voir-produits").click(function(){
		$(".view-produit-par-collection .view-content").fadeIn('slow', function(){$('.view-produit-par-collection .view-content .views-row').show()});
		
	});
	$("#block-views-produit_par_collection-block .view-content h3").click(function(){
		$(".view-produit-par-collection .view-content").fadeOut('slow', function(){$('.view-produit-par-collection .view-content .views-row').hide()});
	});



	//Ce produit m'interesse
	var showOrHideProduit=false;
	$("#block-views-cartouche_produit-block .mail-produit").click(function(){
			if ( showOrHideProduit == true ) {
				$("#block-webform-client-block-44").fadeOut('slow');
				showOrHideProduit = false;
			} else if ( showOrHideProduit == false ) {
				$("#block-webform-client-block-44").fadeIn('slow');
				showOrHideProduit = true;
			}	
	});

	$("#block-webform-client-block-44 .block-inner").prepend('<div class="fermer-formulaire">Fermer</div>');
	
	$(".fermer-formulaire").click(function(){
				$("#block-webform-client-block-44").fadeOut('slow')
			});
	
	//Ascenseurs
	//$('.liste-des-magasins .view-content').jScrollPane();



	//Produits
	var produit = $('.node-type-produit .field-name-field-photo .field-items img');
	
	produit.each(function(){
        $(this).removeAttr('width');
        $(this).removeAttr('height');
      });
    
    


    
    //NAVIGATION PRODUIT
    var nav_produit = $('.node-type-produit #navigation-produit .nav');
	var decalage = 272;
	nav_produit.eq(0).addClass('nav-selected');
	
    nav_produit.each(function(){
    	$(this).click(function(){
    		images = $('.node-type-produit .field-name-field-photo .field-items img');
    		
    		nav_produit.removeClass('nav-selected');
    		$(this).addClass('nav-selected');
    		
    		var temp = $(this).attr('id').split("_");
    		var nav_selected = temp[1];
    		
    		var deplacement = 0;
    		if (nav_selected != 0){
    			for (var i=0;i<nav_selected;i++){
    				deplacement += images[i].width + 12;
    			}
    			//deplacement -=decalage;
    		}
    		
    		$('.node-type-produit .field-name-field-photo .field-items').animate( {left:-deplacement}, 1300, 'easeInOutExpo')
    	})
    });
    
    
    //Apparition Designers
    /*var designers = $('.view-designers .views-row').hide();  
	var i = 0;
	
	//designers.eq(0).fadeIn(200);
	setTimeout(function(){ displayImages(i);i++},1000);
    function displayImages(im) {  
         			designers.eq(im).fadeIn(400);  
         			
     			}
    
    //Apparition Produit
    var produits = $('.page-categories-produits .view-cat-gories .views-row').hide();  
	var i = 0;
	
	setTimeout(function displayImages() {  
         		produits.eq(i++).fadeIn(200, displayImages);  
     			},800);
     */			
     			
    //Resize de la fenetre
	jQuery('body').bind( 'resize', function(e) {
		if($(window).height() < 630 ) 
    	 	$('#footer-menu').fadeOut('fast')
    	 else
    	 	$('#footer-menu').fadeIn('slow')
	});
	
	
	$('.view-display-id-page_1 .views-row').hover(
		function(){
			$(this).find('.views-field-postal-code').addClass('code-postal-hover');
			$(this).find('.views-field-field-ville-principale').addClass('code-postal-hover');
			$(this).find('.views-field-field-ville-principale').addClass('fleche-aller');
		},
		function (){
			$(this).find('.views-field-postal-code').removeClass('code-postal-hover')
			$(this).find('.views-field-field-ville-principale').removeClass('code-postal-hover');
			$(this).find('.views-field-field-ville-principale').removeClass('fleche-aller');

		})
	
	$(".view-designers .view-content, .view-taxonomy-term-2 .view-content").vgrid({
		easeing: "easeOutQuint",
		useLoadImageEvent: true,
		time: 400,
		delay: 20,
		fadeIn: {
			time: 500,
			delay: 250
		}
	});

        	
});
})(jQuery)

;
/**
 * jQuery VGrid v0.1.7 - variable grid layout plugin
 *
 * Terms of Use - jQuery VGrid
 * under the MIT (http://www.opensource.org/licenses/mit-license.php) License.
 *
 * Copyright 2009-2011 xlune.com All rights reserved.
 * (http://blog.xlune.com/2009/09/jqueryvgrid.html)
 */
(function(g){function i(a){var b=a.data("_vgchild"),f=[[0,a.width(),0]],h=0,e,c,j;b.each(function(){e=g(this);var a=e.width(),d=e.height();a+=Number(e.css("margin-left").replace("px",""))+Number(e.css("padding-left").replace("px",""))+Number(e.get(0).style.borderLeftWidth.replace("px",""))+Number(e.css("margin-right").replace("px",""))+Number(e.css("padding-right").replace("px",""))+Number(e.get(0).style.borderRightWidth.replace("px",""));d+=Number(e.css("margin-top").replace("px",""))+Number(e.css("padding-top").replace("px",
""))+Number(e.get(0).style.borderTopWidth.replace("px",""))+Number(e.css("margin-bottom").replace("px",""))+Number(e.css("padding-bottom").replace("px",""))+Number(e.get(0).style.borderBottomWidth.replace("px",""));c=[a,d];a:{for(var a=c[0],d=f.concat().sort(q),b=d[d.length-1][2],k=0,o=d.length;k<o;k++){if(d[k][2]>=b)break;if(d[k][1]-d[k][0]>=a){j=[d[k][0],d[k][2]];break a}}j=[0,b]}d=j;a=f.concat().sort(q);d=[d[0],d[0]+c[0],d[1]+c[1]];b=0;for(k=a.length;b<k;b++)if(d[0]<=a[b][0]&&a[b][1]<=d[1])delete a[b];
else{var o=a,i=b,l=a[b],m=d;if(l[0]>=m[0]&&l[0]<m[1]||l[1]>=m[0]&&l[1]<m[1])l[0]>=m[0]&&l[0]<m[1]?l[0]=m[1]:l[1]=m[0];o[i]=l}a=a.concat([d]).sort(s);d=[];b=0;for(k=a.length;b<k;b++)a[b]&&(d.length>0&&d[d.length-1][1]==a[b][0]&&d[d.length-1][2]==a[b][2]?d[d.length-1][1]=a[b][1]:d.push(a[b]));f=d;h=Math.max(h,j[1]+c[1]);e.data("_vgleft",j[0]);e.data("_vgtop",j[1])});a.data("_vgwrapheight",h);t(a)}function q(a,b){return!a||!b?0:a[2]==b[2]&&a[0]>b[0]||a[2]>b[2]?1:-1}function s(a,b){return!a||!b?0:a[0]>
b[0]?1:-1}function t(a){var b=a.data("_vgchild").length*(a.data("_vgopt").delay||0)+a.data("_vgopt").time||500;a.stop();a.height()<a.data("_vgwrapheight")?g.browser.msie?a.height(a.data("_vgwrapheight")):a.animate({height:a.data("_vgwrapheight")+"px"},a.data("_vgopt").time||500,"easeOutQuart"):(clearTimeout(a.data("_vgwraptimeout")),a.data("_vgwraptimeout",setTimeout(function(){g.browser.msie?a.height(a.data("_vgwrapheight")):a.animate({height:a.data("_vgwrapheight")+"px"},a.data("_vgopt").time||
500,"easeOutQuart")},b)))}function u(a){var b;a.each(function(){b=g(this);b.css("left",~~b.data("_vgleft")+"px");b.css("top",~~b.data("_vgtop")+"px")})}function p(a,b,f,h){var e=g(a).parent(),c=false,j=a.length,i,d,n;for(i=0;i<j;i++)d=g(a[i]),n=d.position(),n.left!=d.data("_vgleft")&&n.top!=d.data("_vgtop")&&(c=true);if(c){if(typeof e.data("_vgopt").onStart=="function")e.data("_vgopt").onStart();a.each(function(d){var c=g(this),j={duration:f,easing:b};if(a.size()-1==d)j.complete=e.data("_vgopt").onFinish||
null;clearTimeout(c.data("_vgtimeout"));c.data("_vgtimeout",setTimeout(function(){c.animate({left:c.data("_vgleft")+"px",top:c.data("_vgtop")+"px"},j)},d*h))})}}function n(a){clearTimeout(a.data("_vgtimeout"));i(a);a.data("_vgtimeout",setTimeout(function(){p(a.data("_vgchild"),a.data("_vgopt").easeing||"linear",a.data("_vgopt").time||500,a.data("_vgopt").delay||0)},500))}function v(a,b){var f=g("<span />").text(" ").attr("id","_vgridspan").hide().appendTo("body");f.data("size",f.css("font-size"));
f.data("timer",setInterval(function(){f.css("font-size")!=f.data("size")&&(f.data("size",f.css("font-size")),b(a))},1E3))}function r(a,b){a.data("vgrid-image-event-added")||(a.data("vgrid-image-event-added",1),a.bind("vgrid-added",function(){a.find("img").each(function(){var e=g(this);e.data("vgrid-image-handler")||(e.data("vgrid-image-handler",1),e.bind("load",function(){b(a)}))})}));a.trigger("vgrid-added");var f=a.append,h=a.prepend;a.append=function(){f.apply(a,arguments);a.trigger("vgrid-added")};
a.prepend=function(){h.apply(a,arguments);a.trigger("vgrid-added")}}g.fn.extend({vgrid:function(a){var b=g(this),f=a||{};b.each(function(){var a=g(this);a.data("_vgopt",f);a.data("_vgchild",a.find("> *"));a.data("_vgdefchild",a.data("_vgchild"));a.css({position:"relative",width:"auto"});a.data("_vgchild").css("position","absolute");i(a);u(a.data("_vgchild"));if(a.data("_vgopt").fadeIn){var b=typeof a.data("_vgopt").fadeIn=="object"?a.data("_vgopt").fadeIn:{time:a.data("_vgopt").fadeIn};a.data("_vgchild").each(function(a){var f=
g(this);f.css("display","none");setTimeout(function(){f.fadeIn(b.time||250)},a*(b.delay||0))})}g(window).resize(function(){n(a)});f.useLoadImageEvent&&r(a,n);f.useFontSizeListener&&v(a,n)});return b},vgrefresh:function(a,b,f,h){var e=g(this);e.each(function(){var c=g(this),e=c.data("_vgopt")||{};c.data("_vgchild")&&(c.data("_vgchild",c.find("> *")),c.data("_vgchild").css("position","absolute"),i(c),b=typeof b=="number"?b:c.data("_vgopt").time||500,f=typeof f=="number"?f:c.data("_vgopt").delay||0,
p(c.data("_vgchild"),a||c.data("_vgopt").easeing||"linear",b,f),typeof h=="function"&&setTimeout(h,c.data("_vgchild").length*f+b));e.useLoadImageEvent&&r(c,n)});return e},vgsort:function(a,b,f,h){var e=g(this);e.each(function(){var c=g(this);c.data("_vgchild")&&(c.data("_vgchild",c.data("_vgchild").sort(a)),c.data("_vgchild").each(function(){g(this).appendTo(c)}),i(c),p(c.data("_vgchild"),b||c.data("_vgopt").easeing||"linear",typeof f=="number"?f:c.data("_vgopt").time||500,typeof h=="number"?h:c.data("_vgopt").delay||
0))});return e}})})(jQuery);
;

