	WIN = (navigator.appVersion.indexOf("Windows")!=-1);
	MAC = (navigator.appVersion.indexOf("Machintosh")!=-1);
	OTH = !WIN && !MAC;

	OPERA = (navigator.userAgent.indexOf("Opera") != -1)
	IE4 = (navigator.appName=='Microsoft Internet Explorer') && (parseFloat(navigator.appVersion)>=4) && !OPERA;
	IE8 = IE4 && (navigator.appVersion.indexOf("MSIE 8") != -1) && WIN;
	IE7 = IE4 && (navigator.appVersion.indexOf("MSIE 7") != -1) && WIN;
	IE6 = IE4 && (navigator.appVersion.indexOf("MSIE 6") != -1) && WIN;
	IE5 = (IE4 && (navigator.appVersion.indexOf("MSIE 5") != -1) && WIN) || IE6;
	NS6 = (navigator.appName=='Netscape') && (parseFloat(navigator.appVersion)>=5);
	NS4 = !NS6 && (navigator.appName=='Netscape') && (parseFloat(navigator.appVersion)>=4);
	IE4 = IE4 && !IE5 && !IE6;

	var elementFocused = null;
	var TabMoyenPaiement = [1, 2, 3, 4, 5, 6];
	
	function arret() {
		if (IE5 || IE6 || IE7) document.execCommand('Stop');
		else stop();
	}
	
	function NavPageT(url) {
		NavPage(url,$("#nbppage").val(),$("#triprix").val());
	}

	function NavPage(url,nbpp,tripx) {
		$.ajax({
			type: "POST",
			url: "./util/php/Ajax/produit/MAJFiltrePrix.php",
			data: "url=" + url + "&n=" + nbpp + "&t=" + tripx,
			success: function(retour) {
				//alert(retour);
				eval(retour);
			}
		});
	}

	function in_array(needle, haystack, argStrict) {
		var key = '', strict = !!argStrict;
		if(strict) {
			for(key in haystack) {
				if(haystack[key] === needle) return true;
			}
		}
		else {
			for(key in haystack) {
				if (haystack[key] == needle) return true;
			}
		}
		return false;
	}


	Array.prototype.in_array = function(p_val) {
		for(var i = 0, l = this.length; i < l; i++) {
			if(this[i] == p_val) {
				rowid = i;
				return true;
			}
		}
		return false;
	}

	var test = "oui";
	
	// Cache et affiche les select seulement pour ie 6 !!
	function cache_select() {
		var br = $.browser;
		if(br.msie && br.version < 7) $("select").hide();
	}
	function affiche_select() {
		var br = $.browser;
		if(br.msie && br.version < 7) $("select").show();
	}

	// Cache et affiche les flash !
	function cache_flash() {
		$("object, embed").each(function(){
			if($(this).parent().attr("id")!="pub_flash") $(this).css('display','none');
		});
	}
	function affiche_flash() {
		$("object, embed").each(function(){
			if($(this).parent().attr("id")!="pub_flash") $(this).css('display','block');
		});
	}

	function lanceTri(id) {
		urlDep = $("#urlDepart").val();
		switch(id) { 
			case "prix" :
				if(urlDep.indexOf("?triprix") > 0) texteASup = "?triprix";
				else texteASup = "&triprix";
				if($("#triprix").val() == "asc") urlDep = urlDep.replace(texteASup + "=desc", "");
				else urlDep = urlDep.replace(texteASup + "=asc", "");
				if(urlDep.indexOf("?") > 0) $(location).attr("href",urlDep + "&triprix=" + $("#triprix").val());
				else $(location).attr("href", urlDep + "?triprix=" + $("#triprix").val());
			return;
			case "nbppage" :
				if(urlDep.indexOf("?nbppage") > 0) deb = urlDep.indexOf("?nbppage");
				else deb = urlDep.indexOf("&nbppage");
				if(deb > 0) {
					texteASup = urlDep.substr(deb, 11);
					urlDep = urlDep.replace(texteASup, "");
				}
				if(urlDep.indexOf("?") > 0) $(location).attr("href", urlDep + "&nbppage=" + $("#nbppage").val());
				else $(location).attr("href", urlDep + "?nbppage=" + $("#nbppage").val());
			return;
		}
	}

	function lanceTriBas(id) {
		urlDep = $("#urlDepart").val();
		switch(id) {
			case "prix" :
				if(urlDep.indexOf('?triprix') > 0) texteASup = "?triprix";
				else texteASup = "&triprix";
				if($("#triprixBas").val() == "asc") urlDep = urlDep.replace(texteASup + "=desc", "");
				else urlDep = urlDep.replace(texteASup + "=asc", "");
				if(urlDep.indexOf("?") > 0) $(location).attr("href",  urlDep + "&triprix=" + $("#triprixBas").val());
				else $(location).attr("href", urlDep + "?triprix=" + $("#triprixBas").val());
			return;
			case "nbppageBas" :
				if(urlDep.indexOf('?nbppage') > 0) deb = urlDep.indexOf("?nbppage");
				else deb = urlDep.indexOf("&nbppage");
				if(deb > 0) {
					texteASup = urlDep.substr(deb, 11);
					urlDep = urlDep.replace(texteASup, "");
				}
				if(urlDep.indexOf("?") > 0) $(location).attr("href", urlDep + "&nbppage=" + $("#nbppageBas").val());
				else $(location).attr("href", urlDep + "?nbppage=" + $("#nbppageBas").val());
			return;
		}
	}

	function executeForm(idform, task) {
		$("#" + idform + " input[name=cas]").val(task);
		$("#" + idform).submit();
	}

	function openCalc(id) {
		$("#verrou").css("width",$(document).width() + "px");
		$("#verrou").css("height",$(document).height() + "px");
		windowCenter(id);
		$(document).scrollTop(0);
		$(document).scrollLeft(0);
		$("#verrou").show("Fast");
		$("#"+id).show("Fast");
		cache_select();
		cache_flash();
	}

	function closeCalc(id) {
		$("#verrou").hide();
		$("#"+id).hide();
		affiche_select();
		affiche_flash();
	}

	function setFocus(obj) {
		elementFocused = obj;
	}

	function unsetFocus() {
		elementFocused = null;
	}

	function lanceAction(e) {
		var code = (e.keyCode ? e.keyCode : e.which);
		if((elementFocused != null) && (code == 13)) {
			switch(elementFocused.id) {
				case "rech_mots" : case "rech_marque" : case "rech_categorie" : lance_recherche(); break;
				case "emailIN" : executeForm('inscrip_newsletter', 'inscription_newsletter'); break;
				case "mdp_log" : case "email_log" : executeForm('form_mini_log', 'valid_log'); break;
				case "codeOffre" : valideRemise(window.document.getElementById('identiteClient').value); break;
				default:return;
			}
		}
	}

	function sleep(milliseconds) {
		var start = new Date().getTime();
		while(true) {
			if((new Date().getTime() - start) > milliseconds) break;
		}
	}

	function windowCenter(myId) {
		var EcranWidth = $(window).width();
		var EcranHeight = $(window).height();
		
		ElementWidth = $("#" + myId).width();
		ElementHeight = $("#" + myId).height();
		
		if((EcranHeight) < ElementHeight){
			$("#" + myId).height(EcranHeight - 10);
			$("#" + myId).width(ElementWidth + 15);
			$("#" + myId).css("overflow","auto");
			ElementWidth = $("#" + myId).width();
			ElementHeight = $("#" + myId).height();
		}
		
		var posX = parseInt((EcranWidth - ElementWidth)/2);
		var posY = parseInt((EcranHeight - ElementHeight)/2);
		
		$("#" + myId).css("left", posX+"px");
		$("#" + myId).css("top", posY+"px");
	}

	function addToFavorites(anchor) {
		if (window.external) window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
	}

	function init_input(id, txt) {
		if($("#"+id).val() == txt) $("#"+id).val("");
		else {
			if($("#"+id).val() == "") $("#"+id).val(txt);
		}
	}

	function cache_err(num) {
		$("#err_" + num).hide("fast")
	}

	function lance_recherche() {
		init_input('rech_mots', 'Mots clés, Référence...');
		$(".rech_bt").css("visibility","hidden");
		$.ajax({
			type: "POST",
			url: "./util/php/Ajax/recherche/lance_recherche.php",
			data: "mq=" + $("#rech_marque").val() + "&cat=" + $("#rech_categorie").val() + "&mots=" + escape($("#rech_mots").val()),
			success: function(retour) {
				if(retour.length) $(location).attr("href",retour);
				else {
					alert("Veuillez effectuer une autre recherche");
					$(".rech_bt").css("visibility","visible");
				}
			}
		});
	}

	Number.prototype.nombreFormate = function (decimales, signe, separateurMilliers) {
		var _sNombre = String(this), i, _sRetour = "", _sDecimales = "";
		if (decimales == undefined) decimales = 2;
		if (signe == undefined) signe = '.';
		if (separateurMilliers == undefined) separateurMilliers = ' ';

		function separeMilliers (sNombre) {
			var sRetour = "";
			while (sNombre.length % 3 != 0) {
				sNombre = "0"+sNombre;
			}
			for (i = 0; i < sNombre.length; i += 3) {
				if (i == sNombre.length-1) separateurMilliers = '';
				sRetour += sNombre.substr(i, 3)+separateurMilliers;
			}
			while (sRetour.substr(0, 1) == "0") {
				sRetour = sRetour.substr(1);
			}
			return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers));
		}
		if (_sNombre.indexOf('.') == -1) {
			for (i = 0; i < decimales; i++) {
				_sDecimales += "0";
			}
			_sRetour = separeMilliers(_sNombre)+signe+_sDecimales;
		} else {
			var sDecimalesTmp = (_sNombre.substr(_sNombre.indexOf('.')+1));
			if (sDecimalesTmp.length > decimales) {
				var nDecimalesManquantes = sDecimalesTmp.length - decimales;
				var nDiv = 1;
				for (i = 0; i < nDecimalesManquantes; i++) {
					nDiv *= 10;
				}
				_sDecimales = Math.round(Number(sDecimalesTmp) / nDiv);
			}else{
				_sDecimales = sDecimalesTmp;
				for (i = sDecimalesTmp.length; i < decimales; i++) {
					_sDecimales += "0";
				}     
			}
			_sRetour = separeMilliers(_sNombre.substr(0, _sNombre.indexOf('.')))+String(signe)+_sDecimales;
		}
		if(_sRetour.length == decimales + 1){
			_sRetour ='0'+_sRetour;
		}
		return _sRetour;
	}
	
	function goToByScroll(id) {
		$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
	}

