var clrz_popshow = new Class({
	Implements: Options,
	options:{ 
		element:'',
		marge:0,
		className:'popinfobox',
		percent:0
		},
	
	
	initialize: function(options){
	
		this.setOptions(options);
		this.classes = ['infobox','warnbox'];
		if(this.options.element)
			this.element = $(this.options.element);
		else
		{
			if($('popinfobox'))
				this.element = $('popinfobox');
			else
				this.element = new Element('div',{id:'popinfobox'}).inject(document.body,'bottom').addClass(this.options.className);
		}
		
		this.elementHeight = this.element.getHeight();
		this.elementWidth = this.element.getWidth();

		this.init();
		
		
		this.scrollevent = this.positioning.bind(this);
		this.fx = new Fx.Morph(this.element, {duration: 600, transition: Fx.Transitions.Back.easeOut,wait:false});
		
		this.element.addEvents({'click':this.hide.bind(this)});
		
		
	},
	
	getElement:function()
	{
		
		return 	this.element;
		
	},
	
	
	switchTo:function(newclass)
	{
		var maclass=this;
		this.classes.each(function(classe,i){	 maclass.element.removeClass(classe); });
		this.element.addClass(newclass);
		
		return this;
	},
	
	
	setHTML:function(html)
	{
		
		this.element.set('html',html);
		
		return this;
		
	},
	
	init:function()
	{

		this.element.inject(document.body,'bottom').setStyles({'width':this.elementWidth*this.options.precent/100,'height':this.elementHeight*this.options.precent/100,'top':100,position:'absolute','margin-top':0,opacity:'0',right:0});
		

	},
	
	
	positioning:function()
	{
		
		this.element.setStyles({'top':(window.getScrollTop()+window.getHeight()/2-this.elementHeight-this.options.marge),'left':window.getWidth()/2-this.elementWidth/2});
		
	},
	
	
		
	show:function()
	{
		this.positioning();
		var maclass = this;
		this.classes.each(function(classe,i){	 maclass.element.removeClass(classe); });
		window.addEvent('scroll',this.scrollevent);
		
		this.fx.start({'width':this.elementWidth,'margin-left':0,'margin-top':0,'height':this.elementHeight,'opacity':0.9}); 
			
		return this;

	},
	
	hide:function()
	{
	
		
		
		this.fx.start({'margin-left':(this.elementWidth*this.options.precent/100),'margin-top':(this.elementHeight*this.options.precent/100),'width':this.elementWidth*this.options.precent/100,'height':this.elementHeight*this.options.precent/100,'opacity':0}); 
		window.removeEvent('scroll',this.scrollevent);
		
			
		return this;
		
	},
	
	delay:function(time)
	{
		
		if(!time)
		var time = 5000;
		this.show();
		var maclass = this;
		(function(){ maclass.hide()}).delay(time);

		return this;
	}
	
	
	
		
	
});

