
	$(function() {
	
		var container = $("ul#items-viewport");
		//var template = '<object CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="320" height="256" data="%s" codebase="http://www.apple.com/qtactivex/qtplugin.cab" type="video/quicktime" id="qtboxMovie"><param value="%s" name="src"><param value="aspect" name="scale"><param value="true" name="controller"><param value="true" name="autoplay"><param value="#000000" name="bgcolor"><param value="true" name="enablejavascript"><EMBED SRC="%s" TYPE="image/x-macpaint" PLUGINSPAGE="http://www.apple.com/quicktime/download" WIDTH="320" HEIGHT="256" AUTOPLAY="true" CONTROLLER="true"></EMBED></object>';
		var template = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="320" height="256" id="player" align="middle">'
			+ '<param name="movie" value="http://www.merrittmusic.com/wp-content/themes/merritt/player.swf" />'
			+ '<param name="quality" value="high" />'
			+ '<param name="bgcolor" value="#000000" />'
			+ '<param name="play" value="true" />'
			+ '<param name="loop" value="true" />'
			+ '<param name="wmode" value="transparent" />'
			+ '<param name="scale" value="showall" />'
			+ '<param name="menu" value="true" />'
			+ '<param name="devicefont" value="false" />'
			+ '<param name="salign" value="" />'
			+ '<param name="allowScriptAccess" value="sameDomain" />'
			+ '<param name="allowFullScreen" value="true" />'
			+ '<param name="FlashVars" value="videoUrl=%s" />'
			+ '<!--[if !IE]>-->'
			+ '<object type="application/x-shockwave-flash" data="http://www.merrittmusic.com/wp-content/themes/merritt/player.swf" width="320" height="256">'
				+ '<param name="movie" value="http://www.merrittmusic.com/wp-content/themes/merritt/player.swf" />'
				+ '<param name="quality" value="high" />'
				+ '<param name="bgcolor" value="#000000" />'
				+ '<param name="play" value="true" />'
				+ '<param name="loop" value="true" />'
				+ '<param name="wmode" value="transparent" />'
				+ '<param name="scale" value="showall" />'
				+ '<param name="menu" value="true" />'
				+ '<param name="devicefont" value="false" />'
				+ '<param name="salign" value="" />'
				+ '<param name="allowScriptAccess" value="sameDomain" />'
				+ '<param name="allowFullScreen" value="true" />'
				+ '<param name="FlashVars" value="videoUrl=%s" />'
			+ '<!--<![endif]-->'
			+ 	'<a href="http://www.adobe.com/go/getflash">'
					+ '<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />'
			+ 	'</a>'
			+ '<!--[if !IE]>-->'
			+ '</object>'
			+ '<!--<![endif]-->'
		+ '</object>';	
		
		// Assign click events to the left nav
		$("div#categories li").css("cursor", "pointer").click(function(e) {
		
			e.preventDefault();
			var $target = $(e.target);
			var id = $target.attr("rel");
			
			$("div#categories li.selected").removeClass("selected");
			$target.addClass("selected");
		
			container.empty().html($("div#hidden-items ul#term_"+id).html());
			
		});
		
		// Assign events to the right nav
		container.find("li").live('click', function(e) {
				
			e.preventDefault();
			var file = $(e.target).attr("file");
			if ( typeof file != 'undefined' && file != "" ) {			
				
				container.find("li.selected").removeClass("selected");
				$("div#hidden-items li.selected").removeClass("selected");
				
				var html = template.replace(/%s/gi, file);				
				$("div#video").html(html);
				
				$(this).addClass("selected");
				$("div#hidden-items li[rel="+$(this).attr("rel")+"]").addClass("selected");
			}
			
		});
		
		// Click the top most left item to get the process started
		$("div#categories li:first").click();
		
	});
