function Dialog(){
	this.container = $('extraContent');
	
	this.load = function(view){
		new Ajax.Updater(this.container, view,{
			onComplete: function(){ 
				this.fadein('dialog', 1);
				this.fadein('overlay', 0.8);
				this.register();
			}.bind(this)});
	}
	
	this.change = function(view){
		this.container.update(view);
		this.register();
	}
	
	this.register = function(){
		$('overlay').observe('click', function(e){ 
			this.fadeout('dialog', 1); 
			this.fadeout('overlay', 0.8); 
			e.stop() 
		}.bind(this));
		
		$('close').observe('click', function(e){ 
			this.fadeout('dialog', 1); 
			this.fadeout('overlay', 0.8); 
			e.stop() 
		}.bind(this));
		
		if($('further')){
			view = $('further').href;
		
			$('further').observe('click', function(e){ 
				e.stop();
				new Ajax.Updater(this.container, view, {
					onComplete: function(){ 
						this.register();
					}.bind(this)
				});
			}.bind(this))
		}

		
		$('form').observe('submit', function(e){ 
			this.request(); e.stop(); 
		}.bind(this));
	}
	
	this.request = function(){
		$('form').request({
			method: 'post',
			onComplete:function(transport) { 
				this.change(transport.responseText); //register wird bei change vorgenommen
			}.bind(this)
		} );
	}
	
	this.fadein = function(ele, opacity){
		$(ele).setStyle({display: 'block'});
		$(ele).setOpacity(0);
				
		if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
		    $(ele).setOpacity(75);
			fixOpacityElement(ele);
			return;
		}

		new Effect.Opacity($(ele),{
			  duration:0.75, 
			  from:0.0, 
			  to:opacity
		});
	}
	
	this.fadeout = function(ele, opacity){
		if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
			this.container.update(""); 
			return;
		}
		
		new Effect.Opacity($(ele),{
			  duration:0.75, 
			  from:opacity, to:0.0,	
			  afterFinish: function() {
			  	   this.container.update(""); 
			  }.bind(this)
			}
		);
	}
	
	
	this.fixOpacityElement = function(dEl){
		var $D = YAHOO.util.Dom;
		if( typeof(dEl) =='string') dEl = $D.get( dEl );
		if(!dEl) return;
	
		
		var dCanvas = document.createElement('canvas');
		if ( typeof(dCanvas.getContext) != 'function' ) return;
		var  dCtx = dCanvas.getContext('2d');
	    
	    var  sDataUrl = '';
		try{ 
				var nOpacity = $D.getStyle(dEl,'opacity');
				var sColor = $D.getStyle(dEl,'backgroundColor');
				if( sColor.indexOf('rgb')!=0)  return;
				
				sColor = 'rgba' + sColor.substr(3 , sColor.length - 4 )  + ', 0.'+nOpacity+')';	
						
				dCanvas.width = 50;
				dCanvas.height = 50;
	
				dCtx.fillStyle = sColor;
				dCtx.fillRect(0, 0, 50 , 50);
				sDataUrl =dCtx.canvas.toDataURL('image/png');
		}catch(err){
				sDataUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAVklEQVRoge3PgQkAIRDAsPMnd3SXED5IM0G7ZmbPA76/A25pRNOIphFNI5pGNI1oGtE0omlE04imEU0jmkY0jWga0TSiaUTTiKYRTSOaRjSNaBrRNKI5crsA5D/L7oUAAAAASUVORK5CYII=';
		};
		
		with(dEl.style){
				opacity =1;
				backgroundRepeat ='repeat-all';
				backgroundImage = 'url(' + sDataUrl + ')';
				backgroundColor = 'transparent';
		};
	    
	}


}
