XDEBUG = false;

function track(event_in, params) {
  // TODO: Add local date time, browser, OS, referrer, 
  params['event'] = event_in;
  params['referrer'] = document.referrer;
  d = new Date();
  var x = new Date(d.toUTCString());
  params['utc_time'] = x.getTime()/1000;
  
  // TODO: need to insert an ID somehow - otherwise the APi version (Ruby) will send their own IP which is no good
  var j = JSON.stringify(params);
  
  if (!XDEBUG) {
    document.write('<img style="display:none;" src="http://rt.seoranker.info/rt.html?data='+window.btoa(j)+'" />');
  } else {
    document.write('<img src="http://localhost:8000/track/?params='+window.btoa(j)+'" />');
  }
}
