var hrefs = document.getElementsByTagName("a");
var link_path = "";
for (var l = 0; l < hrefs.length; l++) {
		try {
			var link_path = hrefs[l].pathname;
			if (location.host == hrefs[l].hostname) {
				if (link_path.match(/\.(avi|css|doc|exe|js|mov|mp3|pdf|ppt|rar|txt|vsd|vxd|wma|wmv|xls|zip)$/)) {
					addtrackerlistener(hrefs[l]);
				}
			} else {
				addtrackerlistener(hrefs[l]);
			}
		}
		catch(err) { }
}


function addtrackerlistener(obj) {
		if (obj.addEventListener) {
		obj.addEventListener('click', trackfiles, true);
	} else if (obj.attachEvent) {
		obj.attachEvent("on" + 'click', trackfiles);
	}
}

function trackfiles(array_element) {
	file_path = "";

	if (location.host != this.hostname) {
		file_path = "/links/" + ((array_element.srcElement) ? "/" + array_element.srcElement.hostname : this.hostname);
	}
	file_path = file_path + ((array_element.srcElement) ? "/" + array_element.srcElement.pathname : this.pathname);
	
	// for other browsers than IE
	if (location.host == this.hostname) {
		file_path = "/links//" + location.host + file_path;
	}	 

	urchinTracker(file_path);
}