BottomBanner = Ext.extend(Object, {
    constructor: function(config){
    	BottomBanner.superclass.constructor.apply(this);
    	
    	this.element = Ext.get(config.item);
    	this.close = Ext.get(config.close);
    	
    	if(this.element != null)this.init();
    },
    init:function()
    {	
		this.dtask = new Ext.util.DelayedTask(function(){
			if(!this.element.isVisible(true)){
				this.element.setVisibilityMode(Ext.Element.VISIBILITY);
				this.element.setVisible(true,{
					duration:2,
					callback:this.initScroll,
					scope:this
				});
			}
			
			this.slideBannerOut();
		},this);
		
    	this.dtask.delay(2000);
    	
    	this.close.on('click',this.closeBanner,this);
    },
    closeBanner:function(){
    	Ext.Ajax.request({
            method:'POST',
            scope:this,
            url:'/lib/backend-request.php',
            params:{
                action:'bottom-banner',
                type:'close'
            },
            success:function(f,o){
                var res = Ext.decode(f.responseText);
                
                if(res.success){
                	this.element.remove();
                }
            }
        });
    },
    slideBannerOut:function(e){
    	var sc = Ext.getBody().getScroll();
	   	var to = sc.top + window.innerHeight - this.element.getHeight();
	   	
	   	var from = sc.top + window.innerHeight;
	   	
	   	this.element.moveTo(0,from);

	   	this.element.moveTo(0,to,{
	    	duration:2
	    });
    }
});
