Overlay.SwfObject = new Class({
	
	Implements: [Options,Events],

	options: 
  {		  
    file      : '',
    container : '',
    width     : 450,
    height    : 450,
    version   : '8.0.0',
    video     : '',                      
    params:
    {
      quality : 'best',
      wmode   : 'transparent'
    },
    attributes:
    {
      id   : '',
      name : ''    
    },
    size: {
			width: 450,
			height: 500
		}
	},
  
	initialize: function(options){
		this.setOptions(options);						
		this.overlay = new Overlay(document.body, {
			onClick: function(){
			}.bind(this),
			duration : 400
		});			   						 
	},

	open: function(){	 
	  this.fireEvent('onOpen');
		this.open = true;
		this.overlay.open();	
    //alert(this.options.video);
    var containerId = this.options.container;
    $$('div.div_swf').each(function(item)
    {
      if (item.name!= containerId)
        item.setStyle('display','none');
      else
        item.setStyle('display','block');         
    });        
    
    var x = this.options.size.width,
			  y = this.options.size.height;
			  
    this.wrapper = new Element('div', {			
			styles: {
				position    : 'fixed',
        'margin-left' : -(x/2)+94,
        left        : '50%',    	
        'margin-top'  : -(y/2)+17,
        top         : '50%',
      	display     : 'block',
      	width       : x,
      	height      : y,
      	padding     : 0,	
      	'z-index'   : 150,
      	clear       : 'both',
      	overflow    : 'hidden'
			}
		}).addClass('assistent').inject(document.body);
    
    this.closeButton = new Element('a',
    {
     html:'<span class="small">Assistenten nicht mehr anzeigen</span>',		
      href:'#',	
			events: {
				click: function(){				  
					this.closeAndStopAssistant();
				}.bind(this)
			}
		}).addClass('stopassistant');
    
    this.closeButton = new Element('a',
    {
      html:'<span class="small">Schliessen</span>',		
      href:'#',	
			events: {
				click: function(){
					this.close();
				}.bind(this)
			}
		}).addClass('close').inject(this.wrapper);  
    
    swfobject.embedSWF(this.options.file, 
                       this.options.container, 
                       this.options.width, 
                       this.options.height, 
                       this.options.version,
                       this.options.video, 
                       this.options, 
                       this.options.params, 
                       this.options.attributes);   
                   			
		return this;
	},
		
	dispose: function(){	
	  this.wrapper.destroy();
    swfobject.removeSWF(this.options.container);	
		this.overlay.overlay.destroy();
		
	},
	
	close: function(){
		this.open = false;
		this.wrapper.destroy();
		swfobject.removeSWF(this.options.container);	
		this.fireEvent('close');
		this.overlay.close();
		return this;
	},
	
	closeAndStopAssistant: function(){
		this.open = false;
		this.fireEvent('closeAndStopAssistant');
		this.overlay.close();
		return this;
	}
	
});
