// Settings
var hhDownloadExtensions = "avi,doc,docx,dwg,dxf,eps,exe,gz,jpg,mov,mp3,mpg,pdf,pps,ppt,pptx,rar,rtf,tar,tif,txt,wav,wmv,xls,xlsx,xml,zip";

// Startup
hhReplaceEvent(window, function() { hhFixTitle(); hhSetupEvents("pageTracker", null, null); }, null, 'load');
hhFixTitle();
var hhGaPath = "/" + (hhSearchText == null || hhSearchText == "" ? hhPath : hhAddParameter(hhAddParameter(hhPath, "search", hhSearchText), "category", hhSearchCategory));
var pageTracker = _gat._getTracker(hhGaAccount);
pageTracker._trackPageview(hhGaPath);

function hhFixTitle() {
	document.title = document.title.replace(/(^[ \t\r\n]*|[ \t\r\n]*$)/g, "").replace(/[ \t\r\n]+/g, " ");
}

/*
* Setup standard onclick events with optional hooks
* Version 1.5
*/
function hhSetupEvents(t, h1, h2) {
	var a = document.getElementsByTagName("A");
	if (a != null) {
		var b, d, e;
		var domainList = null;
		if ((b = /^https?:\/\/([^:\/]*)/i.exec(document.URL)) != null && b.length == 2)
			domainList = "," + b[1].toLowerCase() + "," + (hhSiteDomains != null ? hhSiteDomains + "," : "");
		for (var i = 0; i < a.length; i++) {
			if (a[i].href == null)
				continue;
			d = e = null;
			if (h1 != null && typeof (h1) == "function") {
				h1(a[i]);
			}
			if (domainList != null && (b = /^https?:\/\/([^:\/]*)[^\/]*(.*)$/i.exec(a[i].href)) != null && b.length == 3 && b[1].length > 0 && domainList.indexOf("," + b[1].toLowerCase() + ",") < 0) {
				d = "Exit: " + b[1].toLowerCase() + b[2].replace(/^\/$/, "");
				e = b[0];
			} else if ((b = /^mailto:(.*)$/i.exec(a[i].href)) != null && b.length == 2 && b[1].length > 0) {
				d = "Mail: " + b[1].toLowerCase();
				e = b[0].toLowerCase();
			} else if ((b = /^https?:\/\/[^\/]*(\/.*)\.([^.]*)$/i.exec(a[i].href)) != null && b.length == 3 && b[1].length > 0 && ("," + hhDownloadExtensions + ",").indexOf("," + b[2].toLowerCase() + ",") >= 0) {
				d = "File: " + b[1] + "." + b[2];
				e = b[1] + "." + b[2];
			} else if ((b = /^https?:\/\/[^\/]*(\/.*)([?&])([a-z][a-z]*)(=1.*)$/i.exec(a[i].href)) != null && b.length == 5 && b[3].length > 0 && ("," + hhDownloadExtensions + ",").indexOf("," + b[3].toLowerCase() + ",") >= 0) {
				d = "File: " + b[1] + b[2] + b[3] + b[4];
				e = b[1] + b[2] + b[3] + b[4];
			} else if (a[i].href.match(/^ *javascript:.*\. *print *\( *\) *;? *$/i) && hhGaPath != null && hhGaPath != "") {
				d = "Print: " + document.title;
				e = hhGaPath.replace(/\?.*$/, "") + "?print";
			}
			if (e != null && h2 != null && typeof (h2) == "function") {
				e = h2(e);
			}
			if (d != null) {
				hhOnClick(a[i], "var t = document.title; document.title = '" + d.replace(/([\'\\])/g, "\\$1") + "'; " + t + "._trackPageview('" + e.replace(/([\'\\])/g, "\\$1") + "'); document.title = t;");
			}
		}
	}
}

/*
* Add a query-string parameter
* Version 1.0
*/
function hhAddParameter(u, n, v) {
	if (n == null || n == "" || v == null || v == "")
		return u;
	return u + (u.indexOf("?") == -1 ? "?" : "&") + escape(n) + "=" + escape(v);
}

/*
* Add or replace an onclick event to an element
* Version 1.0
*/
function hhOnClick(e, g) {
	hhReplaceOnClick(e, g, null);
}
function hhReplaceOnClick(e, g, r) {
	hhReplaceEvent(e, g, r, "click");
}
function hhReplaceEvent(e, g, r, n) {
	if (typeof (e) != "object" || n == null)
		return;
	var f = (typeof (g) == "function" ? g : hhGetEventHandler(g));
	var q = (typeof (r) == "function" ? r : hhGetEventHandler(r));
	if (typeof (e.addEventListener) == "function" || typeof (e.addEventListener) == "object") {
		if (q != null) {
			e.removeEventListener(n, q, false);
		}
		if (f != null) {
			e.removeEventListener(n, f, false);
			e.addEventListener(n, f, false);
		}
	} else if (typeof (e.attachEvent) == "function" || typeof (e.attachEvent) == "object") {
		if (q != null) {
			e.detachEvent('on' + n, q);
		}
		if (f != null) {
			e.detachEvent('on' + n, f);
			e.attachEvent('on' + n, f);
		}
	}
}

/*
* Create or get an event handler from a code string
* Version 1.0
*/
var hhLiteralEventHandlers = new Array();
function hhGetEventHandler(t) {
	var f;
	if (t == null)
		return null;
	if ((f = hhLiteralEventHandlers[t]) != null)
		return f;
	f = hhLiteralEventHandlers[t] = new Function(t);
	return f;
}