function cashcalc(cost)
{
if (cost <= 100)
	{
  return couldbuy = "You could have treated yourself to a nice evening out with that amount of money.";
  }
if (cost <= 200)
	{
  return couldbuy = "You could have treated yourself to an iPod with that amount of money.";
  }
if (cost <= 300)
	{
  return couldbuy = "You could have treated yourself a nice handbag or some nice golf clubs with that amount of money.";
  }
if (cost <= 400)
	{
  return couldbuy = "You could have treated yourself to a cool gaming console or three days at a spa with that amount of money.";
  }
if (cost <= 500)
	{
  return couldbuy = "You could have rented a lovely cottage for a week for that amount of money.";
  }
if (cost <= 600)
	{
  return couldbuy = "You could have gone on a nice winter break to the Canary Islands with that amount of money";
  }
if (cost <= 700)
	{
  return couldbuy = "You could have bought yourself a nice plasma screen or a new carpet with that amount of money.";
  }
if (cost <= 800)
	{
  return couldbuy = "You could have bought yourself a whole new wardrobe full of clothes with that amount of money.";
  }
if (cost <= 900)
	{
  return couldbuy = "You could have bought yourself a top notch TV and stereo for that amount of money.";
  }
if (cost <= 1000)
	{
  return couldbuy = "You could have taken your family to Turkey for seven nights for that amount of money.";
  }
if (cost <= 1500)
	{
  return couldbuy = "You could have bought a couple of football season tickets or two pairs of Jimmy Choos for that amount of money.";
  }
if (cost <= 2000)
	{
  return couldbuy = "You could have bought yourself a relaxing two weeks in the sun with that amount of money.";
  }
if (cost <= 2500)
	{
  return couldbuy = "You could have bought yourself a relaxing two weeks in the sun with that amount of money.";
  }
if (cost <= 3000)
	{
  return couldbuy = "You could have bought yourself a holiday of a lifetime with that amount of money.";
  }
if (cost <= 4000)
	{
  return couldbuy = "You could have bought yourself a holiday of a lifetime with that amount of money.";
  }
if (cost <= 5000)
	{
  return couldbuy = "You could have bought yourself a decent second-hand car with that amount of money.";
  }
if (cost <= 6000)
	{
  return couldbuy = "You could have bought yourself a small boat or a new kitchen with that amount of money.";
  }
if (cost <= 7000)
	{
  return couldbuy = "You could have bought yourself a flash second-hand car with that amount of money.";
  }
if (cost <= 8000)
	{
  return couldbuy = "You could be sitting in a nice conservatory for that amount of money.";
  }
if (cost <= 9000)
	{
  return couldbuy = "You could have bought a new car for that amount of money.";
  }
if (cost > 9000)
	{
  return couldbuy = "Wow. That's a lot of money - was it really the best way to spend it?";
  }
else
	{
  return couldbuy = "Was this really the best way to spend that money?"
	}
}

function validate () {
var cigs = document.getElementById("cigs").value;
var months = document.getElementById("months").value;
var years = document.getElementById("years").value;
var totaltime = months + years;
if (cigs == "") { 
	document.getElementById("errorcigs").style.display = "block";
	return false;
								}
else {
  document.getElementById("errorcigs").style.display = "none";
     }
if (totaltime == "" || totaltime == "00") { 
	document.getElementById("erroryears").style.display = "block";
	return false;
  							}
else {
  document.getElementById("erroryears").style.display = "none";
     }
calculate();
}

function calculate() {
var cigs = document.getElementById("cigs").value;
var years = document.getElementById("years").value;
var months = document.getElementById("months").value;
var weeks = (years*52) + (months*4);
var num_cigs = (cigs*weeks);
var packs = (num_cigs/20);
var cost = (num_cigs*0.2225);
var cost = cost.toFixed(2);
cashcalc(cost);
var tari = (num_cigs*12)/1000;
var tari = tari.toFixed(0);
var nico = (num_cigs*0.8)/1000;
var nico = nico.toFixed(0);
var monoxide = (num_cigs*12.528)/1000;
var monoxide = monoxide.toFixed(0);
var arsenic = (num_cigs*1.5)/1000;
var arsenic = arsenic.toFixed(0);
var life = (num_cigs*11);
var lifehours = (num_cigs * 11)/60;
var lifehours = lifehours.toFixed(0);
var lifedays = lifehours/24;
var lifedays = lifedays.toFixed(0);
var lifemonths = lifedays/30;
var lifemonths = lifemonths.toFixed(0);
var timewasted = (num_cigs * 3);
var timehours = (num_cigs * 3)/60;
var timehours = timehours.toFixed(0);
var timedays = timehours/24;
var timedays = timedays.toFixed(0);
var timemonths = timedays/30;
var timemonths = timemonths.toFixed(0);
document.getElementById('answers').style.display = "block";
document.getElementById('numerofcigsdyn').innerHTML = "You have smoked<span class='strong'> " + num_cigs + " cigarettes, or " + packs + " packs of 20</span>";
document.getElementById('costdyn').innerHTML = "You have spent <span class='strong'>&pound;" + cost + " </span>on cigarettes<br/>" + couldbuy;
document.getElementById('taringesteddyn').innerHTML = "You have coated your lungs with<span class='strong'> " + tari + " grams of tar</span> ";
document.getElementById('nicodyn').innerHTML = "You have swallowed<span class='strong'> " + nico + " grams of nicotine</span>";
document.getElementById('monoxidedyn').innerHTML = "You have breathed<span class='strong'> " + monoxide + " grams of carbon monoxide</span>";
document.getElementById('arsenicdyn').innerHTML = "You have ingested<span class='strong'> " + arsenic + " milligrams of arsenic</span> ";
document.getElementById('lifedyn').innerHTML = "You have reduced your life by<span class='strong'> " + life + " minutes.<br/>That's " + lifehours + " hours, or " + lifedays + " days, or " + lifemonths + " months</span>";
document.getElementById('timedyn').innerHTML = "You have spent<span class='strong'> " + timewasted + " minutes smoking.<br/>That's " + timehours + " hours, or " + timedays + " days, or " + timemonths + " months you have spent holding a cigarette.</span>";
document.location.href = "#top";
}
