
	measure = 'Gallon';
	cmeasure = 'Gas'
	currency = '$';
	
document.write('<script src="http://commutebybike.com/js/prototype.js" type="text/javascript"></script>'); 
document.write('<script src="http://commutebybike.com/js/effects.js" type="text/javascript"></script>');

function dogascalc() {
	if (isNaN(document.getElementById('miles').value) || isNaN(document.getElementById('price').value) || isNaN(document.getElementById('mpg').value) || isNaN(document.getElementById('days').value)) {
		alert("Please enter only numbers!");
	} else if (!document.getElementById('miles').value || !document.getElementById('price').value || !document.getElementById('mpg').value || !document.getElementById('days').value) {
		alert("Please fill in every field!");
	} else if (document.getElementById('days').value > 7) {
		alert("There's only 7 days in a week!");
	} else {
		miles = document.getElementById('miles').value;
		price = document.getElementById('price').value;
		mpg = document.getElementById('mpg').value;
		days = document.getElementById('days').value;
		dailytotal = Math.round(((miles/mpg)*price)*100)/100;
		weeklytotal = Math.round((((miles/mpg)*price)*days)*100)/100;
		yearlytotal = Math.round(((((miles/mpg)*price)*days)*52)*100)/100;
	
		total = "<br />Daily Savings: " + currency + dailytotal.toFixed(2) + "<br />Weekly Savings: " + currency + weeklytotal.toFixed(2) + "<br />Yearly Total: " + currency + yearlytotal.toFixed(2);
	
		document.getElementById('answer').innerHTML=total;
		
		new Effect.Appear(document.getElementById('answer'));
	}
}

document.write('<div id="gascalc" style="background:transparent url(http://commutebybike.com/gassave.png) no-repeat scroll left top;color:#444444;height:260px;max-height:260px;min-height:260px;padding:55px 20px 10px;width:155px;font-size:12px;font-face:helvetica,Verdana,Arial,Sans-Serif;">');
document.write('<form>Daily Miles Commuted <br />');
document.write('<input type="text" id="miles" value="" style="width:100%;border:1px #aaaaaa solid;" /><br />');
document.write('Price of '+cmeasure+' Per '+measure+'<br />');
document.write('<input type="text" id="price" value="" style="width:100%;border:1px #aaaaaa solid;" /><br />');
document.write('Your Car\'s MPG<br />');
document.write('<input type="text" id="mpg" value="" style="width:100%;border:1px #aaaaaa solid;" /><br />');
document.write('Days You Ride Per Week<br />');
document.write('<input type="text" id="days" value="" style="width:100%;border:1px #aaaaaa solid;" />');
document.write('<input type="button" value="Calculate" onClick="dogascalc()" style="width:100%;border:1px #aaaaaa solid;"><br />');
document.write('<span id="answer" style="display:none;">15</span></form>');
document.write('<br /><a style="color:#d94401;" target="_blank" href="http://commutebybike.com/?ref='+window.location.hostname+'">commutebybike.com</a>');
document.write('</div>');