/* Google Analytics Include */

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28426201-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

///////////////////
// _trackDownloads
jQuery(document).ready(function($) {
    // helper function - allow regex as jQuery selector
    $.expr[':'].regex = function(e, i, m) {
        var mP = m[3].split(','),
            l = /^(data|css):/,
            a = {
                method: mP[0].match(l) ? mP[0].split(':')[0] : 'attr',
                property: mP.shift().replace(l, '')
            },
            r = new RegExp(mP.join('').replace(/^\s+|\s+$/g, ''), 'ig');
        return r.test($(e)[a.method](a.property));
    };

    $('a:regex(href,"\\.(zip|mp\\d+|mpe*g|pdf|docx*|pptx*|xlsx*|jpe*g|png|gif|tiff*)")$').live('click', function(e) {
        _gaq.push(['_trackEvent', 'download', 'click', this.href.replace(/^.*\/\//, '')]);
    });
});

///////////////////
// _trackError: track 404 - Page not found
if (document.title.search(/Page Not Found/i) !== -1) {
    _gaq.push(['_trackPageview', '/vpv/404/' + location.host + location.pathname + '?from=' + document.referrer]);
}
