$(document).ready(function(){
 
  $(".totalbutton").attr("disabled", "disabled");

  /* Error and check functions */
  function Err_FillAllIn() {
    alert('Please fill out all fields before submitting.');
  }

  function Err_OnlyNums() {
    alert('Only numerals are allowed.');
  }

  function Err_Hours() {
    alert('There are only 24 hours in a day.');
  }

  /* Check that the input is only numbers */
  function CheckNumeric(numstr) {
    toCheck = numstr.toString();
    if (!toCheck.match(/^\d+\.?\d*$/)) {
      return false;
    } else {
      return true;
    }
  }

/* On Update MSG Link Click------ */
  $("#UpdateLink").click(function(){
    if ($("#UpdateDIV").is(":hidden")) {
        $("#UpdateDIV").slideDown("fast");
    } else {
        $("#UpdateDIV").slideUp("fast");
    }
  });

/* Dismiss Update Box to Cookie -- _backend.php handles everything */
  $("#DismissLink").click(function(){
    $("#update").hide();
    $("#UpdateDIV").hide();
    $.ajax({
     type: "POST",
     url: "backend",
     data: "BeginBackend=1&Task=DismissUpdateBox",
     success: function(msg){}
    });
  });

/* CFL----- */
  $(".cflbutton").click(function () {
    var cfl_incan_watts = Math.abs($("input#cfl_incan_watts").val());
    var cfl_cfl_watts = Math.abs($("input#cfl_cfl_watts").val());
    var cfl_hoursaday = Math.abs($("input#cfl_hoursaday").val());
    var cfl_kwh_charge = Math.abs($("input#cfl_kwh_charge").val());
    $("input#cflsubmit").val("1");

    if ((cfl_incan_watts == "") || (cfl_cfl_watts == "") || (cfl_hoursaday == "") || (cfl_kwh_charge == "")) {
      Err_FillAllIn();
      return false;
    }

    if (CheckNumeric(cfl_incan_watts)) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if (CheckNumeric(cfl_cfl_watts)) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if (CheckNumeric(cfl_hoursaday)) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if (CheckNumeric(cfl_kwh_charge)) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if (cfl_cfl_watts > cfl_incan_watts) {
      alert ('CFL wattage should be smaller than incandescent wattage.');
      return false;
    }

    if (cfl_hoursaday > 24) {
      Err_Hours();  
    return false;
    }

    $.ajax({
      success: function() {
        $("#cflspan").css("display","none");                                                //hide input form
        $(".cflreturn").fadeIn(750);                                                        //fade in edit button
        incan_kw = cfl_incan_watts / 1000;                                                  //incan usage in kw - w / 1000
        cfl_kw = cfl_cfl_watts / 1000;                                                      //cfl usage
        kwh_charge = cfl_kwh_charge / 100;                                                  //moneey in cents. ex. 6.3 = 0.063.
        saved_kw = incan_kw - cfl_kw;                                                       //difference in cfl vs incan w usage
        incan_charge_day = incan_kw * cfl_hoursaday * kwh_charge;                           //cost to run the incand setup per day
        incan_charge_month = incan_charge_day * 30;                                         //cost to run the incan setup per 30 days
        incan_charge_year = incan_charge_day * 365;                                         //cost to run the incan setup per 365 days
        cfl_charge_day = cfl_kw * cfl_hoursaday * kwh_charge;                               //cost to run the cfl setup per day
        cfl_charge_month = cfl_charge_day * 30;                                             //cost to run the cfl setup per month
        cfl_charge_year = cfl_charge_day * 365;                                             //cost to run the cfl setup per year
        cfl_savings_month = incan_charge_month - cfl_charge_month;                          //savings  per month
        cfl_savings_year = incan_charge_year - cfl_charge_year;                             //savings per year
        cfl_co2_savings = ((incan_kw - cfl_kw) * (cfl_hoursaday)) * (1.34) * (365);         //1.34lbs of co2 emitted per kwh
        cfl_less_oil = (((cfl_incan_watts - cfl_cfl_watts) * (cfl_hoursaday)) * (365) * 1000000) / 1699400;   // one barrel of oil can power out 1,699,400 watts
        $('#cflcontainer').append("<div id='cflspannew'></div>");
          $('#cflspannew').html("<p class='calchead'>CFL Saver Results</p><p class='calcbody'>With your incandescent setup, you are currently being charged <b>$" + incan_charge_day.toFixed(2) + "</b> per day to run <b>" + cfl_incan_watts + " watts</b> for <b>" + cfl_hoursaday + " hours</b>. At this rate, you will end up paying <b>$" + incan_charge_month.toFixed(2) +"</b> per month, which is <b>$" + incan_charge_year.toFixed(2) + "</b> for an average year.</p>")
          .append("<p class='calcbody'>With the CFL setup, you will be charged <b>$" + cfl_charge_day.toFixed(2) + "</b> per day to run <b>" + cfl_cfl_watts + " watts</b> for <b>" + cfl_hoursaday + " hours</b>. At this rate, you will end up paying <b>$" + cfl_charge_month.toFixed(2) +"</b> per month, which is <b>$" + cfl_charge_year.toFixed(2) + "</b> per year.</p>")
          .append("<p class='calcbody'>By converting this setup from incandescent bulbs to CFL bulbs, you will save <b>$" + cfl_savings_month.toFixed(2) + "</b> per month, which is <b>$" + cfl_savings_year.toFixed(2) + "</b> per year in energy costs. In addition, you will produce <b>" + cfl_co2_savings.toFixed(0) + "</b> LBS less CO2 emissions per year. If a million people were to change their setup like this, our country would consume <b>" + cfl_less_oil.toFixed(0) + " less barrels of oil</b> per year.</p>")
          .append("<p class='calcbody'>The savings calculated do not include the cost of bulbs. It is worth noting that CFLs last around ten times longer than incandescents, but cost twice as much as an incandescent bulb.</p>");
        $("#cflspannew").css("display","block").hide().fadeIn(750);
        $(".totalbutton").removeAttr("disabled");
      }
    });
    return false;
  });

/* PC Standby----- */
  $(".pcsbutton").click(function() {
    var pcs_monitor = $("select#pcs_monitor").val();
    var pcs_hours = Math.abs($("input#pcs_hours").val());
    var pcs_days = Math.abs($("input#pcs_days").val());
    var pcs_pcs = Math.abs($("input#pcs_pcs").val());
    var pcs_kwh_charge = Math.abs($("input#pcs_kwh_charge").val());
    $("input#pcssubmit").val("1");

    if  ((pcs_hours == "") || (pcs_days == "") || (pcs_kwh_charge == "")) {
      Err_FillAllIn();
      return false;  
    }

    if ((CheckNumeric(pcs_hours))) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if ((CheckNumeric(pcs_days))) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if ((CheckNumeric(pcs_pcs))) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if ((CheckNumeric(pcs_kwh_charge))) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if (pcs_days > 7) {
      alert('There are only seven days in a week.');
      return false;
    }

    if (pcs_hours > 24) {
      Err_Hours();  
      return false;
    }

    $.ajax({
      success: function() {
        $("#pcsspan").css("display","none");                                                          //hide input form
        $(".pcsreturn").fadeIn(750);                                                                  //fade in edit button

        if (pcs_monitor == "pcs_lcd") {                                                               //kw difference between use and standy. lcd 60w use 2w standby, crt 120w use 5w standby
          pcs_display_watts = .058;
          pcs_msg = "";
        } else  {
          pcs_display_watts = .115;
          pcs_msg = "<p class='calcbody'>It's worth noting that you indicated you are using a CRT monitor. If you switch to a LCD, it could cut your power draw in half. A CRT monitor pulls roughly between 90w-140w, depending on the model and size. A comparable LCD would draw between 40 and 80w.</p>";
        }
        pcs_watts = .050;                                                                             //a pc saves about 50w when going into s1 standby.
        pcs_kwh_charge = pcs_kwh_charge / 100;
        pcs_savings_day = ((pcs_display_watts + pcs_watts) * pcs_pcs * pcs_hours * pcs_kwh_charge);
        pcs_savings_week = pcs_savings_day * pcs_days;
        pcs_savings_month = pcs_savings_week * 4;
        pcs_savings_year = pcs_savings_week * 52;
        pcs_kwh_day = ((pcs_display_watts + pcs_watts) * pcs_pcs * pcs_hours);
        pcs_kwh_week = pcs_kwh_day * pcs_days;
        pcs_kwh_year = pcs_kwh_week * 52;
        pcs_less_co2 = pcs_kwh_year * 1.34;
        pcs_less_oil = (pcs_kwh_year * 1000000) / 1699400;
        $('#pcscontainer').append("<div id='pcsspannew'></div>");
          $('#pcsspannew').html("<p class='calchead'>PC Standby Results</p>")
          .append("<p class='calcbody'>By putting <b>"+ pcs_pcs +"</b> PC(s) in standby for <b>" + pcs_hours + "</b> hours per day during a <b>" + pcs_days  + "</b> day week, you will save <b>$" + pcs_savings_day.toFixed(2) + "</b> each day, which will equal a savings of <b>$" + pcs_savings_month.toFixed(2) + " each month</b> and <b>$" + pcs_savings_year.toFixed(2) + "</b> each year.</p>")
          .append("<p class='calcbody'>Using this power saving setup, you will produce <b>" + pcs_less_co2.toFixed(0) + "</b> less CO2 emissions per year. If a million people changed their setup like this, our country would consume <b>" + pcs_less_oil.toFixed(0) + " less barrels of oil</b> per year.</p>")
          .append("<p class='calcbody'>These calculations are based on S1 Standby mode, which draws the most power of all standard PC modes. Putting your PC into S3 standby mode will save even more power, but not hardware configurations support it.</p>")
          .append(pcs_msg);
        $("#pcsspannew").css("display","block").hide().fadeIn(750);
        $(".totalbutton").removeAttr("disabled");
      }
    });
  return false;
  });

/* Tire PSI----- */
  $(".psibutton").click(function() {
  
    var psi_current = Math.abs($("input#psi_current").val());
    var psi_recomm = Math.abs($("input#psi_recomm").val());
    var psi_gasprice = Math.abs($("input#psi_gasprice").val());
    var psi_gasperweek = Math.abs($("input#psi_gasperweek").val());
    $("input#psisubmit").val("1");

    if  ((psi_current == "") || (psi_recomm == "") || ( psi_gasprice == "") || (psi_gasperweek == "")) {
      Err_FillAllIn();
      return false;  
    }

    if ((CheckNumeric(psi_current))) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if ((CheckNumeric(psi_recomm))) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if ((CheckNumeric(psi_gasprice))) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if ((CheckNumeric(psi_gasperweek))) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if  (psi_current > psi_recomm) {
      alert("Your current PSI pressure is higher than the recommended. You should deflate your tires to the recommended so you don't damage them.");
      return false;  
    }

    if  (psi_gasprice > psi_gasperweek) {
      alert('Your gas cost per week cannot exceed price per gallon.');
      return false;  
    }

    $.ajax({
      success: function() {
        $("#psispan").css("display","none");                                                          //hide input form
        $(".psireturn").fadeIn(750);                                                                  //fade in edit button
        psi_diff = psi_recomm - psi_current;                                                          //difference in tire psi
        psi_percent = (psi_diff * .003);                                                              //every 1 psi lost = .3% less gas efficiency.
        psi_percent_display = (psi_percent * 100);
        psi_gasextragal = (psi_percent * psi_gasprice);                                               //extra $ paid per gal thanks to loss of efficiency.
        psi_gasnewprice = (psi_gasextragal + psi_gasprice);
        psi_gasextraperweek = (psi_gasextragal * psi_gasperweek);
        psi_gasextrapermonth = (psi_gasextraperweek * 4);
        psi_gasextraperyear = (psi_gasextraperweek * 52);
        psi_extragalsyear = (psi_gasextraperyear / psi_gasprice);  
        psi_extraco2peryear = (psi_extragalsyear * 19.45);                                            //(Gas total extra / reg $ of gas) = # of extra gals wasted. 19.45lbs of co2 are emitted per gal.
        psi_less_oil = (psi_extragalsyear * 1000000) / (19.5);                                        //a barrel of oil outputs 19.5 gals of gasoline.
        $('#psicontainer').append("<div id='psispannew'></div>");
          $('#psispannew').html("<p class='calchead'>Tire PSI Results</p>")
          .append("<p class='calcbody'>Driving with your current tire pressure, you experience a <b>"+ psi_percent_display.toFixed(1) + "%</b> loss of mileage efficiency per gallon. In reality, you are paying <b>$" + psi_gasnewprice.toFixed(3) + "</b> instead of <b>$" + psi_gasprice.toFixed(2) + "</b> per gallon in the long run to fuel your car. This means you are losing <b>$" + psi_gasextraperweek.toFixed(2) + "</b> per week, <b>$" + psi_gasextrapermonth.toFixed(2) + "</b> per month, which ends up to be <b>$" + psi_gasextraperyear.toFixed(2) + "</b> per year thanks to your deflated tires.</p>")
          .append("<p class='calcbody'>With your deflated tires, you end up wasting (and in turn, have to pay for) <b>" + psi_extragalsyear.toFixed(2) + "</b> gallons of extra gas per year.  Thanks to this, your vehicle will emit an extra <b>" +  psi_extraco2peryear.toFixed(0) + "</b> LBS of CO2 into the atmosphere a year. If a million people in your position kept their tires inflated to your specifications, our country would consume <b>" + psi_less_oil.toFixed(0) +" less barrels of oil</b> per year.</p>")
          .append("<p class='calcbody'>To keep regain your tire gas mileage efficiency, check your tire PSI and inflate them to the recommended <b>" + psi_recomm + "</b> PSI  every 2-3 weeks.</p>");
        $("#psispannew").css("display","block").hide().fadeIn(750);
        $(".totalbutton").removeAttr("disabled");
      }
    });
  return false;
  });

/* Vampire----- */   
  $(".vampbutton").click(function() {
  
    var vamp_num_devices = Math.abs($("input#vamp_num_devices").val());
    var vamp_hours = Math.abs($("input#vamp_hours").val());
    var vamp_kwh_charge = Math.abs($("input#vamp_kwh_charge").val());
    $("input#vampsubmit").val("1");

    if  ((vamp_num_devices == "") || (vamp_hours == "") || ( vamp_kwh_charge == "")) {
      Err_FillAllIn();
    return false;  
    }

    if ((CheckNumeric(vamp_num_devices))) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if ((CheckNumeric(vamp_hours))) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if ((CheckNumeric(vamp_kwh_charge))) {
    } else {
      Err_OnlyNums();
      return false;
    }

    if (vamp_hours > 24) {
      Err_Hours();  
    }

    $.ajax({
      success: function() {
      $("#vampspan").css("display","none");                                                          //hide input form
      $(".vampreturn").fadeIn(750);                                                                  //fade in edit button
      vamp_dev_watts = .008;
      vamp_cost_permonth = ((vamp_dev_watts) * (vamp_hours) * (vamp_num_devices) * (30)) * (vamp_kwh_charge / 100);
      vamp_cost_peryear = ((vamp_dev_watts) * (vamp_hours) * (365) * (vamp_num_devices)) * (vamp_kwh_charge / 100);
      vamp_co2_year = (vamp_dev_watts * vamp_hours * vamp_num_devices) * 1.34 * 365;
      vamp_less_oil = (((vamp_dev_watts * vamp_hours * vamp_num_devices) * 365) * 1000000) / 1699400
      $('#vampcontainer').append("<div id='vampspannew'></div>");
        $('#vampspannew').html("<p class='calchead'>Vampire Power Saver</p>")
        .append("<p class='calcbody'>On average, running <b>" + vamp_num_devices + "</b> devices on standby for <b>" + vamp_hours +"</b> hours a day costs you <b>$" + vamp_cost_permonth.toFixed(2) +"</b> per month and <b>$" + vamp_cost_peryear.toFixed(2) + "</b> per year to keep them in standby mode.</p>")
        .append("<p class='calcbody'>These standby devices cause you to emit <b>" + vamp_co2_year.toFixed(0) + "</b> LBS of CO2 emissions. If a million people were to shut off your configuration of standby devices, our country would consume <b>" + vamp_less_oil.toFixed(0) + " less barrels of oil</b> per year.</p>")
        .append("<p class='calcbody'>If you would like to save money, plug all these standby devices into a power strip and flip it off when they are not in use, or just unplug them.</p>");
      $("#vampspannew").css("display","block").hide().fadeIn(750);
      $(".totalbutton").removeAttr("disabled");
      }
    });
  return false;
  });

/* TOTAL OF ALL ON PAGE----- */   
  $(".totalbutton").click(function() {

    //CFL----------------
    var cfl_incan_watts = Math.abs($("input#cfl_incan_watts").attr("value"));
    var cfl_cfl_watts = Math.abs($("input#cfl_cfl_watts").attr("value"));
    var cfl_hoursaday = Math.abs($("input#cfl_hoursaday").attr("value"));
    var cfl_kwh_charge = Math.abs($("input#cfl_kwh_charge").attr("value"));
    var cflsubmit = $("input#cflsubmit").attr("value");

    //PCS----------------
    var pcs_monitor = $("select#pcs_monitor").attr("value");
    var pcs_hours = Math.abs($("input#pcs_hours").attr("value"));
    var pcs_days = Math.abs($("input#pcs_days").attr("value"));
    var pcs_pcs = Math.abs($("input#pcs_pcs").attr("value"));
    var pcs_kwh_charge = Math.abs($("input#pcs_kwh_charge").attr("value"));
    var pcssubmit = $("input#pcssubmit").attr("value");

    //PSI----------------
    var psi_current = Math.abs($("input#psi_current").attr("value"));
    var psi_recomm = Math.abs($("input#psi_recomm").attr("value"));
    var psi_gasprice = Math.abs($("input#psi_gasprice").attr("value"));
    var psi_gasperweek = Math.abs($("input#psi_gasperweek").attr("value"));
    var psisubmit = $("input#psisubmit").attr("value");

    //VAMP----------------
    var vamp_num_devices = Math.abs($("input#vamp_num_devices").attr("value"));
    var vamp_hours = Math.abs($("input#vamp_hours").attr("value"));
    var vamp_kwh_charge = Math.abs($("input#vamp_kwh_charge").attr("value"));
    var vampsubmit = $("input#vampsubmit").attr("value");

    if ((cflsubmit != 1) && (pcssubmit != 1) && (psisubmit != 1) && (vampsubmit != 1)) {
      alert("One calculator must be checked before you can sum the totals.");
      return false;  
    }

  $.ajax({
    success: function() {
      //CFL----------------
      if (cflsubmit == "1") {
        cfl_charge_year_t = (((cfl_cfl_watts / 1000) * cfl_hoursaday * (cfl_kwh_charge / 100)) * 365);
        cfl_savings_month_t = (((cfl_incan_watts / 1000)  * cfl_hoursaday * (cfl_kwh_charge / 100)) * 30) - (((cfl_cfl_watts / 1000) * cfl_hoursaday * (cfl_kwh_charge / 100)) * 30);
        cfl_savings_year_t = (((cfl_incan_watts / 1000)  * cfl_hoursaday * (cfl_kwh_charge / 100)) * 365) - (((cfl_cfl_watts / 1000) * cfl_hoursaday * (cfl_kwh_charge / 100)) * 365);
        cfl_co2_savings_t = (((cfl_incan_watts / 1000) - (cfl_cfl_watts / 1000)) * (cfl_hoursaday)) * (1.34) * (365);         //1.34lbs of co2 emitted per kwh
        cfl_less_oil_t = (((cfl_incan_watts - cfl_cfl_watts) * (cfl_hoursaday)) * (365) * 1000000) / 1699400;   // one barrel of oil can power out 1,699,400 watts
      } else {
        cfl_charge_year_t = 0;
        cfl_savings_month_t = 0;
        cfl_savings_year_t = 0;
        cfl_co2_savings_t = 0;
        cfl_less_oil_t = 0;
      }

      //PCS----------------
      if (pcssubmit == "1") {
        pcs_watts = .050;                                                                             // a pc saves about 50w when going into s1 standby.    
        if (pcs_monitor == "pcs_lcd") {                                                               //kw difference between use and standy. lcs 60w use 2w standby, crt 120w use 5w standby
          pcs_display_watts = .058;
        } else  {
          pcs_display_watts = .115;
        }
        pcs_savings_month_t = (((pcs_display_watts + pcs_watts) * pcs_pcs * pcs_hours * (pcs_kwh_charge / 100)) * pcs_days) * 4;
        pcs_savings_year_t = (((pcs_display_watts + pcs_watts) * pcs_pcs * pcs_hours * (pcs_kwh_charge / 100)) * pcs_days) * 52;
        pcs_kwh_day = ((pcs_display_watts + pcs_watts) * pcs_pcs * pcs_hours);
        pcs_kwh_year = ((pcs_kwh_day * pcs_days) * 52);
        pcs_less_co2_t = (pcs_kwh_year) * 1.34;
        pcs_less_oil_t = (((pcs_kwh_day * pcs_days) * 52) * 1000000) / 1699400;
      } else {
        pcs_savings_month_t = 0;
        pcs_savings_year_t = 0;
        pcs_kwh_day = 0;
        pcs_kwh_year = 0;
        pcs_less_co2_t = 0;
        pcs_less_oil_t = 0;
      }

      //PSI----------------
      if (psisubmit == "1") {
        psi_gas_savings_month_t = (((((psi_recomm - psi_current) * .003) * psi_gasprice) * psi_gasperweek) * 4);
        psi_gas_savings_year_t = (((((psi_recomm - psi_current) * .003) * psi_gasprice) * psi_gasperweek) * 52);
        psi_extragalsyear = (psi_gas_savings_year_t / psi_gasprice);  
        psi_extraco2peryear_t = (psi_extragalsyear * 19.45);                                            //(Gas total extra / reg price of gas) = number of extra gals wasted. 19.45lbs of co2 are emitted per gal.
        psi_less_oil_t = ((psi_extragalsyear) * 1000000) / (19.5);                                        //a barrel of oil outputs 19.5 gals of gasoline.
      } else {
        psi_gas_savings_month_t = 0;
        psi_gas_savings_year_t = 0;
        psi_extragalsyear = 0;
        psi_extraco2peryear_t = 0;
        psi_less_oil_t = 0;
      }

      //VAMP----------------
      if (vampsubmit == "1") {
        vamp_savings_month_t = ((vamp_num_devices * .008 * vamp_hours) *  (vamp_kwh_charge / 100)) * 30;
        vamp_savings_year_t = ((vamp_num_devices * .008 * vamp_hours) *  (vamp_kwh_charge / 100)) * 365;
        vamp_kwh_day = ((vamp_num_devices * .008 * vamp_hours));
        vamp_kwh_year = ((vamp_num_devices * .008 * vamp_hours)) * 365;
        vamp_less_co2_t = (vamp_kwh_year) * 1.34;
        vamp_less_oil_t = ((vamp_kwh_year) * 1000000) / 1699400;
      } else {
        vamp_savings_month_t = 0;
        vamp_savings_year_t = 0;
        vamp_kwh_day = 0;
        vamp_kwh_year = 0;
        vamp_less_co2_t = 0;
        vamp_less_oil_t = 0;
      }

      //Total---------------
      total_savings_month = cfl_savings_month_t + pcs_savings_month_t + psi_gas_savings_month_t + vamp_savings_month_t;
      total_savings_year = cfl_savings_year_t + pcs_savings_year_t + psi_gas_savings_year_t + vamp_savings_year_t;
      total_less_co2 = cfl_co2_savings_t + pcs_less_co2_t + psi_extraco2peryear_t + vamp_less_co2_t;
      total_less_oil = cfl_less_oil_t + pcs_less_oil_t + psi_less_oil_t + vamp_less_oil_t; 
      $("#totalspan").css("display","none");                                                          //hide input form
      $(".totalreturn").fadeIn(750);                                                                  //fade in edit button
      $('#totalcontainer').append("<div id='totalspannew'></div>");
        $('#totalspannew').html("<p class='calchead'>Totals</p>")
        .append("<p class='calcbody'>By making the changes that you have indicated above, you will see a savings of <b>$" + total_savings_month.toFixed(2) + "</b> per month and <b>$" + total_savings_year.toFixed(2) + "</b> per year. You will also emit <b>" +  total_less_co2.toFixed(0) + "</b> less LBS of CO2 into the atmosphere per year. If a million people took the energy saving steps you indicated, our country would consume <b>" + total_less_oil.toFixed(0) +" less barrels of oil per year</b>.</p>");       
      $("#totalspannew").css("display","block").hide().fadeIn(750);
      }
    });
  return false;
  });

/*"Go Back" link functions-----*/
  $(".cflreturn").click(function(){
    $("input#cflsubmit").val("0");
    $(".cflreturn").fadeOut(750);
    $("#cflspannew").remove();
    $("#cflspan").css("display","block").hide().fadeIn(750);
  });

  $(".pcsreturn").click(function(){
    $("input#pcssubmit").val("0");
    $(".pcsreturn").fadeOut(750);
    $("#pcsspannew").remove();
    $("#pcsspan").css("display","block").hide().fadeIn(750);
  });

  $(".psireturn").click(function(){
    $("input#psisubmit").val("0");
    $(".psireturn").fadeOut(750);
    $("#psispannew").remove();
    $("#psispan").css("display","block").hide().fadeIn(750);
  });

  $(".vampreturn").click(function(){
    $("input#vampsubmit").val("0");
    $(".vampreturn").fadeOut(750);
    $("#vampspannew").remove();
    $("#vampspan").css("display","block").hide().fadeIn(750);
  });

  $(".totalreturn").click(function(){
    $(".totalreturn").fadeOut(750);
    $("#totalspannew").remove();
    $("#totalspan").css("display","block").hide().fadeIn(750);
  });
});