$(document).ready(function () {
    // Filetypes that will be instrumented using the dcsMultiTrack() WebTrends function
    var filetypes = "pdf ppt doc docx xls wmv mdb avi mpg mpeg";

    // Construct selectors that will look for both lowercase and uppercase links to files
    var selectors = $.map(filetypes.split(" "), function (filetype) {
        return "a[href$=" + filetype + "], a[href$=" + filetype.toUpperCase() + "]"; 
    }).join(", ");

    var url = "";
    var filename = "";

    // Apply click event to selected files
    $(selectors).map(function () {
        url = $(this).attr("href");
        filename = basename(url); 

        // Pre-clear any events that may have been defined in-line 
        $(this).unbind();

        //console.log('URL: %o FILENAME: %o', url, filename);

        $(this).click(function () {
            dcsMultiTrack("DCS.dcsuri", url, "WT.ti", filename);
            //console.log('URL: %o FILENAME: %o', url, filename);
        });
    });
});
