	
	player.plugin = {
		
		id: "",
		iterator: null,
		
		load: function(id) {
			
			//this.id = id;
			clearInterval(this.iterator);
			this.iterator = null;
			
			return {
				//src:	"http://gdata.youtube.com/apiplayer?enablejsapi=1&key=" + youTubeKey,
				src:	"http://www.youtube.com/v/" + id + "&hl=ru&fs=1&rel=0&enablejsapi=1",
				vars:	{
					width:		w,
					height:		h
				}
			}
			
		},
		
		stateChange: function(state) {
			
			if (state == 1) {
				
				player.stateChange(true);
				
			} else {
				
				player.stateChange(false);
				
			}
			
		},
		
		play: function() {
			
			player.obj.playVideo();
			
		},
		pause: function() {
			
			player.obj.pauseVideo();
			
		},
		stop: function() {
			
			player.obj.stopVideo();
			player.obj.clearVideo();
			
		}
		
	}
	
	function onYouTubePlayerReady() {
		
		//player.obj.cueVideoById(player.plugin.id);
		player.obj.addEventListener("onStateChange", "player.plugin.stateChange");
		player.ready();
		
		player.plugin.iterator = setInterval(function(){
			
			if (Math.round(player.obj.getDuration()) != 0 && player.obj.getCurrentTime() >= player.obj.getDuration()) {
				
				player.stateChange(true);
				player.next();
				
			}
			
		}, 100);
		
	}
	
	
