$(function() {
	if(document.location.hash != '') {
		show_hash_section(document.location.hash);
	}

	$("#presentation-button-bar A").mouseover(function() {
		$(this).parent().parent().parent().addClass(this.id);
	}).mouseout(function() {
		$(this).parent().parent().parent().removeClass(this.id);
	});

	$("#presentation-button-bar A").click(function() {
		var show = $(this).attr('href');
		show_hash_section(show);
	});

	/* Colorpicker setup if required */
	$('.color_selector').ColorPicker({
		color: '#0000ff',
		onShow: function (colpkr) {
			$(colpkr).fadeIn(500);
			return false;
		},
		onHide: function (colpkr) {
			$(colpkr).fadeOut(500);
			return false;
		},
		onSubmit: function (hsb, hex, rgb, el) {
			$(el).val(hex);
			$(el).css('backgroundColor', '#' + hex);
			$(el).ColorPickerHide();
		},
		onBeforeShow: function () {
			$(this).ColorPickerSetColor(this.value);
		}
	});

	/* Table sorter setup if required */
	$("table")
		.tablesorter({widthFixed: true, widgets: ['zebra']})
		.tablesorterPager({container: $("#pager")});
});

function show_hash_section(hash) {
	var id = '-'+hash.split('#')[1];
	$("DIV.hash-section").each(function(index) {
		if(this.id == id) {
			$(this).removeClass('hidden');
			$("#presentation-button-bar").addClass('active-l-'+index);
		} else {
			$(this).addClass('hidden');
			$("#presentation-button-bar").removeClass('active-l-'+index);
		}
	});

	return false;
}



