// JavaScript Document
//-------------------------------------
//addition of totals
//-------------------------------------
function roundoff(amount) {
return (amount == Math.floor(amount)) ? amount + '.00' : ( (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

function total(what,number) {
var grandextraTotal = 0;
var grandTotal = 0;
var ind_Total = 0;
for (var i=0;i<number;i++) {
if (what.elements['price' + i].value == '')
what.elements['price' + i].value = '0.00'; // fix for Opera.

what.elements['subtotal' + i].value=(what.elements['quantity' + i].value - 0) * (what.elements['price' + i].value - 0);
if (what.elements['quantity' + i].value == "0")
what.elements['subtotal' + i].value = "0.00";

subtotal=what.elements['subtotal' + i].value
grandextraTotal += (what.elements['price' + i].value - 0) * (what.elements['quantity' + i].value - 0);

var frameprice = what.elements['price4'].value;
frameprice = frameprice * 1;
grandTotal = (grandextraTotal+frameprice)*what.elements['qty'].value;
ind_Total = grandextraTotal+frameprice;

}

subtotal=roundoff(Math.round(subtotal*Math.pow(10,2))/Math.pow(10,2));
what.grandextraTotal.value = roundoff(Math.round(grandextraTotal*Math.pow(10,2))/Math.pow(10,2));
what.grandTotal.value = roundoff(Math.round(grandTotal*Math.pow(10,2))/Math.pow(10,2));
what.ind_Total.value = roundoff(Math.round(ind_Total*Math.pow(10,2))/Math.pow(10,2));


}
