function trim (str, charlist) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: mdsjack (http://www.mdsjack.bo.it)
    // +   improved by: Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev)
    // +      input by: Erkekjetter
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: DxGx
    // +   improved by: Steven Levithan (http://blog.stevenlevithan.com)
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // *     example 1: trim('    Kevin van Zonneveld    ');
    // *     returns 1: 'Kevin van Zonneveld'
    // *     example 2: trim('Hello World', 'Hdle');
    // *     returns 2: 'o Wor'
    // *     example 3: trim(16, 1);
    // *     returns 3: 6

    var whitespace, l = 0, i = 0;
    str += '';

    if (!charlist) {
        // default list
        whitespace = " \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";
    } else {
        // preg_quote custom list
        charlist += '';
        whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
    }

    l = str.length;
    for (i = 0; i < l; i++) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(i);
            break;
        }
    }

    l = str.length;
    for (i = l - 1; i >= 0; i--) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(0, i + 1);
            break;
        }
    }

    return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}
function strtolower( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Onno Marsman
    // *     example 1: strtolower('Kevin van Zonneveld');
    // *     returns 1: 'kevin van zonneveld'

    return (str+'').toLowerCase();
}
function str_replace(search, replace, subject) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir (http://brettz9.blogspot.com)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'

    var s = subject;
    var ra = r instanceof Array, sa = s instanceof Array;
    var f = [].concat(search);
    var r = [].concat(replace);
    var i = (s = [].concat(s)).length;

    var j = 0;

    while (j = 0, i--) {
        if (s[i]) {

            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    }

    return sa ? s : s[0];
}

function slugify(text)
{
    var voyelleaccent   = new Array(".","€","Â", "à", "â", "ä", "É", "é", "È", "è", "Ê", "ê", "ë", "ï", "î", "ô", "ö", "û", "ü", "ù", "ç");
    var voyellessaccent = new Array("","euros","A", "a", "a", "a", "E", "e", "E", "e", "E", "e", "e", "i", "i", "o", "o", "u", "u", "u", "c");

    for(i=0;i<voyelleaccent.length;i++)
    {
        text = str_replace(voyelleaccent[i], voyellessaccent[i],text);
    }


    //text = str_replace(voyelleaccent, voyellessaccent,text);

    // replace all non letters or digits by -

    text=text.replace(/\W+/g,"-")
    //text = preg_replace('/\W+/', '-', text);

    // trim and lowercase
    text = strtolower(trim(text, '-'));

    return text;
}

function testerRadio(radio) {
    theone=-1;
    for (var i=0; i<radio.length;i++) {
      
        if (radio[i].checked) {
            theone=i
        }
    }
    return theone
}

function actionRechercheSimple()
{
    //RewriteRule annonces-immobilieres/([a-z]*)-([a-z]*)-([a-z]*),([0-9]+)\.htm index.inc.php?page=recherche&nomtransaction=$1&nombien=$2&nomville=3&numpage=$4 [L]


    numtransaction=testerRadio(document.recherche.idtransaction)
    
   
    numbien=document.recherche.idcategorie.options.selectedIndex
    numville=document.recherche.idville.options.selectedIndex
    numbudget=document.recherche.idfourchetteprix.options.selectedIndex
    
    ch="annonces-immobilieres/";

    if (document.recherche.idtransaction[numtransaction].value==1)
    {
        ch=ch+"vente-";
        if (numbien>0)
            ch=ch+slugify(document.recherche.idcategorie.options[numbien].text);
        ch=ch+"-"
        if (numville>0)
            ch=ch+slugify(document.recherche.idville.options[numville].text);
        ch=ch+"-"
        if (numbudget>0)
            ch=ch+slugify(document.recherche.idfourchetteprix.options[numbudget].text);
    }
    else
    {
        ch=ch+"location-";
        if (numbien>0)
            ch=ch+slugify(document.recherche.idcategorie.options[numbien].text);
        ch=ch+"-"
        if (numville>0)
            ch=ch+slugify(document.recherche.idville.options[numville].text);
        
    }
    

        
        
       
    ch=ch+",0.html";
    

    // alert(ch)

    document.recherche.action=ch;
    document.recherche.submit()
    

}






