// Calculator by David Battino, www.batmosphere.com 
function durCalc()
{
var dc = document.getElementById("DurationCalc"); 
var thebpm = dc.bpm.value;
if ((thebpm==0) || isNaN(thebpm) ) // bpm field is blank or non-numeric
{ 
alert("Please enter a valid tempo in beats per minute (bpm)."); 
document.getElementById("DurationCalc").bpm.value = "";
document.getElementById("DurationCalc").Duration.value = "";
return;
}

var DivideIt = eval(6000000 / thebpm); 
var TheDuration = "" + Math.round(DivideIt); // convert total to a string so we can fix # of digits
var dec_point=TheDuration.length-2; 
var first_part=TheDuration.substring(0,dec_point); 
var second_part=TheDuration.substring(dec_point,TheDuration.length); 
var result=first_part+"."+second_part; 
document.getElementById("DurationCalc").Duration.value = result;
}

