﻿jQuery.fn.trackLinks = function(){
    var Url = location.pathname;
    var arrayUrl = Url.split(".");
    var FileExtensionLength = arrayUrl[arrayUrl.length-1].length + 1;
    //log links odd filetypes/downloads 
    $("a[href$='.doc'], a[href$='.xls'], a[href$='.pdf'], a[href$='.zip'], a[href$='.pps'], a[href$='.ppt'], a[href$='.mp3']").bind("click", function(){
        if(pageTracker){pageTracker._trackPageview(Url.substr(0,(Url.length-FileExtensionLength)) + '/documents' + $(this).attr('href'));}
    });
    //log links to external sites
    $("a[href^='http://'], a[href^='https://']").bind("click", function(){
        if(pageTracker){pageTracker._trackPageview(Url.substr(0,(Url.length-FileExtensionLength)) + '/outgoing/' + $(this).attr('href'));}
    });
};