function embedVideoPlayer(videoPath,videoWidth,videoHeight,videoAutoPlay,videoTarget,videoID,videoThumb,videoLink,linkOutText){
	
	var $videoTarget = $('#'+videoTarget);
	$videoTarget.parent().height(videoHeight);
	
	if(videoPath.indexOf('.flv') > 0){
		var playerSWF = "/video_player/FlvPlayer.swf";
		
		var flashvars = {};
		flashvars.flvTarget = videoPath;
		flashvars.flvWidth = videoWidth;
		flashvars.flvHeight = videoHeight;
		flashvars.autoPlay = videoAutoPlay;
		flashvars.flvThumb = videoThumb;
		flashvars.flvLink = videoLink;
		flashvars.linkOutText = linkOutText;
		
		var params = {};
		params.bgcolor = "#FFFFFF";
		params.wmode = "opaque";
		
		var attributes = {};
		attributes.id = "videoPlayer";
		
		$videoTarget.show();
		swfobject.embedSWF(playerSWF, videoTarget, videoWidth, videoHeight, "9.0.0", false, flashvars, params, attributes);
	}
	
	else if(videoPath.indexOf("youtube.com/watch?v=") > 0){
		
		var flashvars = {};
		flashvars.fs = "1";
		
		var params = {};
		params.wmode = "opaque";
		params.autoplay = videoAutoPlay ? "1" : "0";
		params.allowScriptAccess = "always";
		params.allowFullScreen= "true";
		
		var attributes = {};
		attributes.id = videoID;
		
		//http://www.youtube.com/watch?v=12dcxI9S1Nk
		//http://www.youtube.com/v/12dcxI9S1Nk
		videoPath = videoPath.split('/watch?v=').join('/v/').split('&')[0];
		
		if(videoThumb != undefined && videoThumb != ""){
			var playIconLeft = parseInt((videoWidth/2)-64,10);
			var playIconTop = parseInt((videoHeight/2)-63,10);
			$videoTarget.hide();
			$videoTarget
				.parent()
				.prepend(
					'<div class="videoThumbButton">' + 
						'<img src="'+videoThumb+'" width="'+videoWidth+'" height="'+videoHeight+'" class="videoThumb" alt="">' + 
						'<a href="javascript:void(0)" onclick="playYouTubeVideo(\''+videoPath+'\',\''+videoWidth+'\',\''+videoHeight+'\',\''+videoTarget+'\',\''+videoID+'\',this)">' + 
							'<img class="playIcon" src="/video_player/play_icon.png" width="128" height="128" style="left:'+playIconLeft+'px; top:'+playIconTop+'px;" alt="" />' + 
						'</a>' + 
					'</div>');
		}
		else{
			videoPath = videoPath + "?autoplay=0&autohide=1&enablejsapi=1";
			swfobject.embedSWF(videoPath, videoTarget, videoWidth, videoHeight, "9.0.0", false, flashvars, params, attributes);
		}
	}

}

function playYouTubeVideo(videoPath,videoWidth,videoHeight,videoTarget,videoID,calledFrom){

	var flashvars = {};
	flashvars.fs = "1";
	
	var params = {};
	params.wmode = "opaque";
	params.autoplay = "1";
	params.allowScriptAccess = "always";
	params.allowFullScreen= "true";
	
	var attributes = {};
	attributes.id = videoID;
	
	videoPath = videoPath + "?autoplay=1&autohide=1";
	
	$(calledFrom).parent().fadeOut(500,function(){
			swfobject.embedSWF(videoPath, videoTarget, videoWidth, videoHeight, "9.0.0", false, flashvars, params, attributes);
		});
}

