var gPlugIns = '';
var gDahIDAccess = '';
var gVersion = '20090930';
SetAccess();

function SetAccess() 
{
  GetPlugIns();

  var vURL;
  var myAjax;
  var vSourceType = "";
   if (window.location.search.indexOf("gclid") > -1)
   {
     vSourceType = "gaw";
   }
   vURL =  gURLAjaxTracker + '?_action=start&_url_referrer=' + document.referrer + '&_appCode=HPC&_pageType=' + document.getElementById('_pageType').value + '&_pageID=' + 
           document.getElementById('_pageID').value + '&_plugIns=' + gPlugIns + '&_screen_size=' + screen.availWidth+"x"+screen.availHeight + '&_screen_color=' + 
           screen.colorDepth + '&_java='+ navigator.javaEnabled()+ '&nocache=' + Math.random() + '&_tver=' + gVersion + '&_source_type=' + vSourceType;
   myAjax = new Ajax.Request(vURL, { method: 'get', onComplete: GetAccess });
}

function GetAccess(pRequest)
{
  gDahIDAccess = pRequest.responseText;
  if (gDahIDAccess != 'InvalidVersion')
  {
    setTimeout('SetIsActive()', 10000);  
  }
}

function GetPlugIns()
{
  for (var i = 0; i < navigator.plugins.length; i++)
  {
    gPlugIns += navigator.plugins[i].name + ";"
    gPlugIns += navigator.plugins[i].description + ";";
    gPlugIns += navigator.plugins[i].filename + ";";
  }
  gPlugIns = hex_md5(gPlugIns);
}
 
function SetIsActive()
{  
  var vURL;
  var myAjax;
  var vOriginalAccessID =  gDahIDAccess;
    
  if (gDahIDAccess.indexOf("google") > -1 || gDahIDAccess.indexOf("script") > -1)
  {

    gDahIDAccess = '';
  }
  
  vURL = gURLAjaxTracker + '?_action=end&_plugIns=' + gPlugIns + '&_id=' + gDahIDAccess + '&_screen_size=' + screen.availWidth+"x" + 
         screen.availHeight + '&_screen_color=' + screen.colorDepth + '&_java='+ navigator.javaEnabled()+ '&nochache=' + Math.random() +
         '&_original_access_id=' + encodeURIComponent(vOriginalAccessID) + '&_tver=' + gVersion;
         
  myAjax = new Ajax.Request(vURL, { method: 'get', onComplete: GetAccessEnd });
}

function GetAccessEnd(pRequest)
{

  if (gDahIDAccess == '')
  {
    SetAccess();
  }
  else
  {
    setTimeout('SetIsActive()',10000);  
  }
}



