
/* TODO - temporarily disabled because we can't override Image constructor 
// override Image constructor so that we can sneak a peek at the GA pixel
var oldImageConstructor = Image;
function Image(width, height) {
  var out = null;
  if(width == null || height == null) {
    out = new oldImageConstructor();
  } else {
    out = new oldImageConstructor(width, height);
    if(width == 1 && height == 1) {
      window.setTimeout(parameterBind(checkForGaTrackerImage, window, out), 1000);
    }
  }
  return out;
}
*/
// check to see if the one pixel image loaded, if not wait another second
var gaTrackerImageSource = null;
function checkForGaTrackerImage(obj) {
  if(obj.complete) {
    if(obj.src != null && obj.src != '' && obj.src.indexOf('utm.gif') > 0) {
      gaTrackerImageSource = obj.src;
    }
  } else {
    window.setTimeout(parameterBind(checkForGaTrackerImage, this, obj), 1000);
  }
}

function generateUserInfoString() {
  var userInfo = { };
  if(typeof(navigator.userAgent) != 'underfined') { userInfo.userAgent = navigator.userAgent; }
  if(typeof(navigator.platform) != 'underfined') { userInfo.platform = navigator.platform; }
  if(typeof(navigator.appName) != 'underfined') { userInfo.appName = navigator.appName; }
  if(typeof(navigator.appCodeName) != 'underfined') { userInfo.appCodeName = navigator.appCodeName; }
  if(typeof(navigator.appVersion) != 'underfined') { userInfo.appVersion = navigator.appVersion; }
  if(typeof(screen.width) != 'underfined') { userInfo.width = screen.width; }
  if(typeof(screen.height) != 'underfined') { userInfo.height = screen.height; }
  if(typeof(screen.colorDepth) != 'underfined') { userInfo.colorDepth = screen.colorDepth; }
  if(typeof(screen.availWidth) != 'underfined') { userInfo.availWidth = screen.availWidth; }
  if(typeof(screen.availHeight) != 'underfined') { userInfo.availHeight = screen.availHeight; }
  
  if(gaTrackerImageSource != null) {
    var encodingMatch = (/&utmcs=([^&]*)&/g).exec(gaTrackerImageSource);
    if(encodingMatch) { userInfo.gaEncoding = encodingMatch[1]; }
    
    var flashMatch = (/&utmfl=([^&]*)&?/g).exec(gaTrackerImageSource);
    if(flashMatch) { userInfo.gaFlashVersion = unescape(flashMatch[1]); }
    
    var hostMatch = (/&utmhn=([^&]*)&?/g).exec(gaTrackerImageSource);
    if(hostMatch) { userInfo.gaHost = hostMatch[1]; }
    
    var pageMatch = (/&utmp=([^&]*)&?/g).exec(gaTrackerImageSource);
    if(pageMatch) { userInfo.gaPage = unescape(pageMatch[1]); }
  }
  
  return JSON.stringify(userInfo);
}
