$(document).ready(function(){

	$('div.header ul li:not(div.header ul li ul li)').mouseover(function(){
		$(this).children('div.dropdown').show();
		$(this).addClass('dd_active');
		$('a.close').click(function(evt){
			$('div.dropdown').hide();
			evt.preventDefault();
		});
		$('div.header ul li:not(div.header ul li ul li)').mouseleave(function(){
			$(this).removeClass('dd_active');
			$('div.dropdown').hide();
		});
	});
	
	$('.rotational').cycle({
		fx: 'fade',
		speed: 500,
		timeout: 4500,
		pager: 'div.pager'
	});
	
	$('div.tabs a.events').click(function(evt){
		$('#scoreboard').hide();
		$('#events').show();
		$('div.tabs').addClass('events_active');
		evt.preventDefault();
	});
	
	$('div.tabs a.scoreboard').click(function(evt){
		$('#scoreboard').show();
		$('#events').hide();
		$('div.tabs').removeClass('events_active');
		evt.preventDefault();
	});
	
	$('.clear_field').focus(function(){
		if ($(this).val() == $(this).attr('rel')) {
			$(this).val('');
		}
		$(this).blur(function(){
			if ($(this).val().length == 0) {
				$(this).val($(this).attr('rel'));
			}
		});
	});
	
	// Detect highest div and use this to set height for rotational
	var rot_heights = new Array();
	var i = 0;
	$('div.rotational div').each(function(){
		rot_heights[i] = $(this).height();
		i++		
	});
	Array.max = function( array ){
		return Math.max.apply( Math, array );
	};
	var highest_rot = Array.max(rot_heights);
	$('div.rotational').css('height', highest_rot);
	
	// Zebra-stripe action
	$('div.score:odd, div.event:odd, div.column.extra_wide div.content table tr:odd').addClass('altRow');
	//$().ready(function(){$('#mainContent tbody tr:odd').addClass('altRow');});

});
