/**
 * @author bob
 */
var ad_box = new Class({
	Implements: Options,
	options: {
		id: null,
		top: 'auto',  
		left: 'auto', 
		right: 'auto', 
		bottom: 'auto', 
		width: 100, //宽度
		height: 300, //高度
		title: '', //窗口的标题
		content: null
	},
	initialize: function(options) {
		this.setOptions(options);

		var adbox = this.adbox = new Element('div', {'id':this.options.id}).setStyles({
			'top': this.options.top,
			'right': this.options.right,
			'left': this.options.left,
			'bottom':this.options.bottom,
			'position':'fixed',
			'z-index': '10000'
		}).inject(document.body);
		var adhead, adbody;
		adbox.store(
			'adhead', adhead = new Element('div', {'class': 'ad_head'}).inject(adbox)
		).store(
			'adbody', adbody = new Element('div', {'class': 'ad_body'}).inject(adbox)
		);
		new Element('div', {'text': '关闭','id': 'close_ad'+this.options.id}).setStyles({
			'text-align': 'right'
		}).addEvent('click', function(){
			this.hide();
		}.bind(this)).inject(adhead);		
		adbody.adopt(
			this.options.content
		);	
		if(Browser.Engine.trident4) {
			adbox.setStyles({
				'position': 'absolute'
			})
			this.automove();
		}	
	},
	automove: function(){
		var top = window.getScroll().y + this.options.top;
		this.adbox.setStyle('top',top);
		this.automove.delay(200,this);
	},
	
	hide: function(){
		this.adbox.setStyle('display','none');
	}
});
window.addEvent('domready',function(){	
	ad_content_r = new Element('div').adopt(
		new Element('a', {'href': 'http://we.xixun.cn' ,'target':'_blank'}).adopt(
			new Element('img', {'src':'/images/ad/2010/100_307_c.gif','width':'100'})
		)
		
	);	
	var adbox_1 = new ad_box({
		'id' :'adr',
		'top':90,
		'right':0,
		'content': ad_content_r
	});	
	ad_content_l = new Element('div').adopt(
		new Element('a', {'href': 'http://we.xixun.cn'}).adopt(
			new Element('img', {'src':'/images/ad/2010/100_307.gif','width':'100'})
		)
		
	);

})
