//	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
//	Last updated: 	12-Feb-2006
//	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// (With some MAJOR modifications by J.A.D of PWW, 17-Oct-2008...)


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

function trackfiles( e ) {

	var event = ( (e) ? e : document.event );
	anchor = ( event.srcElement && typeof event.srcElement != 'undefined' ) ?
						event.srcElement : event.target;

	var trgt = anchor.href;
	if ( typeof anchor.parentNode.href != 'undefined' ) {
		trgt = anchor.parentNode.href;
	}

	var strRoot = location.protocol + '//' + location.host;
	trgt = trgt.replace( strRoot, '' );
	pageTracker._trackPageview( trgt );
}

attachHandler( window , 'onload', function( ) {
	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(/\.(doc|pdf|xls|ppt|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3|swf)$/)) {
						addtrackerlistener(hrefs[l]);
					}
//				} else {
//					addtrackerlistener(hrefs[l]);
//				}
			}
			catch(err) { }
	}
});