var Banner=new Class({
	Implements: Options,
	options:{
		'text':'Local radios, music, rock, pop, all genres'
		,'link':'http://radiobeta.com'
		,'img':'http://radiobeta.com/msnbanner/logobuttonbig.jpg'
	},
	initialize: function(options){
		this.setOptions(options);
		this.main=new Element("div",{
			styles:{
				'position':'absolute'
				,'width':'213px'
				,'height':'126px' 
				,'background-image':'url(http://radiobeta.com/msnbanner/msnbanner.png)'
				,'background-repeat':'no-repeat'
				,'right':'20px'
				,'top':window.getHeight()
						
			}
		
		});
		this.makeHTML();
	},
	
	makeHTML: function(){
		var _this=this;
		$('banner').adopt(_this.main);
		
		  
	
		this.close=new Element('div',{
					styles:{
					'position': 'absolute'
					,'width': '14px'
					,'height': '14px'
					,'top': '15px'
					,'right': '10px'
					,'z-index': '20'
				}
			}).addEvent('click',function(){ 
				_this.main.setStyle('display','none');
				});

		 

		var img=new Element('img',{
			'src':'http://radiobeta.com/msnbanner/transparent.gif'
				,'width':'14px'
				,'height':'14px'
				,'alt':'Cerrar'
				,'border':'0'
			,'styles':{
				'cursor':'pointer'
				}
			});
		
		
		this.close.adopt(img);
		
		this.main.adopt(this.close);
		
		/** General Thumb **/

		var div = new Element('div', {
			styles:{
				'position': 'absolute'
				,'width': '48px'
				,'height': '48px'
				,'left': '25px'
				,'top': '50px'
				}
			});

		var a=new Element('a', {
				'target':'_blank'
				,'href':this.options.link
			});

		var img=new Element('img', {
			src:this.options.img
			,'width':'46'
			,'height':'46'
			,'border':'0'
			});

		a.adopt(img);
		div.adopt(a);
		this.main.adopt(div);


		/** banner text **/
		
		var div=new Element('div', {
			styles:{
				'position': 'absolute'
				,'width': '113px'
				,'height': '72px'
				,'left': '88px'
				,'top': '47px'
				,'font-size': '11px'
				,'font-family': 'Arial, sans-serif'
				,'color': '#22272A'
				,'line-height': '13px'
				}
			});

		var a=new Element('a', {
			'target':'_blank'
			,'href':this.options.link
			,styles:{
				'text-color':'#000'
				,'text-decoration':'none'
			}
		});

		var div2=new Element('div', {
			styles:{
				'margin-bottom':'10px'
				,'font-weight':'bold'
				,'display':'block'
				,'margin-bottom':'2px'
				,'color':'#000'
			}
			}).appendText(this.options.text);

		a.adopt(div2);
		div.adopt(a);
		this.main.adopt(div);

		
		
		this.fx = new Fx.Tween(_this.main, {
		    duration: 'long',
		    transition: 'elastic:out',
		    link: 'cancel',
		    property: 'top'
		});

		_this.recall();
		window.addEvent('scroll', function(){
			_this.recall();
		});

		window.addEvent('resize', function(){
			_this.recall();
		});
		
	},
	recall: function(){		
		var _this=this;
		var scroll=window.getScroll();
		
		if(scroll.y > 0) var top=scroll.y + window.getHeight();
		else top=window.getHeight();

		top=top-_this.main.getHeight()-20;
		
		var actualTop=_this.main.getStyle('top').toInt();
		_this.fx.start(actualTop, top);
 
		}
});


