// JavaScript Document
// calculate price based on quantity
function changeQty(change){
    var currentQty = parseInt($F('quant')) // Where quant is the id of your quantity input field. Gets value of currentQty field
    
    switch (change) {
        case 'add':
            currentQty += 1
            $('quant').value = currentQty
            calculate()
            calculate1()
            break
        case 'subtract':
            if (currentQty > 0) { // only subtract if qty is greater than zero
                currentQty -= 1
                $('quant').value = currentQty
                calculate()
                calculate1()
            }
            break
        case 'field':
            if (currentQty >= 0) {
                window.setTimeout('calculate()', 500)
                window.setTimeout('calculate1()', 500)
            }
            break
    }
}
function calculate(){
    var startPrice = $F('base_price') // Where base_price is the id of your hidden base price field. Gets value of base_price field
    var currentQty = parseInt($F('quant')) // Where quant is the id of your quantity input field. Gets value of currentQty field
    
    if (currentQty > 0) { // Don't want price to display if zero if customer zeros out quantity
        var qtyPrice = startPrice * currentQty // Calculate the price.
        var qtyPrice = qtyPrice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down.
    } else { // set price back to original price
        qtyPrice = startPrice
    }
    var qtyPrice = qtyPrice + " €"  // do not Add a dollar sign
  

    $('priceHeading2').update(qtyPrice) // Where priceHeading2 is the id of your span for the echoed product price
    new Effect.Highlight($('priceHeading2'))
}
function calculate1(){
    var startPrice = $F('base_price1') // Where base_price is the id of your hidden base price field. Gets value of base_price field
    var currentQty = parseInt($F('quant')) // Where quant is the id of your quantity input field. Gets value of currentQty field
    
    if (currentQty > 0) { // Don't want price to display if zero if customer zeros out quantity
        var qtyPrice = startPrice * currentQty // Calculate the price.
        var qtyPrice = qtyPrice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down.
    } else { // set price back to original price
        qtyPrice = startPrice
    }
    var qtyPrice = qtyPrice + " €"  // do not Add a dollar sign
    //qtyPrice = str.replace('.',',',qtyprice)

    $('priceHeading3').update(qtyPrice) // Where priceHeading3 is the id of your span for the echoed product price
    new Effect.Hightlight($('priceHeading3'),'#CACACA','#131313')
}
