var top_window;

$(document).ready(function(){
	$('#game-calendar td').each(function(){
		//$(this).wrapInner('<a></a>');//.html('<a>' + $(this).html() + '</a>');
		$(this).find('a').click(function(){
			var url = window.location.pathname + '?game=' + $(this).parent().parent().attr('id').replace('game-', '');
			if (!top_window || top_window.closed) {
				top_window = window.open(
					url,
					'_blank',
					'width=800,height=500,centerscreen=yes,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,chrome=yes,toolbar=no');
				} else {
					
					top_window.location = url;
				}
			top_window.focus();
			$('.current').removeClass('current');
			$(this).parent().parent().addClass('current');
			return false;
		});
	});
	
	$('#game-calendar select').change(function(){
		document.forms[0].submit();
	});
/*
	$('#game-calendar td a').each(function(){
		$(this).click(function(){
			//$('form input').attr('value', $(this).parent().parent().find('td:first-child').text());
			//document.forms[0].submit();
		});
	}); */
});
