var pricedb = new Object()

pricedb["min_sale"] = [{value:"50000", text:"£50,000"},
    {value:"100000", text:"£100,000"},
    {value:"150000", text:"£150,000"},
    {value:"200000", text:"£200,000"},
    {value:"300000", text:"£300,000"},
    {value:"500000", text:"£500,000"},
    {value:"1000000", text:"£1,000,000"},
    {value:"1500000", text:"£1,500,000"}];
    
pricedb["min_rental"] = [{value:"500", text:"£500 pcm"},
    {value:"1000", text:"£1000 pcm"},
    {value:"100000000", text:"£1000+ pcm"}];

pricedb["max_sale"] = [{value:"50000", text:"£50,000"},
    {value:"100000", text:"£100,000"},
    {value:"150000", text:"£150,000"},
    {value:"200000", text:"£200,000"},
    {value:"300000", text:"£300,000"},
    {value:"500000", text:"£500,000"},
    {value:"1000000", text:"£1,000,000"},
    {value:"1500000", text:"£1,500,000"},
    {value:"10000000", text:"£5,000,000+"}];
    
pricedb["max_rental"] = [{value:"100000000", text:"Any"},
    {value:"500", text:"£500 pcm"},
    {value:"1000", text:"£1000 pcm"},
    {value:"100000000", text:"£1000+ pcm"}];

function setPrice(choice, elem) {
    var newElem;
    var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
    var priceSelect = document.getElementById('search-side').elements[elem];
    while (priceSelect.options.length) {
        priceSelect.remove(0);
    }
    
    var priceType;
    
    var db = pricedb[choice];
    newElem = document.createElement("option");
    newElem.text = elem == 'Min_Price' ? "Min. Price" : "Max. Price";
    newElem.value = elem == 'Min_Price' ? "0" : "100000000";
    priceSelect.add(newElem, where);
    if (choice != "") {
        for (var i = 0; i < db.length; i++) {
            newElem = document.createElement("option");
            newElem.text = db[i].text;
            newElem.value = db[i].value;
            priceSelect.add(newElem, where);
        }
    }
}

function loadPrices(module){
    
    //define price
    switch(module){
        case '2':
            setPrice('min_sale', 'Min_Price');
            setPrice('max_sale', 'Max_Price');
            break;
            
        case '4':
            setPrice('min_rental', 'Min_Price');
            setPrice('max_rental', 'Max_Price');
            break;
    }
}
