weekCost=0;
monthCost=0;
one=0;
two=0;

function startCalc(){
  interval = setInterval("calc()",1);
}
function calc(){
  one = document.autoSumForm.firstBox.value;
  if(one > 10 ){
  weekCost = 1.75
  }
  
  two = document.autoSumForm.secondBox.value; 
  if(two > 10 && two< 25){
  monthCost = 2.00
  }
  if(two >25 ){
  monthCost = 1.75
  }
 

 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  
  if(two<=10){
	  monthTotal = 20.00;
  } else {
	  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(two>=1 && two <=10){
		if(one >= 1  && one <= 10){
		temp=75.00 + monthTotal;
		temp2=temp.toPrecision(4);
		document.autoSumForm.thirdBox.value = temp2;
	  }
  }else if(two==0){
		if(one >= 1  && one <= 10){
		temp=75.00;
		temp2=temp.toPrecision(4);
		document.autoSumForm.thirdBox.value = temp2;
	  }
  }
  
  if((one <10 && one >0)  && two > 10){
		temp=75.00 + monthTotal;
		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();
  		}
 	}
}
