 //ѡ
 function $t(id,tag){var obj=id&&typeof id!="string"?id:document.getElementById(id)||document;if(!tag){return obj;}else{return obj.getElementsByTagName(tag);}}

//ͼ [ID,߰ť,ұ߰ť,,,Զʱ,ǰʽ,ٶ]
function Scroll(id,leftbut,rightbut,path,page,autoPlayTime,nowClass,rate){
	var nowPage=0,setout,setIn,speed,remain,now_num,target_num,obj=id.split("/"),xy="+",rate=rate||10;
	var scrollId=$t(obj[0]);
	if(nowClass){page=1;$t(obj[0],"div")[0].innerHTML+=$t(obj[0],"div")[0].innerHTML;} //еǰʽ
	var scroll_List=$t(obj[0],obj[1]);
	var scroll_List_Total=scroll_List.length; //б
	var offset_scrollId=(path=="scrollLeft")?scrollId.offsetWidth:scrollId.offsetHeight; //ȡ
	var offset_single=(path=="scrollLeft")?scroll_List[0].offsetWidth:scroll_List[0].offsetHeight; //ȡڲб
	var frameInList=Math.round(offset_scrollId/offset_single); //ɼб
	if(nowClass){scroll_List[nowPage+nowClass].className="nowclass";}
	if(leftbut){$t(leftbut).onmousedown=function(){xy="-";ScrollSpace();};}
	if(leftbut){$t(rightbut).onmousedown=function(){xy="+";ScrollSpace();};}
	if(autoPlayTime){ScrollAutoPlay();}
	function ScrollAutoPlay(){if(remain!=0){setout=setTimeout(ScrollSpace,autoPlayTime);}} //Զź
	function ScrollSpace(){  //ִк
		clearInterval(setIn);clearInterval(setout);
		remain=(xy=="+")?scroll_List_Total-frameInList-nowPage:nowPage; //ұصʣб
		if(xy=="+"){nowPage=remain<page?nowPage+remain:nowPage+page;}else{nowPage=remain<page?remain-nowPage:remain-page;} //,
		setIn=setInterval(ScrollBuffer,5);
		if(nowClass){ //ӵǰʽ
			if(xy=="+"&&scroll_List_Total/2+1<=nowPage){scrollId[path]=0;nowPage=1;}
			if(xy=="-"&&nowPage<=0){scrollId[path]=scroll_List_Total*offset_single/2+offset_single;nowPage=scroll_List_Total/2;}
			for(var n=0;n<scroll_List_Total;n++){scroll_List[n].className="";} 
			scroll_List[nowPage+nowClass].className="nowclass";
		}
	}
	function ScrollBuffer(){ //庯
		now_num=scrollId[path]; //ǰֵ
		target_num=nowPage*offset_single; //Ŀֵ
		speed=(target_num<now_num)?Math.floor((target_num-now_num)/rate):Math.ceil((target_num-now_num)/rate); //Ŀֵ-ǰֵ
		scrollId[path]+=speed;
		if(speed==0){clearInterval(setIn);ScrollAutoPlay();}
	}
}

function focusall(listid,ulid,imgid,imghref){
	var imgsobj=$t(listid,"img");
	var asobj=$t(listid,"a");
	var now=0;
	var nums=imgsobj.length;
	for(var lo=0;lo<nums;lo++){$t(ulid).innerHTML+="<li>"+(lo+1)+"</li>";}
	var listo=$t(ulid,"li");
	for(var i=0;i<nums;i++){och();chimgs(i);}
	function chimgs(i){listo[i].onmouseover=function(){clearInterval(tt);now=i-1;och();ft();}}
	function och(){
		now=(now<nums-1)?now+1:0;
		if(document.all){
		$t(imgid).style.filter="progid:DXImageTransform.Microsoft.Fade()";
		$t(imgid).filters[0].Apply();
		$t(imgid).filters[0].Play(duration=1);
		}
		$t(imgid).src=imgsobj[now].src;
		$t(imghref).href=asobj[now].href;
		for(var b=0;b<nums;b++){listo[b].className="";listo[now].className="show";}
	}
	function ft(){tt=setInterval(och,3000);}
	ft();
}


//ѡ [ID1,ID2,¼,ǰʾ,Զʱ]
function Tag(id1,id2,mouse,num,time,fun){
	var o1=id1.split('/'),o2=id2.split('/');
	var ocon=$t(o2[0],o2[1]),olist=$t(o1[0],o1[1]);
	var olist_sum=olist.length;
	var m=mouse||"onmouseover",now=num||0,setIn;
	tag_ch(now); //Ĭִл
	if(time){TagAutoPlay();} //жǷҪԶ
	function TagAutoPlay(){  //Զź
		setIn=setInterval(function (){now=(now<olist_sum-1)?now+1:0;tag_ch(now);},time);
	}
	for(var i=0;i<olist_sum;i++){mousefun(i);} //Ĭִ¼
	function mousefun(i){ //¼
		olist[i][m]=ocon[i][m]=function(){
			clearInterval(setIn);now=i;tag_ch(i);
			if(fun){eval(fun);}
		};
		if(time){olist[i]["onmouseout"]=ocon[i]["onmouseout"]=function(){TagAutoPlay();};}
	}
	function tag_ch(i){ //л
		for(var v=0;v<olist_sum;v++){
			olist[v].className=olist[v].className.replace("_ show","");
			ocon[v].className=ocon[v].className.replace("_ show","");
			olist[olist_sum-1].className="end "+olist[olist_sum-1].className.replace("end ",""); //һѡ
		}
		olist[i].className=olist[i].className+"_ show";
		ocon[i].className=ocon[i].className+"_ show";
	}
}



//input
function checkInput(el){
    if (!$t(el)) {
        return
    }
    var obj = $t(el);
    var old = obj.className;
    var ov = obj.value;
    
	obj.onclick = function(){obj.className = old + '_';obj.value = '';}
	obj.onblur = function(){ov = obj.value; if (ov == '') {obj.className = old;obj.value = obj.defaultValue;}}
}




//ͼ
function addImg(url){var img = new Image();img.src = url;return img;};
function FocusImg(){
    var img = $t("bigPicList", "img");
    var url = $t("bigPicList", "a");
    var now = 1, len = img.length, tm;
    var burl = $t("bigPic", "a")[0];
	var box = $t("focusBox");
    var bul = $t("focusList", "ul")[0];
	var lbtn = $t('rbtn');
	var rbtn = $t('lbtn');
    burl.appendChild(addImg(img[0].src));
    burl.href = url[0].href;
    var bimg = $t("bigPic", "img")[0];
    var bli = $t("focusList", "li");
	var size = bli[0].offsetWidth;
    bli[0].className = "on";
    function pfn(i){bli[i].onclick = function(){go(i,'right');}};
    for (var i = 0; i < len; i++) {pfn(i);}
	
	rbtn.onclick = function(){
		if(now==0){now=len-2;}else{now = now-2;}
		if(now<=-1){now=0;}
		go(now,'right');
	}
	lbtn.onclick = function(){if(now==0){return;}go(now,'left');}
	
	setTimeout(function(){box.style.cssText='height:0px;background:#010000;border:0px;'},3000)
	
	bimg.onmouseover = function(){box.style.cssText ='';}
	bimg.onmouseout  = function(){box.style.cssText ='height:0px;background:#010000;border:0px;';}
	box.onmouseover = function(){box.style.cssText ='';}
	box.onmouseout  = function(){box.style.cssText ='height:0px;background:#010000;border:0px;';}
    function xunhuan(path){
        if(!path){path='left'}
		uleft = bul.offsetLeft;
		if (/*@cc_on!@*/false) {
            bimg.style.filter = "progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0,motion=forward)";
            bimg.filters[0].Apply();
            bimg.filters[0].Play(duration = 1);
        }
        burl.href = url[now].href;
        bimg.src = img[now].src;
        for (var i = 0; i < len; i++) {
            bli[i].className = "";
        }
		if(now==0){bul.style.left='0px'}
		if( now%3 == 0 && now !=0 && path=='left'){
			bul.style.left = (len-now >=3 ? uleft-3*size : uleft - (len-now)*size) + 'px';
		}
		if( (bli[now].offsetLeft+ bul.offsetLeft) <0 && path=='right'){
			bul.style.left = (now >=3 ? uleft+3*size : uleft + now*size) + 'px';
		}
        bli[now].className = "on";
		if(now < len - 1){
			now++
		}else{
			now = 0;
		}
    }
    function init(){
        tm = setInterval(xunhuan, 5000);
    }
    function go(n,p){
        clearInterval(tm);
        now = n;
        xunhuan(p);
        init();
    };
    init();
}

