function doCalc(){
  var fmObj = document.forms[0];
  var val319 = 146417.71; 
  var val320 = 153731.04;
  var val321 = 180315.02;
  var tot319 = 0;
  var tot320 = 0;
  var tot321 = 0;
  var tmpTot = 0;
  var tmpCalcText;
  
  //first - send funnel tracking to google analytics
  urchinTracker("/calculator/submit");
  if(isNaN(parseInt(fmObj.yis.value)) || parseInt(fmObj.yis.value)==0){
    if(isNaN(parseInt(fmObj.yis.value))){
      alert("The value entered in 'Years in Service' is not a valid number.");
	}else{
	  alert("A zero entered in the 'Years in Service' field will not yeild any savings results. Please enter a number greater than zero.");
	}
    fmObj.yis.focus();
	fmObj.yis.select();
    return;
  }else{
    var tmpYis = parseInt(fmObj.yis.value);
  }
  //calculate the total for each type
  if(fmObj.A319.value!="0"){
    if(isNaN(parseInt(fmObj.A319.value))){
      alert("The number of aircraft entered in the 'A319' field is not a valid number.");
	  fmObj.A319.focus();
	  fmObj.A319.select();
      return;
	}else{
	  tot319 = parseFloat(fmObj.A319.value) * val319 * tmpYis;
	}
  }
  if(fmObj.A320.value!="0"){
    if(isNaN(parseInt(fmObj.A320.value))){
      alert("The number of aircraft entered in the 'A320' field is not a valid number.");
	  fmObj.A320.focus();
	  fmObj.A320.select();
      return;
	}else{
	  tot320 = parseFloat(fmObj.A320.value) * val320 * tmpYis;
	}
  }
  if(fmObj.A321.value!="0"){
    if(isNaN(parseInt(fmObj.A321.value))){
      alert("The number of aircraft entered in the 'A321' field is not a valid number.");
	  fmObj.A321.focus();
	  fmObj.A321.select();
      return;
	}else{
  	  tot321 = parseFloat(fmObj.A321.value) * val321 * tmpYis;
	}
  }
  //now build the results string
  tmpTot = tot319 + tot320 + tot321;
  fmtTot = addSeps(tmpTot.toFixed(2));
  tmpCalcText="Total savings: $" + fmtTot + "\n";
  if(tot319!=0){
    fmt319 = addSeps(tot319.toFixed(2));
    tmpCalcText+="A319 savings: $" + fmt319 + "\n";
  }
  if(tot320!=0){
    fmt320 = addSeps(tot320.toFixed(2));
    tmpCalcText+="A320 savings: $" + fmt320 + "\n";
  }
  if(tot321!=0){
    fmt321 = addSeps(tot321.toFixed(2));
    tmpCalcText+="A321 savings: $" + fmt321 + "\n";
  }
  //display the results
  fmObj.calcresult.value=tmpCalcText;
  document.getElementById('GaugeAnimation').SetVariable("action", true);
}

function addSeps(S){
    S = String(S);
    var RgX = /^(.*\s)?([-+\u00A3\u20AC]?\d+)(\d{3}\b)/;
    return S == (S = S.replace(RgX, "$1$2,$3")) ? S : addSeps(S);
}
	
function clearCalc(){
  var fmObj = document.forms[0];
  fmObj.A319.value="0";
  fmObj.A320.value="0";
  fmObj.A321.value="0";
  fmObj.yis.value="0"
  fmObj.calcresult.value=" ";
  document.getElementById('GaugeAnimation').SetVariable("action", false);
}

function popAssumptions(){
  window.open('assumptions.html','','height=500,width=440,scrollbars=yes,resizable=yes');
}