// Discount source code

// array definition follows as such: Array(percentage discount, amount to obtain discount)
var discount = new Array(new Array(.05, 100.00),new Array(.10, 250.00));

// takes a number(price) and returns the discounted price.
function discountedPrice(price){
    var val = price;
    for(i = 0; i<discount.length; i++){
        if(price >= discount[i][1]){
            val = price - (price*discount[i][0]);
        }
    }
    
    val=""+Math.round(100*val); 
    var dec_point=val.length-2;
    var first_part=val.substring(0,dec_point);
    var second_part=val.substring(dec_point,val.length);
    var result=first_part+"."+second_part;

    // "3" + decimal point + "14"
    return ("$" + result);
}