

/**
* Extende the promo Javascript class with local functions.
*
* Pre-requisites:
*       - Load the main promo.js classfile first.
*/


/**
* Our main function when working with videos.
*
* @param string root The root URI of our installation. 
*	This should be "/" in production, or something like "/~dmuth/md/html"
*	in dev.
*/
Promo.prototype.initVideo = function(root) {

	//
	// Call our parent init function.
	//
	this.init(root);

	var obj = this.getObj();

	/**
	* When a random video button is clicked on, display it.
	* A "loading" blurb is displayed before the AJAX request, and
	* hidden after the request is complete.
	*/
	var settings = {};
	settings["loading"] = ".loading";
	settings["target"] = ".video";
	$(".random_video_show_button").ajaxLoad(settings);

	//
	// Show our movie.
	//
	var settings = {};
	//
	// Show the button to hide the movie.
	//
	settings["callback"] = function(element) { 
		element.parent().find(".promo_video_movie_hide").show();
		};
	$(".promo_video_movie_show").ajaxLoad(settings);

	//
	// Remove our movie, and toggle the hide and show buttons.
	//
	$(".promo_video_movie_hide").click(function() {
		$(this).parent().find(".ajaxload-target").empty();
		$(this).parent().find(".promo_video_movie_show").show();
		$(this).parent().find(".promo_video_movie_hide").hide();

		return(false);
		});


	//
	// Unhide all of the video show buttons.  We do this last because 
	// we want to make sure all other Javascript is present so that 
	// clicking on the show link won't cause the browser to go to a new 
	// page.
	//
	$(".random_video_show_button").show();


	/**
	* Hide a random video
	*/
/*
	$(".random_video_hide_button").click(function() {
		var target = $(this).parent().find(".video");
		var button_show = $(this).parent().find(".random_video_show_button");

		$(this).hide();
		target.hide();
		button_show.show();
			
		return(false);
		});
*/

} // End of initVideo()


