function formatCurrency(num) {
  num = num.toString().replace(/\$|\,/g,'');
  if(isNaN(num))
    num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
  if(cents<10)
    cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    num = num.substring(0,num.length-(4*i+3))+','+
    num.substring(num.length-(4*i+3));
  return (((sign)?'':'-') + '$' + num + '.' + cents);
}
function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function jumpTo(URL_List){

if (!(IsNumeric(URL_List.value)))  {URL_List.value=0;} //set quantity to 0 if not numeric

	var controlName = URL_List.name;
	var price = URL_List.itemPrice;
	var prevValue = URL_List.prevValue;
	//alert ("previous before update:" + prevValue);
	//alert ("price2:"+ price2 + ":" + formatCurrency(price2));
	jumpTo.total = jumpTo.total - (prevValue*price); //subtract from total previous quantity in this box
	//alert ("total after subtracting:" + jumpTo.total);
	jumpTo.total = jumpTo.total + (URL_List.value * price);
	URL_List.prevValue = URL_List.value;
	document.materials_form.t_total.value = formatCurrency(1* jumpTo.total); //tot
}
// To define the static variable, just set it as a property of the function:
//  static variables can only be defined after they are used in the function.
jumpTo.total = 0;

