$(function () {
	  // GA tracking on non-disabled external links
    $("a[href^=http]:not(.disabled)").click(function(){ 
      if(pageTracker) pageTracker._trackPageview('/outgoing/'+ $(this).attr('href'));
    });
    // stop disabled links doing anything
    $('a.disabled').click(function() { 
      return false; 
    });

    var panels = $('div.content-panels > div');
    var tabs = $('ul.mainnav a');
		var blurb_links = $('.photographers a');
		var blurbs = $('#blurbs .blurb');
		var blurb_popup_links = $('.blurb a');
  
    // remove the anchor elements
    panels.each(function () {
      $('[name=' + $(this).attr('id') + ']', $(this)).remove();
    });

    // establish initial selected tab here    
    var hash = window.location.hash.substring(1);
    
    // add the tab click functions and 'click' the initial tab
    tabs.click(function () {
      panels.hide().filter(this.hash).show();
      tabs.removeClass('selected');
      $(this).addClass('selected');
      //window.location.hash = $(this).attr('href');
      return false;
    }).filter(hash.length > 0 ? '[href=#' + hash +']' : ':first').click();

		// turn the blurbs into popups that close when they are clicked
		$('#blurbs').addClass('overlay');
		
		// hide all the blurbs, add a clearer br to the end of each, and
		// add an action to hide the popup when it is clicked
		var clearer = '<br class="overlay_clear"/>';
		blurbs.hide().append(clearer).click(function() {
			$(this).hide();
			return true;
		});

		// make the photographer icons in the grid show the relevant popup
		blurb_links.click(function() {
			blurbs.hide().filter(this.hash).show();
      return false;
		});
		
});