(function(e){
	function c(b,a){
		this.id=b;
		this.videoId=a;
		this.handlers={};
		this.embed();
		c.register(this)
	}
	c.prototype.embed=function(){
		var b={id:this.id},a="http://www.youtube.com/v/{videoId}?enablejsapi=1&playerapiid={playerId}&playlist=0&autoplay=1&rel=0&showinfo=0";
		a=a.replace("{videoId}",this.videoId);
		a=a.replace("{playerId}",this.id);
		if(!swfobject)
		throw new ReferenceError("YoutubePlayer depends on the SWFObject library but it is missing.");
		
		swfobject.embedSWF(a,this.id,"340","218","8",null,null,{allowScriptAccess:"always"},b)
	};
	c.prototype.on=function(b,a){
		this.handlers[b]=this.handlers[b]||[];
		this.handlers[b].push(a)};
		c.prototype.onReady=function(){
			var b=document.getElementById(this.id),a='YoutubePlayer.dispatchEvent("{id}")'.replace("{id}",this.id);
			b.addEventListener("onStateChange",a)};
			c.prototype.notifyEvent=function(b){
				var a=c.STATES;
				for(var d in a)a[d]==b&&this.fireEvent(d)
			};
			c.prototype.fireEvent=function(b){
				var a=this.handlers[b];
				if(a)for(var d=0;d<a.length;d++)a[d](b)
			};
			c.instances=[];
			c.register=function(b){
				this.instances.push(b)
			};
			c.findById=function(b){
				for(var a=null,d=0;d<this.instances.length;d++) if(this.instances[d].id==b)a=this.instances[d];
				return a
			};
			c.dispatchEvent=function(b){
				var a=c.findById(b);
				return function(d){
					a.notifyEvent(d)
				}
			};
			c.STATES={unstarted:-1,ended:0,playing:1,paused:2,buffering:3,cued:5};
			e.YoutubePlayer=c;
			e.onYouTubePlayerReady=function(b){
				c.findById(b).onReady()
			}
		})(window);// JavaScript Document
