var menuStatus = Array();

/* used for the cookie thing. Remove val if
 * it's in the array and add it if not */
function csv2array (str) {
	if ( ! str) return new Array();
			var arr = new Array();
			var tmp = "";
			for (var i=0; i < str.length; i++) {
				if (str[i] == ",") {
					arr.push(tmp);
					tmp = "";
				} else 
					tmp += str[i];
			}
			arr.push(tmp);
			return arr;
}

function toggleInArray(arr, val) {
	if (val == "") return arr; // don't try to fool me!
	for (var i=0; i < arr.length; i++) {
		if (arr[i] == val) {
			arr.splice(i, 1);
			return arr;
			}
	}
	arr.push(val);
	return arr;
}

function toggleStatus(val) {
	$.cookie('tomk32_menu_status', toggleInArray(menuStatus, val));
}


function debug(msg) { 
	if ($('#debug').length == 0) 
		$('body').prepend('<div id="debug"></div>');
	$('#debug').append("<br />" + msg);
}


/* here starts the important JQuery stuff */


$(document).ready(
	function() {

	// keep some posts extended
	if (typeof postsShowFully == "undefined")
		postsShowFully = 2;
	$(".post:lt(" + postsShowFully + ")").addClass('show');


	
	$('.post').not('.show').children('h2.title a').one('click', function() {
		$(this).siblings().show(0);
		$(this).parents('.post:first').toggleClass('show');
		return false;
	});
	$('.post').not('.show').children().not('h2.title').hide(0);



});