// Google analytics tracking code
//
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-148345-11']);
_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);
})();

// Facebox rel=facebox onLoad
//
$(document).ready(function($) {
  $('a[rel*=facebox]').facebox() 
});


$(document).ready(function(){
    
    // Add a favicon to all links with class name favicon
    //
    $("a.favicon").each(function() {
        this.style.paddingLeft = '25px';
        this.style.background = 'transparent url(' + faviconFromLink(this) + ') no-repeat top left';
    });
    
    // Track user clicks on specified links
    //
    $("a.track").click(function() {
        var link = $(this).attr("href");
        var category = $(this).attr("rel");
        
        if(!category) {
            category = "General";
        }
        
        _gaq.push(['_trackEvent', category, link]);
    });
    
});

function faviconFromLink(link) {
    var googleFaviconBaseURL = "http://www.google.com/s2/favicons?domain=";
    return (googleFaviconBaseURL + link.hostname);
}

