﻿var imageTaber = {
  id: "HotNewsImage",
  sum: 4,
  currentTabId: 0,
  oldTabId: 0,
  imgs:new Array(),
  tab: function(n, auto) {
    imageTaber.isAuto = auto;
    if (auto) {
      this.oldTabId = this.currentTabId == 0 ? this.sum: this.currentTabId - 1;
    } else {
      this.oldTabId = this.currentTabId;
      this.currentTabId = n;
    }
    document.getElementById("imageTaber_" + this.oldTabId).className = "";
    document.getElementById("imageTaber_" + n).className = "current";
    document.getElementById(this.id).src = this.imgs[n];
    //HotNewsImageContainer.filters[0].Apply();
    //HotNewsImageContainer.filters[0].Play();
  },
  isAuto: false,
  timer: null,
  autoTab: function() {
    if (imageTaber.isAuto) {
      if (imageTaber.currentTabId < imageTaber.sum) {
        imageTaber.currentTabId++;
      } else {
        imageTaber.currentTabId = 0;
      }
      imageTaber.tab(imageTaber.currentTabId, true);
    }
    if (imageTaber.timer == null) {
      imageTaber.timer = setInterval("imageTaber.autoTab()", 3000);
      imageTaber.isAuto = true;
    }
  },
  reAuto: function() {
    imageTaber.isAuto = true;
  }
}

function sc(sURL, sTitle) {  
  try {
    window.external.addFavorite(sURL, sTitle);
  } catch(e) {
    try {
      window.sidebar.addPanel(sTitle, sURL, "");
    } catch(e) {
      alert("加入收藏失败，请使用Ctrl+D进行添加");
    }
  }
}

function tab(num) {  
  var sum = document.getElementById("subNav").children.length - 1;
  var left = 123 + num * 81; 
  for (var id = 0; id <= sum; id++) {
    var obj = document.getElementById("subNav_" + id);
    if(obj){
      obj.style.display = (id == num) ? "block" : "none";
      obj.style.marginLeft = left + "px";  
    }            
  } 
}

function link_tab(n){
  var links = document.getElementById("links").children;
  var len = links.length;
  for(var x = 1; x < len; x++){
    links[x].style.display = (x == n) ? "block" : "none";
  }
}

function co(obj, show) {
  obj.style.filter = !show ? "Alpha(opacity=50)": "";
  obj.style.opacity = !show ? "0.5": 1;
}

function Fix56_init(){
  if(document.getElementById(imageTaber.id)){
    imageTaber.sum--;
    imageTaber.autoTab();
  }  
}

if (document.all) {
  window.attachEvent('onload', Fix56_init)
} else {
  window.addEventListener('load', Fix56_init, false);
}
