﻿function $(name) { return document.getElementById(name); }
var tabCount = 5;
var curIndex = 0;

var curOverIndex = -1;


//设置一级导航的选中状态
function SelectNav(aIndex)
{
    if (aIndex == 0)
    {
        $("menuTab0").className = "nav01_h";
        return;
    }
    if (aIndex > -1 && aIndex < 5)
    {
        var tab = $("menuTab" + aIndex);
        var count = aIndex + 1;
        if (tab)
        {
            tab.className = "nav0" + count + "_h";
            $("menuTab" + aIndex).className = "nav0" + (curIndex+1);
            curIndex = aIndex;
            $("menuSub" + aIndex).style.display = "";
        }
    }
 
//    var curSelect = $("menuTab" + curIndex);
//    if (curSelect)
//    {
//        curSelect.className="nav0"+curIndex; 
//    }
}

function BigMenuDiv() {
    if (curOverIndex != -1) {

        for (var i = 0; i < tabCount; i++) {
            if (i == curOverIndex) {
                if (curOverIndex == 0) {
                  //  $("menuTab0").className = "nav01_h";
                } else {
                $("menuSub" + curOverIndex).style.display = "";
//                $("menuTab0").className = "nav01";
                }
            } else {
                if (i != 0) {
                    $("menuSub" + i).style.display = "none";
                }
            }
        }
        if ($("menuSub" + curIndex))
        {
            $("menuSub" + curIndex).style.display = "";
        }
        if ($("menuSub" + curOverIndex)&&curIndex!=curOverIndex)
        {
            $("menuSub" + curOverIndex).style.display = "none";
        }
      
    }
}

function AfterPageLoad()
{
    if (curIndex == curOverIndex && curOverIndex == 0)
    {
        $("menuTab0").className = "nav01_h";
    }
    for (var i = 0; i < tabCount; i++) {
        var tempSub = $("menuSub" + i);
        if (tempSub) {
            if (tempSub.style.display != "none") {
            //若为本站首页
//                if (i == 0) {
//                    $("menuTab0").className = "nav01_h";
//                } else {
                    var tempTab = $("menuTab" + i);
                    tempTab.className = "nav0" + (i + 1) + "_h";
                    $("menuTab0").className = "nav01";
                    curIndex = i;
                    curOverIndex = i;
                    $("menuSub" + curIndex).style.display = "";
                    isHaveSelete = true;
//                }
                
            }
        }
    }

}
function MouseOverLink(index) {
    if (index == curIndex&&index!=0) return;
    
    for (var i = 0; i < tabCount; i++)
    {
        var tempSub = $("menuSub" + i);
        if (tempSub)
        {
            if (index == i)
            {
                tempSub.style.display = "block";
            }
            else
            {
                tempSub.style.display = "none";
            }
        }
       
    }
   curOverIndex = index;
}
function MouseOverSub() {

   //if (curOverIndex == curIndex && curOverIndex != 0) return;

    if (curIndex == 0 && curOverIndex != -1 &&curOverIndex!=0)
    {
        $("menuSub" + curOverIndex).style.display = "none";
    }
    if ($("menuSub" + curIndex))
    {
        $("menuSub" + curIndex).style.display = "none";
        if ($("menuSub" + curOverIndex))
            $("menuSub" + curOverIndex).style.display = "";
    }

    // alert("curInddex:"+curIndex+"...curOVer:"+curOverIndex);
    //当前划过目录不显示
//    if ($("menuSub" + curOverIndex))
//    {
////        if ($("menuSub" + curIndex))
////        {
//            $("menuSub" + curIndex).style.display = "";
////        }
//        $("menuSub" + curOverIndex).style.display = "none";
//    }

    //curOverIndex = -1;
}
function HeadMouseLeave()
{
    curOverIndex = -1;
}


function MouseOverTab()
{

    for (var i = 0; i < tabCount; i++)
    {
        var tab = $("menuSub" + i);
        if (tab)
        {
            if (i != 0 && curIndex != 0)
            {
                if (i == curIndex)
                    $("menuSub" + curIndex).style.display = "";
                else
                    $("menuSub" + i).style.display = "none";
            }
        }
    }
    //当前划过目录不显示
    if ($("menuSub" + curOverIndex))
        $("menuSub" + curOverIndex).style.display = "none";
    //恢复原来显示的目录
    if ($("menuSub" + curIndex))
        $("menuSub" + curIndex).style.display = "";
//    if (curIndex == 0)
//    {
//        $("menuTab0").className = "nav01_h";
    //    }
}


