/*****************************************************************************************

	不间断滚动函数参数说明  Id:滚动区域的命名, W:滚动区域的宽度, H:滚动区域的高度
	以下是滚动时显示内容:	
	<div id='$1' style='display:none;'>
		<div style='width:540px;'>
			<img src="http://topic.csdn.net/ui/images/logo_csdn.gif" width='100' alt='1'/>
			<img src="http://topic.csdn.net/ui/images/logo_csdn.gif" width='100' alt='2'/>
			<img src="http://topic.csdn.net/ui/images/logo_csdn.gif" width='100' alt='3'/>
			<img src="http://topic.csdn.net/ui/images/logo_csdn.gif" width='100' alt='4'/>
			<img src="http://topic.csdn.net/ui/images/logo_csdn.gif" width='100' alt='5'/>
		</div>
	</div>
	注意：<div id='$1' style='display:none;'>此处最为重要 ID必须以‘$’开头，后面跟的是什么调用的
	时候就写什么，比如id='$XXX'那么调用的时候Left('XXX',300,100),如果id='$1'就Left(1,300,100)
	
	Div显示方式要设为隐藏，<div style='width:540px;'> 如果是左右不间断滚动必须要加的，而且还要
	指定宽度。调用上下不间断滚动时请删除<div style='width:540px;'> 否则将无法滚动
	
******************************************************************************************/


// 向右不间断滚动

function Left(Id,W,H,CSS){
	document.write('<div id="demo'+Id+'" style="overflow:hidden;height:'+H+'px;width:'+W+'px;"><table align="left" cellpadding="0" cellspace="0" border="0" style="'+CSS+'"><tr><td id="demo1'+Id+'" valign="top">');
	document.write(document.getElementById('$'+Id).innerHTML);
	document.write('</td><td id="demo2'+Id+'" valign="top" width="1"></td></tr></table></div>');
	var speed=40
	var demo = document.getElementById('demo'+Id);
	var demo1 = document.getElementById('demo1'+Id);
	var demo2 = document.getElementById('demo2'+Id);
	demo2.innerHTML=demo1.innerHTML
	var Marquee = function(){
		demo2.offsetWidth-demo.scrollLeft<=0?demo.scrollLeft-=demo1.offsetWidth:demo.scrollLeft++
	}
	var MyMar=setInterval(Marquee,speed)
	demo.onmouseover=function() {clearInterval(MyMar)}
	demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
}

//向左不间断滚动
function Right(Id,W,H,CSS){
	document.write('<div id="demo'+Id+'" style="overflow:hidden;height:'+H+'px;width:'+W+'px;"><table align="left" cellpadding="0" cellspace="0" border="0" class="'+CSS+'"><tr><td id="demo1'+Id+'" valign="top">');
	document.write(document.getElementById('$'+Id).innerHTML);
	document.write('</td><td id="demo2'+Id+'" valign="top" width="1"></td></tr></table></div>');
	var speed=40
	var demo = document.getElementById('demo'+Id);
	var demo1 = document.getElementById('demo1'+Id);
	var demo2 = document.getElementById('demo2'+Id);
	demo2.innerHTML=demo1.innerHTML
	demo.scrollLeft=demo.scrollWidth
	function Marquee(){demo.scrollLeft<=0?demo.scrollLeft+=demo2.offsetWidth:demo.scrollLeft--}
	var MyMar=setInterval(Marquee,speed)
	demo.onmouseover=function() {clearInterval(MyMar)}
	demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
}

//向上不间断滚动
function Up(Id,W,H){
	document.write('<div id="demo'+Id+'" style="overflow:hidden;height:'+H+'px;width:'+W+'px;"><div id="demo1'+Id+'">')
	document.write(document.getElementById('$'+Id).innerHTML)
	document.write('<div id="demo2'+Id+'"></div></div>')
	var speed=40
	var demo = document.getElementById('demo'+Id)
	var demo1 = document.getElementById('demo1'+Id)
	var demo2 = document.getElementById('demo2'+Id)
	demo2.innerHTML=demo1.innerHTML
	function Marquee(){
		demo2.offsetTop-demo.scrollTop<=0?demo.scrollTop-=demo1.offsetHeight:demo.scrollTop++
	}
	var MyMar=setInterval(Marquee,speed)
	demo.onmouseover=function() {clearInterval(MyMar)}
	demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
}

//向下不间断滚动
function Down(Id,W,H){
	document.write('<div id="demo'+Id+'" style="overflow:hidden;height:'+H+'px;width:'+W+'px;"><div id="demo1'+Id+'">')
	document.write(document.getElementById('$'+Id).innerHTML)
	document.write('<div id="demo2'+Id+'"></div></div>')
	var speed=40
	var demo = document.getElementById('demo'+Id)
	var demo1 = document.getElementById('demo1'+Id)
	var demo2 = document.getElementById('demo2'+Id)
	demo2.innerHTML=demo1.innerHTML
	demo.scrollTop=demo.scrollHeight
	function Marquee(){
		demo1.offsetTop-demo.scrollTop>=0?demo.scrollTop+=demo2.offsetHeight:demo.scrollTop--
	}
	var MyMar=setInterval(Marquee,speed)
	demo.onmouseover=function() {clearInterval(MyMar)}
	demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
}
