﻿//修改 By 阿一 于2005-11-20
//完美支持XHTML

var f_delta=0.03;//滑动幅度
var f_closeB=false;//关闭默认状态
var f_canClose=true;//是否允许关闭
var f_IsCloseAll=true;//是否关闭所有
var f_Isfloat=true;//是否漂浮
var f_intervalId;
var f_collection;

function floaters() {
	this.items = [];
	this.addItem = function(id,x,y,src,url,width,height)
	{
		if(src.substring(src.length-4,src.length)==".swf")
		{
			var content='<embed src="'+src+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>';
		}
		else
		{
			var content='<a href="'+url+'" target="_blank"><img src="'+src+'" border="0"></a>';
		}
		//if(f_canClose)content+='<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="right" bgcolor="#6B6B6B"><img src="images/close.gif" onClick="closeBanner(\''+id+'\');"></td></tr></table>';
		document.write('<div id='+id+' style="z-index: 10; position: absolute;width:'+width+'px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+'px;top:'+(typeof(y)=='string'?eval(y):y)+'px">'+content+'</div>');
		
		var newItem= {};
		newItem.object= document.getElementById(id);
		newItem.x= x;
		newItem.y= y;
		
		this.items[this.items.length]= newItem;
	}
	this.play = function()
	{
		f_collection= this.items
		if(f_Isfloat)f_intervalId=setInterval('play()',1);
	}
	}
	function play()
	{
		if(screen.width<=500 || f_closeB)
		{
			for(var i=0;i<f_collection.length;i++)
			{
				f_collection[i].object.style.display = 'none';
			}
			clearInterval(f_intervalId);
			return;
		}
		
		var scrollLeft=document.body.scrollLeft;
		if(scrollLeft==0)scrollLeft=document.documentElement.scrollLeft;//XHTML版本scrollLeft
		var scrollTop=document.body.scrollTop;
		if(scrollTop==0)scrollTop=document.documentElement.scrollTop;
		
		for(var i=0;i<f_collection.length;i++)
		{
			var followObj= f_collection[i].object;
			var followObj_x= (typeof(f_collection[i].x)=='string'?eval(f_collection[i].x):f_collection[i].x);
			var followObj_y= (typeof(f_collection[i].y)=='string'?eval(f_collection[i].y):f_collection[i].y);
			
			if(followObj.offsetLeft!=(scrollLeft+followObj_x)) {
			var dx=(scrollLeft+followObj_x-followObj.offsetLeft)*f_delta;
			dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
			followObj.style.left=followObj.offsetLeft+dx;
		}

		if(followObj.offsetTop!=(scrollTop+followObj_y)) {
			var dy=(scrollTop+followObj_y-followObj.offsetTop)*f_delta;
			dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
			followObj.style.top=followObj.offsetTop+dy;
		}
	}
} 
function closeBanner(DivName)
{
	for(var i=0;i<f_collection.length;i++)
	{
		if(f_IsCloseAll)
			f_collection[i].object.style.display = 'none';
		else
			if(f_collection[i].object.id==DivName)f_collection[i].object.style.display = 'none';
	}
	if(f_Isfloat&&f_IsCloseAll)clearInterval(f_intervalId);
	return;
}
//theFloaters.addItem('DivName',x,y,'src',url,width,height);
function ShowAd(Url1,Pic1,Url2,Pic2)
{
var theFloaters= new floaters();
if(Pic1!=""){theFloaters.addItem('followDiv1','Math.floor((document.body.clientWidth-770)/2-114)',200,Pic1,Url1,80,350);}
if(Pic2!=""){theFloaters.addItem('followDiv2','Math.floor(document.body.clientWidth-(document.body.clientWidth-770)/2+20)',200,Pic2,Url2,80,350);}
theFloaters.play();
}


