function presentFlash(flashSource, bgColor, width, height, wmode, flashVars) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ width +'" height="'+ height +'" id="'+ flashSource +'" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain">');
	document.write('<param name="movie" value="/images/'+ flashSource +'.swf">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="bgcolor" value="'+ bgColor +'">');
	document.write('<param name="menu" value="false">');
	document.write('<param name="wmode" value="'+ wmode +'">');
	document.write('<param name="flashvars" value="'+ flashVars +'">');
	document.write('<embed src="/images/'+ flashSource +'.swf" flashvars="'+ flashVars +'" menu="false" wmode="'+ wmode +'" quality="high" bgcolor="'+ bgColor +'" width="'+ width +'" height="'+ height +'" name="'+ flashSource +'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
	document.write('</object>');
}

//function openDetails(stockNumber) {
//	stockLimo = window.open('/stock/'+stockNumber+'.html', 'stockLimo' ,'menubar=no,toolbar=no,scrollbars=yes,resizable=no,width=406px,height=450px');
//	stockLimo.focus();
//}

function popUp(inv_id) {
	stockLimo = window.open('/sections/sales/details.aspx?inv_id='+inv_id, 'stockLimo' ,'menubar=no,toolbar=no,scrollbars=yes,resizable=no,width=406px,height=450px');
	stockLimo.focus();
}

function popUpImage(img_file, img_w, img_h) {
	stockImage = window.open('/sections/sales/image.aspx?img='+img_file, 'stockImage' ,'menubar=no,toolbar=no,scrollbars=no,resizable=no,width='+img_w+'px,height='+img_h+'px');
	stockImage.focus();
}

function calculateBAC( form ) {
	var bodyWeight, numberOfDrinks, alcoholLevel, numberOfHours, metabolicRate
	var gendervalue, milliliters, ounces, bloodAlcoholLevel, result
	bodyWeight = parseInt( form.bodyWeight.options[form.bodyWeight.selectedIndex].value );
	bodyWeight = bodyWeight / 2.2046;
	numberOfDrinks = parseInt( form.numberOfDrinks.options[form.numberOfDrinks.selectedIndex].value ) * 12;
	alcoholLevel = numberOfDrinks * .045;
	numberOfHours = parseInt( form.numberOfHours.options[form.numberOfHours.selectedIndex].value );
	metabolicRate = numberOfHours * .012;
	gendervalue = .4900;
	if (form.gender.options[form.gender.selectedIndex].value == "male") gendervalue = .5800;
	milliliters = ( bodyWeight * gendervalue ) * 1000;
	ounces = 23.36 / milliliters;
	grams = ( 23.36 / milliliters ) * .806;
	bloodAlcoholLevel = ( ( grams * 100 ) * alcoholLevel ) - metabolicRate;
	if (bloodAlcoholLevel < 0)
	result = "0.0000";
	else
	result = bloodAlcoholLevel.toString().substring(0,6);
	form.average.value = result;
}
