//	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, <script>mail2("colm.mcbarron","iqcontent",0,"","Colm McBarron")</script>
//	Last updated: 	12-Feb-2006
//	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//

var hrefs = document.getElementsByTagName("a");
var link_path = "";
for (var l = 0; l < hrefs.length; l++) {
        try {
			var link_path = hrefs[l].pathname;
            //alert(location.hostname+":"+location.port+" :::::: "+hrefs[l].hostname+":"+hrefs[l].port);
            if (location.hostname+":"+location.port == hrefs[l].hostname+":"+hrefs[l].port) {
				if (link_path.match(/\.(doc|pdf|xls|ppt|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3)$/)) {
					addtrackerlistener(hrefs[l]);
                    //alert("if");
				}
			} else {
				//addtrackerlistener(hrefs[l]); //we are ignoring any external link tracking for CSE
                //alert("else");
			}
		}
		catch(err) { }
}

function addtrackerlistener(obj) {
    obj.onclick = Function('trackfiles("'+obj.title+'","'+obj.href+'")');
}

function trackfiles(title, href) {
    cseTrackDocuments(title, href.substring(href.lastIndexOf(".")+1, href.lastIndexOf(".")+4));
}

