/* - - - - - - - - - - - - - - - - - - - - - - -
calculations for tool - requires global.js
 - - - - - - - - - - - - - - - - - - - - - - - */


var tool_types = new Array();

 function calc_tool(idx) {
     p = document.getElementById('product_price' + idx);
     if (p) {
       pv = p.innerHTML;  //check to make sure a product has a price
       if (pv != '') {
         //if there is a unit weight associated with this unit - then use that one
         qty = document.getElementById('qty' + idx);
         wu  = document.getElementById('weight_unit' + idx);
         if (wu.innerHTML == 'GM') {  //need to multiply by gram weight
           w  = document.getElementById('product_weight' + idx);
           wght = w.innerHTML;

					 dw = document.getElementById('display_weight'+idx);
					 if (dw) {
             p = wght * qty.value;
             dw.value = p;
					 };	 
         } else {  //charge each
           wght = 1;
         };

         if ( wght == NaN || wght == '' ) wght = 0;

         price = (pv * wght) * qty.value;

         prc = document.getElementById('price' + idx);
         prc.value = price.toFixed(2);  //round to 4dps at this stage.  IE5.5 and NS6+
       };
     };
 }
