//Written by Manuel Villanueva

function McgPerKgPerMin(form) {

var mcg = form.mcg.value;
var wt = form.wt.value;
var volume = form.volume.value;
var available = form.available.value;
if (form.D1.selectedIndex == 0) {
   
//calculates weight using kg

var answer = (((mcg * wt) / 1000 * 60 ) / available) * volume;
form.answer.value = Math.round(answer);
}

//calculates weight using lbs
else {

var answer = (((mcg * wt / 2.2) / 1000 * 60 ) / available) * volume;
form.answer.value = Math.round(answer);
}

//if statements--
if((form.mcg.value==null)||(form.mcg.value=="")||(isNaN(form.mcg.value))){
alert('Please enter a dose with numbers and or periods only. All other characters are not allowed');
form.mcg.focus();
form.mcg.select();
return false
}
if((form.wt.value==null)||(form.wt.value=="")||(isNaN(form.wt.value))){
alert('Please enter a weight with numbers and or periods only. All other characters are not allowed');
form.wt.focus();
form.wt.select();
return false
}
if((form.available.value==null)||(form.available.value=="")||(isNaN(form.available.value))){
alert('Please enter a dose with numbers and or periods only. All other characters are not allowed');
form.available.focus();
form.available.select();
return false
}
if((form.volume.value==null)||(form.volume.value=="")||(isNaN(form.volume.value))){
alert('Please enter a volume with numbers and or periods only. All other characters are not allowed');
form.volume.focus();
form.volume.select();
return false
}
}