$(document).ready(function() {
	
	// function for setting up a Flash video using SWFObject
	function setupMovie(movieId, w, h, movie, splash, start) {
		var options = { 
			swf: "mediaplayer.swf", 
			id: "movieplayer" + new Date().getTime(),
			height: h, 
			width: w, 
			params: { 
				play: start,
				allowfullscreen: true,
				flashvars: { 
					width:w,
					height:h,
					file:movie
				} 
			} 
		};
		if (splash) options.params.flashvars["image"] = splash;
		
		$("#" + movieId).flash(options);
	}
	
	// code for toggling on/off menu items
	$(".menu-item").bind("click", function() {
		$(".content").hide();
		$($(this).attr("rel")).show();
		return false;
	});

	// show Overview tab
	$("a[rel=#overview]").click();	
	
	// Overview videos
	$("div.feature span.video a").bind("click", function() {
		window.scrollTo(0, document.body.scrollHeight);

		var movieId = "movie";
		$("<div id='"+movieId+"'></div>").appendTo(this);

		setupMovie(movieId, "720", "540", $(this).attr("rel"), null, true);

		var title = $(this).parent().prev().text();

		$("#" + movieId).dialog({
			modal: true, 
			title: title,
			width: 740, 
			height: 585,
			minHeight: 585,
			zIndex: 10000,
			bgiframe: true,
			resizable: false,
			close: function() {
				$("#" + movieId).dialog("destroy").remove();
			}
		});
		$(".ui-dialog-overlay").addClass("ui-widget-overlay");
		$("#" + movieId).dialog("open");
		
		return false;
	});
	
	setupMovie("container", "720", "400", "GoomzeePromo-MLS.flv", "images/rc_video_splash2.jpg", false);
});
