﻿ var Speed_1 = 10; //速度(毫秒)
var Space_1 =10; //每次移动(px)
var PageWidth_1 = 172; //翻页宽度
var interval_1 = 3000; //翻页间隔
var fill_1 = 0; //整体移位
var MoveLock_1 = false;
var MoveTimeObj_1;
var MoveWay_1="right";
var Comp_1 = 0;
var AutoPlayObj_1=null;
function GetObj(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}}
function AutoPlay_1(){clearInterval(AutoPlayObj_1);AutoPlayObj_1=setInterval('ISL_GoDown_1();ISL_StopDown_1();',interval_1)}
function ISL_GoUp_1(){if(MoveLock_1)return;clearInterval(AutoPlayObj_1);MoveLock_1=true;MoveWay_1="left";MoveTimeObj_1=setInterval('ISL_ScrUp_1();',Speed_1);}
function ISL_StopUp_1(){if(MoveWay_1 == "right"){return};clearInterval(MoveTimeObj_1);if((GetObj('ISL_Cont_1').scrollLeft-fill_1)%PageWidth_1!=0){Comp_1=fill_1-(GetObj('ISL_Cont_1').scrollLeft%PageWidth_1);CompScr_1()}else{MoveLock_1=false}
AutoPlay_1()}
function ISL_ScrUp_1(){
if(GetObj('ISL_Cont_1').scrollLeft<=0){GetObj('ISL_Cont_1').scrollLeft=GetObj('ISL_Cont_1').scrollLeft+GetObj('List1_1').offsetWidth}
GetObj('ISL_Cont_1').scrollLeft-=Space_1}
function ISL_GoDown_1(){clearInterval(MoveTimeObj_1);if(MoveLock_1)return;clearInterval(AutoPlayObj_1);MoveLock_1=true;MoveWay_1="right";ISL_ScrDown_1();MoveTimeObj_1=setInterval('ISL_ScrDown_1()',Speed_1)}
function ISL_StopDown_1(){if(MoveWay_1 == "left"){return};clearInterval(MoveTimeObj_1);if(GetObj('ISL_Cont_1').scrollLeft%PageWidth_1-(fill_1>=0?fill_1:fill_1+1)!=0){Comp_1=PageWidth_1-GetObj('ISL_Cont_1').scrollLeft%PageWidth_1+fill_1;CompScr_1()}else{MoveLock_1=false}
AutoPlay_1()}
function ISL_ScrDown_1(){
if(GetObj('ISL_Cont_1').scrollLeft>=GetObj('List1_1').scrollWidth)
{

 GetObj('ISL_Cont_1').scrollLeft=GetObj('ISL_Cont_1').scrollLeft-GetObj('List1_1').scrollWidth
}
GetObj('ISL_Cont_1').scrollLeft+=Space_1
}
function CompScr_1(){if(Comp_1==0){MoveLock_1=false;return}
var num,TempSpeed=Speed_1,TempSpace=Space_1;if(Math.abs(Comp_1)<PageWidth_1/2){TempSpace=Math.round(Math.abs(Comp_1/Space_1));if(TempSpace<1){TempSpace=1}}
if(Comp_1<0){if(Comp_1<-TempSpace){Comp_1+=TempSpace;num=TempSpace}else{num=-Comp_1;Comp_1=0}
GetObj('ISL_Cont_1').scrollLeft-=num;setTimeout('CompScr_1()',TempSpeed)}else{if(Comp_1>TempSpace){Comp_1-=TempSpace;num=TempSpace}else{num=Comp_1;Comp_1=0}
GetObj('ISL_Cont_1').scrollLeft+=num;setTimeout('CompScr_1()',TempSpeed)}}
function picrun_ini()//初始化
{
GetObj("List2_1").innerHTML=GetObj("List1_1").innerHTML;
GetObj('ISL_Cont_1').scrollLeft=fill_1>=0?fill_1:GetObj('List1_1').scrollWidth-Math.abs(fill_1);
GetObj("ISL_Cont_1").onmouseover=function(){clearInterval(AutoPlayObj_1)}
GetObj("ISL_Cont_1").onmouseout=function(){AutoPlay_1()}
AutoPlay_1();
}

//选项卡
function $a(id, tag) { var re = (id && typeof id != "string") ? id : document.getElementById(id); if (!tag) { return re; } else { return re.getElementsByTagName(tag); } }

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"; } }
    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 addImg(url) { var img = new Image(); img.src = url; return img; }


function ShowSubMenu(main,child) {
    document.getElementById("" + child + "").className = (document.getElementById("" + child + "").className == 'none') ? '' : 'none';
    document.getElementById("" + main + "").innerHTML = (document.getElementById("" + main + "").innerHTML == '+') ? '-' : '+';
}


//行业首页焦点图
function id(id) { return document.getElementById(id); }
function moveElement(elementID, final_x, final_y, interval) {
    if (!document.getElementById) return false;
    if (!document.getElementById(elementID)) return false;
    var elem = document.getElementById(elementID);
    if (elem.movement) {
        clearTimeout(elem.movement);
    }
    if (!elem.style.left) {
        elem.style.left = "0px";
    }
    if (!elem.style.top) {
        elem.style.top = "0px";
    }
    var xpos = parseInt(elem.style.left);
    var ypos = parseInt(elem.style.top);
    if (xpos == final_x && ypos == final_y) {
        return true;
    }
    if (xpos < final_x) {
        var dist = Math.ceil((final_x - xpos) / 10);
        xpos = xpos + dist;
    }
    if (xpos > final_x) {
        var dist = Math.ceil((xpos - final_x) / 10);
        xpos = xpos - dist;
    }
    if (ypos < final_y) {
        var dist = Math.ceil((final_y - ypos) / 10);
        ypos = ypos + dist;
    }
    if (ypos > final_y) {
        var dist = Math.ceil((ypos - final_y) / 10);
        ypos = ypos - dist;
    }
    elem.style.left = xpos + "px";
    elem.style.top = ypos + "px";
    var repeat = "moveElement('" + elementID + "'," + final_x + "," + final_y + "," + interval + ")";
    elem.movement = setTimeout(repeat, interval);
}
function classNormal() {
    var focusBtnList = id('focus_change_btn').getElementsByTagName('li');
    for (var i = 0; i < focusBtnList.length; i++) {
        focusBtnList[i].className = '';
    }
}
function focusChange() {
    var focusBtnList = id('focus_change_btn').getElementsByTagName('li');
    focusBtnList[0].onmouseover = function () {
        moveElement('focus_change_list', 0, 0, 5);
        classNormal()
        focusBtnList[0].className = 'current'
    }
    focusBtnList[1].onmouseover = function () {
        moveElement('focus_change_list', -250, 0, 5);
        classNormal()
        focusBtnList[1].className = 'current'
    }
    focusBtnList[2].onmouseover = function () {
        moveElement('focus_change_list', -500, 0, 5);
        classNormal()
        focusBtnList[2].className = 'current'
    }
}
setInterval('autoFocusChange()', 5000);
var atuokey = false;
function autoFocusChange() {
  if(id('focus_change')!=null){
    id('focus_change').onmouseover = function () { atuokey = true }
    id('focus_change').onmouseout = function () { atuokey = false }
    if (atuokey) return;
    var focusBtnList = id('focus_change_btn').getElementsByTagName('li');
    for (var i = 0; i < focusBtnList.length; i++) {
        if (focusBtnList[i].className == 'current') {
            var currentNum = i;
        }
    }
    if (currentNum == 0) {
        moveElement('focus_change_list', -250, 0, 5);
        classNormal()
        focusBtnList[1].className = 'current'
    }
    if (currentNum == 1) {
        moveElement('focus_change_list', -500, 0, 5);
        classNormal()
        focusBtnList[2].className = 'current'
    }
    if (currentNum == 2) {
        moveElement('focus_change_list', 0, 0, 5);
        classNormal()
        focusBtnList[0].className = 'current'
    }
  }
}
//if (window.addEventListener) window.addEventListener("load", focusChange, false);
//if (window.attachEvent) window.attachEvent("onload", focusChange);
window.onload = function () {
  if(id('focus_change')!=null){focusChange();}
}

function set(index)
{
for(var i=1;i<=2;i++)
{
 document.getElementById("s_l"+i).className="";
}
document.getElementById("s_l"+index).className="s_l_sld"; 
document.getElementById("s_l_value").value=index;
}

