var banner = new Class({
	Implements: [Options],
	options: {
		offset: {
			top: 'auto',
			bottom: 175
		}
	},
	
	initialize: function(element,options){
		var posX =0 ,posY = 0;
		this.setOptions(options);
		this.element = $(element);
		
		if (this.element.getOffsetParent()){
			posX -= this.element.getOffsetParent().getPosition().x;
			posY -= this.element.getOffsetParent().getPosition().y;
		} 
		
		posX += this.element.getPosition().x;
		posY += this.element.getPosition().y;		
		
		this.options.offset.top = posY;
		
		this.element.setStyles({
			position:'absolute',
			left:posX,
			top:posY
		});
		
		if (window.getSize().y <= this.element.getSize().y)
			return;
		
	
		
		window.addEvent('scroll', (function(){
			if (window.getScroll().y > this.options.offset.top){
				if (window.getScroll().y <   (window.getScrollSize().y - window.getSize().y) - this.options.offset.bottom){
					this.element.setStyle('top', window.getScroll().y);
				} else {
				
				}
			} else {
				this.element.setStyle('top', this.options.offset.top);
			}
		}).bind(this))
		
	}
	
});


window.addEvent('load', function(){
	if ($('ban2'))
		new banner($('ban2'));
	
	if ($('ban1'))
		new banner($('ban1'));
})
