function cc_RechercheFormat(v)
{
    v = v.replace('&','%26');
    return v;
}

function cc_RechercheNouveautes(f)
{
    var url    = JS_ABS_URL + '/nouveautes.html';
    var params = new Array();
    var _n     = '';
    // parametres
    var _m     = f.marque.value;
    var _a     = f.aff;
    if( _a[1].checked ) _a = 0; else _a = 1;
    
    if( _m > 0 )
    {
        _n = f.marque.options[f.marque.selectedIndex].text;
        _n = cc_RechercheFormat(_n);
        _n = _n.replace(',','.')
        params[params.length] = 'm' + _m + '-' + _n;
    }

    if( _a == 1 )
        params[params.length] = 'aff-vignettes';
    else
        params[params.length] = 'aff-liste';
    url += '/' + cc_Implode(',',params);
    location.href = url;
}

function cc_Recherche(f)
{
    var url    = JS_ABS_URL + '/recherche.html';
    var params = new Array();
    var _n     = '';
    // parametres
    var _k     = f.keyword.value;
    var _m     = f.marque.value;
    var _a     = f.aff;
    if( _a[1].checked ) _a = 0; else _a = 1;
    var _pxMin = f.px_min.value.replace(' ','');
    var _pxMax = f.px_max.value.replace(' ','');
    var _t     = f.tri.value;
    
    if( _k )
        params[params.length] = cc_RechercheFormat(_k);
    if( _m > 0 )
    {
        _n = f.marque.options[f.marque.selectedIndex].text;
        _n = cc_RechercheFormat(_n);
        _n = _n.replace(',','.')
        params[params.length] = 'm' + _m + '-' + _n;
    }
    if( _pxMin > 0 )
        params[params.length] = 'prix-Min-' + _pxMin+'-Euros';
    if( _pxMax > 0 )
        params[params.length] = 'prix-Max-' + _pxMax+'-Euros';
    if( _t > 0 )
    {
        _n = f.tri.options[f.tri.selectedIndex].text;
        _n = cc_RechercheFormat(_n);
        _n = _n.replace(',','.')
        params[params.length] = 't' + _t + '-' + _n;
    }
    if( _a == 1 )
        params[params.length] = 'aff-vignettes';
    else
        params[params.length] = 'aff-liste';
    url += '/' + cc_Implode(',',params);
    location.href = url;
}

function forceAbsIntVal()
{
    inp   = forceAbsIntVal.arguments[0];
    limit = forceAbsIntVal.arguments[1];
    if( !cc_Isset(limit) ) limit = 0;
    
    nd();
    v = inp.value;
    valeurInitiale = v;
    v = v.replace(/\s/g,'');
    v = supprimerPremiersZeros(v);
    intv = '';
    valide = true;
    for (i = 0; i < v.length; i++)
    {
        var c = v.charAt(i);
        if( !isDigit(c) )
            valide = false;
        else
            intv += c;
    }
    if( !intv ) { inp.value = 0; return; }
    if( valide ) intv = v;
    
    if( limit && intv > limit ) intv = limit;
    intv = espacerChiffres(intv);
    inp.value = intv;
    
    if( !valide )
    {
        overlib('Valeur incorrecte !<br /><b>' + valeurInitiale + '</b> a &eacute;t&eacute; remplac&eacute; par <b> ' + intv + '</b>', STICKY, CAPTION, 'Correction automatique', CENTER);
    }
}

function supprimerPremiersZeros(v)
{
    if( v.indexOf(',') != -1 && v.indexOf(',') < 2 ) return v;
    if( v.indexOf('.') != -1 && v.indexOf('.') < 2 ) return v;
    for (i = 0; i < v.length; i++)
    {
        c = v.charAt(i);
        if( c == 0 ) continue;
        break;
    }
    v = v.substring(i);
    return v;
}

function espacerChiffres(v)
{
    if( v.length <= 3 ) return v;
    newv = '';
    j = -1;
    for (i = v.length; i >= 0; i--)
    {
        if( j == 3 )
        {
            newv = ' ' + newv;
            j = 0;
        }
        j++;
        c = v.charAt(i);
        newv = c + newv;

    }
    return newv;
}