/* Common JS to calculate a price range*/

function priceRange(lang, price) {

    //First, remove the formatting, if any...
    //one does the spaces, one does the hex "a0", and one does "$"...
    price = price.replace(/ /gi, "");
    price = price.replace(/ /gi, "");
    price = price.replace(/\$/gi, "");

    if (lang=="en") {
        price = price.replace(/,/gi, "");
    } else {
        price = price.replace(/,/gi, ".");
    }

    if (price<22000) {
        sPrice="<22,000";
    } else if (price>=22000 && price <30000) {
        sPrice="22,000-30,000";
    } else if (price>=30000 && price <40000) {
        sPrice="30,000-40,000";
    } else if (price>=40000 && price <50000) {
        sPrice="40,000-50,000";
    } else if (price>50000) {
        sPrice=">50,000";
    } else {
        sPrice="Error";
    }
    
    return sPrice;
}

