(function(g, h, k) {
	var l = function() {
		g.focusedElement = null;
		g.focusedForm = null;
		for ( var i = 0, f = h.forms; i < f.length; i++) {
			f[i].focusedElement = null;
			for ( var j = 0, e = f[i].elements; j < e.length; j++) {
				p(e[j], 'focus', n);
				p(e[j], 'blur', o);
			}
		}
	};
	var m = function() {
		if (g._gaq && g.focusedElement) {
			if (g.focusedElement.type != "submit" && g.focusedElement.type != "button") {
				g._gaq.push( [ '_trackEvent', 'Form Abondoned',
						location.pathname, g.focusedForm.name ]);
				g._gaq.push( [ '_trackEvent', 'Form Element Abondoned',
						location.pathname, g.focusedElement.name ]);
			}
		}
	};
	var n = function() {
		g.focusedElement = this.form.focusedElement = this;
		g.focusedForm = this.form.focusedForm = this.form;
	};
	var o = function() {
		g.focusedElement = this.form.focusedElement = null;
		g.focusedForm = this.form.focusedForm = null;
	};
	var p = function(a, b, c) {
		if (a !== k) {
			var b = 'on' + b.toLowerCase().replace(/^on/, '');
			if (a[b] === k) {
				a[b] = c;
			} else {
				var d = a[b];
				a[b] = function() {
					if (d) {
						c.apply(a, arguments);
						return d.apply(a, arguments);
					} else {
						return c.apply(a, arguments);
					}
				};
			}
		}
	};
	p(g, 'unload', m);
	p(g, 'load', l);
})(window, document);

