var Application = function()
{
  var me = this;
  
  me.init();
      
  $(document).ready(function()
  {
    me.initUI();
  });
}

Application.prototype.init = function()
{
  this.setupVisitorTracking();
}

Application.prototype.initUI = function()
{
  var me = this;
  
  this.affiliate = eval('(' + $("#affiliate_infos").text() + ')');
  this.webSite = eval('(' + $("#web-site-infos").text() + ')');
  this.user = eval('(' + $("#user-infos").text() + ')');
  
  document.body.onunload = function(){me.free()};
}

Application.prototype.free = function()
{
  if (typeof(eval(window)["GUnload"]) == "function") 
    GUnload();
}

Application.prototype.setupVisitorTracking = function()
{
  window["_gaq"] = window["_gaq"] || [];
  window["_gaq"].push(['_setAccount', 'UA-18405348-1']);
  window["_gaq"].push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
}

var application = new Application();
