/* - - - - - - - - - - - - - - - - - - - - - - -
calculations for all rdshape products - requires global.js
 - - - - - - - - - - - - - - - - - - - - - - - */

var rdshape_types = new Array();

 function calc_rdshape(idx) {
   if (idx == undefined) {
   } else {
     p = document.getElementById('product_price' + idx);
     if (p) {
       pv = p.innerHTML;  //check to make sure a product has a price
       if (pv != '') {
         wght = document.getElementById('product_weight' + idx).innerHTML;  //the weight in grammes

         wght = pv * wght;

         qty = document.getElementById('qty' + idx).value;
         if (qty == '') qty = 0;
         price = parseFloat(wght);
         prc = document.getElementById('price' + idx);
         prc.value = price.toFixed(2);  //round to 4dps at this stage.  IE5.5 and NS6+

         wght = document.getElementById('product_weight' + idx).innerHTML;  //the weight in grammes
         wght = wght * qty;
         dw = document.getElementById('display_weight' + idx);
         if (dw) {
           dw.value = wght;
         };

         finishchrge = 0;
         hm_charge = 0;
         fc_charge = 0;

         //always add the hallmark or fashion charge

         //the hallmark charge
         hmcs = document.getElementById('hallmark_charge'+current_idx);
         if (hmcs) hm_charge = hmcs.value;

         //the fashion charge
         fcs = document.getElementById('fashion_charge'+current_idx);
         if (fcs) fc_charge = fcs.value;

         //the finish charge
         for(i=0;i<fin_charges.length;i++) {
           cd = 'finishing_code'+current_idx+'_'+fin_charges[i][0];
           fchrgeid = document.getElementById(cd);
           if ( (fchrgeid) && (fin_charges[i][1] != '') && (fchrgeid.checked) ) finishchrge = finishchrge + parseFloat(fin_charges[i][1]);
         };
         if (finishchrge == '') finishchrge = 0;

         //add to the price
         prcvalue = parseFloat(price) + parseFloat(hm_charge) + parseFloat(fc_charge) + parseFloat(finishchrge);
         prcvalue = prcvalue * qty;
         prc.value = prcvalue.toFixed(2);
       };
     };
   };
 }
