 $(document).ready(function() {
   
   $(".yt").click(function(){
        var odkazYT = $(this).attr("href");
        var pole = odkazYT.split("?v=");
        var idVidea = pole[1];
        var test = "neco";
        $('embed, object, select').css({ 'visibility' : 'hidden' });
        var ovladani = '<div class="ovladani"><a href="javascript:play();" class="play"></a><a href="javascript:pause();" class="pause"></a><a href="javascript:close();" class="close"></a></div>';
        var htmlPole = '<div id="cerna"><span id="idVidea">'+idVidea+'</span></div><div id="videolayer"><div class="player"><div id="ytplayer"><p style="text-align:center;">Načítám video</p></div>'+ovladani+'</div></div>';
        $("body").append(htmlPole);
        var topValue = ((document.body.scrollHeight/2)-180)+"px";
        var leftValue = ((document.body.clientWidth/2)-205)+"px";
        $("#videolayer").css({ top:topValue, left:leftValue });
        var params = { allowScriptAccess: "always" };
        var atts = { id: "ytplayer" };
        //swfobject.embedSWF("http://www.youtube.com/v/"+idVidea+"&enablejsapi=1&playerapiid=ytplayer", "ytplayer", "400", "300", "8", null, null, params, atts);
        swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytplayer", "ytplayer", "400", "300", "8", null, null, params, atts);
        
        $('#cerna').css({opacity: "0",}).fadeTo("slow", 0.9);
        $("#videolayer div").slideDown("500");
        $("#videolayer").css({cursor:"pointer"});
                  $('#cerna,.close').click(function() {
                      				_finish();
                      				return false;
          			   });
        return false;
    });

	 function _finish() {
			$('#videolayer').remove();
			$('#cerna').fadeOut(function() { $('#cerna').remove(); });
			
			// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'visible' });
		}
 });
      function seekTo(seconds) {
          if (ytplayer) {
            ytplayer.seekTo(seconds, true);
          }
        }
 
 
 	  function onYouTubePlayerReady(playerId) {
      ytplayer = document.getElementById("ytplayer");
      var idVidea = document.getElementById("idVidea").innerHTML;
      if (ytplayer) {
//      setInterval(updateytplayerInfo, 250);
      ytplayer.loadVideoById(idVidea, parseInt(0));
      ytplayer.playVideo();
      
      }
    }
    function _finish() {
			$('#videolayer').remove();
			$('#cerna').fadeOut(function() { $('#cerna').remove(); });
			
			// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'visible' });
		}
		function close() {
    _finish();
    }
    function play() {
    ytplayer.playVideo();
    }
    function getCurrentTime() {
          if (ytplayer) {
            return ytplayer.getCurrentTime();
          }
    }
    function pause() {
    ytplayer.pauseVideo();
    }

