/*
 * 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
 *
 * Plugin home & Author URL:
 *   http://jquery-howto.blogspot.com
 *
 */
(function(d){
   d.extend({
      jYoutube:function(a,b){
         if(a===null)return"";
         b=b===null?"big":b;
         var c;
         c=a.match("[\\?&]v=([^&#]*)");
         a=c===null?a:c[1];
         a=a.replace(/^\s+|\s+$/g,"");
         return b=="small"?"http://img.youtube.com/vi/"+a+"/2.jpg":"http://img.youtube.com/vi/"+a+"/0.jpg"
      }
   })
})(jQuery);

/*
 * jYouTubeImgInserter 1.0 - Extension (delo.si) specific for JYoutube
 *
 * Copyright (c) 2010 jQuery Howto
 *
 * Licensed under the GPL license:
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Plugin home & Author URL:
 *   http://www.delo.si
 *
 */

(function(d){
   d.extend({
      jYouTubeImgInserter:function( id ,url, size ){
                                           
         var thumb_url= $.jYoutube(url, size);
         $('img#' + id).attr('src',thumb_url);                    
      }
   })
})(jQuery);

(function(d){
   d.extend({
      jYoutubeVideoUrl: function( url ){
         if(url === null){
            return "";
         }

         var vid;
         var results;

         results = url.match("[\\?&]v=([^&#]*)");

         vid = ( results === null ) ? url : results[1];

         // trim spaces
         vid = vid.replace(/^\s+|\s+$/g,"");

         return "http://www.youtube.com/v/"+vid;
        
      }
   })
})(jQuery);
