	
	var isIE6 = $.browser.msie && ( $.browser.version.indexOf("6.") == -1 );
	var isIE7 = $.browser.msie && ( $.browser.version.indexOf("7.") == -1 );
	
	/* Document ready */
	
	$(function() {
		
		if (!cfg.rememberPositions) $("#wrap-left, #wrap-right").clearPositions();
		$("#wrap-left, #wrap-right").readPositions();
		$("#wrap-left, #wrap-right").sortable({ handle:"h4" , opacity:0.75 , cursor:"move" , update:function() { $("#wrap-left, #wrap-right").savePositions(); } });
		
		$("a[rel^=sub]").createNavigation({ offsetLeft:8 , offsetRight:14 });
		$("div#header-subnav ul li a").enableDropShadow();
		if (cfg.animateMarquees) $("div.marquee").marquee();
		$("div#promo-top-banners").slideshow();
		$("div#box-center-exclu").slideshow();
		$("input#newsletter-email").focusable({ text:"Mon Email" });
		$("input#recherche").focusable({ text:"Rechercher" });
		
		$("a.content-list-item").each(function() {
			
			$(this).prepend("<span class=\"item-bg\"></span>");
			$(this).find("span.item-bg").css({ opacity:0 });
			$(this).mouseover(function() { $(this).find("span.item-bg").stop().animate({ opacity:1 },250); });
			$(this).mouseout(function() { $(this).find("span.item-bg").stop().animate({ opacity:0 },250); });
			
		});
		
		$("table tr").each(function() {
			var i = 0;
			$(this).find("td").each(function() {
				$(this).addClass("column-" + ( i + 1 ));
				i++;
			});
		});
		
		$(".png24, #promo-top-banners img, #promo-top.promo-top-inner img, div.home-list-item img").png24();
		
		var loc = self.location.toString().substr(0,self.location.toString().indexOf("/",8));
		$("a[href^=http]").each(function() {
			if ($(this).attr("href").indexOf(loc) != 0 && $(this).attr("href").split("www.").join("").indexOf(loc) != 0) {
				$(this).attr("target","_blank");
			}
		});
		
	});
	
	/* Navigation */
	
	(function($) {
		$.createNavigation = { active:[] };
		$.fn.createNavigation = function(settings) {
			
			this._options = $.extend({ offsetLeft:0 , offsetRight:0 },settings);
			this._timer = null;
			this._nav = new Array();
			
			this._show = function(fO,fId,fLink) {
				
				for ( var _i = 0 ; _i < this._nav.length ; _i++ ) $(this._nav[_i]).hide();
				
				$(fO).stop().show().css({ opacity:1 });
				
				var _left = $(fLink).parent().get(0).offsetLeft + this._options.offsetLeft;
				if ($(fLink).parent().prev().length == 0) { _left = 0; }
				if (_left + $(fO).width() > $(fLink).parent().parent().width()) _left = $(fLink).parent().parent().width() - $(fO).width() + this._options.offsetRight;
				if (_left < 0) _left = 0;
				
				$(fO).css({ left:_left + "px" });
				
				window.clearTimeout(this._timer);
				
			};
			
			this._hide = function(fO,fId,fLink) {
				
				window.clearTimeout(this._timer);
				this._timer = window.setTimeout(function(fC,fO,fId) {
					return(function() { $(fO).animate({ opacity:"hide" },500); });
				}(this,fO,fId),1000);
				
			};
			
			return this.each(function(fC) {
				return(function() {
					
					var _rel = $(this).attr("rel");
					if (_rel.indexOf("[") != -1 && _rel.lastIndexOf("]") != -1) {
						
						var _id = _rel.substr(_rel.indexOf("[") + 1,_rel.lastIndexOf("]") - _rel.indexOf("[") - 1);
						var _o = $("#" + _id);
						fC._nav.push(_o);
						$(_o).hide();
						
						if ($(this).hasClass("selected") || $(this).parent().hasClass("selected")) {
							fC._show(_o,_id,this);
						}
						
						$(this).mouseover(function(fC,fO,fId) { return(function() { fC._show(fO,fId,this); }); }(fC,_o,_id));
						$(this).mouseout(function(fC,fO,fId) { return(function() { fC._hide(fO,fId,this); }); }(fC,_o,_id));
						
						$(_o).mouseover(function(fC,fO,fId,fLink) { return(function() { fC._show(fO,fId,fLink); }); }(fC,_o,_id,this));
						$(_o).mouseout(function(fC,fO,fId,fLink) { return(function() { fC._hide(fO,fId,fLink); }); }(fC,_o,_id,this));
						
					}
					
				});
			}(this));
			
		};
	})(jQuery);
	
	/* Drop shadow */
	
	(function($) {
		$.enableDropShadow = { active:[] };
		$.fn.enableDropShadow = function(settings) {
			return this.each(function() {
				
				var _t = $(this).html();
				
				$(this).empty();
				$(this).append("<span class=\"text-shadow\"></span>");
				$(this).append("<span class=\"text-face\"></span>");
				$(this).find("span").html(_t);
				if ($(this).parent().hasClass("selected")) $(this).find("span.text-shadow").css({ opacity:0.25 });
				
				if (!isIE6 && !isIE7) {
					$(this).mouseover(function() { $(this).find("span.text-shadow").css({ opacity:0.25 }); });
					$(this).mouseout(function() { if (!$(this).parent().hasClass("selected")) $(this).find("span.text-shadow").css({ opacity:1 }); });
				} else {
					$(this).find("span.text-face").css({ color:"#FFFFFF" });
				}
				
			});
		};
	})(jQuery);
	
	/* Boxes positions */
	
	(function($) {
		$.savePositions = { active:[] };
		$.fn.savePositions = function(settings) {
			return this.each(function() {
				
				var _order = new Array();
				$(this).children().each(function() {
					if ($(this).attr("id") != null) { _order.push($(this).attr("id")); }
				});
				
				$.cookie("boxesPosition_" + $(this).attr("id"),_order.join(","),{ expires:30 });
				
			});
		};
	})(jQuery);
	
	(function($) {
		$.readPositions = { active:[] };
		$.fn.readPositions = function(settings) {
			return this.each(function() {
				
				var _orderStr = $.cookie("boxesPosition_" + $(this).attr("id"));
				if (_orderStr != null) {
					var _order = _orderStr.split(",");
					var _o;
					for ( var _i = _order.length - 1 ; _i >= 0 ; _i-- ) {
						_o = $("#" + _order[_i]);
						if ($(_o).length > 0) {
							$(_o).clone().prependTo($(_o).parent());
							$(_o).remove();
						}
					}
				}
				
			});
		};
	})(jQuery);
	
	(function($) {
		$.clearPositions = { active:[] };
		$.fn.clearPositions = function(settings) {
			return this.each(function() {
				
				$.cookie("boxesPosition_" + $(this).attr("id"),null);
				
			});
		};
	})(jQuery);
	
	/* Marquee */
	
	(function($) {
		$.marquee = { active:[] };
		$.fn.marquee = function(settings) {
			
			this._options = $.extend({ speed:45 },settings);
			
			this._move = function(fO,fInitY,fFinalY,fResumed) {
				
				if (fResumed == null) fResumed = false;
				if (!fResumed) $(fO).find("div:last").css({ top:fInitY + "px" });
				
				var _speed = ( $(fO).find("div:last").get(0).offsetTop - fFinalY ) * this._options.speed;
				$(fO).find("div:last").animate({ top:fFinalY + "px" },_speed,"linear",function(fC,fO,fInitY,fFinalY) {
					return(function() { fC._move(fO,fInitY,fFinalY); });
				}(this,fO,fInitY,fFinalY));
				
			};
			
			return this.each(function(fC) {
				return(function() {
					
					this._interv = null;
					this._moving = true;
					
					var _str = $(this).html();
					$(this).html("<div></div>");
					$(this).find("div:last").html(_str);
					$(this).find("div:last").css({ position:"absolute" , left:"0px" , width:$(this).width() + "px" });
					
					var _initY = $(this).height();
					var _finalY = -1 * $(this).find("div:last").height();
					
					$(this).mouseover(function() { $(this).find("div:last").stop(); });
					$(this).mouseout(function(fC,fO,fInitY,fFinalY) {
						return(function() { fC._move(fO,fInitY,fFinalY,true); });
					}(fC,this,_initY,_finalY));
					
					fC._move(this,_initY,_finalY);
					
				});
			}(this));
			
		};
	})(jQuery);
	
	/* Slideshow */
	
	(function($) {
		$.slideshow = { active:[] };
		$.fn.slideshow = function(settings) {
			
			this._options = $.extend({ delay:5 , time:0.25 },settings);
			
			this._change = function(fO) {
				
				if ($(fO).children(":visible").length > 1) {
					$(fO).children().hide();
					$(fO).children(":first").show();
					this._prepare(fO);
				} else if ($(fO).children(":visible").length == 0) {
					$(fO).children(":first").show();
					this._prepare(fO);
				} else if ($(fO).children(":visible").length == 1) {
					
					var _previous = $(fO).children(":visible");
					var _next = $(_previous).next().length > 0 ? $(_previous).next() : $(fO).children(":first");
					
					$(fO).children().css({ zIndex:0 });
					$(_next).css({ zIndex:1 });
					$(_next).animate({ opacity:"show" },this._options.time * 1000,function(fC,fO,fPrevious) {
						return(function() {
							
							$(fPrevious).animate({ opacity:"hide" });
							fC._prepare(fO);
							
						});
					}(this,fO,_previous));
					
				}
				
			};
			
			this._prepare = function(fO) {
				
				window.setTimeout(function(fC,fO) {
					return(function() { fC._change(fO); });
				}(this,fO),this._options.delay * 1000);
				
			};
			
			return this.each(function(fC) {
				return(function() {
					
					fC._change(this);
					
				});
			}(this));
			
		};
	})(jQuery);
	
	/* Slideshow */
	
	(function($) {
		$.focusable = { active:[] };
		$.fn.focusable = function(settings) {
			
			this._options = $.extend({ text:"" },settings);
			
			return this.each(function(fC) {
				return(function() {
					
					$(this).focus(function(fC) {
						return(function() { if ($(this).attr("value") == fC._options.text) $(this).attr("value",""); });
					}(fC));
					$(this).blur(function(fC) {
						return(function() { if ($(this).attr("value") == "") $(this).attr("value",fC._options.text); });
					}(fC));
					
				});
			}(this));
			
		};
	})(jQuery);
	
	/* Search form */
	
	var checkSearch = function() {
		
		var s = "#recherche";
		
		if ($(s).attr("value") == "" || $(s).attr("value") == "Rechercher") {
			alert("La recherche ne peut être vide.");
			$(s).focus();
			return(false);
		} else if ($(s).attr("value").length <= 3) {
			alert("Le texte recherché doit contenir plus de 3 caractères.");
			$(s).focus();
			return(false);
		} else {
			return(true);
		}
		
	};
	
	/* PNG24 */
	
	(function($) {
		$.png24 = { active:[] };
		$.fn.png24 = function(settings) {
			return this.each(function() {
				if (isIE6) {
					switch ($(this).get(0).nodeName.toUpperCase()) {
						case "IMG":
							$(this).css({ filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + $(this).attr("src") + "',sizingMethod='scale')" });
							$(this).attr("src",cfg.dist + "images/empty.png");
						break;
						default:
							if ($(this).css("backgroundImage").length > 7) {
								var img = $(this).css("backgroundImage");
								img = img.substr(5,img.length - 7);
								$(this).css({ filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img + "',sizingMethod='crop')" , background:"none" });
							}
						break;
					}
				}
			});
		};
	})(jQuery);
	
	/* SWF */
	
	function loadFlash(fTarget,fFilename,fP) {
		
		var flashvars = {};
		var params = { scale:"noScale" , align:"BL" , showMenu:"false" };
		var attributes = { id:fTarget , name:fTarget };
		swfobject.embedSWF(fFilename,fTarget,fP.width,fP.height,"8.0.0","swf/expressInstall.swf",flashvars,params,attributes);
		
	}
	
	var charger_flash = loadFlash;
	