

var clrz_popshow = new Class({
	Implements: Options,
	options:{ 
		element:'',
		marge:0,
		className:'popinfobox'
		
		},
	
	
	initialize: function(options){
		
		this.setOptions(options);
		
		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.init();
		
		
		this.scrollevent = this.positioning.bind(this);
		this.fx = new Fx.Morph(this.element, {duration: 600, transition: Fx.Transitions.Sine.easeOut,wait:false});
		
		this.element.addEvents({'click':this.hide.bind(this)});
		
		
	},
	
	getElement:function()
	{
		
		return 	this.element;
		
	},
	
	setHTML:function(html)
	{
		
		this.element.set('html',html);
		
		return this;
		
	},
	
	init:function()
	{

		this.element.inject(document.body,'bottom').setStyles({'top':100,position:'absolute','margin-top':this.element.getHeight(),opacity:'0',right:0});
		

	},
	
	
	positioning:function()
	{
		
		this.element.setStyles({'top':(window.getScrollTop()+window.getHeight()-this.element.getHeight()-this.options.marge)});
		
	},
	
	
		
	show:function()
	{
		this.positioning();
		window.addEvent('scroll',this.scrollevent);
		
		this.fx.start({'margin-top':0,'opacity':0.8}); 
			
		return this;

	},
	
	hide:function()
	{
	
		
		
		this.fx.start({'margin-top':(this.element.getHeight()+this.options.marge),'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);

		
	}
	
	
	
		
	
});


