// gaAddons v2.1.2, Copyright 2010-2011, Stephane Hamel - gaAddons.com
// Licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
var _GA_SCOPE_VISITOR = 1,
    _GA_SCOPE_SESSION = 2,
    _GA_SCOPE_PAGE = 3,
    gaAddons;
if (!window.console) {
  window.console = {};
}
console.log = console.log ||
function () {};
console.info = console.info || console.log;
console.dir = console.dir || console.log;
console.group = console.group || console.log;
console.groupEnd = console.groupEnd ||
function () {};
(function ($) {
  var copyright = "gaAddons v2.1.2, Copyright 2010-2011, Stephane Hamel - gaAddons.com. Licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License";
  String.prototype.mreplace = function (hash, options) {
    if (!options) {
      options = "g";
    }
    var str = this,
        key;
    for (key in hash) {
      if (Object.prototype.hasOwnProperty.call(hash, key)) {
        str = str.replace(new RegExp(key, options), hash[key]);
      }
    }
    return str;
  };
  gaAddons = {
    _: {
      _4Q: {
        account: "",
        loc: "4Q-WEB2",
        lID: 1,
        src: "http://4qinvite.4q.iperceptions.com/1.aspx",
        allowLinker: true,
        domainName: "none"
      },
      _formAnalysis: {
        onBounce: true,
        minFields: 3,
        formList: "",
        lastForm: null,
        lastField: "Empty",
        selector: "form"
      },
      _options: {
        debug: false,
        delay: 100
      },
      _setDayOfWeek: {
        index: 1,
        name: "DayOfWeek",
        value: null,
        scope: _GA_SCOPE_SESSION,
        days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
      },
      _setDualMode: {
        path: "//" + location.host + "/__utm.gif"
      },
      _setXDomain: {
        domainName: null,
        action: "click",
        include: null,
        exclude: /^$/,
        url: null,
        selector: "a"
      },
      _trackDownload: {
        onBounce: true,
        method: "page",
        category: "download",
        action: "click",
        value: 0,
        include: /\.(docx*|xlsx*|pptx*|exe|rar|zip|pdf|xpi|mp3|mp4|flv|wmv)$/i,
        exclude: /^$/,
        format: "/Êtegory%/¬tion%/%hostname%%pathname%",
        selector: "a"
      },
      _trackError: {
        method: "event",
        category: "error",
        error: /(404|500)/,
        value: 0
      },
      _trackLoadTime: {
        onBounce: true,
        category: "loadTime",
        method: "event",
        bucket: [100, 500, 1500, 2500, 5000],
        time: (new Date).getTime(),
        value: 0,
        index: 1,
        scope: _GA_SCOPE_PAGE
      },
      _trackMailTo: {
        onBounce: true,
        method: "event",
        category: "mailto",
        action: "click",
        value: 0,
        include: /./,
        exclude: /^$/,
        selector: "a"
      },
      _trackOutbound: {
        onBounce: true,
        method: "event",
        category: "outbound",
        action: "click",
        value: 0,
        include: /./,
        exclude: /^$/,
        format: "/Êtegory%/¬tion%/%hostname%%pathname%",
        selector: "a"
      },
      _trackPageview: {
        title: document.title,
        url: document.href,
        delay: 100
      },
      _trackRealBounce: {
        category: "NoBounce",
        delay: 30,
        value: 0
      }
    },
    _get__utmb: function () {
      var kv = document.cookie.match("(^|;) ?__utmb=([^;]*)(;|$)");
      return kv ? parseInt(kv[2].split(/\./)[1]) : 1;
    },
    _4Q: function () {
      var a = arguments[1];
      window.pageTracker4Q = _gaq._getAsyncTracker();
      _gaq._push([a.tracker + "_setAllowLinker", a.allowLinker], [a.tracker + "_setDomainName", a.domainName]);
      $.getScript(a.src + "?sdfc=" + a.account + "&lID=" + a.lID + "&loc=" + a.loc);
    },
    _formAnalysis: function () {
      $(document).bind("ready", arguments[1], function (e) {
        var a = e.data;
        if (!a.onBounce && _gaq._firstGACall) {
          return;
        }
        if (!a.formList) {
          $(e.data.selector).each(function () {
            var n = $(this).attr("name");
            if (!gaAddons._._formAnalysis.lastForm && n && $(":input", this).not(":button,:hidden,:submit").length > a.minFields) {
              $(":input", this).focusout(function () {
                gaAddons._._formAnalysis.lastForm = $(this).parents("form").attr("name");
                gaAddons._._formAnalysis.lastField = $(this).attr("name");
              });
              $(this).submit(function (e) {
                $(window).unbind("unload.gaAddons");
                var a = gaAddons._._formAnalysis;
                if (a.lastForm) {
                  _gaq.push([a.tracker + "_trackEvent", "form analysis:" + a.lastForm, e.type, a.lastField]);
                }
              });
            }
          });
        }
        if (a.formList) {
          $(window).bind("unload.gaAddons", function (e) {
            var a = gaAddons._._formAnalysis;
            if (a.lastForm) {
              _gaq.push([a.tracker + "_trackEvent", "form analysis:" + a.lastForm, e.type, a.lastField]);
            }
          });
        }
      });
    },
    _options: function () {
      $.extend(gaAddons._._options, arguments[1]);
    },
    _setDayOfWeek: function () {
      if (_gaq._firstGACall) {
        var a = arguments[1];
        a.value = a.value || a.days[(new Date).getDay()];
        _gaq._push([a.tracker + "_setCustomVar", a.index, a.name, a.value, a.scope]);
      }
    },
    _setDualMode: function () {
      var a = arguments[1];
      _gaq._push([a.tracker + "_setLocalGifPath", a.path + "#" + document.cookie.replace(/;\s*/g, "&")], [a.tracker + "_setLocalRemoteServerMode"]);
    },
    _setXDomain: function () {
      var a = arguments[1],
          url = location.href;
      if (a.url) {
        url = a.url;
      }
      var cd = null;
      if (a.domainName && a.include && ((new RegExp(a.domainName, "i")).test(url) || (cd = url.match(a.include)))) {
        if (!/\\\//.test(a.include)) {
          _gaq._push([a.tracker + "_setDomainName", cd ? cd[0] : a.domainName], [a.tracker + "_setAllowLinker", true], [a.tracker + "_setAllowHash", false]);
        } else {
          if (cd) {
            _gaq._push([a.tracker + "_setDomainName", "none"], [a.tracker + "_setAllowLinker", true]);
          } else {
            _gaq._push([a.tracker + "_setAllowLinker", true], [a.tracker + "_setDomainName", a.domainName], [a.tracker + "_setAllowHash", false]);
          }
        }
      }
      if (a.domainName && !a.include && (new RegExp(a.domainName, "i")).test(url)) {
        _gaq._push([a.tracker + "_setDomainName", a.domainName], [a.tracker + "_addIgnoredRef", a.domainName]);
        gaAddons._._setXDomain.include = a = /^$/;
      }
      if (!a.domainName && a.include && /^\//.test(a.include) && (new RegExp(a.include, "i")).test(url)) {
        _gaq._push([a.tracker + "_setCookiePath", a.include]);
      }
      $(document).ready(function () {
        var a = gaAddons._._setXDomain;
        if (a.include) {
          $(a.selector).each(function () {
            var h = $(this).attr("href");
            if (a.include.test(h) && !a.exclude.test(h) && !/(mailto\:|__utma)/.test(h)) {
              $(this).mouseup(function (e) {
                if (/__utma/.test(this.href)) {
                  return;
                }
                var pageTracker = a.tracker ? _gat._getTrackerByName(a.tracker.replace(/\./, "")) : _gat._getTrackerByName(),
                    n = pageTracker._getLinkerUrl(this.href);
                if (gaAddons._._options.debug) {
                  console.info("_getLinkerUrl: " + this.href + " > " + n);
                }
                this.href = n;
              });
            }
          });
        }
      });
    },
    _trackDownload: function () {
      $(document).bind("ready", arguments[1], function (e) {
        $(e.data.selector).each(function () {
          var h = $(this).attr("href");
          if ((e.data.onBounce || !_gaq._firstGACall) && e.data.include.test(h) && !e.data.exclude.test(h)) {
            $(this).bind("mouseup", e.data, function (e) {
              if (e.data.action === "click" && e.which !== 1) {
                return;
              }
              var v = this.href.match(/\/\/(.+)$/)[1],
                  t = this.target.length ? this.target : "_self",
                  ftype = this.pathname.match(/\.([^\.]+)/);
              var p = e.data.format.mreplace({
                'Êtegory%': e.data.category,
                '¬tion%': e.which === 1 ? "click" : "mouseup",
                '%target%': t,
                '%value%': e.data.value,
                '%pagename%': document.title,
                '%title%': $(this).text(),
                '%hash%': this.hash,
                '%host%': this.host,
                '%hostname%': this.hostname,
                '%href%': this.href,
                '%pathname%': this.pathname,
                '%port%': this.port,
                '%protocol%': this.protocol,
                '%search%': this.search,
                '%filetype%': ftype ? ftype[1] : "n/a",
                '%location.hash%': document.location.hash,
                '%location.host%': document.location.host,
                '%location.hostname%': document.location.hostname,
                '%location.href%': document.location.href,
                '%location.pathname%': document.location.pathname,
                '%location.port%': document.location.port,
                '%location.protocol%': document.location.protocol,
                '%location.search%': document.location.search,
                '%location%': document.location
              });
              if (e.data.method === "event") {
                var ar = p.split(/\//);
                _gaq.push([e.data.tracker + "_trackEvent", ar.slice(1, 2).toString(), ar.slice(2, 3).toString(), ar.slice(3).join("/"), e.data.value]);
              } else {
                _gaq.push([e.data.tracker + "_trackPageview", p]);
              }
              if (e.which === 1 && !e.metaKey && t !== "_blank") {
                setTimeout("window.open(\"" + this.href + "\",\"" + t + "\")", gaAddons._._options.delay);
                e.preventDefault();
                return false;
              }
            });
          }
        });
      });
    },
    _trackError: function () {
      var a = arguments[1];
      $.ajax({
        type: "HEAD",
        url: this.href,
        complete: function (XMLHttpRequest, textStatus) {
          if (a.error.test(XMLHttpRequest.status)) {
            _gaq._push(a.method === "event" ? [a.tracker + "_trackEvent", a.category, XMLHttpRequest.status, document.referrer, a.value] : [a.tracker + "_trackPageview", "/" + a.category + "/" + XMLHttpRequest.status + "/" + document.referrer]);
          }
        }
      });
    },
    _trackLoadTime: function () {
      var a = arguments[1];
      gaAddons._._trackLoadTime.now = a.onBounce || !_gaq._firstGACall;
      $(document).ready(function () {
        var a = gaAddons._._trackLoadTime;
        if (a.now) {
          var diffTime = (new Date).getTime() - a.time,
              i, bucketString;
          if (typeof a.bucket === "object") {
            for (i = 0; i < a.bucket.length; i++) {
              if (diffTime < a.bucket[i]) {
                bucketString = i ? a.bucket[i - 1] + "-" + (a.bucket[i] - 1) : "0-" + (a.bucket[0] - 1);
                break;
              }
            }
            if (!bucketString) {
              bucketString = a.bucket[a.bucket.length - 1] + "+";
            }
          } else {
            i = parseInt(diffTime / (a.bucket * 1000));
            bucketString = i * a.bucket + "-" + ((i + 1) * a.bucket - 1);
          }
          _gaq.push(a.method === "event" ? [a.tracker + "_trackEvent", a.category, bucketString, "", a.value ? a.value : diffTime] : [a.tracker + "_setCustomVar", a.index, a.category, bucketString, _GA_SCOPE_PAGE]);
        }
      });
    },
    _trackMailTo: function () {
      $(document).bind("ready", arguments[1], function (e) {
        $(e.data.selector).each(function () {
          var h = $(this).attr("href");
          if (!/^mailto:/i.test(h)) {
            return;
          }
          if ((e.data.onBounce || !_gaq._firstGACall) && e.data.include.test(h) && !e.data.exclude.test(h)) {
            $(this).bind("mouseup", e.data, function (e) {
              if (e.data.action === "click" && e.which !== 1) {
                return;
              }
              var v = this.href.match(/mailto:([^?]+)/)[1];
              _gaq.push(e.data.method === "event" ? [e.data.tracker + "_trackEvent", e.data.category, e.data.action, v, e.data.value] : [e.data.tracker + "_trackPageview", "/" + e.data.category + "/" + v]);
              setTimeout("location.href='" + this.href + "'", gaAddons._._options.delay);
              this.href = "javascript:void()";
              e.preventDefault();
              return false;
            });
          }
        });
      });
    },
    _trackOutbound: function () {
      $(document).bind("ready", arguments[1], function (e) {
        $(e.data.selector).each(function () {
          var h = $(this).attr("href");
          if (!/^http/i.test(h)) {
            return;
          }
          var r = new RegExp("//" + location.hostname, "i");
          if ((e.data.onBounce || !_gaq._firstGACall) && !r.test(h) && e.data.include.test(h) && !e.data.exclude.test(h) && (!gaAddons._._setXDomain.include || gaAddons._._setXDomain.include && !gaAddons._._setXDomain.include.test(h))) {
            $(this).bind("mouseup", e.data, function (e) {
              if (e.data.action === "click" && e.which !== 1) {
                return;
              }
              var h = $(this).attr("href"),
                  v = this.href.match(/\/\/(.+)$/)[1],
                  t = this.target.length ? this.target : "_self",
                  ftype = this.pathname.match(/\.([^\.]+)/);
              var p = e.data.format.mreplace({
                'Êtegory%': e.data.category,
                '¬tion%': e.which === 1 ? "click" : "mouseup",
                '%target%': t,
                '%value%': e.data.value,
                '%pagename%': document.title,
                '%title%': $(this).text(),
                '%hash%': this.hash,
                '%host%': this.host,
                '%hostname%': this.hostname,
                '%href%': this.href,
                '%pathname%': this.pathname,
                '%port%': this.port,
                '%protocol%': this.protocol,
                '%search%': this.search,
                '%filetype%': ftype ? ftype[1] : "n/a",
                '%location.hash%': document.location.hash,
                '%location.host%': document.location.host,
                '%location.hostname%': document.location.hostname,
                '%location.href%': document.location.href,
                '%location.pathname%': document.location.pathname,
                '%location.port%': document.location.port,
                '%location.protocol%': document.location.protocol,
                '%location.search%': document.location.search,
                '%location%': document.location
              });
              if (e.data.method === "event") {
                var ar = p.split("/");
                _gaq.push([e.data.tracker + "_trackEvent", ar.slice(1, 2).toString(), ar.slice(2, 3).toString(), ar.slice(3).join("/"), e.data.value]);
              } else {
                _gaq.push([e.data.tracker + "_trackPageview", p]);
              }
              if (e.which === 1 && !e.metaKey && t !== "_blank") {
                setTimeout("window.open(\"" + this.href + "\",\"" + t + "\")", gaAddons._._options.delay);
                e.preventDefault();
                return false;
              }
            });
          }
        });
      });
    },
    _trackPageview: function () {
      if (typeof arguments[1] === "object") {
        var a = arguments[1];
        var oTitle = document.title;
        document.title = a.title;
        _gaq._push([arguments[0], a.url]);
        setTimeout("document.title = '" + oTitle + "'", a.delay);
      } else {
        _gaq._push([arguments[0], arguments[1]]);
      }
    },
    _trackRealBounce: function () {
      var a = arguments[1];
      if (_gaq._firstGACall) {
        setTimeout("_gaq.push(['" + a.tracker + "_trackEvent','" + a.category + "','over " + a.delay + " seconds', ''," + a.value + "])", a.delay * 1000);
      }
    }
  };
  Array.prototype.gaAddons = function () {
    this._push = Array.prototype.push;
    this._firstGACall = gaAddons._get__utmb() === 1;
    this.push = function () {
      for (v = 0; v < arguments.length; v++) {
        var a = arguments[v];
        var tracker = a[0].split(".");
        var method = tracker.length & 2 ? tracker[1] : tracker[0];
        if (gaAddons[method] && method !== "_trackPageview" || method === "_trackPageview" && typeof a[1] === "object") {
          if (a.length > 1) {
            a[1] = $.extend({}, gaAddons._[method], a[1]);
          } else {
            a[1] = gaAddons._[method];
          }
          a[1].tracker = tracker.length & 2 ? tracker[0] + "." : "";
          if (gaAddons._._options.debug) {
            console.group("gaAddons." + method);
            console.dir(a[1]);
            console.groupEnd();
          }
          gaAddons[method].apply(this, a);
        } else {
          if (gaAddons._._options.debug) {
            console.group("ga." + a[0]);
            a[1] ? console.dir(a[1]) : "";
            console.groupEnd();
          }
          this._push.call(this, a);
        }
      }
      return arguments.length;
    };
  };
})(jQuery);
var _gaq = [];
_gaq.gaAddons();
