/* this function sets the first tab to active and also gives the first and the last tab classes "first" and "last". In addition it hides unselected content in case of "no_all"-class so you won't have to do it in the html code. Comfy, eh? */
function tabbey_initialize ( tabbey_id ) {
	$("#"+tabbey_id+" li:first").addClass("active");
	$("#"+tabbey_id+" li:first a").addClass("first");
	$("#"+tabbey_id+" li:last a").addClass("last");
	if ( ( $("#"+tabbey_id).hasClass("no_all") ) && ( $("#"+tabbey_id).hasClass("auto") ) ) {
		$("div.content_"+tabbey_id).hide();
		$("div.content_"+tabbey_id+".tab_0").show();
	}
}
$(document).ready(function(){
	$(".tabbey li a").click(function () {
		/* find out what we've been clicking */
		var tabbey_id = this.parentNode.parentNode.id;
		var tab_index = $("#"+tabbey_id+" li a").index(this);
		/* set the tab */
		$("#"+tabbey_id+" li").removeClass("active");
		$("#"+tabbey_id+" li.tab_"+tab_index).addClass("active");
		/* set the content */
		if ( $("#"+tabbey_id).hasClass("auto") ) {
			if ( ( tab_index )|| ( $("#"+tabbey_id).hasClass("no_all") ) ) {
				$("div.content_"+tabbey_id).hide();
				$("div.content_"+tabbey_id+".tab_"+tab_index).show();
			}
			else {
				$("div.content_"+tabbey_id).show(); /* show_all exception */
			}
		}
	});
});
