// JavaScript Document
// calculate price based on quantity
function changeQty(change,id){
	
	
	
	var prodid = 'qnt_' + id;
	if($(prodid)){
		var qtd = $F('qnt_' + id);
		var currentQty = parseInt(qtd);
	    
	    switch (change) {
	        case 'add':
	            currentQty += 1
	            $(prodid).value = currentQty
	            break
	        case 'subtract':
	            if (currentQty > 0) { // only subtract if qty is greater than zero
	                currentQty -= 1
	                $(prodid).value = currentQty
	            }
	            break
	    }
	}
    
}
function calculate(prodid){
	if($(prodid)){
		var qtd = $F(prodid);
	var currentQty = parseInt($F(qtd)) // Where quant is the id of your quantity input field. Gets value of currentQty field    
	var jsnormalprice = $F('jsnormalprice') // Where jsnormalprice is the id of your hidden base price field. Gets value of base_price field	
	var jsspecialprice = $F('jsspecialprice') // Where  is the id of your hidden base price field. Gets value of base_price field	

	if (currentQty > 0) { // Don't want price to display if zero if customer zeros out quantity
        var new_jsnormalprice = jsnormalprice * currentQty // Calculate the price.		
        var new_jsnormalprice = new_jsnormalprice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down.
		
        var new_jsspecialprice = jsspecialprice * currentQty // Calculate the price.		
        var new_jsspecialprice = new_jsspecialprice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down.
    
	} else { // set price back to original price
        new_jsnormalprice = jsnormalprice
        new_jsspecialprice = jsspecialprice
    }	
	
    $('jsnormalpriceshow').update(new_jsnormalprice) // Where jsnormalpriceshow is the id of your span for the echoed product price
    $('jsspecialpriceshow').update(new_jsspecialprice) // Where jsspecialpriceshow is the id of your span for the echoed product price
	}
}


