weekCost=0;
monthCost=0;
function startCalc(){
  interval = setInterval("calc()",1);
}
function calc(){
  one = document.autoSumForm.firstBox.value;
 //one=0;
  if(one >=1 && one<=5){
  weekCost = 7.0;
  }
  if(one >=6 && one<=10){
  weekCost = 5.0;
  }
  if(one >=11 && one<=99999){
  weekCost = 3.0;
  }
 
  
  
  two = document.autoSumForm.secondBox.value; 
  if(two >=1 && two<=5){
  monthCost = 7.0;
  }
  if(two >=6 && two<=10){
  monthCost = 5.0;
  }
  if(two >=11 && two<=99999){
  monthCost = 3.0;
  }  
    
  
//calculate weekly slips cost
  weekTotal = (weekCost * 1) * (one * 1);
// convert to monthly charge
  //weekToMonth = (weekTotal * 52) / 12;
   weekToMonth = weekTotal;
// calculate the monthly slips total  
  monthTotal = (monthCost * 1) * (two * 1);
//  if( one > 0 ) weekToMonth=weekToMonth + 20; // 
  // add weekly slips costs to monthly slip costs
  roundtotal= weekToMonth + monthTotal
  // round to pence
  finaltotal = roundtotal.toPrecision(3);
  // write to form total field
  document.autoSumForm.thirdBox.value = finaltotal;
 
   
 
}
function stopCalc(){
  clearInterval(interval);
}

function autoSelect(selectTarget) {
 	if(selectTarget != null && ((selectTarget.childNodes.length == 1
      && selectTarget.childNodes[0].nodeName == "#text") || (selectTarget.tagName == "INPUT"
      && selectTarget.type == "text"))) {
  		if(selectTarget.tagName == 'TEXTAREA' || (selectTarget.tagName == "INPUT" && selectTarget.type == "text")) {
  			 selectTarget.select();
  		} else if(window.getSelection) { // FF, Safari, Opera
   			var sel = window.getSelection();
   			var range = document.createRange();
   			range.selectNode(selectTarget.firstChild);
   			sel.removeAllRanges();
   			sel.addRange(range);
  		} else { // IE
   			document.selection.empty();
   			var range = document.body.createTextRange();
   			range.moveToElementText(selectTarget);
   			range.select();
  		}
 	}
}
