//	Javascript to tag file downloads and external links in Google Analytics
//	To use, place reference to this file should be placed at the bottom of all pages, 
//	just above the Google Analytics tracking code.
//	All outbound links and links to non-html files should now be automatically tracked.
//
//  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//	Created by: 	Colm McBarron, colm.mcbarron@iqcontent.com
//      Modified by Sean Neilan, www.metristpartners.com to work in IE and Firefox for lindane.com
//	Last updated: 	June 29, 2007
//	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//

var hrefs = document.getElementsByTagName("a"); // get all the anchors into an array

for (var l = 0; l < hrefs.length; l++)
{
	addtrackerlistener(hrefs[l]); // add a tracker to every single anchor
}

function addtrackerlistener(obj) // add the tracker itself, with code for ie and firefox
{
	if (obj.addEventListener) // for Firefox
	{
		obj.addEventListener('click', trackfiles, true);
	} 
	else if (obj.attachEvent) // for IE
	{
		obj.attachEvent("on" + 'click', trackfiles);
	}
}

function trackfiles(array_element) // if an anchor is an internal pdf or an external link, report it
{
	url_report = ""; // the url to report to urchintracker, if it's still blank at the end, then the anchor is an internal html/xhtml file
	
	// these two lines make sure that both IE and Firefox will get the hostname and pathname of the anchor
	path_name = ((array_element.srcElement) ? "/" + array_element.srcElement.pathname : this.pathname);
	host_name = ((array_element.srcElement) ? array_element.srcElement.hostname : this.hostname);
	
	if (host_name.match(/lindane\.com/)) // if it's internal, report it too
	{
		if (path_name.match(/pdf/))
		{
			url_report = path_name;
		}
	}
	else  // if it's external, report it
	{
		url_report = "/offsite/" + host_name + path_name;
	}
	
	if (url_report != "") // if the anchor is external or an internal download, lets now report it!
	{
		_uacct = "UA-1557184-1";
		urchinTracker(url_report);
	}
}
