// We dont want the try adding the tracking code until the page links are loaded
if (document.addEventListener) { 
document.addEventListener("DOMContentLoaded", addEvents, null); // Firefox
} else {
addEvents(); // IE : Call the function immediately because the script is referenced with the defer attribute supported by IE
}

function addEvents()
{
// quit if this function has already been called 
if (arguments.callee.done) return; 
// flag this function so we don't do the same thing twice 
arguments.callee.done = true;
for (i=0; i <document.links.length; i++) 
{
var x = document.links[i];
// Only attach tracking code to specific file types
var extensions = new RegExp(".+\.(zip|pdf|xls|doc|csv|txt|ppt|xml|rtf)$");
var doc = x.href.toLowerCase().match(extensions);
if (doc)
{
if (x.attachEvent)
{
x.attachEvent('onclick', function () {TrackIt(window.event.srcElement)}); // IE
} else {
x.addEventListener('click', function () {TrackIt(this)}, false); // Firefox
}
}
}
}

function TrackIt(link)
{
// Remove the conversion to Lowercase if you are on a Case sensitive web server
urchinTracker(link.href.toLowerCase());
}

