/**************************************************************************************************
* wrapper code to include on websites that will load the Google Analytics code after the web page has completed loading
* base code was copied from http://beepinteractive.com/2008/07/02/adding-google-analytics-onload/
*
* REQUIRED: set variable mtkGaID  to accounts Google Analytics ID before including this code
*                       example:  var mtkGaID = "UA-000000-0";
*
* Matt Harting 12.4.2008
**************************************************************************************************/
if (window.addEventListener)
{
  window.addEventListener("load", mtk_load_ga, false);
}
else if (window.attachEvent)
{
  window.attachEvent("onload", mtk_load_ga);
}
 
function mtk_load_ga()
{
  var gaJsHost  = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  var s    = document.createElement('script');
  s.src    = gaJsHost + "google-analytics.com/ga.js";
  s.type    = "text/javascript";
  document.getElementsByTagName("head")[0].appendChild(s);
 
  var i    = 0;
  mtk_run_ga();
 
  function mtk_run_ga()
  {
    if (typeof _gat == "object")
    {
      var pageTracker = _gat._getTracker(mtkGaID);
      pageTracker._initData();
      pageTracker._trackPageview();
    }
    else if (i < 20)
    {
      i++;
      setTimeout(mtk_run_ga, 500);
    }
  }
}
