function check_insc(champ, valeur, id_update) {
	var url = encodeURI('/inscription/index.php?check=1&'+champ+'='+valeur);
	new Ajax.Updater(id_update, url);
}

function check_email_parrainage(champ, valeur, id_update) {
	var url = encodeURI('/inscription/parrainage.php?check=1&'+champ+'='+valeur);
	new Ajax.Updater(id_update, url);
}

function number_format(number, decimals, dec_point, thousands_sep) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://getsprink.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // +    revised by: Luke Smith (http://lucassmith.name)
    // +     bugfix by: Diogo Resende
    // +     bugfix by: Rival
    // +     input by: Kheang Hok Chin (http://www.distantia.ca/)
    // +     improved by: davook
    // +     improved by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: number_format(1234.56);
    // *     returns 1: '1,235'
    // *     example 2: number_format(1234.56, 2, ',', ' ');
    // *     returns 2: '1 234,56'
    // *     example 3: number_format(1234.5678, 2, '.', '');
    // *     returns 3: '1234.57'
    // *     example 4: number_format(67, 2, ',', '.');
    // *     returns 4: '67,00'
    // *     example 5: number_format(1000);
    // *     returns 5: '1,000'
    // *     example 6: number_format(67.311, 2);
    // *     returns 6: '67.31'
    // *     example 7: number_format(1000.55, 1);
    // *     returns 7: '1,000.6'
    // *     example 8: number_format(67000, 5, ',', '.');
    // *     returns 8: '67.000,00000'
    // *     example 9: number_format(0.9, 0);
    // *     returns 9: '1'
    var n = number, prec = decimals;
    var toFixedFix = function (n,prec) {
        var k = Math.pow(10,prec);
        return (Math.round(n*k)/k).toString();
    };
 
    n = !isFinite(+n) ? 0 : +n;
    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
    var sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep;
    var dec = (typeof dec_point === 'undefined') ? '.' : dec_point;
 
    var s = (prec > 0) ? toFixedFix(n, prec) : toFixedFix(Math.round(n), prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;
 
    var abs = toFixedFix(Math.abs(n), prec);
    var _, i;
 
    if (abs >= 1000) {
        _ = abs.split(/\D/);
        i = _[0].length % 3 || 3;
 
        _[0] = s.slice(0,i + (n < 0)) +
              _[0].slice(i).replace(/(\d{3})/g, sep+'$1');
        s = _.join(dec);
    } else {
        s = s.replace('.', dec);
    }
    if (s.indexOf(dec) === -1 && prec > 1) {
        s += dec+new Array(prec).join(0)+'0';
    }
    return s;
}

//'/flash/preview/xeememory'
function AC_FL_RunContent_lite(url, width, height) {
	if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', width,
			'height', height,
			'src', url,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', url,
			'bgcolor', '#ffffff',
			'name', url,
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', url,
			'salign', ''
			); //end AC code
	}
}

function bouton_waiting(bouton_id, texte, loader) {
	texte = typeof(texte) != 'undefined' ? texte : 'Chargement en cours';
	loader = typeof(loader) != 'undefined' ? loader : true;

	$(bouton_id).innerHTML = ((loader) ? '<img src="/images/bouton-loader.gif" width="16" height="16" border="0" align="absbottom"> ' : '') + texte;
}

var indice_gagnant = 0;
function scroll_gagnants() {
    if ($('div_gagnants_' + indice_gagnant)) {
        Effect.toggle('div_gagnants_' + indice_gagnant, 'appear', {
            afterFinish: function() {
                indice_gagnant++;
                if (!$('div_gagnants_' + indice_gagnant)) indice_gagnant = 0;
                Effect.toggle('div_gagnants_' + indice_gagnant, 'slide', {
                    afterFinish: function() {
                        window.setTimeout('scroll_gagnants()', 6000);
                    }
                });
            }
        });
    }
}

var win_encheres;
function display_enchere(id) {
    win_encheres = new Window({
        className: "alphacube",
        title: "Poser une enchère",
        width: 364,
        height: 170,
        zIndex: 100,
        resizable: false,
        showEffect: Effect.Appear,
        hideEffect: Effect.Fade,
        draggable:true,
        wiredDrag: true
    });
    win_encheres.getContent().update('<table width="720" height="540" border="0"><tr><td align="center" valign="center"><img src="/images/ajax-loader.gif" width="32" height="32" border="0"></td></tr></table>');
    win_encheres.showCenter();
    win_encheres.setAjaxContent('/encheres_ajax.php?action=display&id='+id);
}

//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/geral/utf-8 [v1.0]
UTF8 = {
	encode: function(s){
		for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
			s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
		);
		return s.join("");
	},
	decode: function(s){
        /*
		s = s.split("");
        var a, b;
        for(i = 0; i < s.length; i++) {
			a = s[i]["charCodeAt"](0);
            a & 0x80;

        }
        */
        for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
            ((a = s[i][c](0)) & 0x80) &&
            (
                s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
                o(((a & 0x03) << 6) + (b & 0x3f)) :
                o(128), s[++i] = ""
            )
        );

		return s.join("");
	}
};

