/*
 * jYoutube 1.0 - YouTube video image getter plugin for jQuery
 *
 * Copyright (c) 2009 jQuery Howto
 *
 * Licensed under the GPL license:
 *   http://www.gnu.org/licenses/gpl.html
 *
 * URL:
 *   http://jquery-howto.blogspot.com
 *
 * Author URL:
 *   http://me.boo.uz
 *
 */
(function($){
	$.extend({
		jYoutube_embed: function( url, width, height ){
			if(url === null){ return ""; }
			if(!width){ width = 560; }
			if(!height){ height = 340; }

			var vid;
			var results;
			var embed = '';

			results = url.match("[\\?&]v=([^&#]*)");

			vid = ( results === null ) ? url : results[1];

			embed  = '<object width="' + width + '" height="' + height + '">';
			embed += '<param name="movie" value="http://www.youtube.com/v/' + vid + '&hl=pt_BR&fs=1&rel=0"></param>';
			embed += '	<param name="allowFullScreen" value="true"></param>';
			embed += '	<param name="allowscriptaccess" value="always"></param>';
			embed += '	<embed src="http://www.youtube.com/v/' + vid + '&hl=pt_BR&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' + width + '" height="' + height + '"></embed>';
			embed += '</object>';

			return embed;
		}
	})
})(jQuery);
