$(document).ready(function() {

    //**********************************************************************
    //Purpose:          Records specified link type clicks in Google Analytics,
    //                  uses jQuery, code references include:
    //                  1. http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55529
    //                  2. http://stackoverflow.com/questions/179713/how-to-change-the-href-for-a-hyperlink-using-jquery
    //                  3. http://www.carronmedia.com/extend-google-analytics-with-jquery/
    //Organization:     Bostrom, Inc.
    //Author:           Chris Hecht
    //Date:             3/2010
    //**********************************************************************

    //load Google Analytics 
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    $.getScript(gaJsHost + "google-analytics.com/ga.js", function() {

        //add to Google Analytics
        try {
        //***** site-specific code here *****
            var pageTracker = _gat._getTracker("UA-6471070-1");
            pageTracker._trackPageview();
        }
        catch (err) {
        }

        //secify file types to track
        var filetypes = /\.(zip|pdf|doc*|xls*|ppt*|)$/i;
        //loop through all links
        $('a').each(function() {
        //if link contains an href (<a name does not and breaks in IE 8) and is to specified file type
            if ($(this).attr('href') != null && $(this).attr('href').match(filetypes)) {
                //remove protocol and domain from path
                //***** site-specific code here *****
                var filePath = $(this).attr('href').replace(/^https?\:\/\/(www.)escsi\.org\//i, '');
                //bind to onclick event of current link
                $(this).click(function() {
                    //handle error if Google Analytics is not available
                    try {
                    //add to Google Analytics
                    pageTracker._trackPageview(filePath);
                    }
                    catch (err) {
                    }
                });
            }
        });

    });

});
