  var ytplayer_playlist = [ ];
  var ytplayer_playitem = 0;
  swfobject.addLoadEvent( ytplayer_render_player );
  swfobject.addLoadEvent( ytplayer_render_playlist );
  function ytplayer_render_player( )
  {
    swfobject.embedSWF
    (
      'http://www.youtube.com/v/' + ytplayer_playlist[ ytplayer_playitem ][0] + '&enablejsapi=1&rel=0&fs=1',
      'ytplayer_div1',
      '488',
      '367',
      '8',
      null,
      null,
      {
        allowScriptAccess: 'always',
        allowFullScreen: 'true'
      },
      {
        id: 'ytplayer_object'
      }
    );
  }
  function ytplayer_render_playlist( )
  {
	var groupby = 5;

	var li = null;
	
    for ( var i = 0; i < ytplayer_playlist.length; i++ )
    {
      
       
      var img = document.createElement( "img" );
      img.src = "http://img.youtube.com/vi/" + ytplayer_playlist[i][0] + "/default.jpg";
      var a = document.createElement( "a" );
      a.href = "#";
      a.className = "wrapper";	  
      
      a.onclick = (
        function( j )
        {
          return function( )
          {
            ytplayer_playitem = j;
            ytplayer_playlazy( 500 );

            return false;
          };
        }
      )( i );
      
      a.appendChild( img );

      if(groupby == 0)
      {
          groupby = 5;
      }
      
      if(groupby == 5)
      {
      
	      li = document.createElement( "li" );
	
	      li.appendChild( a );
	      
	      document.getElementById( "ytmenu" ).appendChild( li );
      }
      else
      {
    	  li.appendChild( a );
      }
      
      groupby--;
    }

    $("#ytplayer_menu").easySlider({
		auto: true,
		continuous: true,
		pause: 5000,
		nextText: '',
		prevText: ''
	});
    
  }
  function ytplayer_playlazy( delay )
  {
    if ( typeof ytplayer_playlazy.timeoutid != 'undefined' )
    {
      window.clearTimeout( ytplayer_playlazy.timeoutid );
    }
    ytplayer_playlazy.timeoutid = window.setTimeout( ytplayer_play, delay );
  }
  function ytplayer_play( )
  {
    var o = document.getElementById( 'ytplayer_object' );
    if ( o )
    {
      o.loadVideoById( ytplayer_playlist[ ytplayer_playitem ][0] );
    }
  }
  //
  // Ready Handler (this function is called automatically by YouTube JavaScript Player when it is ready)
  // * Sets up handler for other events
  //
  function onYouTubePlayerReady( playerid )
  {
    var o = document.getElementById( 'ytplayer_object' );
    if ( o )
    {
      o.addEventListener( "onStateChange", "ytplayer_statechange" );
      o.addEventListener( "onError", "ytplayer_error" );
    }
  }
  //
  // State Change Handler
  // * Sets up the video index variable
  // * Calls the lazy play function
  //
  function ytplayer_statechange( state )
  {
    if ( state == 0 )
    {
      ytplayer_playitem += 1;
      ytplayer_playitem %= ytplayer_playlist.length;
      ytplayer_playlazy( 5000 );
    }
  }
  //
  // Error Handler
  // * Sets up the video index variable
  // * Calls the lazy play function
  //
  function ytplayer_error( error )
  {
    if ( error )
    {
      ytplayer_playitem += 1;
      ytplayer_playitem %= ytplayer_playlist.length;
      ytplayer_playlazy( 5000 );
    }
  }
  //
  // Add items to the playlist one-by-one
  //
  
  function ytplayer_add(code, title)
  {
	  var arr = new Array(code, title);
	  ytplayer_playlist.push(arr);
  }