/* 
Created by: Peter Haylock  copyright 2010

*/
function Format(expr,decplaces) 
{ 
var str=""+Math.round(eval(expr)*Math.pow(10,decplaces)); 
while(str.length<=decplaces) 
{ 
str="0"+str; 
} 
var decpoint=str.length-decplaces; 
return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length); 
} 


function startCalc01(){
  interval = setInterval("calc01()",100);
}
function calc01(){
  one = document.autoSumForm.qty01.value;
  two = document.autoSumForm.MachinesDVD01.value;  
  document.autoSumForm.tot01.value = Format((one * 1) * (two * 1),2);
  three = document.autoSumForm.tot01.value;
  four = document.autoSumForm.tot02.value;
  five = document.autoSumForm.tot03.value;
  six = document.autoSumForm.tot04.value;
  seven = document.autoSumForm.tot05.value;
  eight = document.autoSumForm.tot06.value;
  document.autoSumForm.subtot.value = Format((three * 1) + (four * 1) + (five * 1) + (six * 1) + (seven * 1) + (eight * 1),2);
}
function stopCalc01(){
  clearInterval(interval);
}


function startCalc02(){
  interval = setInterval("calc02()",100);
}
function calc02(){
  one = document.autoSumForm.qty02.value;
  two = document.autoSumForm.MachinesDVD02.value;  
  document.autoSumForm.tot02.value = Format((one * 1) * (two * 1),2);
  three = document.autoSumForm.tot01.value;
  four = document.autoSumForm.tot02.value;
  five = document.autoSumForm.tot03.value;
  six = document.autoSumForm.tot04.value;
  seven = document.autoSumForm.tot05.value;
  eight = document.autoSumForm.tot06.value;
  document.autoSumForm.subtot.value = Format((three * 1) + (four * 1) + (five * 1) + (six * 1) + (seven * 1) + (eight * 1),2);
}
function stopCalc02(){
  clearInterval(interval);
}

function startCalc03(){
  interval = setInterval("calc03()",100);
}
function calc03(){
  one = document.autoSumForm.qty03.value;
  two = document.autoSumForm.MachinesDVD0102.value;  
  document.autoSumForm.tot03.value = Format((one * 1) * (two * 1),2);
  three = document.autoSumForm.tot01.value;
  four = document.autoSumForm.tot02.value;
  five = document.autoSumForm.tot03.value;
  six = document.autoSumForm.tot04.value;
  seven = document.autoSumForm.tot05.value;
  eight = document.autoSumForm.tot06.value;
  document.autoSumForm.subtot.value = Format((three * 1) + (four * 1) + (five * 1) + (six * 1) + (seven * 1) + (eight * 1),2);
}
function stopCalc03(){
  clearInterval(interval);
}

function startCalc04(){
  interval = setInterval("calc04()",100);
}
function calc04(){
  one = document.autoSumForm.qty04.value;
  two = document.autoSumForm.MachinesDVD03.value;  
  document.autoSumForm.tot04.value = Format((one * 1) * (two * 1),2);
  three = document.autoSumForm.tot01.value;
  four = document.autoSumForm.tot02.value;
  five = document.autoSumForm.tot03.value;
  six = document.autoSumForm.tot04.value;
  seven = document.autoSumForm.tot05.value;
  eight = document.autoSumForm.tot06.value;
  document.autoSumForm.subtot.value = Format((three * 1) + (four * 1) + (five * 1) + (six * 1) + (seven * 1) + (eight * 1),2);
}

function stopCalc04(){
  clearInterval(interval);
}
function startCalc05(){
  interval = setInterval("calc05()",100);
}
function calc05(){
  one = document.autoSumForm.qty05.value;
  two = document.autoSumForm.StrumpshawDVD.value;  
  document.autoSumForm.tot05.value = Format((one * 1) * (two * 1),2);
  three = document.autoSumForm.tot01.value;
  four = document.autoSumForm.tot02.value;
  five = document.autoSumForm.tot03.value;
  six = document.autoSumForm.tot04.value;
  seven = document.autoSumForm.tot05.value;
  eight = document.autoSumForm.tot06.value;
  document.autoSumForm.subtot.value = Format((three * 1) + (four * 1) + (five * 1) + (six * 1) + (seven * 1) + (eight * 1),2);
}
function stopCalc05(){
  clearInterval(interval);
  }
function startCalc06(){
  interval = setInterval("calc06()",100);
}
function calc06(){
  one = document.autoSumForm.qty06.value;
  two = document.autoSumForm.SuffolkDVD.value;  
  document.autoSumForm.tot06.value = Format((one * 1) * (two * 1),2);
  three = document.autoSumForm.tot01.value;
  four = document.autoSumForm.tot02.value;
  five = document.autoSumForm.tot03.value;
  six = document.autoSumForm.tot04.value;
  seven = document.autoSumForm.tot05.value;
  eight = document.autoSumForm.tot06.value;
  document.autoSumForm.subtot.value = Format((three * 1) + (four * 1) + (five * 1) + (six * 1) + (seven * 1) + (eight * 1),2);
}
function stopCalc06(){
  clearInterval(interval);
}


function delcalc(){
  interval = setInterval("delcalc2()",250);
}
/* orders add £1.95 but if over £100.00 carriage free*/
function delcalc2(){
  if (document.autoSumForm.subtot.value < 100.00) 
	  document.autoSumForm.delivery.value = Format((1.95 * 1),2);
 
  else {
	  document.autoSumForm.delivery.value = Format((0.00 * 1),2);
  }
  }
function stopdelcalc(){
  clearInterval(interval);
}

function totalorder(){
  interval = setInterval("totalorder2()",500);
}
function totalorder2(){
  one = document.autoSumForm.subtot.value;
  two = document.autoSumForm.delivery.value;  
  document.autoSumForm.amount.value = Format((one * 1) + (two * 1),2);
  
}

function stoptotalorder(){
  clearInterval(interval);
}
