jQuery(document).ready(function($) {
	/**
	 * expand and contract sidebar sections/categories
	 */
	$(".ts_title").click(function(e) {
		e.preventDefault(); // stop "switchcat" links
		$(this).parent().find(".ts_entry:first").slideToggle();
	});

	/**
	 * The sidebar links are designed to reload the entire page with
	 * new player parameters so that they'll work when javascript is disabled.
	 *
	 * When JS *is* enabled, this fn will reload only the "ajaxplayer" div with the new video
	 */
	$("a.vidlink").click(function(e) {
		e.preventDefault(); // prevent navigation away from watch.php
		var newHref = $(this).attr("href").replace(/watch\.php/,"player.php"); // Must replace 'watch.php' with 'player.php' for the ajax version
		$("#ec_tutorial_title").text($(this).text());	// Update the title
		$("#ajaxplayer").load(newHref);			// Load new video in the ajaxplayer div
	});
});
