function initXmlHttp() {
  var http = false;
  if(typeof ActiveXObject != 'undefined') {
    try {
      http = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        http = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e) {
        http = false;
      }
    }
  } else if(XMLHttpRequest) {
    try {
      http = new XMLHttpRequest();
    } catch(e) {
      http = false;
    }
  }
  return http;
}

function getQueryParam(name) {
  var regex = new RegExp( "[\\?&]" + name + "=([^&#]*)" );
  var results = regex.exec( window.location.href );
  if(results == null) return '';
  else return results[1];
}

function getGa() {
  var ga = ''
  var gaCookie = getQueryParam('__utma');
  if(gaCookie == '') return ga;
  ga += "&__utma=" + gaCookie;
  ga += "&__utmb=" + getQueryParam('__utmb');
  ga += "&__utmc=" + getQueryParam('__utmc');
  ga += "&__utmx=" + getQueryParam('__utmx');
  ga += "&__utmz=" + getQueryParam('__utmz');
  ga += "&__utmv=" + getQueryParam('__utmv');
  ga += "&__utmk=" + getQueryParam('__utmk');
  return ga;
}

function iframe() {
  var params = "req=" + encodeURIComponent(document.location) + "&ref=" + encodeURIComponent(document.referrer);
  if(typeof regdata != "undefined") params += "&regdata=" + regdata;
  if(typeof breg != "undefined") params += "&breg=" + breg;
  if(typeof cclg != "undefined") params += "&cclg=" + cclg;
    // get some ga stuff if passed to request
  var ga = getGa();
  if(ga != '') params += ga;
  var tagDiv = document.createElement('div');
    // setAttribute does NOT work in ie7
//  tagDiv.setAttribute('style','width:1px; height:1px; overflow:hidden; position:absolute; top:-10px');
  tagDiv.style.position = 'absolute';
  tagDiv.style.width = '1px'; tagDiv.style.height = '1px';
  tagDiv.style.left = '-1000px'; tagDiv.style.overflow = 'hidden';
  var tagIframe = document.createElement('iframe');
  tagIframe.style.width = '1px'; tagIframe.style.height = '1px';
//  tagIframe.setAttribute('style','width:1px; height:1px; position:absolute; top:-10px');
  var msec = new Date().getTime();
  tagIframe.id = 'triframe';
  tagIframe.src = '/tracking?vs=' + msec + '&' + params;
  tagDiv.appendChild(tagIframe);
  document.getElementsByTagName('body')[0].appendChild(tagDiv);
}

try { if (noTracking) {} } catch (err) { var noTracking = false; }

if(!noTracking) {
  iframe();
}

