jQuery(document).ready(function() {

   jQuery(".wrap-hover").hover(function() {
    jQuery(this).css("z-index", "2");
    jQuery(this).parent().siblings().find(".wrap-hover").css("z-index", "1");
   })

jQuery('.link_un, .link_deux').click(function() {
   	jQuery('#masque, .pop-up').prependTo('body');
   });

   function removeElm() {
     jQuery('#masque, .pop-up').fadeOut()
   }

   jQuery('#masque').bind('click', removeElm);

   jQuery(document).keyup(function(e) { 
     if (e.keyCode == 27) { removeElm() } 
   });



		jQuery("button.fp-add-to-cart").click(function() {
			jQuery("#product_addtocart_form").submit();
		});
	    jQuery(".col-axi input").clearField('Aucun');	    		
		// Ajout d'une fonction pour limiter la valeur de l'axe du champs prescription entre  0 et 180	    
	    jQuery(".col-axi input").keyup(function (){
	    	if(jQuery(this).val() !== 'Aucun') {
	    		var val = parseInt(jQuery(this).val());
	    		val = isNaN(val) ?  0 : val;
	    		jQuery(this).val((val > 180) ? 180 : val);
	    	}
	    });
	    
		if (jQuery.browser.msie) {
			// FIX IE click sur l'image dans un label ne fonctionne pas!!
			jQuery('label img').click(function() {
				var label = jQuery(this).parents('label:first');
				jQuery(label).click();
				jQuery('#' + jQuery(label).attr('for')).trigger('change');
			});
		}
		jQuery("div#shopping-cart-header").append("<div id=\"myCart\"></div>");	
		jQuery("div#shopping-cart-header").append("<div id=\"lastViews\"></div>");
		
		/*** Focus sur le champ d'email ***/
		
		jQuery("#top-nl-email").focus(function() { if (jQuery(this).val() == "Votre adresse email") jQuery(this).val(""); });
		jQuery("#top-nl-email").blur(function() { if (jQuery(this).val() == "") jQuery(this).val("Votre adresse email"); });
		
		/*** Slideshow ***/
		
		jQuery("div.slideshow").slideshow({ delay:7500 , title:jQuery("div.slideshow").parent().find("h3") });
		
		/*** Marks ***/
		
		jQuery("div.marks").hscroll({ offset:13 });
		
		/*** Lightbox **/
		
		jQuery("a[rel=lightbox]").colorbox();
		
		
		/*** Total Sub Form */
		if(jQuery('#total-sub-form').length && jQuery('.recapitulatif .total').length) {
			try {
			var totalOffset = jQuery('.recapitulatif .total').offset();
			jQuery('#total-sub-form').offset({top: totalOffset.top - 50});
			} catch(e) {}
		}
		
		/*** Tabs ***/
		
		jQuery("a.button-toggle-view.b-see, a.button-toggle-view.b-try").click(function() {
			
			
			//switchButtonsToggle( jQuery( this ) );
		
			if (jQuery(this).hasClass("b-see")) {
				
				jQuery("div.product-image-container.c-see, div.product-image-container.c-try").hide();
				jQuery("a.button-toggle-view.b-see, a.button-toggle-view.b-try").removeClass("selected");
				
				jQuery("div.product-image-container.c-see").show(); jQuery("a.button-toggle-view.b-see").addClass("selected");
				
				jQuery("#product-thumbnails").show();
				jQuery(".product-images").css({ height:"226px" });
				jQuery(".product-images .product-image-zone").css({ width:"344px" , height:"210px" });
				
				jQuery("div.product-image-container.c-try").empty();
				
			} else if (jQuery(this).hasClass("b-try")) {
				
				jQuery("div.product-image-container.c-try").html("<div><div id='flash-content'></div></div>");
				
				if (loadTio()) {
					
					jQuery("div.product-image-container.c-see, div.product-image-container.c-try").hide();
					jQuery("a.button-toggle-view.b-see, a.button-toggle-view.b-try").removeClass("selected");
					
					jQuery("div.product-image-container.c-try").show();
					jQuery("a.button-toggle-view.b-try").addClass("selected");
					
					jQuery("#product-thumbnails").hide();
					jQuery(".product-images").css({ height:"343px" });
					jQuery(".product-images .product-image-zone").css({ width:"461px" , height:"327px" });
					
				}
				
			}
			
			return(false);
		});
		
		
		jQuery("div.product-image-container.c-see").show();
		jQuery("div.product-image-container.c-try").hide();
		jQuery("a.button-toggle-view.b-see").addClass("selected");

		/*** Colors ***/
		
		jQuery(".color.disabled").css({ opacity:0.35 });
		
		/*** Stars ***/
		
		jQuery(".r-stars-selector").each(function() {
			
			var _inputs = [];
			jQuery(this).find("input[type=radio]").hide();
			jQuery(this).find("input[type=radio]").each(function() { _inputs.push(this); });
			jQuery(this).append("<span class='small-stars-selector s-0'></span>");
			
			for ( var i = 0 ; i < 5 ; i++ ) {
				
				jQuery(this).find("span.small-stars-selector").append("<span></span>");
				
				jQuery(this).find("span.small-stars-selector span:last").css({
					display:"block",
					position:"relative",
					float:"left",
					width:Math.round( jQuery(this).find("span.small-stars-selector").width() / 5 ) + "px",
					height:jQuery(this).find("span.small-stars-selector").height() + "px"
				});
				
				jQuery(this).find("span.small-stars-selector span:last").mouseenter(function(fNum,fInputs) {
					return(function() {
						jQuery(this).parent().removeClass();
						jQuery(this).parent().addClass("small-stars-selector").addClass("s-" + ( fNum + 1 ));
					});
				}(i,_inputs));
				
				jQuery(this).find("span.small-stars-selector span:last").mouseout(function(fNum,fInputs) {
					return(function() {
						var _sel = -1 , i = 0;
						jQuery(_inputs).each(function() { if (jQuery(this).is(":checked")) { _sel = i; } i++; });
						jQuery(this).parent().removeClass();
						jQuery(this).parent().addClass("small-stars-selector").addClass("s-" + ( _sel + 1 ));
					});
				}(i,_inputs));
				
				jQuery(this).find("span.small-stars-selector span:last").click(function(fNum,fInputs) {
					return(function() {
						jQuery(this).parent().removeClass();
						jQuery(this).parent().addClass("small-stars-selector").addClass("s-" + ( fNum + 1 ));
						jQuery(_inputs[fNum]).attr("checked",true);
					});
				}(i,_inputs));
				
			}
			
		});
		
		/*** Global messages ***/
		
		jQuery("#global-messages").each(function() {
			
			if (jQuery("#overlay").length == 0) jQuery("body").append("<div id='overlay'></div>");
			jQuery("#overlay").css({ zIndex:5000 , opacity:0.8 });
			jQuery(this).css({ zIndex:5001 });
			jQuery(this).find(".hide-global-messages").click(function() { jQuery("#overlay, #global-messages").remove(); });
			
		});
		
		/*** Product steps ***/
		
		var defaultStep = 1;
		var useStepsAnimations = false;
		
		jQuery("div.product-steps div.product-step h3").click(function() {
			var _step = jQuery(this).parent();
			if (jQuery(_step).find("div.product-step-content").is(":visible")) { jQuery(_step).removeClass("openned"); } else { jQuery(_step).addClass("openned"); }
			if (useStepsAnimations) {
				jQuery(_step).find("div.product-step-content").animate({ height:"toggle" },500);
			} else { jQuery(_step).find("div.product-step-content").toggle(); }
		});
		
		/*jQuery(".configure-glasses").click(function() {
			if (useStepsAnimations) {
				jQuery("div.product-steps div.product-step.step-" + defaultStep + " div.product-step-content").animate({ height:"show" },500);
			} else { jQuery("div.product-steps div.product-step.step-" + defaultStep + " div.product-step-content").toggle(); }
		});*/
		
		var _showAuto = self.location.toString().split("#").length > 0 && self.location.toString().split("#")[1] == "glasses" ;
		if (_showAuto) {
			jQuery("div.product-steps div.product-step.step-" + defaultStep).addClass("openned");
			jQuery("div.product-steps div.product-step.step-" + defaultStep + " div.product-step-content").show();
		}
		
		//jQuery("#options_17019_2").attr("checked","checked");

		var itempHS=0;
		jQuery(".product-options input[type=radio]").each(function() {
			if(itempHS == 0){
				this.checked=true;
				//alert(this.name);
			}
			itempHS = itempHS +1 ;
		});
					
		jQuery(".product-options input[type=text]").each(function() {
			
			var _select = "<select id=\""+jQuery(this).attr('id')+"\" name=\""+jQuery(this).attr('name')+"\" class=\"product-custom-option\" >\n";
			var j=0; var k=0; var l=0;
			if (jQuery(this).hasClass('maximum-length-10')) { j =-10; k=10; l=0.25; }
			else if (jQuery(this).hasClass('maximum-length-12')) { j=-6; k=6; l=0.25; }
			else if (jQuery(this).hasClass('maximum-length-8')) { j=1; k=3.5; l=0.25; }
			else if (jQuery(this).hasClass('maximum-length-180')) { j=0; k=180; l=5; }
			else if (jQuery(this).hasClass('maximum-length-40')) { j=25; k=40; l=0.5; }
			
			if (j>0) {
				_select += '<option value="">-- Choisir --</option>\n';
			}
			
			for (i=j;i<=k;i=i+l) {
				if (i >= 0 ) {
					num = '+'+i.toFixed(2) ;
				} else {
					num = i.toFixed(2);
				}
				
				_select += '<option value="'+num+'"';
				if (i == 0) { _select += ' selected '; }
				_select += '>'+num+'</option>\n';
			}
			_select += "</select>";			

			jQuery(this).replaceWith(_select);
		});
		
		

		
	});
	
	function switchButtonsToggle(  ) {

			jQuery("div.product-image-container.c-try").html("<div><div id='flash-content'></div></div>");
	
			jQuery("div.product-image-container.c-see, div.product-image-container.c-try").hide();
			jQuery("a.button-toggle-view.b-see, a.button-toggle-view.b-try").removeClass("selected");
			
			jQuery("div.product-image-container.c-try").show();
			jQuery("a.button-toggle-view.b-try").addClass("selected");
			
			jQuery("#product-thumbnails").hide();
			jQuery(".product-images").css({ height:"343px" });
			jQuery(".product-images .product-image-zone").css({ width:"461px" , height:"327px" });

	}
	
	
	function setLocation(fUrl) { self.location = fUrl; }
	
	/***
	 * HScroll
	 ***/
	
	(function($) {
		
		$.hscroll = { active:[] };
		$.fn.hscroll = function(settings) {
			
			this.settings = $.extend({ offset:0 },settings);
			this.ready = true;
			
			return(this.each(function(fC) {
				return(function() {
					
					jQuery(this).append("<a href='#' class='hscroll-previous'>Précédent</a>");
					jQuery(this).append("<a href='#' class='hscroll-next'>Suivant</a>");
					
					jQuery(this).find("a.hscroll-previous, a.hscroll-next").click(function(fC) {
						return(function() {
							
							if (fC.ready) {
								
								var _global = jQuery(this).parent();
								var _mask = jQuery(_global).find("div:first");
								var _container = jQuery(_global).find("div:first div:first");
								var _side = jQuery(this).hasClass("hscroll-next") ? "next" : "previous" ;
								
								var _nextX = jQuery(_container)[0].offsetLeft;
								
								switch (_side) {
									case "next": _nextX -= ( jQuery(_mask).width() + fC.settings.offset ) ; break;
									case "previous": _nextX += ( jQuery(_mask).width() + fC.settings.offset ) ; break;
								}
								
								var _totalWidth = 0;
								jQuery(_container).children().each(function() { _totalWidth += jQuery(this).width(); });
								
								if (_nextX < fC.settings.offset && _nextX > -1 * _totalWidth) {
									fC.ready = false;
									jQuery(_container).animate({ left:_nextX + "px" },1000,function(fC) { return(function() { fC.ready = true; }); }(fC));
								}
								
							}
							
							return(false);
							
						});
					}(fC));
					
				});
			}(this)));
			
		};
		
	}(jQuery));
	
	/***
	 * Slideshow
	 ***/
	
	(function($) {
		
		$.slideshow = { active:[] };
		$.fn.slideshow = function(settings) {
			
			this.settings = $.extend({ delay:5000 , title:null },settings);
			this.defaultTitle = this.settings.title != null ? jQuery(this.settings.title).html() : "" ;
			
			return(this.each(function(fC) {
				return(function() {
					
					fC.timer = null;
					
					jQuery(this).append("<div class='slideshow-tools'></div>");
					
					for ( var i = 0 ; i < jQuery(this).find("p").length ; i++ ) {
						
						jQuery(this).find("div.slideshow-tools").append("<a class='page'></a>");
						jQuery(this).find("div.slideshow-tools a.page:last").attr("href","#");
						jQuery(this).find("div.slideshow-tools a.page:last").html(i + 1);
						jQuery(this).find("div.slideshow-tools a.page:last").click(function(fContainer,fId,fC) {
							return(function() { slideshowGoto(fC,fContainer,fId); return(false); });
						}(this,i,fC));
						
					}
					
					jQuery(this).find("div.slideshow-tools").append("<a class='toggle-playback'></a>");
					jQuery(this).find("div.slideshow-tools a.toggle-playback:last").attr("href","#");
					jQuery(this).find("div.slideshow-tools a.toggle-playback:last").html("Lire / Pause");
					jQuery(this).find("div.slideshow-tools a.toggle-playback:last").click(function(fContainer,fC) {
						return(function() { slideshowToggle(fC,fContainer); return(false); });
					}(this,fC));
					
					jQuery(this).find("p").hide();
					
					slideshowGoto(fC,this,0,false);
					slideshowPlay(fC,this);
					
				});
			}(this)));
			
		};
		
	}(jQuery));
	
	function slideshowGoto(fC,fContainer,fId,fAnimate) {
		
		if (fAnimate == null) fAnimate = true;
		
		var i = 0;
		var currentVisible = 0;
		jQuery(fContainer).find("p").each(function() {
			if (jQuery(this).is(":visible")) { currentVisible = i; }
			i++;
		});
		
		if (fId == "next") {
			if (jQuery(fContainer).find("p").length >= currentVisible + 2) {
				fId = currentVisible + 1;
			} else { fId = 0; }
		} else if (fId == "previous") {
			if (currentVisible > 0) {
				fId = currentVisible - 1;
			} else { fId = jQuery(fContainer).find("p").length - 1; }
		}
		
		if (!jQuery(jQuery(fContainer).find("p")[fId]).is(":visible")) {
			
			if (fC.timer != null) slideshowPlay(fC,fContainer);
			
			if (fAnimate) {
				
				var _old = jQuery(fContainer).find("p:visible");
				
				jQuery(fContainer).find("p").css({ zIndex:1 , opacity:1 });
				jQuery(jQuery(fContainer).find("p")[fId]).css({ top:jQuery(fContainer).height() + "px" , zIndex:2 });
				jQuery(jQuery(fContainer).find("p")[fId]).show();
				
				jQuery(jQuery(fContainer).find("p")[fId]).animate({ top:"0px" },500,function(fContainer,fOld) {
					return(function() { jQuery(fOld).hide(); });
				}(fContainer,_old));
				
				jQuery(_old).animate({ opacity:0 },500);
				
			} else {
				
				jQuery(fContainer).find("p:visible").hide();
				jQuery(jQuery(fContainer).find("p")[fId]).css({ top:"0px" }).show();
				
			}
			
			var _title;
			if (fC.settings.title != null) {
				_title = jQuery(jQuery(fContainer).find("p")[fId]).attr("title");
				if (_title != null) { jQuery(fC.settings.title).html(_title); }
			}
			if (_title == null || _title == "") jQuery(fC.settings.title).html(fC.defaultTitle);
			
			jQuery(fContainer).find("div.slideshow-tools a.page").removeClass("selected");
			jQuery(jQuery(fContainer).find("div.slideshow-tools a.page")[fId]).addClass("selected");
			
		}
		
	}
	
	function slideshowPlay(fC,fContainer) {
		
		window.clearTimeout(fC.timer);
		fC.timer = window.setTimeout(function(fC,fContainer) {
			return(function() {
				
				slideshowGoto(fC,fContainer,"next");
				slideshowPlay(fC,fContainer);
				
			});
		}(fC,fContainer),fC.settings.delay);
		
		jQuery(fContainer).find("div.slideshow-tools a.toggle-playback").removeClass("toggled");
		
	}
	
	function slideshowPause(fC,fContainer) {
		
		window.clearTimeout(fC.timer);
		fC.timer = null;
		
		jQuery(fContainer).find("div.slideshow-tools a.toggle-playback").addClass("toggled");
		
	}
	
	function slideshowToggle(fC,fContainer) {
		
		if (fC.timer == null) {
			slideshowPlay(fC,fContainer);
		} else { slideshowPause(fC,fContainer); }
		
	}
	
	/***
	 * Color selector
	 ***/
	
	(function($) {
		
		$.colorSelector = { active:[] };
		$.fn.colorSelector = function(settings) {
			
			this.settings = $.extend({ colors:{} },settings);
			
			return(this.each(function(fC) {
				return(function() {
					
					jQuery(this).find("li").each(function(fC,fObj) {
						return(function() {
							
							var _c = jQuery(this).find("span.label label").text();
							while ( _c.charAt(0) == " " ) _c = _c.substr(1,_c.length);
							while ( _c.charAt(_c.length - 1) == " " ) _c = _c.substr(0,_c.length - 1);
							
							var _color = fC.settings.colors[_c];
							
							jQuery(fObj).append("<a></a>");
							jQuery(fObj).find("a:last").attr("href","#");
							jQuery(fObj).find("a:last").attr("title",_c);
							jQuery(fObj).find("a:last").html(_c);
							jQuery(fObj).find("a:last").addClass("color");
							jQuery(fObj).find("a:last").css({ backgroundColor:_color , borderColor:_color , opacity:0.35 });
							
							jQuery(fObj).find("a:last").click(function(fLi) {
								return(function() {
									jQuery(this).parent().find("a").stop().animate({ opacity:0.35 },250);
									jQuery(this).stop().animate({ opacity:1 },250);
									jQuery(fLi).find("input").attr("checked",true);
									return(false);
								});
							}(this));
							
						});
					}(fC,this));
					
					jQuery(this).find("li:first input").attr("checked",true);
					jQuery(this).find("a:first").css({ opacity:1 });
					
				});
			}(this)));
			
		};
		
	}(jQuery));

	/***
	 * Swap images
	 ***/
	
	(function($) {
		
		$.swapImages = { active:[] };
		$.fn.swapImages = function(settings) {
			
			this.settings = $.extend({ images:[] , container:null , thumbnails:null },settings);
			
			return(this.each(function(fC) {
				return(function() {					
					
					jQuery(fC.settings.thumbnails).empty();
					//jQuery(fC.settings.container).empty();
					
			
					var _is = fC.settings.images;
					
					//for ( var i = 0 ; i < 3 ; i++ ) {
					/*la ligne précédente était décommentée
					 * cela générait cependant un bug de type thumbnail affiché mais pas main img
					 */
					
					//la variable suivante nous permet de ne pas dépasser une taille de 3, afin d'éviter problèmes d'affichage et d'impression
					var imgsSize = _is.length > 3 ? 3 : _is.length;
					for ( var i = 0 ; i < imgsSize ; i++ ) {


						jQuery(fC.settings.thumbnails).append("<a><img /></a>");
						jQuery(fC.settings.thumbnails).find("a:last img").attr("src",_is[i].thumbnail);
						jQuery(fC.settings.thumbnails).find("a:last img").attr("alt","");
						jQuery(fC.settings.thumbnails).find("a:last").attr("href","#");
						jQuery(fC.settings.thumbnails).find("a:last").click(function(fContainer,fP) {
							return(function() {

								jQuery(fContainer).html("<a><img /></a>");
								jQuery(fContainer).find("img").attr("src",fP.small);
								jQuery(fContainer).find("img").attr("alt","");
								jQuery(fContainer).find("a").attr("href",fP.normal);
								jQuery(fContainer).find("a").colorbox();
								return(false);

							});
						}(fC.settings.container,_is[i]));

					}

					if (_is.length > 0) {
						jQuery(fC.settings.container).html("<a><img /></a>");
						jQuery(fC.settings.container).find("img").attr("src",_is[0].small);
						jQuery(fC.settings.container).find("img").attr("alt","");
						jQuery(fC.settings.container).find("a").attr("href",_is[0].normal);
						jQuery(fC.settings.container).find("a").colorbox();
					}					

					
					
				});
			}(this)));
			
		};
		
	}(jQuery));
	
	/***
	 * Recipients
	 ***/
	
	function add_recipient(b) {
		
		if (fP.max == null) fP.max = 1;
		
		if (jQuery(".recipient-item").length < fP.max) {
			jQuery(".recipient-item:last").clone().appendTo(jQuery(".recipient-item:last").parent());
			jQuery(".recipient-item:last .required em").remove();
		} else {
			alert("Vous ne pouvez pas faire plus de " + fP.max + " envois.");
		}
		
		if (jQuery(".recipient-item").length >= fP.max) jQuery(".add-recipient-button button").hide();
		
	}
	
	/***
	 * Message box
	 ***/
	
	function messagebox(fMessage,fP) {
		
		if (fP == null) {
			fP = { buttons:["ok"] };
		} else if (fP instanceof Array) {
			fP = { buttons:fP };
		}
		
		jQuery("body").append("<div id='msg-overlay'></div>");
		jQuery("body").append("<div id='msg-box'></div>");
		
		if (fP.useMargins === false) jQuery("#msg-box").css({ padding:"0px" });
		if (fP.width != null) jQuery("#msg-box").css({ width:fP.width + "px" , marginLeft:Math.round(fP.width*-0.5) + "px" });
		if (fP.height != null) jQuery("#msg-box").css({ height:fP.height + "px" , marginTop:Math.round(fP.height*-0.5) + "px" });
		if (fP.center === true) jQuery("#msg-box").css({ top:"50%" });
		
		jQuery("div#msg-overlay").show();
		jQuery("div#msg-box").show();
		jQuery("div#msg-box").html(fMessage);
		
		if (fP.buttons != null && fP.buttons.length > 0) {
			jQuery("div#msg-box").append("<div class='buttons'></div>");
			for ( var i = 0 ; i < fP.buttons.length ; i++ ) {
				
				var _label = fP.buttons[i];
				switch (fP.buttons[i]) {
					case "ok": _label = "OK"; break;
					case "cancel": _label = "Annuler"; break;
					case "yes": _label = "Oui"; break;
					case "no": _label = "Non"; break;
				}
				
				jQuery("div#msg-box div.buttons:last").append("<button class='button'><span><span>" + _label + "</span></span></button>");
				jQuery("div#msg-box div.buttons:last button").click(function(fAction) {
					return(function() {
						switch (fAction) {
							case "ok": messageboxClose(); break;
							case "cancel": messageboxClose(); break;
							case "yes": messageboxClose(); break;
							case "no": messageboxClose(); break;
						}
					});
				}(fP.buttons[i]));
				
			}
		}
		
		jQuery("div#msg-overlay").css({ opacity:0.6 });
		
	}
	
	function messageboxClose() {
		
		jQuery("div#msg-overlay, div#msg-box").remove();
		
	}
	
	/***
	 * Ecran d'attente des étapes de commande des verres
	 ***/
	
	(function($) {
		
		$.glassesWaitingBegin = { active:[] };
		$.fn.glassesWaitingBegin = function(settings) {
			this.settings = $.extend({},settings);
			return(this.each(function(fC) {
				return(function() {
					jQuery(this).append("<div class='waiting-step'></div>");
					jQuery(this).find("div.waiting-step").css({
						width:( jQuery(this).width() + 20 ) + "px",
						height:( jQuery(this).height() + 27 ) + "px",
						opacity:0.7,
						zIndex:10
					});
				});
			}(this)));
		};
		
		$.glassesWaitingStop = { active:[] };
		$.fn.glassesWaitingStop = function(settings) {
			this.settings = $.extend({},settings);
			return(this.each(function(fC) {
				return(function() {
					jQuery(this).find("div.waiting-step").remove();
				});
			}(this)));
		};
		
	}(jQuery));
	
	/***
	 * Prix flottant
	 ***/
	
	(function($) {
		
		$.floatingPrice = { active:[] };
		$.fn.floatingPrice = function(settings) {
			
			this.settings = $.extend({},settings);
			
			this.refreshScroll = function(fAnimate) {				
				var _scroll = jQuery(window).scrollTop();				
				var _breadcrumbsHeight = 32;
				var wrapTop = jQuery("#wrap").offset().top;
				var delta = _scroll - wrapTop;
				
				if (fAnimate == null) {
					fAnimate = true;
				}
				
				if (delta > _breadcrumbsHeight) {
					_top = _scroll > wrapTop ?  _scroll - wrapTop : wrapTop;
				} else {
					_top = _breadcrumbsHeight;
				}
				
				if (fAnimate) { 
					jQuery("#floating-price").stop().animate({ top:_top + "px" },500); 
				} else {
					jQuery("#floating-price").stop().css({ top:_top + "px" }); 
				}				
			};
			/*
			return(this.each(function(fC) {
				return(function() {
					
					jQuery(this).append("<div id='floating-price'><div id='floating-price-inner'></div></div>");
					
					var _f = jQuery("#floating-price");
					var _fi = jQuery("#floating-price #floating-price-inner");
					
					jQuery(_fi).append("<div id='fp-monture'><img src='' /><p class='fp-monture-price'></p><span>La monture</span></div>");			
					jQuery(_fi).append("<div id='fp-verre'><img src='' /><p class='fp-verre-price'></p><span>La paire de verre</span></div>");			
					jQuery(_fi).append("<br style='clear:both' /><br/>");
					jQuery(_fi).append("<h4>Monture :</h4>");
					jQuery(_fi).append("<p class='fp-monture-desc'></p>");				
					jQuery(_fi).append("<h4>Verre :</h4>");
					jQuery(_fi).append("<p class='fp-verre-desc'></p>");
					jQuery(_fi).append("<br style='clear:both' />");
					jQuery(_fi).append("<ul class='fp-infos'><li>&nbsp;</li></ul>");
					jQuery(_fi).append("<p class='fp-txt-total'> Total article : </p>");					
					jQuery(_fi).append("<p class='fp-price'></p>");
					jQuery(_fi).append("<br style='clear:both' />");
					jQuery(_fi).append("<button type='button' class='fp-add-to-cart'><span>Ajouter au panier</span></button>");														
					jQuery(_fi).append("<span class='fp-availability'> En stock </span>");
					jQuery(_fi).append("<span class='fp-shipping'> Livraison <br /> 48H </span>");
					jQuery(_fi).append('<div class="bottom"><div class="billing-and-shipping-methods"><b>Paiement sécurisé / livraison</b></div></div>');
					var bottom = jQuery('div.bottom', jQuery(_fi));					
					jQuery("#wrap-right .widget-static-block img:first").parent().clone().appendTo(bottom);					
					
					jQuery("button.fp-add-to-cart").click(function() {
						jQuery("#glasses-enabled").val(1);
						jQuery("#product-addtocart-form").submit();
					});
					
					jQuery(window).scroll(function(fC) { return(function() { fC.refreshScroll(); }); }(fC));
					fC.refreshScroll(false);
					
				});
			}(this)));
			*/
		};
		
	}(jQuery));
	
	/***
	 * Number format
	 ***/
	
	function number_format(fNum) {
		
		var _str = Math.abs(fNum).toString().split(".").join(",");
		if (Math.abs(fNum) < 10) _str = "0" + _str;
		if (_str.indexOf(",") == -1) _str += ",00";
		if (_str.length < 5) _str += "0";
		_str = ( fNum < 0 ? "-" : "+" ) + _str;
		return(_str);
		
	}
	
	/***
	 * Valeurs de formulaire
	 ***/
	
	function get_radio_value(fName,fDefault) {
		
		var _value = fDefault != null ? fDefault : "" ;
		jQuery("input[name=" + fName + "]").each(function() { if (jQuery(this).attr("checked")) _value = jQuery(this).val(); });
		return(_value);
		
	}
	
	
	
	
			/*** Sous-navigation ***/
		
		/*jQuery("ul#nav li.level0").subNavigation({ child:"ul.level0:first" });*/
	
	/***
	 * Sous-menu
	 ***/
	/*
	(function($) {
		
		$.subNavigation = { active:[] };
		$.fn.subNavigation = function(settings) {
			
			this.settings = $.extend({ child:null },settings);
			this.timer = null;
			
			this.showMenu = function(fE) {
				
				window.clearTimeout(this.timer);
				this.timer = null;
				
				jQuery("#subnav").remove();
				if (jQuery(fE).find(this.settings.child).length > 0) {
					
					jQuery("body").append("<div id='subnav'><ul></ul></div>");
					jQuery("#subnav ul").html(jQuery(fE).find(this.settings.child).html());
					jQuery("#subnav").css({
						position:"absolute",
						left:jQuery(fE).offset().left + "px",
						top:( jQuery(fE).offset().top + jQuery(fE).height() ) + "px",
						zIndex:500
					});
					
					jQuery("#subnav").mouseover(function(fC,fE) { return(function() { window.clearTimeout(fC.timer); fC.timer = null; }); }(this,fE));
					jQuery("#subnav").mouseout(function(fC,fE) { return(function() { fC.hideMenu(fE); }); }(this,fE));
					
				}
				
			};
			
			this.hideMenu = function(fE) {
				
				this.timer = window.setTimeout(function(fC,fE) {
					return(function() {
						jQuery("#subnav").remove();
					});
				}(this,fE),600);
				
			};
			
			return(this.each(function(fC) {
				return(function() {
					
					jQuery(this).mouseover(function(fC) { return(function() { fC.showMenu(this); }); }(fC));
					jQuery(this).mouseout(function(fC) { return(function() { fC.hideMenu(this); }); }(fC));
					
				});
			}(this)));
			
		};
		
	}(jQuery));
	
	function toggleMenu() {}
	*/
	
	/***
	 * Rollover products
	 ***/	 
	
		jQuery( function() { 
		
		jQuery("div.products-list div.product").each(
			function(){
				var $wPic = 406;
				var $hPic = 210;
				var $product = jQuery(this);
				var $productX = null; 
				var $productAbsX = null;
				var $productY = null;
				var $productAbsY = null;
				var $scrollY = null;
				var $wParent = $product.parent().width();
				var $xParent = $product.parent().offset().left;
				var $dY = 20;
				var $hWindow = null;
				var $w = $product.width();
				var $x = null;
				var $y = null;
				
				var centerX = function( xMouse ) { 
									 $productX =  $product.position().left;
									 $productAbsX = $product.offset().left;
									 $x = xMouse - ( $wPic / 2 ) ;
									 if ( $x < $xParent ) $x = $xParent;
									 if ( ( xMouse + ($wPic / 2) ) > ( $xParent + $wParent )) $x = $xParent + $wParent - $wPic;
								  	 return $x;
								  };
				
				var centerY = function( yMouse ) {
									$hWindow = jQuery(window).height();
									$productY = $product.position().top;
									$productAbsY = $product.offset().top;
									$scrollY = jQuery(document).scrollTop();
									$y = yMouse - $hPic - $dY;
									
									if ( ( yMouse - $hPic - $dY ) < $scrollY ) { $y = yMouse + $dY }
									
									return $y;
								  }
					 
				var $src = $product.find("div.product-zoom a").attr("href") ;
				var $ctn = $product.find("a.product-image img");
					 $ctn.mouseover( function(e) { jQuery("body").append("<div id=\"ctn-zoom\" style=\"position: absolute; left: "+centerX( e.pageX )+"px; top: "+centerY( e.pageY )+"px; z-index: 5487; border: 2px solid #333; background:#FFFFFF; \"><img src=\""+$src+"\" /></div> ")} );
					 $ctn.mouseout( function() { jQuery("div#ctn-zoom").remove(); } );
					 $ctn.mousemove( function( e ) { jQuery("div#ctn-zoom").css( {"left": centerX( e.pageX ) +"px", "top": centerY( e.pageY ) } ) } );
			}
		);
		
		
		
	});
	
		
		
		/**
		 * jQuery-Plugin "Simple clearField"
		 * 
		 * @version: 1.1, 07.11.2009
		 * 
		 * @author: Andres Vidal
		 *          code@andresvidal.com
		 *          http://www.andresvidal.com
		 * 
		 * @example: $('selector').clearField("Default Text");
		 * @example: $('selector').clearField("Default Text", { blurClass: 'myBlurredClass', activeClass: 'myActiveClass', stopSubmit: true });
		 * 
		 */

		(function($) {

			$.fn.clearField = function(text, options) {
				// define config(defaults) and override with settings, if available
				// by extending the config settings, we don't modify the argument
				settings = jQuery.extend({
					blurClass: "default",
					activeClass: '',
					stopSubmit: true
				}, options);
				
				// do the rest of the plugin, using settings
				// loop each element
				this.each(function() {
					// element-specific code here
					var el = $(this);
					var cvalue = el.val();
					var parentForm = el.parents('form');

					// onload check if value is present, else add settings.text and settings.blurClass
					if(cvalue == "" || cvalue == text) {
						el.addClass(settings.blurClass).val(text);
					}
					
					// Set focus action
					el.focus(function() {
						if(jQuery.trim(el.val()) == text) {
							el.removeClass(settings.blurClass).addClass(settings.activeClass).val('');
						}			
					});
					
					// Set blur action
					el.blur(function() {										
						if(el.val() == "") {
							el.removeClass(settings.activeClass).addClass(settings.blurClass).val(text);
						}			
					});
					
					//check on form submit if default text is changed
					parentForm.submit(function(){
						if(el.val().trim() == "" || el.val().trim() == text && settings.stopSubmit == true) {
							return false;
						}
					});
					
				});
				
				return this;
			};
			
		})(jQuery);
		
		
