jQuery.fn.ytplaylist = function (a) {
	a = jQuery.extend({ holderId: "ytvideo", playerHeight: "300", playerWidth: "450", addThumbs: false, thumbSize: "small", showInline: false, autoPlay: true, showRelated: true, allowFullScreen: true }, a);
	return this.each(function () {
		function e(b) {
			var c = ""; c += '<object height="' + a.playerHeight + '" width="' + a.playerWidth + '">';
			c += '<param name="movie" value="http://www.youtube.com/v/' + b + f + g + h + '"> </param>';
			c += '<param name="wmode" value="transparent"> </param>';
	if(a.allowFullScreen)c+='<param name="allowfullscreen" value="true"> </param>';
		c += '<embed src="http://www.youtube.com/v/' + b + f + g + h + '"'; if (a.allowFullScreen) c += ' allowfullscreen="true" ';
		c += 'type="application/x-shockwave-flash" wmode="transparent"  height="180" width="235"></embed>';
		c += "</object>"; return c
} function d(b) { b = b.match("[\\?&]v=([^&#]*)"); return b = b[1] } var i = $(this), f = "", g = "&rel=0", h = "";
	if(a.autoPlay)f="&autoplay=1";if(a.showRelated)g="&rel=1";if(a.allowFullScreen)h="&fs=1";var j=i.children("li:first-child").addClass("currentvideo").children("a").attr("href");
	$("#" + a.holderId + "").html(e(d(j))); i.children("li").children("a").click(function () {
		if (a.showInline) {
			$("li.currentvideo").removeClass("currentvideo");
			$(this).parent("li").addClass("currentvideo").html(e(d($(this).attr("href")))) 
		}
		else {
			$("#" + a.holderId + "").html(e(d($(this).attr("href"))));
			$(this).parent().parent("ul").find("li.currentvideo").removeClass("currentvideo");
			$(this).parent("li").addClass("currentvideo")
		} return false
	});
	a.addThumbs&&i.children().each(function(){var b=$(this).text(),c=a.thumbSize=="small" ? "http://img.youtube.com/vi/" + d($(this).children("a").attr("href")) + "/2.jpg" : "http://img.youtube.com/vi/" + d($(this).children("a").attr("href")) + "/0.jpg";
		$(this).children("a").empty().html("<img src='" + c + "' alt='" + b + "' />" + b).attr("title", b)
	})
})
};

