function WScrollPost()
{
	var scrollPos; 
	if (typeof(window.pageYOffset) != 'undefined')    //针对Netscape 浏览器
	{ 
		scrollPos = window.pageYOffset; 
	} 
	else if (typeof(document.compatMode) != 'undefined' &&   document.compatMode != 'BackCompat')
	{ 
		scrollPos = document.documentElement.scrollTop; 
	} 
	else if (typeof(document.body) != 'undefined') 
	{ 
		scrollPos = document.body.scrollTop; 
	}
	return scrollPos;
}
function eduAd_Property(width,height,src,href,align,top,left)
{
	this.width = width;
	this.height = height;
	this.src = src;
	this.href = href;
	this.algin = align;
	this.top = 0;
	this.left = 0;
	this.self = null;

	this.close = function()
	{
		this.self.style.display = 'none';
	}

	this.move = function()
	{
		this.self.style.pixelTop = this.top + WScrollPost();
	}
}
function eduAd(name)
{
	this.name = name;
	this.ad = new Array();
	var _rootEl=document.compatMode=="CSS1Compat"?document.documentElement:document.body;/*得到当前窗体的根元素*/ 
	//屏幕的宽度	
	this.width = _rootEl.clientWidth;window.status = this.width;
	//屏幕的高度
	this.height = _rootEl.clientHeight;
	//左边广告离左边的距离
	this.left_left = 0;
	//右边广告离左边的距离
	this.right_left = 0;
	//页面的宽度
	this.page_width = 0;
	//间隔
	this.padding = 30;

	this.addAd = function(width,height,src,href,align)
	{
		var newad = new eduAd_Property(width,height,src,href,align,0,0);
		this.ad[this.ad.length] = newad;
	}


	this.display = function (page_width)
	{
		this.page_width = page_width;
		//获取页面的高度和宽度
		if(this.width>page_width)
		{
			this.left_left = Math.ceil((this.width-page_width)/2)-2;
			this.right_left = this.left_left + page_width+2;
			if(this.width % 2 == 1) this.left_left-=1;
		}
		else
		{
			this.left_left = 0;
			this.right_left = page_width;
			if(this.width % 2 == 1) this.left_left-=1;
		}
		
		var left_top = 200;
		var right_top = 200;
		var len = this.ad.length;
		for(i=0;i<len;i++)
		{
			

			
			if(this.ad[i].algin == 'left')
			{
				this.ad[i].top = left_top;
				left_top += this.ad[i].height + this.padding;
				this.ad[i].left = this.left_left-this.ad[i].width;

			}
			else
			{
				this.ad[i].top = right_top;
				right_top += this.ad[i].height + this.padding;
				this.ad[i].left = this.right_left;
			}
			var str = '<DIV id="advLayer'+i+'" style="position:absolute; left:'+this.ad[i].left+'px; top:'+this.ad[i].top+'px; width:'+this.ad[i].width+'px; height:'+this.ad[i].height+'px; z-index:99;">';
			str += '<table border="0" cellspacing="0" cellspadding="0"><tr><td>';
			var pos = this.ad[i].src.lastIndexOf(".");
			var ext = this.ad[i].src.substr(pos+1,this.ad[i].src.length-pos-1);
			var ext = ext.toLowerCase();
			if(ext == 'swf')
			{
				str += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100" height="100">';
		        str += '<param name="movie" value="'+this.ad[i].src+'" />';
		        str += '<param name="quality" value="high" />';
				str += '<param name="wmode" value="transparent" />';
				str += '<embed src="' + this.ad[i].src + '" wmode="transparent"  quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100" height="100"></embed>';
		        str += '</object>';
			}
			else
			{
				str += '<A href="'+this.ad[i].href+'" target="_blank">';
				str += '<IMG src="'+this.ad[i].src+'" width="'+this.ad[i].width+'" height="'+this.ad[i].height+'" border="0">';
				str += '</A>';
			}
			str += '</td></tr><tr><td align="right"><a href="javascript:Ad.Close('+i+')"><img src="/images/close.gif" id="advLayerclose'+i+'"></a></td></tr></table></DIV>';
			document.write(str);
			this.ad[i].self = document.getElementById("advLayer"+i);
		}
	}

	this.Close = function(idx)
	{
		this.ad[idx].close();
	}

	this.Move = function()
	{
		var len = this.ad.length;
		for(i=0;i<len;i++)
			this.ad[i].move();
		
		//window.status = document.body.scrollTop;
	}


}
