// Google Analytics global configuration interface
var _gaq = _gaq || [], pageTracker = null;

(function(window, document){
  var p = document.location.protocol, run_once = false;
 
  // Asynchronous javascript loader
  function _ld(url){
    var x = 'script', s = document.getElementsByTagName(x)[0], q = document.createElement(x);
    q.async = true; q.src = url; q.type = 'text/javascript';
    return s.parentNode.insertBefore(q, s);
  }

  // Load global utilities
  _ld('/js/global/util.js');

  // Load Google Analytics
  _ld(p + '//' + ((p == 'https:') ? 'ssl' : 'www') + '.google-analytics.com/ga.js');

  // Mapping old Site Catalyst IDs to Google Analytics WPIDs
  var _accounts = {
    'ezAir-R-PC-PC': "UA-4086206-7",
    'ezAir-C-PC-PC': "UA-4086206-4", 
    'ezAir-F-PC-PC': "UA-4086206-5",
    'ezAir-B-PC-PC': "UA-4086206-6",
    'ezAir-P-PC-PC': "UA-4086206-8",
    'ezAir-R-PC-PO': "UA-4086206-18",
    'ezAir-C-PC-PO': "UA-4086206-19",
    'ezAir-F-PC-PO': "UA-4086206-20",
    'ezAir-B-PC-PO': "UA-4086206-21",
    'ezAir-P-PC-PO': "UA-4086206-22",
    'PCUT': "UA-4086206-10",
    'PCUC': "UA-4086206-11",
    'PCUA': "UA-4086206-14",
    'PCUF': "UA-4086206-15",
    'PCUR': "UA-4086206-16",
    '_default': "UA-4086206-1"
  };


  function do_tracking(name){
    var account = _accounts[name] || _accounts['_default'];
    if(!run_once){
      _gaq.push( // Apply Google Analytics configuration
          [ '_setAccount', account ],
          [ '_setDomainName', 'princess.com' ],
          [ '_setAllowLinker', true ],
          [ '_trackPageview' ],
          function(){ pageTracker = _gat._getTrackerByName('') }
      );
      run_once = true;
    }
  }

  window.ganalyze = window.setSiteCatalystVariable = do_tracking; 

})(window, document);



function gaDownloadURL(url,params,appName){
  if (window.focus()) {
    self.focus();
  }	
  window.open(url,"new",params);	
  pageTracker._trackPageview(appName);		
}


