var totalMin = 0;

function clearTotal(){
  totalMin = 0;
  document.mytimecalc.totaltime.value = "0 hrs : 0 min";
}

function zeroTime(){
  document.mytimecalc.myHours.selectedIndex = 0;
  document.mytimecalc.myMinutes.selectedIndex = 0;
}

function addTime(){
  var h = document.mytimecalc.myHours[document.mytimecalc.myHours.selectedIndex].value;
  var m = document.mytimecalc.myMinutes[document.mytimecalc.myMinutes.selectedIndex].value;
  h -= 0;m -= 0;
  h *= 60;
  totalMin = totalMin + h + m;
  updateTotal();
}

function subTime(){
  var h = document.mytimecalc.myHours[document.mytimecalc.myHours.selectedIndex].value;
  var m = document.mytimecalc.myMinutes[document.mytimecalc.myMinutes.selectedIndex].value;
  h -= 0;m -= 0;
  h *= 60;
  totalMin = totalMin - h - m;
  updateTotal();
}

function updateTotal(){
 var h = Math.floor(totalMin / 60);
 var m = (totalMin % 60);
 document.mytimecalc.totaltime.value = h + " hrs : " + m + " min";
}
