weekCost=0;
monthCost=0;
function startCalc(){
  interval = setInterval("calc()",1);
}
function calc(){
  one = document.autoSumForm.firstBox.value;
  if(one >7 && one<11){
  weekCost = 2.00
  }
  if(one >11 && one<26){
  weekCost = 1.75
  }
  if(one >25 && one<51){
  weekCost = 1.50
  }  
  
  two = document.autoSumForm.secondBox.value; 
  if(two >1 && two<8){
  monthCost = 3.00
  }
  if(two >7 && two<11){
  monthCost = 2.00
  }
  if(two >10 && two<26){
  monthCost = 1.75
  }
  if(two >11 && two<26){
  monthCost = 1.75
  }
  if(two >25 && two<51){
  monthCost = 1.65
  }  
  if(two >50){
  monthCost = 1.50
  }

 if(one >100){
document.autoSumForm.firstBox.value = 100;  
}
//calculate weekly slips cost
  weekTotal = (weekCost * 1) * (one * 1);
// convert to monthly charge
  weekToMonth = (weekTotal * 52) / 12;
// calculate the monthly slips total  
  monthTotal = (monthCost * 1) * (two * 1);
  // add weekly slips costs to monthly slip costs
  roundtotal= weekToMonth + monthTotal
  // round to pence
  finaltotal = roundtotal.toPrecision(4);
  // write to form total field
  document.autoSumForm.thirdBox.value = finaltotal;
  
  if(weekTotal + monthTotal < 15){
 	//document.autoSumForm.thirdBox.value = "£10.00";
  }
  if(one == 0 && two < 8){
 	document.autoSumForm.thirdBox.value = "15.00";
  }
    if(one > 0 && one < 8){
	temp=65.00 + (two * monthCost);
	temp2=temp.toPrecision(4);
 	document.autoSumForm.thirdBox.value = temp2;
  }
}
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();
  		}
 	}
}