	$(document).ready(function() {
	   	calendarAjax();
	   	tabreplays();
		$("ul.sf-menu").supersubs({ 
		minWidth:    5, 
		maxWidth:    27, 
		extraWidth:  1 
		}).superfish({animation: {height:'show'}, delay: 300});
		
		var highestColFrontpage = Math.max($('#latest-news-frontpage').height(),$('#race-calendar-frontpage').height(),$('#next-racing-frontpage').height());
			$('#latest-news-frontpage').height(highestColFrontpage);
			$('#race-calendar-frontpage').height(highestColFrontpage); 
			$('#next-racing-frontpage').height(highestColFrontpage); 
		
		$('#gallery').before('<div id="pic_nav">').cycle({
				           fx: 'fade',
				           pause: 'true',
				           speed:  'slow',
				           pager: '#pic_nav',
				           pause:   2
			});
								
			$(function() {
        	$('#gallery a').lightBox();
    		});
		});
		
		function tabreplays() {
          var tabContainers = $('div.tabs > div');
          tabContainers.hide().filter(':first').show();
          $('div.tabs ul.tabNavigation a').click(function () {
              tabContainers.hide();
              tabContainers.filter(this.hash).show();
              $('div.tabs ul.tabNavigation a').removeClass('selected');
              $(this).addClass('selected');
              return false;
           }).filter(':first').click();
                     if (window.location.hash)
          {
               $("div.tabs ul.tabNavigation a[href='"+window.location.hash.toUpperCase()+"']").click();
          }
                    
      };             
              
		
		function calendarAjax () {
      		$('thead th a').live('click', function() {
        	$('#calendar_holder').fadeOut().load($(this).attr('href')+' #calendar' , function(){
        	$(this).fadeIn();
      			});
          return false;
         });
        }