$(document).ready(function(){
  $("#cur-go").click(function(){
    var to = $("#cur-to").val();
    var from = $("#cur-from").val();
    var amount = $("#cur-amt").val();
    var url = "/currency.php";
    $.get(url + '?process=1&a=' + amount + '&to=' + to + '&from=' + from,function(data){
      var res = amount + from + ' = ' + data + to;
      $("#fx-result").html(res);
    });
  });
});

/*
   Inserts GA using DOM insertion of <script> tag and "script onload" method to
   initialize the pageTracker object. Prevents GA insertion from blocking I/O!

   As suggested in Steve Souder's talk. See:
http://google-code-updates.blogspot.com/2009/03/steve-souders-lifes-too-short-write.html
*/
function gaLoad (key) {
  // account for SSL
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  var t;
  var s;
  s = document.createElement('script');
  s.type = 'text/javascript';
  s.src = gaJsHost + 'google-analytics.com/ga.js';
  s.loaded = false;

  // call the GA tracker
  function ga() {
    t = _gat._getTracker(key);
    t._trackPageview();
  }

  // set up the hooks
  s.onload = function () {
    s.loaded = true;
    ga();
  };
  s.onreadystatechange = function() {
    // test that it is complete(4), exists(200) and hasn't already been loaded
    if (s.readyState == 4  && !s.onloadDone && s.status == 200) {
      s.loaded = true;
      ga();
    }
  };

  // insert the script into the head
  document.getElementsByTagName('head')[0].appendChild(s);
}

// load Google Analytics
gaLoad('UA-6455204-10'); 
