(function($){
	$.fn.youtube = function(settings){
		options = $.extend({path:'scrips/'}, settings);
		
		$(this).each(function(){
			//alert($(this).children('table').attr('id'));
			var _this = $(this);
			var _table = $(this).children('table');
			var _tr = _table.children('tr');
			var _divMiniatura = _table.find('div.hvc-miniatura');
			var _imgMiniatura = _table.find('img.hvc-image');
			var _tdTitulo = _table.find('td.hvc-titulo');
			var _youtubeCode = _imgMiniatura.attr('title');
			var _btnPlay = '<img src="'+options.path+'/button-play.png" width="37" height="23" style="position:absolute; z-index:2; bottom:5px; left:5px;" />';
			var _button = '<div class="hvc-button" style="position:absolute; z-index:3; width:120px; height:90px; top:0; left:0; cursor:pointer; background:#FFF; opacity:0; filter:alpha(opacity=0);-khtml-opacity: 0;-moz-opacity: 0;"></div>';
			var _objectVideo = '<object width="440" height="352"><param name="movie" value="'+_youtubeCode+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+_youtubeCode+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="440" height="352"></embed></object>';
			//configuro el contenedor de la imagen miniatura
			_divMiniatura.css({position:'relative',width:'120px',height:'90px'});
			//configuro la imagen miniatura
			_imgMiniatura.css({position:'absolute','z-index':1,top:0});
			//configuro el botón play
			_imgMiniatura.after(_button);
			//cargo la imagen del boton play
			_imgMiniatura.after(_btnPlay);
			//evento del boton play
			$(this).find('div.hvc-button').click(function(){
				_table.css('display','none');
				_this.append(_objectVideo).css('padding-top','10px');
			});
		
		});
		
	}
})(jQuery);
