//载入广告代码
function loadad(adid,fileurl,fileurl1,filetype,width,height,adtype,link)
{
	switch (adtype)
	{
		//弹出广告
		case 1:
			var adwin = window.open('',''+adid+'','width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top=80,left=80');
			adwin.document.write("<html>");
			adwin.document.write("<head>");
			adwin.document.write("<title>弹出广告</title>");
			adwin.document.write("<script>self.resizeBy("+width+"-document.body.clientWidth,"+height+"-document.body.clientHeight);</"+"script>");
			adwin.document.write("</head>");
			adwin.document.write("<body style=\"margin:0px;\">");
			if(filetype==0)
			{
				if(link!="")
				{
					adwin.document.write("<div><a href=\""+link+"\" target=\"_blank\"><img src=\""+fileurl+"\" width=\""+width+"\" height=\""+height+"\" border=\"0\"/></a></div>");
				}
				else
				{
					adwin.document.write("<div><img src=\""+fileurl+"\" width=\""+width+"\" height=\""+height+"\"/></div>");
				}
			}
			else
			{
				adwin.document.write("<script language=\"javascript\" src=\"/inc/swfobject.js\"></"+"script>");
				adwin.document.write("<div id=\"adpanel\"></div>");
				adwin.document.write("<script>writeFlash(\""+fileurl+"\",\"ad\","+width+","+height+",8,\"#000000\",\"adpanel\");</"+"script>");
			}
			adwin.document.write("</body>");
			adwin.document.write("</html>");
			break;
		//浮动广告
		case 2:
			document.write( '<div id="'+adid+'" style="position:absolute; left: 27px; top: 1115px;z-index:1000;">');
			var htmlcontent;
			htmlcontent = '<img src="'+fileurl+'" width="'+width+'" height="'+height+'" border="0"/>';
			if(link!="")
			{
				htmlcontent = '<a href="'+link+'" target="_blank">'+htmlcontent+'</a>';
			}
			htmlcontent = '<div id = "'+adid+'_visual">'+htmlcontent+'</div>';
			htmlcontent += '<div style="position:relative;top:-12px;text-align:right;width:'+width+'px;"><img id="'+adid+'_close" src="/images/ad_close.gif" alt="关闭本广告" style="cursor:pointer;"/></div>';
			document.write (htmlcontent);
			document.write ('</div>');
			var clientwidth;
			var clientheight;
			if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 7.0")==-1)
			{
				clientwidth = document.body.clientWidth;
				clientheight = document.body.clientHeight;
			}
			else
			{
				clientwidth = document.documentElement.clientWidth;
				clientheight = document.documentElement.clientHeight;
			}
			var img = document.getElementById(adid);
			img.style.top = clientheight+"px";
			function changePos(xPos,yPos,xon,yon)
			{
				var scrollleft;
				var scrolltop;
				if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 7.0")==-1)
				{
					scrollleft = document.body.scrollLeft;
					scrolltop = document.body.scrollTop;
				}
				else
				{
					scrollleft = document.documentElement.scrollLeft;
					scrolltop = document.documentElement.scrollTop;
				}
				Hoffset = img.offsetHeight;
				Woffset = img.offsetWidth;
				img.style.left = xPos + scrollleft+"px";
				img.style.top = yPos + scrolltop+"px";
				if (yon) 
				{
					yPos = yPos + 1;
				}
				else 
				{
					yPos = yPos - 1;
				}
				if (yPos < 0) 
				{
					yon = 1;
					yPos = 0;
				}
				if (yPos >= (clientheight - Hoffset)) 
				{
					yon = 0;
					yPos = (clientheight - Hoffset);
				}
				if (xon) 
				{
					xPos = xPos + 1;
				}
				else 
				{
					xPos = xPos - 1;
				}
				if (xPos < 0) 
				{
					xon = 1;
					xPos = 0;
				}
				if (xPos >= (clientwidth - Woffset)) 
				{
					xon = 0;
					xPos = (clientwidth - Woffset);
				}
				floattimeout = setTimeout(_changePos(xPos,yPos,xon,yon),20);
				var obj = document.getElementById(adid);
				obj.onmouseover = function(){clearTimeout(floattimeout);};
				obj.onmouseout = function(){floattimeout = setTimeout(_changePos(xPos,yPos,xon,yon),20);};
				document.getElementById(adid+"_close").onclick = function(){obj.style.display="none";clearTimeout(floattimeout);};
			}

			function _changePos(xPos,yPos,xon,yon)
			{
				return function()
				{
					changePos(xPos,yPos,xon,yon);
				}
			}
			changePos(20,clientheight,0,0);
			break;
		//对联广告
		case 3:	
			var delta=0.8;
			function floaters() 
			{
				this.items	= [];
				this.addItem	= function(id,x,y,content,url)
				{
					document.write('<div id="'+id+'" style="z-index:1000;position:absolute;width:'+width+'px;height:'+height+'px;left:'+(typeof(x)=='string'?eval(x):x)+'px;top:'+(typeof(y)=='string'?eval(y):y)+'px;"><div id="'+id+'_visual">'+content+'</div><div style="position:relative;top:-12px;text-align:right;"><img alt="关闭本广告" style="cursor:pointer;" id="'+id+'_close" src="/images/ad_close.gif"/></div></div>');
					var newItem				= {};
					newItem.object			= document.getElementById(id);
					newItem.x				= x;
					newItem.y				= y;
					this.items[this.items.length]		= newItem;
				}
				this.play	= function()
				{
					setInterval(_play(this.items),30);
				}
			}
			function _play(collection)
			{
				return function()
				{
					play(collection);
				}
			}
			function play(collection)
			{
				if(screen.width<=800)
				{
					for(var i=0;i<collection.length;i++)
					{
						collection[i].object.style.display	= 'none';
					}
					return;
				}
				for(var i=0;i<collection.length;i++)
				{
					var followObj		= collection[i].object;
					var followObj_x		= (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
					var followObj_y		= (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);

					var scrollleft;
					if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 7.0")==-1)
					{
						scrollleft = document.body.scrollLeft;
					}
					else
					{
						scrollleft = document.documentElement.scrollLeft;
					}
					if(followObj.offsetLeft!=(scrollleft+followObj_x)) 
					{
						var dx=(scrollleft+followObj_x-followObj.offsetLeft)*delta;
						dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
						followObj.style.left=followObj.offsetLeft+dx+"px";
					}
					var scrolltop;
					if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 7.0")==-1)
					{
						scrolltop = document.body.scrollTop;
					}
					else
					{
						scrolltop = document.documentElement.scrollTop;
					}
					if(followObj.offsetTop!=(scrolltop+followObj_y)) 
					{
						var dy=(scrolltop+followObj_y-followObj.offsetTop)*delta;
						dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
						followObj.style.top=followObj.offsetTop+dy+"px";
					}
					//followObj.style.display	= '';
				}
			}	
			var theFloaters	= new floaters();
			if(fileurl!="")
			{
				var content;
				content = '<img src = "'+fileurl+'" style="width:'+width+'px;height:'+height+'px;border:0px;"/>';
				if(link!="")
				{
					content = '<a href="'+link+'" target="_blank">'+content+'</a>';
				}
				theFloaters.addItem(adid+'_left','5',80,content,fileurl);
				document.getElementById(adid+"_left_close").onclick = function()
				{
					for(var i=0;i<theFloaters.items.length;i++)
					{
						theFloaters.items[i].object.style.display	= 'none';
					}
				}
			}
			if(fileurl1!="")
			{
				var content1;
				content1 = '<img src = "'+fileurl1+'" style="width:'+width+'px;height:'+height+'px;border:0px;"/>';
				if(link!="")
				{
					content1 = '<a href="'+link+'" target="_blank">'+content1+'</a>';
				}
				theFloaters.addItem(adid+'_right','document.body.clientWidth-'+width+'-5',80,content1,fileurl1);
				document.getElementById(adid+"_right_close").onclick = function()
				{
					for(var i=0;i<theFloaters.items.length;i++)
					{
						theFloaters.items[i].object.style.display	= 'none';
					}
				}
			}
			theFloaters.play();
			if(filetype==1&&fileurl!="")
			{
				document.write('<script lauguege="javascript">writeFlash("'+fileurl+'","'+adid+'_left_visual",'+width+','+height+',8,"","'+adid+'_left_visual");</'+'script>');
			}
			if(filetype==1&&fileurl1!="")
			{
				document.write('<script lauguege="javascript">writeFlash("'+fileurl1+'","'+adid+'_right_visual",'+width+','+height+',8,"","'+adid+'_right_visual");</'+'script>');
			}
			break;
		default:
			break;
	}
}