//选择器
function $a(id,tag){var re=(id&&typeof id!="string")?id:document.getElementById(id);if(!tag){return re;}else{return re.getElementsByTagName(tag);}}

//标签切换效果[标题框子元素("id/li"),内容框子元素("id/li"),事件(mouseover/click),默认显示第几条(-1表示在鼠标移出全部隐藏,仅在事件mouseover有效),轮播时间(1秒=1000)]
function SwitchTag(tit,box,s,show,time)
{
	var t=tit.split('/'),b=box.split("/"),ts=$a(t[0],t[1]),bs=$a(b[0],b[1]),s=s||"onmouseover",now=show=show||0,c;
	for(var i=0;i<ts.length;i++){ts[i].old=ts[i].className.replace("show","");bs[i].old=bs[i].className.replace("show","");reg(i);}
	function init(){
		for(var i=0;i<ts.length;i++){
			ts[i].className=ts[i].old;
			bs[i].className=bs[i].old;
			
			};
		if(now!=-1){ //自动切换显示位置初始
			ts[now].className+=(t[2]||"")+" show";
			bs[now].className+=(b[2]||"")+" show";
			//alert(bs[now].className)
			}
		}
	//鼠标悬浮在标题上时取消自动切换	
	function reg(i){
		ts[i][s]=function(){clearInterval(c);now=i;init();
		}
	//鼠标悬浮在内容上时取消自动切换	
	if(show!=-1&&time){
		bs[i].onmouseover=function(){clearInterval(c);};bs[i].onmouseout=function(){go();};ts[i].onmouseout=function(){go();}
		}
	if(show==-1&&s=="onmouseover"){
		ts[i].onmouseout=function(){now=-1;init();}}
		}
	function go(){
		c=setInterval(
					  function(){(now<ts.length-1)?now++:now=0;init();},time
					  );
		}
	if(show!=-1&&time){go();};init();
}

//滚动
function slideLine(ul, delay, speed, lh) {
	var slideBox = (typeof ul == 'string')?document.getElementById(ul):ul;
	
	var delay = delay||1000, speed=speed||20, lh = lh||20;
	var tid = null, pause = false;
	var start = function() {
		tid = setInterval(slide, speed);
	}
	var slide = function() {
		if (pause) return;		
		slideBox.scrollTop += 1;
		if (slideBox.scrollTop % lh == 0) {
			clearInterval(tid);	
			slideBox.appendChild(slideBox.getElementsByTagName('div')[0]);
			slideBox.scrollTop = 0;
			setTimeout(start, delay);}
	}
	slideBox.onmouseover = function(){ pause=true; }
	slideBox.onmouseout = function(){ pause=false; }
	setTimeout(start, delay);
}