jQuery(document).ready(function() {
	
	jQuery("#videoNav li:not(#audio) a").click(function(){
											
											 play_video(this.href);
											 jQuery("#videoNav li").removeClass();
											 jQuery(this).parent('li').addClass('active');
											 jQuery("#screen").removeClass("load");
											 return false;
											   }
											 );
	
	jQuery("#videoNav li#audio a").click(function(){
											 jQuery("#screen").addClass("load");
											 play_audio();
											 jQuery("#videoNav li").removeClass();
											 jQuery(this).parent('li').addClass('active');
											 return false;
											   }
											 );
	
});

function play_video(vidurl){
	
	// remove existing flash video
	if(swfobject.removeSWF('projector')){
		}
	
	// get playlist url from tab
	if (vidurl == '' || vidurl == 'undefined'){
		var playlistURL = jQuery(this).attr("href");
	}else{
		var playlistURL = vidurl;
	}

	// place removed div back which will be replaced by swfobjet
	jQuery("#screen").append("<div id='projector'>");
	
	var flashvars = {
	playlistXML: playlistURL
	};
	var params = {
	allowfullscreen: "true",
	allowscriptaccess: "always",
	wmode: "transparent"
	};
	var attributes = {
	id: "projector"
	};

swfobject.embedSWF("hdflvplayer/hdplayer.swf", "projector", "640", "480", "9.0.0","flash/expressInstall.swf", flashvars, params, attributes);
	
}

// for audio player only
function play_audio(){
// remove existing flash video
	if(swfobject.removeSWF('projector')){}	

// place removed div back which will be replaced by swfobjet
	jQuery("#screen").append("<div id='projector'>");
	
			var stageW = 640;
			var stageH = 480; 
			var cacheBuster = Date.parse(new Date());
			
			var flashvars = {
			stageW: stageW,
			stageH: stageH,
			pathToFiles: "mp3player/",
			settingsPath: "xml/settings.xml",
			xmlPath: "xml/mp3_player.xml",
			keepSelected: "t",
			selectedWindow: "4",
			slideshow: "t",
			imageWidth: "200"
			};
			
			var params = {
			bgcolor: "#000000",
			allowfullscreen: "true",
			wmode: "transparent"
			};
			
			var attributes = {};
			
			swfobject.embedSWF("mp3player/preview.swf?t="+cacheBuster, "projector", stageW, stageH, "9.0.124", "flash/expressInstall.swf", flashvars, params, attributes);

}