﻿// JScript 文件
//选项卡特效
//样式
/*Example for a Menu Style
<style type="text/css">
.menu {background-color:#008bd3;border-bottom:1px solid #d7d7d7; height:23px;width:300px;}
.menu ul {margin:0px; padding:0px; list-style:none; text-align:center;}
.menu li {display:inline; line-height:23px;}
.menu li a {color:#ffffff; text-decoration:none; padding:5px 5px 6px 5px; }
.menu li a.tabactive {border-left:1px solid #d7d7d7; border-right:1px solid #d7d7d7; color:#000000; background-color:#ffffff; font-weight:bold;  position:relative;}
#tabcontent1,#tabcontent2,#tabcontent3,#tabcontent4,#anothercontent1,#anothercontent2, #anothercontent3, #anothercontent4,#anothercontent5, #anothercontent6 {border:1px solid #ececec; width:298px; text-align:center;padding:6px 0px; font-size:12px; margin-bottom:5px;}
</style>
*/
//基本参数设置
//EASY TABS 1.2 - MENU SETTINGS

//Set the id names of your tablinks (without a number at the end)
var tablink_idname = "tablink"

//Set the id names of your tabcontentareas (without a number at the end)
var tabcontent_idname ="tabcontent"

//Set the number of your tabs in each menu 选项卡的个数
var tabcount = "5"

//Set the Tabs wich should load at start (In this Example:Menu 1 -> Tab 2 visible on load, Menu 2 -> Tab 5 visible on load) 开始显示的选项卡的编号
var loadtabs = "1"  

//Set the Number of the Menu which should autochange (if you dont't want to have a change menu set it to 0)
var autochangemenu = false;

//the speed in seconds when the tabs should change
var changespeed = 5;

//should the autochange stop if the user hover over a tab from the autochangemenu? 0=no 1=yes
var stoponhover = 0;

//END MENU SETTINGS



 
var timer;

var counter=0; //计数器标记变量

var totaltabs=tabcount;  //选项卡的个数

var currenttab=loadtabs;  //标记当前选项卡所在的位置

var currentTabTemp=currenttab;//记录上一个选项卡的编号

var next=currenttab+1; //记录下一个选项卡的编号，自动改变时使用。

function easytabs(autochangemenu,active) {

    currentTabTemp=currenttab;//记录上一个选项卡的编号
    
    if (autochangemenu){ //autochangemenu标记是否自动切换

        currenttab=active;

    } 
    if (autochangemenu &&(stoponhover==1)) {

        stop_autochange()

    }  
    else if (autochangemenu &&(stoponhover==0)) {

              counter=0;

          }  
//    menunr = menunr-1;

    //for (i=1;i <= tabcount;i++){

        document.getElementById(tablink_idname+currentTabTemp).className='menutd';
        //设置选项卡按钮的默认样式，取消当选项卡被选择后的样式区别。

        document.getElementById(tabcontent_idname+currentTabTemp).style.display = 'none';//隐藏选项卡控制的层
     
   // } 
    document.getElementById(tablink_idname+active).className='tabactive';//设置用户选择的选项卡的样式的类名

    document.getElementById(tabcontent_idname+active).style.display = 'block'; //显示用户选择的选项卡控制的层

}


function start_autochange(){ //自动切换选项卡

    counter=counter+1; //计数器自加一

    timer=setTimeout("start_autochange()",1000); //获取计时器句柄变量的值，每一秒执行一次函数。

    if (counter == changespeed+1) { //当计数器加到等于切换选项卡的时间间隔时，切换当前选项卡。

        next++;

        if (next>totaltabs) { //如果当前选项卡编号大于选项卡的个数，从第一个选项卡开始再次执行。

            next=1;

        } 
        easytabs(autochangemenu,next);
        restart_autochange(); //初始化所有变量的值再次进入计时状态。
    }
} 

function restart_autochange(){

    clearTimeout(timer);

    counter=0;

    start_autochange();
} 

function stop_autochange(){

    clearTimeout(timer);

    counter=0;
} 


