function CalcBAC(mBodyWeight, mPercentWater, mgEtOH, mMetabolicRate) {
        var mTimeHours = 1.0*document.getElementById('txtHours').value;
		var mTimeMinutes = 1.0*document.getElementById('txtMinutes').value;
		var mTimeInHours=mTimeHours + mTimeMinutes/60;
	   if (Validate(mTimeInHours)) {   
		//Based on calculations done by http://www.nhtsa.dot.gov/people/injury/alcohol/bacreport.html
		//I'm following their math by each letter -- if you're confused by a step, check out the website and go to the letter for more information
		//A) Convert weight to kg
		var mBodyWeightKG = document.getElementById('txtWeight').value;  //100
		//B) Find total body water
		var mBodyWaterML = mBodyWeightKG * mPercentWater * 1000;	//Men have a higher water content than women    58000
		//C) cGramsPerOzEtOH is a constant variable (above)
		//D) Find alcohol per mL of water
		var mConcEtOHinWater = mgEtOH / mBodyWaterML;  //23.36 * 0.48/58000= 0.000193324
		
		//E) Find alcohol per mL of blood
		var mConcEtOHinBlood = mConcEtOHinWater * .806; //Blood is 80.6% water      0.000155819
		//F) Convert mConcEtOHinBlood from g/mL to g/100 mL (gram percent)
		var mGramPercentEtOHinBlood = mConcEtOHinBlood * 100;  //0.0155819
		//Note: mGramPercentEtOHinBlood is the BAC with instant consumption, absorption, and distribution
		//G) G was taken care of back in D with the variable mOuncesEtOH
		//H) Calculate BAC after time span
		var mBAC = mGramPercentEtOHinBlood - (mMetabolicRate * mTimeInHours);  //0.0155819- (0.01*1)= 0.0055819
		if(mBAC < 0) { mBAC = 0; }
		
		var mDrive = (Math.round( (mBAC - .05) / mMetabolicRate * 1000)/1000);
		
		var mSober = (Math.round(mBAC / mMetabolicRate * 10000)/10000);
		if (mDrive < 0) { mDrive = 0; }
		if (mSober < 0) { mSober = 0; }
		var hourDrive = (Math.floor( mDrive));
		var minDrive = Math.round((mDrive - hourDrive)* 60);
		var hourSober = (Math.floor( mSober));
		var minSober = Math.round((mSober - hourSober)* 60);
		document.getElementById('lblBAC').value ='Το επίπεδο αλκοόλης στο αίμα σας εκτιμάται τώρα ίσο με ' + (Math.round(mBAC*1000)/1000) +' g / 100 mL.';
		document.getElementById('lblDrive').value ='Μπορείτε να οδηγήσετε νόμιμα σε  ' + hourDrive + ' ώρες και ' + minDrive + ' λεπτά από τώρα.';
		document.getElementById('lblSober').value ='Το επίπεδο της αλκοόλης στο αίμα σας θα μηδενιστεί σε  ' + hourSober + ' ώρες και ' + minSober + ' λεπτά από τώρα.';
	
		}
}


function SetEtOHValues() {
	document.getElementById('txtPctEtOH').value = document.getElementById('lstDrinks').value ;
}
function AddEtOH() {
	var currentEtOH =document.getElementById('txtOuncesEtOH').value;
	currentEtOH = eval(currentEtOH) + (.01 * document.getElementById('txtPctEtOH').value * document.getElementById('txtServingsEtOH').value * document.getElementById('drpServingType').value*0.79);
    document.getElementById('txtOuncesEtOH').value =Math.round(currentEtOH*100)/100  ;
	document.getElementById('txtServingsEtOH').value = 0;
	document.getElementById('lblBAC').value = '';
	document.getElementById('lblDrive').value = '';
	document.getElementById('lblSober').value = '';
}
function ClearEtOH() {
    document.getElementById('txtOuncesEtOH').value =0 ;
	document.getElementById('txtServingsEtOH').value = 0;
	document.getElementById('lblBAC').value = '';
	document.getElementById('lblDrive').value = '';
	document.getElementById('lblSober').value = '';
}
function Validate(time) {
	if (document.getElementById('txtOuncesEtOH').value == 0) {
		alert('Πρέπει να καθορίσετε τουλάχιστον ένα ποτό για να \rυπολογισθεί το επίπεδο αλκοόλης στον οργανισμό σας.');
		return false;
	}
	if (document.getElementById('txtWeight').value == 0) {
		alert('Πρέπει να καθορίσετε το βάρος σας για να \rυπολογισθεί το επίπεδο αλκοόλης στον οργανισμό σας.');
		return false;
	}

	if (time< 1.0) {
		alert('Πρέπει να καθορίσετε παρέλευση τουλάχιστον \rμιας ώρας από την κατανάλωση των ποτών.');
		return false;
	}
return true;
}
