$(document).ready(function() {

	// Configuration générale
	
	if($("#MainContainer").hasClass("PageComparateur") == true) {
	   ComparateurTableau(); 
	}
	
	Test = false;
	PauseTimer = 1000;
	MouseOutTimer = 200;
	EffectTimer = 500;
	idProduct = 0;
	typeSite = "";
	urlSite = "";
	simulCreditParam = "";
	condiCreditParam = "";
	idProduitAddViewAll = "0";
	/*
	+-------------------------------------------------------------------+
	|	Récupération de l'idproduct en cours							|
	+-------------------------------------------------------------------+
	*/

	$(".MainContainer").ready(function() {
		var listBalises = document.getElementsByTagName('div');
		$("#lnkAddToBag").attr("href",  $("#lnkAddToBag").attr("savehref") + "&quantite1=" + $("#QuantityProduct").val());
		for(var i=0;i<listBalises.length; i++)
		{
			if(listBalises[i].getAttribute('id') == 'MainContainer')
			{
				idProduct = listBalises[i].getAttribute('idproduct');
				typeSite = listBalises[i].getAttribute('typeSite');
				urlSite  = listBalises[i].getAttribute('urlSite');
				break;
			}
		}
	});

	/*
	+-------------------------------------------------------------------+
	|	Google Analytics												|
	+-------------------------------------------------------------------+
	*/
	// ID user
	$.ga("UA-775221-1");
	// => Ajouter la classe CSS "ga-page" pour tracker les liens
	// cf. http://squarefactor.com/words/2009/feb/13/google-analytics-jquery-plugin/


	/*
	+-------------------------------------------------------------------+
	|	PNG Fix															|
	+-------------------------------------------------------------------+
	*/
	if( $.browser.msie && ($.browser.version == "6.0")  ) {
		DD_belatedPNG.fix('.png');
	}



	/*
	+-------------------------------------------------------------------+
	|	Print															|
	+-------------------------------------------------------------------+
	*/
	$(".PrintContent a").click(function() {
	  window.open(urlSite + 'PrintFicheProduit.aspx?idproduct=' + idProduct + '','', config='height=800, width=800, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, directories=no, status=no');
		return false;
	});
	
	$(".DispoMagPrint a").click(function() {
		window.print();
		return false;
	});
           
	
	
	
	
	
	
	/*
	+-------------------------------------------------------------------+
	|	Quantité														|
	+-------------------------------------------------------------------+
	*/	
	// cf. "Fonction d'accrementation" en fin de fichier
	
		// Changement de la quantité avec la souris
		si2 = new Object();
		function AccrementationBind() {
			
			// Suppression des actions existantes
			$(".Accrementation a, .Accrementation .Quantity input").unbind();
			
			// Application des actions existantes
			$(".Accrementation a").mousedown(function() {
				// Changement de la quantité au maintien du click
				Link = $(this);
				si2 = window.setInterval('AccrementationChange(Link);', 500);
			})
			.mouseup(function() {
				// Stop du changement de la quantité au maintien du click
				window.clearInterval(si2);
			})
			.click(function() {
				// Changement de la quantité au click
				AccrementationChange($(this));
				// Blocage du click
				return false;
			});
			
			// Changement de la quantité avec le clavier
			$(".Accrementation .Quantity input").bind("keyup blur", function() {
				var v = $(this).val();
				v = v.replace(/^0+/gi, "");
				var r = v.split("");
				var v2 = new String;
				for(var i in r) {
					if( (r[i].charCodeAt(0) >= 48) && (r[i].charCodeAt(0) <= 57) ) {
						v2 += r[i];
					}
				}
				// Si la quantité est 0 ou inexistante
				if( (v2 < 1) || (v2 == "") ) {
					v2 = 1;
				}
				// Si la quantité est supérieure à 999
				else if(v2 > 999) {
					v2 = 999;
				}
				v = v2;
				
				// Qté courante
				if($(this).attr("name") == "QuantityProduct") {
					$(".Quantity input[name='QuantityProduct']").val(v);
				}
				else {
					$(this).val(v);
				}
				
				// Calcul du prix
				//AccrementationPrice();
				
			});
			
		}
		AccrementationBind();
	
	
	
	
	/*
	+-------------------------------------------------------------------+
	|	Services														|
	+-------------------------------------------------------------------+
	*/
	// Scroll des services
	ServicesCpt = 0; // Compteur
	ServicesNbAff = 3; // Nombre de services affichés
	ServicesNbItems = $(".ServicesContainer .ScrollDefil > table").length; // Nombre d'items
	ServicesHauteurItems = $(".ServicesContainer .ScrollDefil > table").height(); // Hauteur d'un item
	ServicesMargeSupItems = parseInt($(".ServicesContainer .ScrollDefil > table").css("margin-top")); // Marge supérieure d'un item
	ServicesMargeInfItems = parseInt($(".ServicesContainer .ScrollDefil > table").css("margin-bottom")); // Marge inférieure d'un item
	ServicesHauteurTotItems = ServicesHauteurItems + ServicesMargeSupItems + ServicesMargeInfItems; // Hauteur totale d'un item
	
	// Si pas besoin de défillement on grise les boutons
	if(ServicesNbItems <= ServicesNbAff) {
		$(".ServicesContainer a.Scroll").css("opacity", .33)
										.css("cursor", "default");
	}
	
	// Grisage du bouton Up au chargement
	$(".ServicesContainer a.ScrollUp")	.css("opacity", .33)
										.css("cursor", "default");
	
	$(".ServicesContainer a.Scroll").click(function() {

		// Si les boutons sont nécessaires
		if(ServicesNbItems > ServicesNbAff) {	
		
			// Dégrisage des boutons
			$(".ServicesContainer a.Scroll")	.css("opacity", 1)
												.css("cursor", "pointer");
												
			// Scroll vers le bas
			if( $(this).hasClass("ScrollDown") == true) {
				// On scroll sauf si le dernier item est affiché 
				if( ServicesCpt < (ServicesNbItems - ServicesNbAff) ) {
					ServicesCpt++;
					$(this).parents(".ServicesContent").find(".ScrollDefil").animate({
						top: -(ServicesHauteurTotItems * ServicesCpt)
					}, EffectTimer);
				}
				// Grisage si lien non nécesaire
				if(ServicesCpt >= (ServicesNbItems - ServicesNbAff)) {
					$(this)	.css("opacity", .33)
							.css("cursor", "default");
				}
				
			}
			
			// Scroll vers le haut
			else if( $(this).hasClass("ScrollUp") == true) {
				// On scroll sauf si le premier item est affiché 
				if(ServicesCpt > 0) {
					ServicesCpt--;
					$(this).parents(".ServicesContent").find(".ScrollDefil").animate({
						top: -(ServicesHauteurTotItems * ServicesCpt)
					}, EffectTimer);
				}
				// Grisage si lien non nécesaire
				if(ServicesCpt == 0) {
					$(this)	.css("opacity", .33)
							.css("cursor", "default");
				}
			}
		
		}
		
		// Blocage du click
		return false;
	});
	
	
	// Item Carte
	$(".SelectionCarte input[type='radio']").click(function() {
		$(this).parents(".SelectionCarte").find("input[type='checkbox']").attr("checked", true).trigger("focus");
	});
	$(".SelectionCarte input[type='checkbox']").click(function() {
		if( $(this).attr("checked") == true ) {
			if( $(this).parents(".SelectionCarte").find("input[type='radio']:checked").length == 0) {
				$(this).parents(".SelectionCarte").find("table tr:first-child input[type='radio']").attr("checked", true);
			}
		}
		else {
			$(this).parents(".SelectionCarte").find("input[type='radio']").attr("checked", false);
			$(this).trigger("focus");
		}
	});
	
	// Prix des services
	$("input.ServicesPrix").attr("checked", false);
	if($("input.ServicesPrix:first").attr("name") == "Extension") {
	  $("input.ServicesPrix:first").attr("checked", true);
    AccrementationPrice();
  }
	$("input.ServicesPrixCarte").attr("checked", false);
  $("input.ServicesPrix").bind("click", function() {
		AccrementationPrice();
	});
	$("input.ServicesPrixCarte").bind("click", function() {
		AccrementationPrice();
	});
	
	$("#lnkAddToBag").bind("click", function() {
      $(this).attr("href",  $(this).attr("savehref") + "&quantite1=" + $("#QuantityProduct").val());
  });

	
	
	
	
	
	
	
	/*
	+-------------------------------------------------------------------+
	|	ViewAll															|
	+-------------------------------------------------------------------+
	*/
	// Voir tous les portables
	st1 = new Object();
	$(".searchbox a").click(function() {
		//idnoeud
		Link = $(this);
		
		// Si le ViewAll est déjà ouvert, on le ferme
		if( $(".ViewAll").is("div:visible") == true) {
			//$(".ViewAll").remove();
			$(".ViewAll").fadeOut(EffectTimer);
			window.clearTimeout(st1);
			return false;
		}
		
		
		// Si le ViewAll a déjà été chargé on l'affiche
		else if( $(".ViewAll").is("div:hidden") == true) {
			$(".ViewAll").fadeIn(EffectTimer);
			window.clearTimeout(st1);
			return false;
		}
		
		// Sinon construction du ViewAll
		else {
			
			//$(".ViewAll").remove();
			ViewAllBloc = ''
				+	'<div class="ViewAll">'
				+	'	<div class="ViewAllTop png"><a href="#" class="Scroll ScrollUp">&nbsp;</a></div>'
				+	'	<div class="ViewAllContent png">'
				+	'	<div class="ViewAllContentIn Wait">'
				+	'	</div>'
				+	'	</div>'
				+	'	<div class="ViewAllBottom png"><a href="#" class="Scroll ScrollDown">&nbsp;</a></div>'
				+	'</div>'
				+	'';
				
			$("body").prepend(ViewAllBloc);
			ViewAllRelative = $(this).parents(".SecondNavigation");
			$(".ViewAll")	.css("top", 	ViewAllRelative.offset().top + ViewAllRelative.height() - 10 )
							.css("left", 	ViewAllRelative.offset().left - 5);
							
			// Affichage du bloc
			$(".ViewAll").fadeIn(EffectTimer, function() {
															
				// Récupération du contenu du ViewAll en Ajax
				Href = Link.attr("href");
				$.ajax({
					type: "POST",
					url: "FicheProduitWS.asmx/ChargerListeProduit",
					data:"idnoeud="+ Link.attr("idnoeud") + "&refproduct="+ Link.attr("refproduct") + "&search="+ Link.attr("recherche") + "&filter="+ Link.attr("filter") + "&typSite="+ Link.attr("typsite"),
					success: function(Asw) {
						
						if(Test == true) {Pause(PauseTimer)}
								
						// Masquage du ViewAll
						$(".SecondNavigation, .ViewAll").mouseover(function() {
							window.clearTimeout(st1);
							ViewAllHide();
							//PanelHide("ViewAll");
						});
						
						// Suppression de l'image du Loader
						$(".ViewAllContentIn").removeClass("Wait");

						// Insertion du contenu Ajax
						$(".ViewAllContentIn").html($("ViewAll", Asw).text());
						
						// Zone cliquable
						$(".ViewAll .ViewAllContentIn > ul > li").css("cursor", "pointer");
						$(".ViewAll .ViewAllContentIn > ul > li").click(function() {
							document.location.href = $(this).find("a").attr("href");											  
						});
						$(".ViewAll .ViewAllContentIn > ul > li:nth-child(5n)").addClass("last");
						
						
						// Actions Up/Down		
						ViewAllCpt = 0; // Compteur														
						ViewAllNbParLigne = 5; // Nombre d'item affichés par ligne
						ViewAllNbItems = $(".ViewAll .ViewAllContentIn > ul > li").length; // Nombre d'items
						ViewAllHauteurItems = $(".ViewAll .ViewAllContentIn > ul > li").height(); // Hauteur d'un item
						ViewAllNbLignes = Math.ceil(ViewAllNbItems / ViewAllNbParLigne);
						
						// Si il n'y a pas plus de 2 lignes : grisages des up/down
						if(ViewAllNbItems <= (ViewAllNbParLigne*2)) {
							$(".ViewAll a.Scroll")	.css("opacity", .33)
													.css("cursor", "default");
						}
						
						// Si il n'y a pas besoin de 2 lignes pour tout afficher : on resize sur 1 ligne
						if(ViewAllNbItems > ViewAllNbParLigne) {
							$(".ViewAll .ViewAllContentIn").animate({height:(ViewAllHauteurItems*2)+30}, EffectTimer);
						}
						
						// Grisage du bouton Up au chargement
						$(".ViewAll a.ScrollUp")	.css("opacity", .33)
													.css("cursor", "default");
						
						$(".ViewAll a.Scroll").click(function() {
							
							// Si les boutons sont nécéssaires
							if(ViewAllNbItems > (ViewAllNbParLigne*2)) {
								
								// Dégrisage des boutons
								$(".ViewAll a.Scroll")	.css("opacity", 1)
														.css("cursor", "pointer");
								
								// Scroll vers le bas
								if( $(this).hasClass("ScrollDown") == true) {
									// On scroll sauf si le dernier item est affiché 
									if( (ViewAllCpt + 2) < ViewAllNbLignes) {
										ViewAllCpt++;
										$(this).parents(".ViewAll").find(".ViewAllContentIn ul").animate({
											top: -(ViewAllHauteurItems * ViewAllCpt)
										}, EffectTimer);
									}
									// Grisage si lien non nécesaire
									if(ViewAllCpt >= (ViewAllNbLignes - 2)) {
										$(this)	.css("opacity", .33)
												.css("cursor", "default");
									}
								}
								
								// Scroll vers le haut
								else if( $(this).hasClass("ScrollUp") == true) {
									// On scroll sauf si le premier item est affiché 
									if(ViewAllCpt > 0) {
										ViewAllCpt--;
										$(this).parents(".ViewAll").find(".ViewAllContentIn > ul").animate({
											top: -(ViewAllHauteurItems * ViewAllCpt)
										}, EffectTimer);
									}
									// Grisage si lien non nécesaire
									if(ViewAllCpt == 0) {
										$(this)	.css("opacity", .33)
												.css("cursor", "default");
									}
									
								}
							
							}						
							
							// Blocage du click
							return false;
							
						});
						
						$("a.ComparateurAdd").unbind();
						$("a.ComparateurAdd").click(function() {
                            
							if( $(".FooterMenuOngletComparateurContent").is("div") == true)
		                    {
			                    BlockSize(".ComparateurTableau", ".ComparateurTableau table");
			                    AjouterComparateurClick($(this));
		                    }
		                    else
		                    {
		                        idProduitAddViewAll = $(this).attr("idProductAdded");
		                    }
		                    $("li.FooterMenuOngletComparateur a").trigger("click", ["ComparatorContent"]);
		                    return false;
							
							// Si le ViewAll est déjà ouvert, on le ferme
							if( $(".ViewAll").is("div:visible") == true) {
								//$(".ViewAll").remove();
								$(".ViewAll").fadeOut(EffectTimer);
								window.clearTimeout(st1);
							}
							return false;
							
						});					
					
					}					
					
				});
			
			});
		
		}
		
		
		
		
		// Blocage du click
		return false;
		
	});

		// Fonction de Masquage du ViewAll
		function ViewAllHide() {
			$("html").mouseover(function(o) {
				o = o.target;
				while(o.parentNode) {
					var fc = /(^| )(ViewAll|searchbox)( |$)/g;
					if( fc.test(o.className) == true ) {
						window.clearTimeout(st1);
						break; 
					}
					if(o.nodeName.toLowerCase() == "html") {
						st1 = window.setTimeout('$(".ViewAll").fadeOut(EffectTimer, function() {/*$(this).remove();*/});', MouseOutTimer); 
						$("html").unbind("mouseover");
						break; 
					}
					o = o.parentNode;
				}
			});
		}
		
	
	
	
	
	/*
	+-------------------------------------------------------------------+
	|	RecentViewed															|
	+-------------------------------------------------------------------+
	*/
	st2 = new Object();
	
	$(".RecentContent a").mouseover(function() {
		Link = $(this);
		window.clearTimeout(st2);

		RecentViewedBoxRelative = Link;
		$(".RecentViewedBox")	.css("top", 	RecentViewedBoxRelative.offset().top + RecentViewedBoxRelative.height() - 5 )
								.css("left", 	RecentViewedBoxRelative.offset().left - $(".RecentViewedBox").width() + 35);
									
		
		
		// Récupération du contenu du RecentViewed en Ajax
			Href = Link.attr("href");
			var id_product = Link.attr("idProduct");
			var curProd;
			$(".RecentViewedBox .RecentViewedBoxContent dl.Vignette").each(function(i){
       if ($(this).attr("prodref") == id_product){
          curProd = $(this)
          $(this).show();
       }
       else{
          $(this).hide();
       }
      });
      
    // Affichage du bloc  
		$(".RecentViewedBox").fadeIn(EffectTimer, function() {												
			// ******** ajout
     $(".RecentViewedBoxContentIn").removeClass("Wait");
					$(".RecentViewedBox").css("cursor", "pointer");
					$(".RecentViewedBox").click(function() {
						document.location.href = curProd.find("a").attr("href");											  
					});
					
					$(".RecentViewed, .RecentViewedBox").mouseover(function() {
						window.clearTimeout(st2);
						RecentViewedBoxHide();
					});
			// ******** fin ajout
			
		});
		
	})
	.click(function() {
		// Blocage du click
		return false;
	});
	
	
					

		// Fonction de Masquage du RecentViewed
		function RecentViewedBoxHide() {
			$("body").mouseover(function(o) {
				o = o.target;
				while(o.parentNode) {
					var fc = /(^| )(RecentViewedBox|RecentViewed)( |$)/g;
					if( fc.test(o.className) == true ) {
						window.clearTimeout(st2);
						break; 
					}
					if(o.nodeName.toLowerCase() == "html") {
						st2 = window.setTimeout('$(".RecentViewedBox").fadeOut(EffectTimer, function() {$(this).hide();});', MouseOutTimer);
						//$("html").unbind("mouseover");
						break; 
					}
					o = o.parentNode;
				}
			});
		}
		
	$("a.simulcredit").popin({
		width : 767,
		height : 580,
		className : 'Top5CartePopin',
		loaderImg : '../img/fiche_produit/AjaxLoaderWhite.gif',
		opacity: .5,
		simulcredit: true
	});
	
	$("a.condicredit").popin({
		width : 767,
		height : 580,
		className : 'Top5CartePopin',
		loaderImg : '../img/fiche_produit/AjaxLoaderWhite.gif',
		opacity: .5,
		condicredit: true
	});
	

		/*
	+-------------------------------------------------------------------+
	|	DesignationCarte															|
	+-------------------------------------------------------------------+
	*/
	$(".DesignationCarte a").popin({
		width : 530,
		height : 580,
		className : 'Top5CartePopin',
		loaderImg : '../img/fiche_produit/AjaxLoaderWhite.gif',
		opacity: .5
	});
	
	
	/*
	+-------------------------------------------------------------------+
	|	Top5Carte															|
	+-------------------------------------------------------------------+
	*/
	$(".Top5Carte a").popin({
		width : 530,
		height : 580,
		className : 'Top5CartePopin',
		loaderImg : '../img/fiche_produit/AjaxLoaderWhite.gif',
		opacity: .5
	});

	
	$(".Top10Carte a").popin({
		width : 530,
		height : 580,
		className : 'Top5CartePopin',
		loaderImg : '../img/fiche_produit/AjaxLoaderWhite.gif',
		opacity: .5
	});

	
	
	/*
	+-------------------------------------------------------------------+
	|	SocializeContent												|
	+-------------------------------------------------------------------+
	*/
	var st3 = new Object();
	
	$("a.SocializeContent").click(function() {

		// Si le SocializeContent est déjà ouvert, on le ferme
		if( $(".SocializeContentBloc").is("div") == true) {
			$(".SocializeContentBloc").remove();
			window.clearTimeout(st3);
			return false;
		}
		//alert();			
		// Positionnement
		SocializeContentRelative = $(this);
		$("body").prepend('<div class="SocializeContentBloc Wait"></div>');
		$(".SocializeContentBloc").css("top", SocializeContentRelative.offset().top + SocializeContentRelative.height()  );
		$(".SocializeContentBloc").css("left", SocializeContentRelative.offset().left);
		$(".SocializeContentBloc").width(SocializeContentRelative.width() - 2);
			
		// Récupération du contenu du SocializeContent en Ajax
		Href = SocializeContentRelative.attr("href");
		$.ajax({
			type: "POST",
			url: "FicheProduitWS.asmx/GetPartage",
			data:"idProduct=" + idProduct + "&typeSite=" + typeSite +"&titre=" + window.document.title,
			success: function(Asw) {
				if(Test == true) {Pause(PauseTimer)}
				
				// Insertion du contenu Ajax
				$(".SocializeContentBloc").removeClass("Wait");
				$(".SocializeContentBloc").html($("ContentPartage", Asw).text());
				
				
				SocializeContentHide();
				$(".SocializeContentBloc ul").fadeIn(EffectTimer, function() {
				
					// Masquage du ViewAll
					$(".SocializeContent, .SocializeContentBloc").mouseover(function() {
						window.clearTimeout(st3);
						SocializeContentHide();
						//PanelHide("SocializeContent");
					});
					
					// Actions sur les liens de la liste
					$(this).find("a").click(function() {
					 	window.open($(this).attr("href"), '', '');
						$(".SocializeContentBloc").remove();
						return false;
					 });
					
					$(this).find("li.SocializeContentSendToFriend a").unbind("click").popin({											 
						width : 555,
						height : 550,
						className : 'SendFriendContent',
						loaderImg : '../img/fiche_produit/AjaxLoaderWhite.gif',
												opacity: .4,
						onComplete : function() {
							$(".SocializeContentBloc").remove();
							$(".SendFriendForm").submit(function() {	
															 
								Mnq = 0;
								Err = 0;
								
									
								$(this).find("input[type='text'], textarea").each(function() {
									if(
											($(this).hasClass("SendFriendOblig") == true)
										&&	( $.trim($(this).attr("value")) == "" )
									) {
										$(this).css("background-color", "#FEE");
										Mnq++;
									}
									else if(
											($(this).hasClass("SendFriendOblig") == true)
										&&	($(this).hasClass("SendFriendEmail") == true)
										&&	( !$(this).attr("value").match('^[-_\.0-9a-zA-Z]{1,}@[-_\.0-9a-zA-Z]{1,}[\.][0-9a-zA-Z]{2,}$') )
									) {
										$(this).css("background-color", "#FEE");
										Err++;
									}
									else {
										$(this).css("background-color", "#FFF");
									} 
								
								});
									
									
								if(Mnq > 0) {
									alert("Vous devez remplir les champs obligatoires.");
									return false;
								}
								if(Err > 0) {
									alert("Vos emails ne sont pas corrects.");
									return false;
								}
								else {
									
									o = $(this);
									BlockSize(".SendFriendForm", ".SendFriendForm");
									
									s = $(this).serialize();  
									a = $(this).attr("action"); 
									$(this).animate({
											opacity:0
										},
										EffectTimer,
										"linear",
										function() {
										
										var fromMail =$("#SendFriendMymail").val();
										var fromName =$("#SendFriendMyName").val();
										var toMail=new Array($("#SendFriendEmail01").val(),$("#SendFriendEmail02").val(),$("#SendFriendEmail03").val());
										var toName=new Array($("#SendFriendName01").val(),$("#SendFriendName02").val(),$("#SendFriendName03").val());
										var objectMail=$("#MessageObjectSendFriend").val();
										var bodyMail=$("#MessageSendFriend").val();
										
										
										
										$.ajax({
											url: "FicheProduitWS.asmx/SendFriend",
											type: "POST",
											dataType: "xml",
											data:"idProduct=" + idProduct + "&fromMail=" + fromMail + "&fromName=" + fromName + "&toMail=" + toMail + "&toName=" + toName + "&objectMail=" + objectMail + "&bodyMail=" + bodyMail,
											success: function(Asw){
											/*$.ajax({ 
												type: "POST", 
												data: s, 
												url: a, 
												success: function(Asw){ */
													//$(o).empty().html(Asw).animate({opacity:1},EffectTimer);
													$(o).empty().html($("ContentOnglet", Asw).text()).animate({opacity:1},EffectTimer);
												} 
											});
									});
									
									return false;									
									
								}
								
							}); // submit
							
						} // oncomplete
						
					});	//popin
							
				}); // fadein
				
			} // success
			
		}); // ajax
										   
		// Blocage du click
		return false;

		
	}); // click
	

		// Fonction de Masquage du ViewAll
		function SocializeContentHide() {
			$("html").mouseover(function(o) {
				o = o.target;
				while(o.parentNode) {
					var fc = /(^| )(SocializeContent|SocializeContentBloc)( |$)/g;
					if( fc.test(o.className) == true ) {
						window.clearTimeout(st3);
						break; 
					}
					if(o.nodeName.toLowerCase() == "html") {
						st3 = window.setTimeout('$(".SocializeContentBloc").fadeOut(EffectTimer, function() {$(this).remove();});', MouseOutTimer);
						$("html").unbind("mouseover");
						break; 
					}
					o = o.parentNode;
				}
			});
		}
		
	
	
	
	
	/*
	+-------------------------------------------------------------------+
	|	VignetteProduct													|
	+-------------------------------------------------------------------+
	*/
	// Actions sur les miniatures
	VignetteProduct();
	
		
	
	
	
	
	/*
	+-------------------------------------------------------------------+
	|	ProductZoom														|
	+-------------------------------------------------------------------+
	*/
	function ProductZoom()  {
		
		$(".ProductZoomZone").addClass("Wait");
		
		// Placement de l'image courante en grand format
		Src = $(".VignetteProductCurrent img");
		//alert(Src.attr("src"));		
		if(Src.attr("src") != undefined)
		{
		var tst;
		tst = Src.attr("src").lastIndexOf("/",Src.attr("src").length);
		var r = Src.attr("src").substring(0,tst+1)+"z" + Src.attr("src").substring(tst+2,Src.attr("src").length);
			
		// Chargement de la première image
		var i = new Image(); 
    $(i).attr("src", r);
		if(Test == true) {Pause(PauseTimer)}
		$(".ProductZoomZone img").attr("src", r);
		if(i.complete == true) {
			ProductZoomLoadFirst();
		} else {
			$(i).load(function() {
				ProductZoomLoadFirst();
			});
		}
		}
		
	}
	
	// Chargement de la 1ere image
	function ProductZoomLoadFirst() {
		
		// Affichage de l'image
		$(".ProductZoomZone img").fadeIn(EffectTimer, function() {
			
			$(".ProductZoomZone").removeClass("Wait");
			
			// Image Draggable
			$(this).draggable();
			$(this).css("cursor", "move");


			// Clonage des vignettes
			l = 0; var img = new Array();
			$(".ProductContent .VignetteProduct").clone().insertAfter(".ProductZoom .ProductZoomZone");
			$(".ProductZoom .VignetteProduct").addClass("Wait");
			
			Vig = $(".ProductZoom .VignetteProduct a").each(function(j) {
				
			/*
				// Remplacement des URL
				var c = $(this).attr("href").match(/(s|p|m|g|z)([0-9]*)(\.jpg)$/);
				var r = $(this).attr("href").replace(/(s|p|m|g|z)([0-9]*)(\.jpg)$/, "z" + c[2] + c[3]);
				$(this).attr("href", r);
				
				// Remplacement des images
				var c = $(this).find("img").attr("src").match(/(s|p|m|g|z)([0-9]*)(\.jpg)$/);
				var r = $(this).find("img").attr("src").replace(/(s|p|m|g|z)([0-9]*)(\.jpg)$/, "p" + c[2] + c[3]);
				
				// Chargement des vignettes
				img[j] = new Image(); $(img[j]).attr("src", r);
				if(Test == true) {Pause(PauseTimer)}
				$(this).find("img").attr("src", r);
			*/
			
				// Chargement des vignettes
				var tst = $(this).attr("href").lastIndexOf("/",$(this).attr("href").length);
		    var r = $(this).attr("href").substring(0,tst+1)+"z" + $(this).attr("href").substring(tst+2,$(this).attr("href").length);
				$(this).attr("href", r);
				
				var r = $(this).find("img").attr("src")
				img[j] = new Image(); $(img[j]).attr("src", r);
				if(Test == true) {Pause(PauseTimer)}
				$(this).find("img").attr("src", r);
				
				if(img[j].complete == true) {
					ProductZoomLoadVignettes();
				} else {
					$(img[j]).load(function() {
						ProductZoomLoadVignettes();
					});
				}
				
			});
			
			
			
			// Boutons de Zoom
			$(".ProductZoomSlider").slider({
				orientation: "vertical",
				range: "min",
				min: 0,
				max: 100,
				value: 0,
				animate: true
			})
			.bind("slide slidechange", function(event, ui) {
				ma = 500;	// Agrandissement maximum
				mi = 500;	// Taille minimum
				t = (ma * (ui.value/100)) + mi;
				$(".ProductZoomZone img")
					.height(t)
					.width(t)
					.css("margin-top", -(t/2) )
					.css("margin-left", -(t/2) );
			});
			
			$(".ProductZoomBtnIn a").click(function() {
				$(".ProductZoomSlider").slider('value', $(".ProductZoomSlider").slider('option', 'value') + 10 );
				return false;
			});
			
			$(".ProductZoomBtnOut a").click(function() {
				$(".ProductZoomSlider").slider('value', $(".ProductZoomSlider").slider('option', 'value') - 10 );
				return false;
			});	
				
			
		});		
	
	}
	
	// Chargement des vignettes
	function ProductZoomLoadVignettes() {
		
		l++;
		//  Chargement du bloc lorsque toutes les images sont loadées
		if( l == $(".ProductZoom .VignetteProduct a").length ) {
			$(".ProductZoom .VignetteProduct")
				.css("opacity", .01)
				.animate({
					opacity: .9
				},
				EffectTimer,
				"linear",
				function() {
					VignetteProduct();
					$(".ProductZoom .VignetteProduct").removeClass("Wait");
				});
			$(".ProductZoom .VignetteProduct a")
				.show();
		}
		
	}
	
	// Popin de zoom
	$("a.VignetteProductCurrent").popin({
		width : 691,
		height : 550,
		className : 'VignetteProductZoom',
		loaderImg : '../img/fiche_produit/AjaxLoaderWhite.gif',
		opacity: .4,
		onComplete: ProductZoom
	});
	$("a.ZoomIcon").popin({
		width : 691,
		height : 550,
		className : 'VignetteProductZoom',
		loaderImg : '../img/fiche_produit/AjaxLoaderWhite.gif',
		opacity: .4,
		onComplete: ProductZoom
	});
		
	/*
	+-------------------------------------------------------------------+
	|   PopIn Error														|
	+-------------------------------------------------------------------+
	*/
	//$("a.GotoBag").popin({
	//	width : 400,
	//	height : 200,
	//	className : 'VignetteProductZoom',
	//	loaderImg : 'img/fiche_produit/AjaxLoaderWhite.gif',
	//	opacity: .4,
	//	onComplete: ProductZoom
	//});
	
	$("a.erreurComparateurMemeProduit").popin({
		width : 400,
		height : 200,
		className : 'VignetteProductZoom',
		loaderImg : '../img/fiche_produit/AjaxLoaderWhite.gif',
		opacity: .4,
		onComplete: ProductZoom
	});	

	$("a.erreurComparateurTropProduit").popin({
		width : 400,
		height : 200,
		className : 'VignetteProductZoom',
		loaderImg : '../img/fiche_produit/AjaxLoaderWhite.gif',
		opacity: .4,
		onComplete: ProductZoom
	});	
	
	
	
	
	/*
	+-------------------------------------------------------------------+
	|   PopIn DispoMag													|
	+-------------------------------------------------------------------+
	*/
	$("a.DispoMag").popin({
		width : 700,
		height : 750,
		className : 'VignetteProductZoom',
		loaderImg : '../img/fiche_produit/AjaxLoaderWhite.gif',
		opacity: .4,
		onComplete: DispoMag,
		dispo: true,
		idProduct: idProduct		
	});	
	
	// Chargement des disponibilités magasin
	function DispoMag() {	
				
		
				
		$("input.CkbDispo").click(function() {
		
		var id_product = idProduct;
		var magIdList = ""	
		
		// Récupère une référence de l'élément englobant tes checkbox
		var div = window.parent.document.getElementById("divCkb")
		// Récupère tous les "input" qu'il y a dedans
		var cbs = div.getElementsByTagName("input")
		// Vérifié l'état des checkbox
		for(var i in cbs)
		{
			if(cbs[i].type == "checkbox")
			{
				if( cbs[i].checked)
				{
					magIdList += cbs[i].value + ";" ;
				}
				//alert("Checkbox " + cbs[i].name + ": " + cbs[i].checked + " valeur " + cbs[i].value);
			}
		}		
		
		$(".ChoiceMag").addClass("Wait");
		
		$.ajax({				
				url: "FicheProduitWS.asmx/GetMagDispo",
				type: "POST",
				dataType: "xml",
				data: "id_product=" + id_product + "&magIdList=" + magIdList + "&typeSite=" + typeSite,
				success: function(Asw) {
										
					if(Test == true) {Pause(PauseTimer)}
					
					// Suppression de l'image du Loader
					$(".ChoiceMag").removeClass("Wait");
					
					// Insertion du contenu Ajax
					$(".MagArrayContent").html($("ContentDispo", Asw).text());
					//$(".MagArrayContent").html("test");
									
				}
			});
			
			var myDate = new Date(); 
			
			var time = myDate.getTime(); 
			var hour = myDate.getHours(); 
			var minute = myDate.getMinutes(); 
			var second = myDate.getSeconds(); 
			if (hour < 10) { hour = "0" + hour; } 
			if (minute < 10) { minute = "0" + minute; } 
			if (second < 10) { second = "0" + second; } 
			var theTime = hour + ":" + minute + ":" + second; 

			var day = myDate.getDate();
			var month = myDate.getMonth();
			var year = myDate.getFullYear();
			if (day < 10) { day = "0" + day; } 
			if (month < 10) { month = "0" + month; } 
			var theDate = day + "/" + month + "/" + year; 

			$(".DetailHourPopinMag").html("Disponibilit&eacute; valable dans les magasins cit&eacute;s ci-dessus au <strong>"+theDate+"</strong> &agrave; <strong>"+theTime+"</strong>");
		
		});
		
	}
	
	/*
	+-------------------------------------------------------------------+
	|	ComparateurAdd													|
	+-------------------------------------------------------------------+
	*/
	$(".ComparatorContent a.lnkAddToComparateur").click(function() {
		
        if( $(".FooterMenuOngletComparateurContent").is("div") == true)
		{
			BlockSize(".ComparateurTableau", ".ComparateurTableau table");
			AjouterComparateurClick($(this));
		}
		
		idProduitAddViewAll = $(this).attr("idProductAdded");
		
		$("li.FooterMenuOngletComparateur a").trigger("click", ["ComparatorContent"]);
		return false;
	});
	
	/*
	+-------------------------------------------------------------------+
	|	FooterMenu														|
	+-------------------------------------------------------------------+
	*/
	$(".FooterMenu a").click(function(e, t) {			
		$(".FooterProductContent").addClass("Wait");
			
			
		BlockSize(".FooterProductContent", ".FooterProductContent");
				
		// Masquage des onglets
		$(".FooterProductContent > div[class^='FooterMenuOnglet']").hide();
		
		// Réinitialisation des styles
		$(".FooterMenu li, .FooterMenu li a, .FooterMenu li a span").removeClass("OnFooterMenu LeftOnFooterMenu OnFirstFooterOnglet OnLastFooterOnglet");
		// Mise à jour des styles
		$(this).addClass("OnFooterMenu");
		$(this).parent("li").prev("li").children("a").children("span").addClass("LeftOnFooterMenu");
		if($(this).parent("li").prev().is("li") == false) {
			$(this).parent("li").addClass("OnFirstFooterOnglet");
		}
		else if($(this).parent("li").next().is("li") == false) {
			$(this).children("span").addClass("OnLastFooterOnglet");
		}
		else if($(this).parent("li").prev("li").attr("class") == "") {
			$(this).parent("li").addClass("OnFirstFooterOnglet");
		}		
		// Création de la page
		FooterProductContentClass = $(this).parent("li").attr("class").split(" ")[0] + 'Content';
		
		// Si l'onglet a déjà été chargé, on l'affiche
		if( $("." + FooterProductContentClass).is("div") == true){
            
			// Affichage de l'onglet
			$("." + FooterProductContentClass).show();
			
			// Espace dispo pour le Scroll
			BlockSize(".FooterProductContent", ".FooterMenu");
			ScrollSpace();
			
			// Suppression de l'image du Loader
			$(".FooterProductContent").removeClass("Wait");
			
			// Triggers
			if(t == "GiveAvis") {
				$(".AvisEcrireArrow a").trigger("click");	
			}
			
			// Scroll sur l'onglet sauf au chargement de la page
			if(FooterMenuFirstLoad == false) {
				if(t == "ComparatorContent") {
					$(window).scrollTo( $(".ComparateurTableau").prev(), EffectTimer );
				}
				else if(t == "LireAvis") {
					$(window).scrollTo( $(".AvisListeContent"), EffectTimer );
				}
				else if($(this).parent().is(".FooterMenuOngletServices") == true) {
					//console.log("pas de scroll");
				}
				else {
					$(window).scrollTo( $(".FooterMenu"), EffectTimer );
				}
			}
			FooterMenuFirstLoad = false;
			
		}
		
		// Sinon on crée l'onglet
		else {		
			var typeOnglet;
			var UrlFrom = $("#UrlFrom").val();
			var idProduct2 = idProduitAddViewAll;
			var give = false;
			idProduitAddViewAll = "0";
			switch(FooterProductContentClass)
			{
				case "FooterMenuOngletAccessoiresContent" :
					typeOnglet = "0";break;
				case "FooterMenuOngletDescriptifContent" :
					typeOnglet = "1";break;
				case "FooterMenuOngletComparateurContent" :
					typeOnglet = "2";break;
				case "FooterMenuOngletServicesContent" :
					typeOnglet = "3";break;
				case "FooterMenuOngletAvisContent" :
					typeOnglet = "4";
					
					for (i=0;i<$(this).attr("class").split(" ").length;i++)
					{
						if($(this).attr("class").split(" ")[i] == "avisGive")
							give=true;
					}
					
					break;
			}
			
			
			// Suppression de l'image du Loader
			$(".FooterProductContent").addClass("Wait");
			$("body").css("cursor", "wait");
			
			// Récupération du contenu de l'onglet en Ajax
			o = $(this);
			Href = $(this).attr("href");
			
			var saveComparateur;
			if(t == "ComparatorContent")
                saveComparateur = 1;
            else
                saveComparateur = 0;
            
			$.ajax({
				url: "FicheProduitWS.asmx/GetOnglet",
				type: "POST",
				dataType: "xml",
				data: "typeOnglet=" + typeOnglet + "&idProduct=" + idProduct + "&idProduct2=" + idProduct2 + "&saveComparateur=" + saveComparateur + "&typeSite=" + typeSite + "&UrlFrom=" + UrlFrom,
				success: function(Asw){
					
					if(Test == true) {Pause(PauseTimer)}
					// Suppression de l'image du Loader
					$(".FooterProductContent").removeClass("Wait");
					// Affichage de l'onglet
					$(".FooterProductContent").append('<div class="' + FooterProductContentClass + '" style="display:none"></div>');
					$("." + FooterProductContentClass).html($("ContentOnglet", Asw).text());
          			
					$("." + FooterProductContentClass).slideDown(EffectTimer, function() {
          														
						$("body").css("cursor", "auto");	
						
						if(FooterProductContentClass == "FooterMenuOngletAvisContent")
						{
							AvisContent($(this));
							OngletAvis();
						}
						else if(FooterProductContentClass == "FooterMenuOngletDescriptifContent")
						{
							OngletDescriptif();
						}
						else if(FooterProductContentClass == "FooterMenuOngletAccessoiresContent")
						{
							OngletAccessoires();
						}
						else if(FooterProductContentClass == "FooterMenuOngletComparateurContent")
						{
							OngletComparateur();
						}		
					
						// Espace dispo pour le Scroll
						BlockSize(".FooterProductContent", ".FooterMenu");
						ScrollSpace();
						
						// Triggers
						if(t == "GiveAvis" || give) {
							$(".AvisEcrireArrow a").trigger("click");	
						}
			
						// Scroll sur l'onglet sauf au chargement de la page
						if(FooterMenuFirstLoad == false) {
							if(t == "ComparatorContent") {
								$(window).scrollTo( $(".ComparateurTableau").prev(), EffectTimer );
							}
							else if(t == "LireAvis") {
								$(window).scrollTo( $(".AvisListeContent"), EffectTimer );
							}
							else if($(o).parent().is(".FooterMenuOngletServices") == true) {
								//console.log("pas de scroll");
							}
							else {
								$(window).scrollTo( $(".FooterMenu"), EffectTimer );
							}
						}
						FooterMenuFirstLoad = false;
																		
					});
					
					
					
					
				}
				
			});
			
		}		
		// Blocage du click
		return false;
	});
	
	// Chargement du 1er onglet au chargement de la page
	FooterMenuFirstLoad = true;
  $("a.OnFooterMenu").trigger("click");
	
	
	
		
	
	/*
	+-------------------------------------------------------------------+
	|	Triggers														|
	+-------------------------------------------------------------------+
	*/
	/*$("a.Accessoires").click(function() {
		$("li.FooterMenuOngletAccessoires a").trigger("click");
		return false;
	});*/
	
	$("a.CaractContentDescriptif").click(function() {
		$("li.FooterMenuOngletDescriptif a").trigger("click");
		return false;
	});
	$("a.LireAvis").click(function() {
		$("li.FooterMenuOngletAvis a").trigger("click", ["LireAvis"]);
		return false;
	});
	$("a.GiveAvis").click(function() {
		$("li.FooterMenuOngletAvis a").trigger("click", ["GiveAvis"]);
		return false;
	});
	//$(".ComparatorContent a").click(function() {
	//	$("li.FooterMenuOngletComparateur a").trigger("click", ["ComparatorContent"]);
	//	return false;
	//});
	$(".ServicesContent .ScrollContent a.openOnglet").click(function() {
		$("li.FooterMenuOngletServices a").trigger("click", ["ServicesContent"]);
		return false;
	});
	
	/*
	+-------------------------------------------------------------------+
	|	Zone description prdouit sans pictos							|
	+-------------------------------------------------------------------+
	*/
	if(!$('.PictoContainer').is('div'))
		$('.VisualContainer').addClass('VisualContainerFull');
	
	
	
	
	
	


});

// Préchargement de l'image du loader
var AjaxLoader = new Image();
AjaxLoader.src = "../img/fiche_produit/AjaxLoader.gif";
		
		
/*	
+-------------------------------------------------------------------+
|	Fonctions externes												|
+-------------------------------------------------------------------+
*/	
// Fonction d'accrementation
function AccrementationChange(Obj) {
		
	// Qté courante
	if( $(Obj).parents(".Accrementation").find(".Quantity input").attr("name") == "QuantityProduct") {
		AccCur = $(".Quantity input[name='QuantityProduct']");
	}
	else {
		AccCur = $(Obj).parents(".Accrementation").find(".Quantity input");
	}
	
	// Décrémentation
	if( $(Obj).hasClass("LessQte") == true) {
		// Si la quantité est supérieure à 1
		if(AccCur.val() > 1) {
			AccCur.val( Number(AccCur.val()) - 1 );
		}
	}
	
	// Incrémentation
	else if( $(Obj).hasClass("MoreQte") == true) {
		// Si la quantité est inférieure à 999
		if(AccCur.val() < 999) {
			AccCur.val( Number(AccCur.val()) + 1 );
		}
	}
	var lastIndexOfQuantite = $("#lnkAddToBag").attr("savehref").lastIndexOf("quantite1");
  $("#lnkAddToBag").attr("href",  $("#lnkAddToBag").attr("savehref") + "&quantite1=" + $("#QuantityProduct").val());
	// Calcul du prix
	//AccrementationPrice();
	return false;
}


// Fonction du prix d'accrementation
function AccrementationPrice() {
	
	// Prix du produit
	PrixProduct		= eval( $(".Price input").attr("value") );
	PrixProductQte 	= PrixProduct * eval( $(".AddBag input[name='QuantityProduct']").attr("value") );
	
	// Calcul du prix des services
	ServicesPrix = ServicesPrixTot = 0;
	ServicesIntitules = new Array();
	
	var link = "";
	link = $("#lnkAddToBagService").attr("savehref");
	//alert(link);
	listLinkService = "";
	$("input.ServicesPrix:checked").each(function(i) {
	  // nos prix étant en français, les "," ne sont pas comprises
	  var prixAdd = $(this).attr("value").replace(/,/g, ".");
		ServicesPrix 			= eval(ServicesPrix + eval(prixAdd));
		ServicesIntitules[i] 	= $(this).parents("table").find("td:eq(1) > span").html();
		if($(this).attr("prodref") != "-1"){
		  listLinkService += "_" + $(this).attr("prodref");
		}
	});
	$("input.ServicesPrixCarte:checked").each(function(i) {
		listLinkService += "_" + $(this).attr("prodref");
	});
	
	link +=  listLinkService;
	$("#lnkAddToBagService").attr({ href: link });
	ServicesPrixTot = PrixProduct + ServicesPrix;
	AccrementationPriceHtml(ServicesPrixTot, ".FooterServices .PriceIncludeServ");
  if(ServicesIntitules.length > 0) {
	  if(("+" + ServicesIntitules.join(" + ")).length > 110) {
	   $(".DetailSelectServ strong").html((" + " + ServicesIntitules.join(" + ")).substr(1, "107")+"...");
    }
    else{
		$(".DetailSelectServ strong").html(" + " + ServicesIntitules.join(" + ") );
		}
	} else {
		$(".DetailSelectServ strong").empty();
	}
	
	// Calcul du prix des accessoires
	AccessoiresPrix = AccessoiresPrixTot = 0;
	
	$(".AccessoiresPackItemsContent li").each(function() {
		AccessoiresItemPrix	= eval( $(this).find("input[name^='PriceAccesoires']").attr("value") );
		AccessoiresItemQte	= eval( $(this).find("input[name='Quantity']").attr("value") );
		AccessoiresPrix = AccessoiresPrix + ( AccessoiresItemPrix * AccessoiresItemQte );
	});
	
	AccessoiresPrixTot = PrixProductQte + AccessoiresPrix;
	AccrementationPriceHtml(AccessoiresPrixTot, ".AccessoiresPackPrixPrice");
	
}

// Fonction de sortie HTML prix d'accrementation
function AccrementationPriceHtml(t, l) {
	t = t.toString().split(".");
	t[1] = (t[1] == null) ? "00" : t[1].substr(0,2);
	t[1] = (t[1].length < 2) ? t[1] + "0" : t[1];
	$(l).html(t[0] + '<span>,' + t[1] + '</span>&euro;');
}



// Actions sur les miniatures du produit
function VignetteProduct() {
	$(".VignetteProduct a").unbind("click");
	$(".VignetteProduct a").click(function() {							   
		$(this).parents(".ProductContent, .ProductZoom").find(".ProductContentBloc, .ProductZoomZone").addClass("Wait");
		$(this).parents(".ProductContent, .ProductZoom").find(".VignetteProduct a").removeClass("OnView");
		Link = $(this);
		Link.addClass("OnView");
		$(this).parents(".ProductContent, .ProductZoom").find(".VignetteProductCurrent img, .ProductZoomZone img").fadeOut(EffectTimer, function() {
			var i = new Image(); $(i).attr("src", Link.attr("href"));
			if(Test == true) {Pause(PauseTimer)}
			Link.parents(".ProductZoom").find(".ProductZoomZone img")
				.width(500)
				.height(500)
				.css("margin-top", -250)
				.css("margin-left", -250)
				.css("top", "50%")
				.css("left", "50%");
										
			$(".ProductZoomSlider").slider('option', 'value', 0 );
			Link.parents(".ProductContent, .ProductZoom").find(".VignetteProductCurrent img, .ProductZoomZone img").attr("src", "");
			

			if(i.complete == true) {
				Link.parents(".ProductContent, .ProductZoom").find(".VignetteProductCurrent img, .ProductZoomZone img").attr("src", Link.attr("href"));
				Link.parents(".ProductContent, .ProductZoom").find(".VignetteProductCurrent img, .ProductZoomZone img").fadeIn(EffectTimer, function() {
					Link.parents(".ProductContent, .ProductZoom").find(".ProductContentBloc, .ProductZoomZone").removeClass("Wait");
				});
			} else {
				$(i).load(function() {
					Link.parents(".ProductContent, .ProductZoom").find(".VignetteProductCurrent img, .ProductZoomZone img").attr("src", Link.attr("href"));
					Link.parents(".ProductContent, .ProductZoom").find(".VignetteProductCurrent img, .ProductZoomZone img").fadeIn(EffectTimer, function() {
						Link.parents(".ProductContent, .ProductZoom").find(".ProductContentBloc, .ProductZoomZone").removeClass("Wait");
					});
				});
			}
			/*
				var r = $(this).find("img").attr("src")
				img[j] = new Image(); $(img[j]).attr("src", r);
				if(Test == true) {Pause(PauseTimer)}
				$(this).find("img").attr("src", r);
				
				if(img[j].complete == true) {
					ProductZoomLoadVignettes();
				} else {
					$(img[j]).load(function() {
						ProductZoomLoadVignettes();
					});
				}
			*/
			
		});
		return false;
	});
}


// Fonction Bloqueur de taille
function BlockSize(c, r) {
	if( $.browser.msie && ($.browser.version == "6.0")  ) {
		H = ( $(r).height() > 250 ) ? $(r).height() : 250;
		$(c).height(H);
	}
	else {
		$(c).css("min-height", $(r).height() + "px");
	}
}




// Fonction Esapce de Scroll pour les onglets
function ScrollSpace() {
	
	// Calcul des espaces
		var myWidth = 0, myHeight = 0;
		//Non-IE
		if( typeof( window.innerWidth ) == 'number' ) {
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		}
		//IE 6+ in 'standards compliant mode'
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		}
		//IE 4 compatible
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		
	// Mise en place de l'espace nécessaire
	/*if( myHeight > $(".FooterContainer").height() ) {
		$(".Container").css("padding-bottom", ( myHeight - $(".FooterContainer").height() ) );	
	} 
	else {
		$(".Container").css("padding-bottom", 0);	
	}*/
	
}
		




// Fonction TEST de Pause
function Pause(time) {
	d = new Date();
	diff = 0;
	while(diff < time) {
		n = new Date();
		diff = n-d;
	} 
}

	

function conditionsCredit(quel)
 {
  alert(quel);
	  if(quel=='standard')
	{
		$(location).attr('href',"http://www.surcouf.com/Adherent/accueil_carte.aspx");
	}
	  else if(quel=='special')
	{
		//window.open('URL DES CONDITIONS SPECIALES','CIBLE','OPTIONS POPUP'); 
		alert('ByeBye');
	}
}


	
function simulerCredit(codecredit,totalttc,date)
        {
        simulCreditParam = 'totalttc='+totalttc+'&date='+date+'&codecredit='+codecredit;
        $("a.simulcredit").trigger('click');
        }
        

	
function conditionsCredit(codecredit,totalttc,date)
        {
        condiCreditParam = 'totalttc='+totalttc+'&date='+date+'&codecredit='+codecredit;
        $("a.condicredit").trigger('click');
        }

	
	function closePopin()
    {
      $(".popin-voile").trigger('click');
    }

/*
+-------------------------------------------------------------------+
|	FooterMenu - Accessoires										|
+-------------------------------------------------------------------+
*/
function OngletAccessoires() {
	
	// Initialisation des actions
	$(".AccessoiresCarrousel .CarrouselPagination a, .AccessoiresCarrousel .CarrouselScrollBtn a, .AccessoiresCarrousel .AccessoiresLienPack a").unbind();
	
	CarrouselNbItemsAff = 3; // Nombre d'items affichés dans le carrousel
		
	// Création du carrousel
	if( $(".AccessoiresCarrousel .CarrouselScroll").length == 0) {
		
		$(".AccessoiresCarrouselContent").each(function() {
																		
																		
			$(this).show().css("opacity", 0.01);
			
			// Insertion des éléments de scroll
			$(this).html(''
				+	'<ul class="CarrouselScroll">'
				+	'	<li class="CarrouselScrollBtn CarrouselScrollLeft"><a href="#">&nbsp;</a></li>'
				+	'	<li class="CarrouselContent">'
				+		$(this).html()
				+	'	</li>'
				+	'	<li class="CarrouselScrollBtn CarrouselScrollRight"><a href="#">&nbsp;</a></li>'
				+	'</ul>'
				+	'');
			
			// Fit des items
			CarrouselItemsWidth = $(this).find(".CarrouselContent > ul > li").width();
			CarrouselItemsNb = $(this).find(".CarrouselContent > ul > li").width( ( $(this).find(".CarrouselContent").width() / CarrouselNbItemsAff ) );
			$(this).find(".CarrouselContent > ul").width( CarrouselItemsWidth * (CarrouselItemsNb.length + 9) );
			
			// Pagination
			CarrouselPagesNb = Math.ceil( CarrouselItemsNb.length / CarrouselNbItemsAff );
			
			// CSS
			$(this).find(".CarrouselScrollLeft a").css("opacity", .33).css("cursor", "default");
			if(CarrouselPagesNb == 1) {
				$(this).find(".CarrouselScrollRight a").css("opacity", .33).css("cursor", "default");
			}
			
			var CarrouselPagesHtml = "";
			for(i=0; i<CarrouselPagesNb; i++) {
				CarrouselPagesHtml += '<li><a href="#" class="' + ( (i == 0) ? 'on' : '' ) + '">&nbsp;</a></li>';
			}
			
			$(this).parents(".AccessoiresCarrousel").prepend(''
				+	'<div class="CarrouselPagination">'
				+	'	<p>S&eacute;rie <span>1</span>&nbsp;sur ' + CarrouselPagesNb + '</p>'
				+	'	<ul>'
				+			CarrouselPagesHtml
				+	'	</ul>'
				+	'</div>'
			);
			
			$(this).animate({opacity:1}, EffectTimer);
			
		});
		
	}
	
	// Création des actions
	$(".AccessoiresCarrousel .CarrouselPagination a").click(function() {
		
		// Style CSS
		$(this).parents(".CarrouselPagination").find("a").removeClass("on");
		$(this).addClass("on");
		$(this).parents(".AccessoiresCarrousel").find(".CarrouselScrollBtn a").css("opacity", 1).css("cursor", "pointer");
		
		CarrouselPagesNum 				= $(this).parent("li").prevAll().length;
		CarrouselPagesNumEnd			= $(this).parent("li").nextAll().length;
		CarrouselPagesPositionWidth 	= ( CarrouselNbItemsAff * $(this).parents(".AccessoiresCarrousel").find(".CarrouselContent > ul > li").width() );
		
		// NÝ de page
		$(this).parents(".CarrouselPagination").find("p span").text(CarrouselPagesNum+1);
			
		if( (CarrouselPagesNum == 0) && (CarrouselPagesNumEnd == 0) ) {
			$(this).parents(".AccessoiresCarrousel").find(".CarrouselScrollBtn a").css("opacity", .33).css("cursor", "default");
		}
		else if(CarrouselPagesNum == 0) {
			$(this).parents(".AccessoiresCarrousel").find(".CarrouselScrollLeft a").css("opacity", .33).css("cursor", "default");
		}
		else if(CarrouselPagesNumEnd == 0) {
			$(this).parents(".AccessoiresCarrousel").find(".CarrouselScrollRight a").css("opacity", .33).css("cursor", "default");
		}
		
		
		
		// Mouvement
		$(this).parents(".AccessoiresCarrousel").find(".CarrouselContent > ul").animate({
				left: -(CarrouselPagesPositionWidth * CarrouselPagesNum)
			},
			EffectTimer
		);
		
		return false;
	});
	
	$(".AccessoiresCarrousel .CarrouselScrollBtn a").click(function() {
		if( $(this).parent().hasClass("CarrouselScrollLeft") == true ) {
			$(this).parents(".AccessoiresCarrousel").find(".CarrouselPagination a.on").parent("li").prev("li").children("a").trigger("click");
		} else {
			$(this).parents(".AccessoiresCarrousel").find(".CarrouselPagination a.on").parent("li").next("li").children("a").trigger("click");
		}
		return false;
	});
	
	
	// Affichage du pack
	$(".AccessoiresLienPack a").click(function() {
		
		Href = $(this).attr("href");
		$("body").css("cursor", "wait");
		
		$(".AccessoiresPackContent").fadeOut(EffectTimer, function() {
															
			$(this).empty();
			$(".AccessoiresPack").height(200).addClass("Wait");
			
			// Récupération du contenu en Ajax
			$.ajax({
				type: "POST",
				url: Href,
				success: function(Asw) {
					
					if(Test == true) {Pause(PauseTimer)}
					
					// Suppression de l'image du Loader
					$(".AccessoiresPack").removeClass("Wait");
					$("body").css("cursor", "auto");
					
					// Affichage de l'onglet
					$(".AccessoiresPackContent").html(Asw);

					// CSS
					AccessoiresPackItemsLastLine = ( ( Math.ceil($(".AccessoiresPackItems ul li").length / 3) - 1 ) * 3 );
					$(".AccessoiresPackItems ul li:gt(" + AccessoiresPackItemsLastLine + "), .AccessoiresPackItems ul li:eq(" + AccessoiresPackItemsLastLine + ")").css("border-bottom", "none");
					$(".AccessoiresPackItems ul li:lt(" + ($(".AccessoiresPackItems ul li").length - 1) + ")").addClass("AccessoiresPackItemsPictoPlus");
					$(".AccessoiresPackItems ul li:nth-child(3n)").removeClass("AccessoiresPackItemsPictoPlus");
					$(".AccessoiresPackItems ul li:nth-child(3n+1)").addClass("AccessoiresPackItemsFirst");
					
					// Données
					$(".AccessoiresPack .Quantity input[name='QuantityProduct']").attr("value", $(".AddBag .Quantity input[name='QuantityProduct']").attr("value") );
					
					// Actions
					AccrementationBind();
					$(".AccessoiresPack .Quantity input[name='QuantityProduct']").trigger("keyup");
					
					// Affichage
					$(".AccessoiresPackContent").fadeIn(EffectTimer, function() {
						$(".AccessoiresPack").css("height", "auto");
						$(window).scrollTo($(".AccessoiresPack"), EffectTimer );
					});
					
				}
				
			}); // ajax
			
		}); // fadeOut
	
		return false;
		
	}); // click
	
	
} // function






/*
+-------------------------------------------------------------------+
|	FooterMenu - Descriptif											|
+-------------------------------------------------------------------+
*/
function OngletDescriptif() {
	
	$(".TitleOngletDescribe").unbind();
	
	$(".TitleOngletDescribe").show();
	$(".TitleOngletDescribe h6").addClass("png");
	$(".LineContainer div:nth-child(odd)").addClass("GreyLineDetail");
	$(".TitleOngletDescribe").css("cursor","pointer");
	
	$(".TitleOngletDescribe").toggle(function(){  
		BlockSize(".FooterMenuOngletDescriptifContent", ".FooterMenuOngletDescriptifContent");
		$(this).next(".LineContainer").hide(EffectTimer);
		$(this).find("img").attr("src", "../img/fiche_produit/GreyUpArrow.jpg");	
		},
		function(){
		$(this).next(".LineContainer").show(EffectTimer);
		$(this).find("img").attr("src", "../img/fiche_produit/GreyDownArrow.jpg");
		
		});

}






/*
+-------------------------------------------------------------------+
|	FooterMenu - Comparateur										|
+-------------------------------------------------------------------+
*/
function OngletComparateur() {
	ComparateurSimilaires();
	ComparateurSimilairesMouvement( $(".SimilairesCarrousel .CarrouselPagination a.on") );
	ComparateurCompare();
	ComparateurSimilaires3th();
	ComparateurTableau();
}

// Initilisation des actions
function ComparateurSimilaires() {
	
	$(".SimilairesCarrousel .CarrouselPagination a, .SimilairesCarrousel a.Scroll, form.SimilairesForm").unbind();
	
	SimilairesCarrouselNbItemsAff = 3; // Nombre d'items affichés dans le carrousel
	SimilairesCarrouselItemNb = $(".SimilairesCarrouselContentList > li");
	SimilairesCarrouselPagesNb = Math.ceil( SimilairesCarrouselItemNb.length / SimilairesCarrouselNbItemsAff );
	SimilairesCarrouselItemsWidth = SimilairesCarrouselItemNb.height();		
	
	var SimilairesCarrouselPagesHtml = "";
	for(i=0; i<SimilairesCarrouselPagesNb; i++) {
		SimilairesCarrouselPagesHtml += '<li><a href="#" class="' + ( (i == 0) ? 'on' : '' ) + '">&nbsp;</a></li>';
	}
	
	$(".SimilairesCarrousel .CarrouselPagination").remove();
	$(".SimilairesCarrousel").prepend(''
		+	'<div class="CarrouselPagination">'
		+	'	<p>S&eacute;rie <span>1</span>&nbsp;sur ' + SimilairesCarrouselPagesNb + '</p>'
		+	'	<ul>'
		+			SimilairesCarrouselPagesHtml
		+	'	</ul>'
		+	'</div>'
	);
	
	// Création des actions
	$(".SimilairesCarrousel .CarrouselPagination a").click(function() {
																	
		// Style CSS
		$(this).parents(".CarrouselPagination").find("a").removeClass("on");
		$(this).addClass("on");			
		
		// Mouvement
		ComparateurSimilairesMouvement($(this));	
		
		return false;
	});
	
	$(".SimilairesCarrousel a.Scroll").click(function() {
		if( $(this).hasClass("ScrollUp") == true ) {
			$(this).parents(".SimilairesCarrousel").find(".CarrouselPagination a.on").parent("li").prev("li").children("a").trigger("click");
		} else {
			$(this).parents(".SimilairesCarrousel").find(".CarrouselPagination a.on").parent("li").next("li").children("a").trigger("click");
		}
		return false;
	});
	
	
	// Formulaire
	$("form.SimilairesForm").submit(function() {
											
		$(this).unbind().submit(function() {return false;});
		
		s = $(this).serialize();  
		a = $(this).attr("action"); 
		
		$(".SimilairesCarrouselContent").addClass("Wait");
		$(".SimilairesCarrousel a.Scroll").css("opacity", .33).css("cursor", "default");
		
		$("ul.SimilairesCarrouselContentList").fadeOut(EffectTimer, function() {
																		
			$(this).remove();
			$(".SimilairesCarrousel .CarrouselPagination").remove();
			$(".SimilairesCarrouselContent").removeClass("Wait");
			
			$.ajax({ 
				type: "POST", 
				data: s, 
				url: a, 
				success: function(Asw){ 
					
					$(".SimilairesCarrouselContent").empty().html(Asw);
					$("ul.SimilairesCarrouselContentList").hide().fadeIn(EffectTimer, function() {
						ComparateurSimilaires();
						ComparateurSimilairesMouvement( $(".SimilairesCarrousel .CarrouselPagination a.on") );
						ComparateurSimilaires3th();
						ComparateurCompare();
					}) 
					
				} 
			}); 
		});
		
		return false;
	});
	
}




// Mouvement et CSS des produits
function ComparateurSimilairesMouvement(Obj) {
	
	$(Obj).parents(".SimilairesCarrousel").find("a.Scroll").css("opacity", 1).css("cursor", "pointer");
	
	CarrouselPagesNum 				= $(Obj).parent("li").prevAll().length;
	CarrouselPagesNumEnd			= $(Obj).parent("li").nextAll().length;
	
	// NÝ de page
	$(Obj).parents(".CarrouselPagination").find("p span").text(CarrouselPagesNum+1);
		
	if( (CarrouselPagesNum == 0) && (CarrouselPagesNumEnd == 0) ) {
		$(Obj).parents(".SimilairesCarrousel").find("a.Scroll").css("opacity", .33).css("cursor", "default");
	}
	else if(CarrouselPagesNum == 0) {
		$(Obj).parents(".SimilairesCarrousel").find("a.ScrollUp").css("opacity", .33).css("cursor", "default");
	}
	else if(CarrouselPagesNumEnd == 0) {
		$(Obj).parents(".SimilairesCarrousel").find("a.ScrollDown").css("opacity", .33).css("cursor", "default");
	}
		
	// Mouvement
	$(Obj).parents(".SimilairesCarrousel").find(".SimilairesCarrouselContentList").animate({
			top: -(SimilairesCarrouselItemsWidth * CarrouselPagesNum)
		},
		EffectTimer
	);
}



// Lien Comparer
function ComparateurCompare() {
	BlockSize(".ComparateurTableau", ".ComparateurTableau table");
				
	$(".ComparateurRecommandationLienCompare a").unbind();
	$(".ComparateurRecommandationLienCompare a").click(function() {
		return AjouterComparateurClick($(this));
	});
	
	
	
	$(".ComparateurTableauCancel a").unbind();
	$(".ComparateurTableauCancel a").click(function() {
	
	
		var idProductCanceled = $(this).attr("idProductAdded");
		var idProduct1 = $("#prod_ref1").val();
		var idProduct2 = $("#prod_ref2").val();
		var idProduct3 = $("#prod_ref3").val();
		var idProduct4 = $("#prod_ref4").val();
				
		if(idProduct1 == undefined)
		{
			idProduct1='0';
		}
		if(idProduct2 == undefined)
		{
			idProduct2='0';
		}
		if(idProduct3 == undefined)
		{
			idProduct3='0';
		}
		if(idProduct4 == undefined)
		{
			idProduct4='0';
		}
		
		var tabId = new Array(idProduct1,idProduct2,idProduct3,idProduct4);
		
		for(var i = 0; i < tabId.length; i++)
		{
			if(tabId[i] == idProductCanceled)
			{
				switch (i)
				{
					case 0 :
						tabId[0] = tabId[1]
						tabId[1] = tabId[2]
						tabId[2] = tabId[3]
						tabId[3] = '0'
					break;
					
					case 1 :
						tabId[1] = tabId[2]
						tabId[2] = tabId[3]
						tabId[3] = '0'
					break;
					
					case 2 :
						tabId[2] = tabId[3]
						tabId[3] = '0'
					break;
					
					case 3 :
						tabId[3] = '0'
					break;
				}
			}
		}
		
		$("#prod_ref1").val(tabId[0]);
		$("#prod_ref2").val(tabId[1]);
		$("#prod_ref3").val(tabId[2]);
		$("#prod_ref4").val(tabId[3]);	
		idProduct1 = $("#prod_ref1").val();
		idProduct2 = $("#prod_ref2").val();
		idProduct3 = $("#prod_ref3").val();
		idProduct4 = $("#prod_ref4").val();
		var UrlFrom = $("#UrlFrom").val();

		$(".ComparateurTableau").addClass("Wait");
		$(window).scrollTo( $(".ComparateurTableau").prev("h5"), EffectTimer);
			
		$(".ComparateurTableau table").fadeOut(EffectTimer, function() {
			
			// Récupération du contenu en Ajax
			$.ajax({
			url: "FicheProduitWS.asmx/GetComparateur",
			type: "POST",
			dataType: "xml",
			data:"isAjout=0&idProductUpdated=" + idProductCanceled + "&idProduct=" + idProduct + "&typeSite=" + typeSite + "&UrlFrom=" + UrlFrom,
			success: function(Asw){
					$(".ComparateurTableau").empty().html($("ContentOnglet", Asw).text());
					$(".ComparateurTableau table").hide().fadeIn(EffectTimer, function() {
						$(".ComparateurTableau").removeClass("Wait");
						ComparateurCompare();
						ComparateurTableau();
					})					
				}
			});
		
		});
		$(".ComparateurTableau").removeClass("Wait");
		return false;
	});
	
}






// CSS Pointillés du 3eme item
function ComparateurSimilaires3th() {
	$(".SimilairesCarrousel .ComparateurRecommandationItem:nth-child(3n)").css("background-image", "none");
}

	

// Toggle du tableau
function ComparateurTableau() {
	
	$(".ComparateurTableau table .ComparateurRecommandationItem p a img").addClass("png");
	
	
	j = 0;
	$(".ComparateurTableau table tr").each(function(i) {
		if(
				($(this).children("th").hasClass("ComparateurTableauOnglet") == false)
			&&	($(this).hasClass("ComparateurTableauLineFirst") == false)
			&&	($(this).hasClass("ComparateurTableauLineSep") == false)
			&&	( (j%2 == 0) )
		) {
			$(this).addClass("ComparateurTableauLineGrey")
		}
		if($(this).children("th").hasClass("ComparateurTableauOnglet") == true) {				
			j = 0;
		}
		j++;
	});
	
	$(".ComparateurTableau h6").toggle(function() {
		$(this).addClass("Close");
		ComparateurStop = false;
		$(this).parent("th").parent("tr").nextAll().each(function(i) {
			if( $(this).hasClass("ComparateurTableauLineOnglet") == true) {
				ComparateurStop = true;
			}
			if(ComparateurStop == false) {
				$(this).hide();
			}
		});
	},function() {
		$(this).removeClass("Close");
		ComparateurStop = false;
		$(this).parent("th").parent("tr").nextAll().each(function(i) {
			if( $(this).hasClass("ComparateurTableauLineOnglet") == true) {
				ComparateurStop = true;
			}
			if(ComparateurStop == false) {
				$(this).show();
			}
		});
	});
	
}






/*
+-------------------------------------------------------------------+
|	FooterMenu - Avis												|
+-------------------------------------------------------------------+
*/
function OngletAvis() {
		$(".AvisEcrireArrow a, .AvisEcrire a, .AvisFormChpStars, .AvisFormChpStarsItem, .AvisTitreTri a, .AvisForm, .AvisListeItemUtile").unbind();
		AvisUtilite();
		
	// Ouverture du formulaire
	$(".AvisEcrireArrow a").click(function() {
		$(".AvisForm").slideToggle(EffectTimer);
		$(this).parent().toggleClass("AvisEcrireArrowUp");
		return false;
	});
	$(".AvisEcrire a").click(function() {
		$(".AvisEcrireArrow a").trigger("click");
		return false;
	});
	
	
	// Passage de la souris sans voter
	$(".AvisFormChpStars").mouseout(function() {
		$(".AvisFormChpStarsItem").removeClass("AvisFormChpStarsItemLight");	
		$(".AvisFormChpStarsSentence").hide().text("");
		$(".AvisFormChpStars input:checked").parent(".AvisFormChpStarsItem").trigger("mouseover");
	});

	// Passage de la souris
	$(".AvisFormChpStarsItem").mouseover(function() {
													
		// On/Off des étoiles suivantes et préédentes par rapport au curseur
		$(this).nextAll("li").removeClass("AvisFormChpStarsItemLight");
		$(this).prevAll("li").addClass("AvisFormChpStarsItemLight");
		$(this).addClass("AvisFormChpStarsItemLight");
		
		// Affichage de l'intitule
		$(".AvisFormChpStarsSentence")
			.show()
			.css("left", $(this).offset().left - $(".AvisFormChpStars").offset().left - 24)
			.text( $(this).find("label").text() );

	})
	.click(function() {
		$(this).find("input").attr("checked", true);
		$(".AvisFormChpStarsSentence").attr("value",$(this).find("input").val())
		//$(".AvisFormChpStars, .AvisFormChpStarsItem").unbind();
		//$(".AvisFormChpStars, .AvisFormChpStarsItem").unbind();
		$(".AvisFormChpStars").removeClass("AvisFormChpStarsActive");
	});
	


	// Tri des avis
	$(".AvisTitreTri a").click(function() {				
		AvisContent($(this));				
		return false;
	});
	
	
	// Validation du formulaire
	$(".AvisForm").submit(function() {
		//alert($(".AvisFormChpStarsSentence").attr("value"));
		Mnq = 0;
			Err = new Array();
		Chp = ["input[name='AvisFormChpNom']", "input[name='AvisFormChpTitre']", "textarea[name='AvisFormChpComm']", "input[name='AvisFormEmail']"];


		
		for(i=0; i<Chp.length; i++) {
			if($.trim( $(this).find(Chp[i]).attr("value") ) == "" ) {
					$(this).find(Chp[i]).css("background-color", "#FEE");
					Mnq++;
			}
			else if($(".AvisFormChpStarsSentence").attr("value") == "0" || $(".AvisFormChpStarsSentence").attr("value") == undefined || $(".AvisFormChpStarsSentence").attr("value") == "")
			{
				$(".AvisFormChpNote").css("background-color", "#FEE");
				Mnq++;
			}
				
			else if(
					(Chp[i] == "input[name='AvisFormEmail']")
				&& 	( !$(this).find(Chp[i]).attr("value").match('^[-_\.0-9a-zA-Z]{1,}@[-_\.0-9a-zA-Z]{1,}[\.][0-9a-zA-Z]{2,}$') )
			) {
				$(this).find(Chp[i]).css("background-color", "#FEE");
				Err.push("Votre email n'est pas valide.");
			}
			else {
				$(this).find(Chp[i]).css("background-color", "#FFF");
			}
		}
		
		if(Mnq > 0) {
			alert("Vous devez remplir les champs obligatoires.");
			return false;
		}
		if(Err.length > 0) {
			alert(Err.join("\n"));
			return false;
		}
		
		else {
			
			var email = $(this).find(Chp[3]).attr("value");
			var comm = $(this).find(Chp[2]).attr("value");
			var titre = $(this).find(Chp[1]).attr("value");
			var nom = $(this).find(Chp[0]).attr("value");
			var note = $(".AvisFormChpStarsSentence").attr("value");
			
			
			$(".AvisEcrire, .AvisEcrireArrow").fadeOut(EffectTimer);
			
			s = $(this).serialize();  
			a = $(this).attr("action"); 
			$(this).animate({
				opacity:0
			},
			EffectTimer,
			"linear",
			function() {
				$.ajax({ 
					url: "FicheProduitWS.asmx/SetAvis",
					type: "POST",
					dataType: "xml",
					data:"idProduct=" + idProduct + "&email=" + email + "&comm=" + comm + "&titre=" + titre + "&nom=" + nom + "&note=" + note,
					success: function(Asw){
						BlockSize(".AvisForm", ".AvisForm");
						$(".AvisForm").empty().html($("ContentOnglet", Asw).text()).animate({opacity:1, height:100, minHeight:100},EffectTimer);
					} 
				});
			});
			
			return false;
		}
									
	
	});
	
}


// Utilite de l'avis
function AvisUtilite() {
	
	$(".AvisListeItemUtile").unbind().submit(function() {
		
		u = $(this);
		s = u.serialize();  
		a = u.attr("action"); 
		u.animate({
			opacity:0
		},
		EffectTimer,
		"linear",
		function() {
			$.ajax({ 
				type: "POST", 
				data: s, 
				url: a, 
				success: function(Asw){ 
					u.empty().html(Asw).animate({opacity:1},EffectTimer);
				} 
			});
		});
		
		return false;		
	});	
	
}


// Content des avis
function AvisContent(monProd) 
{
	
	BlockSize(".AvisListe", ".AvisListe");
		
		var tri = monProd.attr("id");
		$(".AvisListe").addClass("Wait");
		$(window).scrollTo( $(".AvisListe"), EffectTimer);
			
		$(".AvisListeContent").fadeOut(EffectTimer, function() {
			
			// Récupération du contenu en Ajax
			$.ajax({
				url: "FicheProduitWS.asmx/GetOngletAvisContentWS",
				type: "POST",
				dataType: "xml",
				data:"idProduct=" + idProduct + "&typeSite=" + typeSite + "&tri=" + tri,
				success: function(Asw){
					$(".AvisListeContent").empty().hide().html($("ContentOnglet", Asw).text()).fadeIn(EffectTimer, function() {
						$(".AvisListe").removeClass("Wait");
						//AvisUtilite();
					})
				}
			});
		
		});
		return false;
	
}

//contenu du comparateur
function AjouterComparateurClick(monProd) 
{
	var canAddAProduct = false;
	var idProductAdded = $(monProd).attr("idProductAdded");
	var idProduct1 = $("#prod_ref1").val();
	var idProduct2 = $("#prod_ref2").val();
	var idProduct3 = $("#prod_ref3").val();
	var idProduct4 = $("#prod_ref4").val();
	var UrlFrom = $("#UrlFrom").val();
		
	if(idProduct1 == undefined)
	{
		idProduct1='0';
	}
	if(idProduct2 == undefined)
	{
		idProduct2='0';
	}
	if(idProduct3 == undefined)
	{
		idProduct3='0';
	}
	if(idProduct4 == undefined)
	{
		idProduct4='0';
	}
	
	
	if(idProduct2 == idProductAdded || idProduct3 == idProductAdded || idProduct4 == idProductAdded)
	{
		$("a.erreurComparateurMemeProduit").trigger("click");
	}
	else if(idProduct1 == '0')
	{
		idProduct1=idProductAdded;
		canAddAProduct = true;
	}
	else if(idProduct2 == '0')
	{
		idProduct2=idProductAdded;
		canAddAProduct = true;
	}
	else if(idProduct3 == '0')
	{
		idProduct3=idProductAdded;
		canAddAProduct = true;
	}
	else if(idProduct4 == '0')
	{
		idProduct4=idProductAdded;
		canAddAProduct = true;
	}
	else
	{
        // cas d'un ajout provoquant un dépassement de la capacité du comparateur
        // avant on affichait un message d'erreur mais maintenant on autorise l'ajout et c'est le webservice qui se charge d'éliminer le produit ajouté au comparateur en premier
        canAddAProduct = true;
        /*
		$("a.erreurComparateurTropProduit").trigger("click");
        */
	}
    	
	if(canAddAProduct==true)
	{
		$(".ComparateurTableau").addClass("Wait");
		$(window).scrollTo( $(".ComparateurTableau").prev("h5"), EffectTimer);
        
		$(".ComparateurTableau table").fadeOut(EffectTimer, function() {
            			
			// Récupération du contenu en Ajax
			$.ajax({
			url: "FicheProduitWS.asmx/GetComparateur",
			type: "POST",
			dataType: "xml",
			data:"isAjout=1&idProductUpdated=" + idProductAdded + "&idProduct=" + idProduct + "&typeSite=" + typeSite + "&UrlFrom=" + UrlFrom,
			success: function(Asw){
					$(".ComparateurTableau").empty().html($("ContentOnglet", Asw).text());
					$(".ComparateurTableau table").hide().fadeIn(EffectTimer, function() {
						$(".ComparateurTableau").removeClass("Wait");
						ComparateurCompare();
						ComparateurTableau();
					})			
					
				}
			});
		
		});
		$(".ComparateurTableau").removeClass("Wait");
	}
	return false;
}
