	var youtubeplayer = new Class({
		
		initialize: function(e, $namen, $closen, $urls, $shop) {
			/* Prepare */
			if ($shop) {this._shop = true;} else {this._shop = false;}
			e = new Event (e);
			this._target = $(e.target);
			e = this._target.getCoordinates();
			this.generateSurrounding($namen,$closen);

			/* Clear */
			this.removeYouTube();
			
			/* Create */ 
			this.thedivb = new Element("div" , {"class":"ytplayerBack"});
			this.thediv = new Element("div" , {"class":"ytplayer"});
			this.thediv.adopt(this._wrapper);
			if (window.ie&&!window.ie7) {
				this.thedivb.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+tplpath+"images/fog.png',sizingMethod='image')";
			} else {
				this.thedivb.addClass("videoBackOther");
			}
			this.thedivb.addEvent("click", this.removeYouTube.bind(this) );
			this._x =(window.getWidth()-797)/2;
			this._y =e.top-570;
			if (this._y<0) this._y = 0;
			if (this._x<0) this._x = 0;
			this.thediv.setStyles({"top":(this._y+221)+"px","left":(this._x+183)+"px"});
			this.thedivb.setStyles({"top":this._y+"px","left":this._x+"px"});

			$$("body")[0].adopt(this.thedivb);
			$$("body")[0].adopt(this.thediv);
			this._video.innerHTML = '<span style="display:none;">.</span><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/'+$urls+'&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'+$urls+'&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>';
			window.ytplayer = this.thediv;
			window.ytplayerb = this.thedivb;
			if (this._shop) {
				this._target.addClass("videoselected")
			};
		},
		
		generateSurrounding: function($gameName, $close) {
			var $wrapper = new Element("div", {"class":"ytplayerWrapper"});
			var $title = new Element("div",{"class":"ytplayerTitle"});
			var $gameName = new Element("div", {"class":"h1 ytplayerGameName"}).setHTML($gameName);
			var $closeButton = new Element("a", {"class":"ytplayerCloseButton","href":"javascript:;"}).setHTML($close);
			$closeButton.addEvent("click",this.removeYouTube.bind(this));
			var $videoWrapper = new Element("div",{"class":"ytplayerVideoWrapper"});
			$title.adopt($closeButton);
			$title.adopt($gameName);
			$wrapper.adopt($title);
			$wrapper.adopt($videoWrapper); 
			this._wrapper = $wrapper;
			this._title = $title;
			this._gameName = $gameName;
			this._closeButton = $closeButton;
			this._video = $videoWrapper;
		},
		
		removeYouTube: function() {
			if (this._shop) {
				$elems = $$(".videoselected");
				for (i = 0; i < $elems.length; i++) {
					$elems[i].removeClass("videoselected");
				}
			}
			
			if (window.ytplayer) {
				window.ytplayer.remove();
				window.ytplayer = null;
			}
			if (window.ytplayerb) {
				window.ytplayerb.remove();
				window.ytplayerb = null;
			}
		}
		
	});