$(document).ready(function(){
    where_are_you();
    });
function where_are_you(){
$.getJSON('/ip.php',function (data) { 
    if (data.postalcode.length > 0) {
      get_weather(data.postalcode);
    } else {
      $('#cold').text("I HAVE NO IDEA WHERE YOU ARE, SO LET'S JUST ASSUME IT'S COLD THERE");
    }
  });
}


function get_weather(zip){
  $.get("/weather.php?airport="+zip,function (data) {
      temp = $(data).find('temp_f').attr('data');
      if (temp > 90) {
      $('#cold').html("FUCK YOU, IT'S HOT ("+temp+"&deg;F)");
      } else if(temp > 80) {
      $('#cold').html("NOT EVEN CLOSE ("+temp+"&deg;F)");
      } else if(temp > 70) {
      $('#cold').html("MAYBE IN YOUR FRIDGE ("+temp+"&deg;F)");
      } else if (temp > 60) {
      $('#cold').html("IM PRETTY COMFORTABLE ("+temp+"&deg;F)");
      } else if (temp > 50) {
      $('#cold').html("NAH ("+temp+"&deg;F)");
      } else if (temp > 40) {
      $('#cold').html("IM CHILLY ("+temp+"&deg;F)");
      } else if (temp > 30) {
      $('#cold').html("IT IS COLD ("+temp+"&deg;F)");
      } else if (temp > 20) {
      $('#cold').html("WHAT THE FUCK DON'T YOU UNDERSTAND ABOUT NORMAL OPERATING TEMPERATURE ("+temp+"&deg;F)");
      } else if (temp > 10) {
      $('#cold').html("NO SERIOUSLY, WHY NOT WEAR SOME SHORTS ("+temp+"&deg;F)");
      } else if (temp > 0) {
        $('#cold').html("FUCK YOU, YES IT'S COLD ("+temp+"&deg;F)");
      } else {
        $('#cold').html("DICK, OF COURSE IT'S FUCKING COLD OUT ("+temp+"&deg;F)");
      }
  });
}


