function restoreBlockState(blockId) {
	if ($.cookie('blockState-'+blockId) > 0) {
		$("#"+blockId).show();
	}
	else {
		$("#"+blockId).hide();
	}
}

// toggles a block, and saves the actual state in cookie, if second parameter is true
// the saved state should be restored on load with restoreBlockState(blockId);
function toggleBlock(blockId, saveCookie) {
	if( $("#"+blockId+":visible").length ) {
		$("#"+blockId).hide(200);
		if (saveCookie) {
			$.cookie('blockState-'+blockId, 0, { path: "/" });
		}
	}
	else {
		$("#"+blockId).show(200);
		if (saveCookie) {
			$.cookie('blockState-'+blockId, 1, { path: "/" });
		}
	}
}

$(document).ready(function() {
	$('a.new-window').live('click', function() {
		window.open($(this).attr('href'));
		return false;
	});

	$("#search_form-submit").click( function(event) {
		event.preventDefault();
		var val = $("#search_form-text").attr("value");
		if ( (typeof(val) != "undefined") && val ) {
			$("#search_form").submit();
		}
	} );
	
	var h_mn = $('div.home-middle').height();
	var ih_c = $('div#content').innerHeight();
	
	if( h_mn < ih_c ) {
		$('div.home-middle').height(ih_c);
	}
});

