$(document).ready(function(){    $('a').each(function(){        var link = $(this)[0].href;        var pdfFiles = /\.(pdf)$/i;        var imgFiles = /\.(jpg|gif|png)$/i;        var allFiles = /\.(pdf|doc*|xls*|ppt*|jpg|gif|png|zip|mp3|mp4|mov)$/i;        var action = '';        var _onclick = new String($(this).attr('onclick'));		        //remove onclick pagetrack event from links        if(_onclick.indexOf('pageTracker') != -1)        {            $(this).removeAttr('onclick');        }		        //check to make sure link is not external        if ((!link.match(/^https?\:/i)) || (link.match(document.domain)))        {            //if link leads to a download, we listen to the click event of that link            //All Files event is guranteed to be tracked at this point            if(link.match(allFiles))            {                $(this).click(function() {                    action = 'Link Click Capture';					                    //if it's a pdf file and not from downloads directory                    if(link.match(pdfFiles) && link.indexOf('/downloads') == -1)                    {                        trackIt('PDF Downloads', action, link, 1);                    }                    //if it's a pdf file or image file and from downloads directory or peerx directory                    else if((link.match(pdfFiles) || link.match(imgFiles)) && (link.indexOf('/downloads') != -1 || link.indexOf('/peerx/cool-stuff') != -1))                    {                        trackIt('N4T Downloads', action, link, 1);                    }					                    //catch all event                    trackIt('All Files', action, link, 1);                });            }        }    });});function trackIt(category, action, link, opt){//    pageTracker._trackEvent(category, action, link, 1);    _gaq.push(['_trackEvent', category, action, link]);}
