var ViewerOverlay = function (id) {
	this.overlay = new Overlay(id, {	visible: false,
										zindex: 2000,
										fixedcenter: true,
										modal: true
	});

	this.overlay.addClass('opaque');
	
	this.showPhoto = function (encryptedContentId, alt) {
		var src = Utilities.getUrlByContentId(encryptedContentId, 529);
		
		this.overlay.YUIoverlay.cfg.setProperty('width', '70px');
		
		// Mostra il loader
		this.overlay.show(null, this.overlay.generateOverlay(this._generateImg(src, false) + this.overlay.loaderContent.body), null);
		
		var overlay = this.overlay;
		var viewer = new ViewerOverlay('textOverlay');
		
		var timeout = window.setInterval(function () {
			var img = YAHOO.util.Dom.get('oMediai');
			
			if(IsImageOk(img)) {
				overlay.hide();
				window.clearInterval(timeout);
				
				viewer._showContent(viewer._generateImg(src, true));
			}
		}, 300);
	};
	
	this.showVideo = function (encryptedContentId, w, h) {
		this.overlay.show(null, this.overlay.generateOverlay(this._generateVideo(encryptedContentId, w, h)), null);		
	};
	
	this._showContent = function (html) {
		var me = this;
		var img = YAHOO.util.Dom.get('oMediai');
		var w = ((YAHOO.env.ua.ie > 0) ? 340 : img.width) + 50;
		
		this.overlay.YUIoverlay.cfg.setProperty('width', w + 'px');
		this.overlay.show(null, this.overlay.generateOverlay(html), null);
		this.overlay.YUIoverlay.center();
	};
	
	this._generateImg = function (src, visible) {
		return '<center><img id="oMediai" src="' + src + '" alt=""' + (visible ? ' class="show"' : '') + '/></center>';
	};
	
	this._generateVideo = function (encryptedContentId, w, h, visible) {
		return '<center><embed id="oMediai" class="show" height="' + w + '" width="' + h + '" type="application/x-shockwave-flash" src="http://' + location.hostname + '/player/mediaplayer.swf" name="single" quality="high" allowfullscreen="true" wmode="opaque" allowscriptaccess="always" flashvars="width=' + w + '&amp;height=' + h +  '&amp;file=http://www.theclub.it/cr/' + encryptedContentId + '/video.flv&amp;image=http://www.theclub.it/cr/' + encryptedContentId + '/video.jpg" id="single"/></center>';
	};
};

OverlayConfiguration.viewer = new ViewerOverlay('textOverlay');
OverlayManager.viewer = function (args) {
	OverlayConfiguration.viewer.show(args[0], args[1]);
};