$(document).ready(function() {
	// Background colour crossfade on main nav
	$('#nav-site li').not('.active').hover(
		function(){ $(this).find('a').stop().animate({ backgroundColor: '#1373c6' }, 250); },
		function(){ $(this).find('a').stop().animate({ backgroundColor: '#93c94a' }, 250); }
	);
	
	// Open the scoring chart on the scores page
	$('#scoring-chart-link').fancybox({
			autoScale: false,
			padding: 5,
			onStart: function(){
				$('html, body').scrollTop(($('body').height() / 2) - $(window).height() / 2);
			}
		});
	
	// Open the video overlay on the home page
	$('#video-home a').fancybox({
		autoScale: false,
		autoDimensions: false,
		height: 480,
		width: 720,
		hideOnOverlayClick: false,
		padding: 5,
		onComplete: function(){
			$('#fancybox-content > div').css('overflow', 'hidden');
		}
	});
		
	// Add the FAQ numbers
	$('#faq-items dt').each(function(i){
		$(this).prepend('<span class="faq-num">'+(i + 1)+'</span>')
	});
	
	// Add even/odd class names to table rows for 'zebra' style alternating rows
	$('table.zebra tr:even').addClass('row-even');
	$('table.zebra tr:odd').addClass('row-odd');
});

$(window).load(function(){
	// Find columns and make them the same size
	$('.row').each(function(){
		var h = 0;
		$(this).children('.col').each(function(){
			if ($(this).height() > h) {
				h = $(this).height();
			}
		}).css('min-height', h+'px');
	});
});


/**
 * Function: toggle_option
 * Takes the unique ID of a checkbox, toggles the 'checked' attribute and the parent node's classname.
 * 
 * Parameters:
 * @param id string
 *   Unique ID
*/
function toggle_option(id) {
	var $input = $('#'+id);
	if ($input.attr('checked') == 'checked') {
		$input.removeAttr('checked').parent().removeClass('checked').blur();
	} else {
		$input.attr('checked', 'checked').parent().addClass('checked').blur();
	}
	return;
}
