/**************************************
*Filename:      setTab.js
*Version:       1.0.0(2009-04-24)
*Author:        jasy[TMUED]

参数说明：
id1:标签切换父容器的ID
tag1:标签切换的相应标签
tabclass:标签选中状态的class
id2:切换内容的父容器ID
tag2:切换内容的相应子标签
changeEvent:标签切换的触发事件(值为click时为点击切换,值为hover时为鼠标经过切换)
changeTime:是否定时切换changeTime值即为定时切换间隔时间，无则不定时切换)
isClick:是否单击开关内容区(可选true或false值);
isClickAll:是否单独开关内容区（可选true或false值）;
fadeTime:是否渐显效果,值为渐显速度.无值则为无渐显动画;
***************************************/

//标签切换主函数
function setTab(id1, tag1, tabclass, id2, tag2, changeEvent, changeTime, isClick, isClickAll, fadeTime) {
  var tli = document.getElementById(id1).getElementsByTagName(tag1);
  var cli = document.getElementById(id2).getElementsByTagName(tag2);
  var temp = 0;
  var opaStep = 0.1;
  var isScroll = true;
  for (i = 0; i < tli.length; i++) {
    cli[i].style.display = "none";
  }
  tli[temp].className = tabclass;
  cli[temp].style.display = "block";
  for (i = 0; i < tli.length; i++) {
    tli[i].value = i;
    tli[i].onmouseout = function() {
      isScroll = true;
    }
    tli[i].onmouseover = function() {
      isScroll = false;
    }
    if (changeEvent == "click") {
      tli[i].onclick = function() {
        setTabCon(this.value);

      }
    } else if (changeEvent == "hover") {
      tli[i].onmouseover = function() {
        setTabCon2(this.value);
        isScroll = false;
      }
      tli[i].onclick = function() {
        setTabCon(this.value);

      }
    }
  }

  //设置标签标题与内容切换
  function setTabCon(n) {
    if (isClickAll) {
      tli[n].className = (tli[n].className == "on") ? "": "on";
      if (fadeTime) { (cli[n].style.display == "block") ? fadeOut(cli[n]) : fadeIn(cli[n]);
      } else {
        cli[n].style.display = (cli[n].style.display == "block") ? "none": "block";
      }
    } else if (isClick) {
      for (j = 0; j < tli.length; j++) {
        tli[j].className = n == j ? tabclass: "";
        if (fadeTime) {
          if (n == j) {
            if (cli[j].style.display == "none") {
              fadeIn(cli[j]);
            } else {
              fadeOut(cli[j])
            };
          } else {
            cli[j].style.display = "none";
            /*fadeOut(cli[j]);*/
          }
        } else {
          cli[j].style.display = n == j ? "block": "none";
        }
      }
      temp = n;
    } else {
      for (j = 0; j < tli.length; j++) {
        tli[j].className = n == j ? tabclass: "";
        if (fadeTime) {
          if (n == j) {
            if (cli[j].style.display == "none") {
              fadeIn(cli[j]);
            }
          } else {
            cli[j].style.display = "none";
            /*fadeOut(cli[j]);*/
          }
        } else {
          cli[j].style.display = n == j ? "block": "none";
        }
      }
      temp = n;
    }
  }

  //设置标签标题与内容切2
  function setTabCon2(n) {
    for (j = 0; j < tli.length; j++) {
      tli[j].className = n == j ? tabclass: "";
      if (fadeTime) {
        if (n == j) {
          if (cli[j].style.display == "none") {
            fadeIn(cli[j]);
          }
        } else {
          cli[j].style.display = "none";
          /*fadeOut(cli[j]);*/
        }
      } else {
        cli[j].style.display = n == j ? "block": "none";
      }
    }
    temp = n;
  }

  //设置透明度
  function setAlpha(obj, opa) {
    document.all ? obj.style.filter = "Alpha(opacity=" + opa * 100 + ")": obj.style.opacity = opa;
  }

  //渐显
  function fadeIn(obj) {
    obj.style.display = "block";
    var opa = 0;
    function setFadeIn() {
      if (opa < 1) {
        setAlpha(obj, opa);
        opa += opaStep;
        setTimeout(setFadeIn, fadeTime);
      }
    }
    setFadeIn();
  }

  //渐隐
  function fadeOut(obj) {
    var opa = 1;
    function setFadeOut() {
      if (opa > 0) {
        setAlpha(obj, opa);
        opa -= opaStep;
        setTimeout(setFadeOut, fadeTime);
      } else {
        obj.style.display = "none";
      }
    }
    setFadeOut();
  }

  //定时切换
  if (changeTime) {
    function setTiming() {
      if (isScroll) {
        setTabCon2(temp);
        temp++;
        temp = (temp == tli.length) ? 0 : temp;
      }
      setTimeout(setTiming, changeTime);
    }
    setTiming();
  }
}


/*************************************changeimg***************************************/
// JavaScript Document
var Speed_1 = 10; //速度(毫秒)
var Space_1 = 10; //每次移动(px)
var PageWidth_1 = 131; //翻页宽度
var fill_1 = 0; //整体移位
var MoveLock_1 = false;
var MoveTimeObj_1;
var MoveWay_1 = "right";
var Comp_1 = 0;
var AutoPlayObj_1 = null;
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 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();', 5000)
}
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)
  }
}