/*----------------------------------------------------------------------------*/
/*-- HoundMaster - Head Javascript                                          --*/
/*--   Dynamically loads all necessary added javascript files to unload the --*/
/*-- responsibility from the landshifters. This also enables the javascript --*/
/*-- to be loaded cacheless and keep all js files up2date with the server.  --*/
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/*-- Loads the php javascript synchronously                                 --*/
/*----------------------------------------------------------------------------*/
function houndM_load_phpjs (url, query)
   {
   /*-- Now build ajax the tracker --*/
   var x = (window.ActiveXObject)?
      new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();

   if (x)
      {
      /*-- Set the content type --*/
      var fullscript = url + "?" + query;

      /*-- Specify the load method then send the request --*/
      x.open("GET", fullscript, false);
      x.send(null);

      /*-- Now having the response, add it in the system --*/
      var html_doc = document.getElementsByTagName('head')[0];

      /*-- Create the javascript --*/
      var js = document.createElement('script');

      /*-- Attach javascript data --*/
      js.language = 'javascript';
      js.type = 'text/javascript';
      js.text = x.responseText;

      /*-- Attach the javascript --*/
      html_doc.appendChild(js);
      }
   }
/*----------------------------------------------------------------------------*/

/*-- Standard path variables --*/
var houndM_js_php = "./houndM_tracker.php";

/*-- Generate a random key for javascript noncache inclusion --*/
var rand_no = Math.floor((999-99) * Math.random()) + 100;

/*-- Get various related variables for the system --*/
/*-- REFERER -----------------------------------------------*/
var referer = "";
if (document.referrer && document.referrer != "")
   referer = document.referrer;

/*-- LOAD JAVASCRIPT ---------------------------------------*/
/*-- Include the PHP javascript for server side variables --*/
var query = "k=" + rand_no + "&a=js";
if (typeof tracker_id != 'undefined') query +=  "&ccnt=" + tracker_id.length;
if (typeof tpl_id != 'undefined') query +=  "&tpl=" + tpl_id;
if (referer) query +=  "&r=" + referer;
houndM_load_phpjs (houndM_js_php, query);


