/**-----------------------控制页面导航---------------------**/
/**用法：
1.初始化时调用initIt函数
2.点击父目录时调用expandIt函数
**/
/**--------------------------------------------------------**/

// 获取功能变量ind的值
function getIndex(el) {
    ind = null;
    for (i=0; i<document.layers.length; i++) {
        whichEl = document.layers[i];
        if (whichEl.id == el) {
            ind = i;
            break;
        }
    }
    return ind;
}

// 定义页面上元素的显示位置
function arrange() {
    nextY = document.layers[firstInd].pageY +document.layers[firstInd].document.height;
    for (i=firstInd+1; i<document.layers.length; i++) {
        whichEl = document.layers[i];
        if (whichEl.visibility != "hide") {
            whichEl.pageY = nextY;
            nextY += whichEl.document.height;
        }
    }
}

// 页面载入时，首先调用该函数，初始菜单状态为未打开
function initIt(){
	// 判断是否为IE或Netsape
	NS4 = (document.layers) ? 1 : 0;
	IE4 = (document.all) ? 1 : 0;
	ver4 = (NS4 || IE4) ? 1 : 0;
    if (!ver4) return;
    
    // 控制初始显示情况
    if (NS4) {
        for (i=0; i<document.layers.length; i++) {
            whichEl = document.layers[i];
            if (whichEl.id.indexOf("Child") != -1){
				 whichEl.visibility = "hide";
				 }
       }
        arrange();
    }
    else {
        divColl = document.all.tags("DIV");
        for (i=0; i<divColl.length; i++) {
            whichEl = divColl(i);
            if (whichEl.className == "child"){
				//isShow = whichEl.id.indexOf(strToShow);
				//if(isShow==-1&&strToShow!="")
					whichEl.style.display = "none";			
				//else if(isShow==0&&strToShow!="")
					//whichEl.style.display = "block";	
				}	
        }
    }
}

// 页面载入时，首先调用该函数，初始菜单状态为打开第一个导航
function initItOpen()
{
	initIt();
	KB1Child.style.display = "block";
}

// 控制左侧导航菜单显示
function expandIt(el) {
	if (!ver4) return;
    if (IE4) {
        whichEl = eval(el + "Child");
        if (whichEl.style.display == "none") {
            whichEl.style.display = "block";
        }
        else {
            whichEl.style.display = "none";
        }
    }
    else {
        whichEl = eval("document." + el + "Child");
        if (whichEl.visibility == "hide") {
            whichEl.visibility = "show";
        }
        else {
            whichEl.visibility = "hide";
        }
        arrange();
    }
}
  
// 控制头部导航菜单显示
function expandHead(el) {
	initIt();
	expandIt(el); 
}

// 改变头部导航菜单左侧图标样式
function changeState(el){
	var pic = new Array();
	pic = ['head1','head2','head3'];
	
	for(var i=0;i<pic.length;i++)
	{
		var whichPic = document.getElementById(pic[i]);
		whichPic.width = "5";
		whichPic.height = "7";
		whichPic.src = "/sinoyd/newImages/arrow.jpg";
	}
	
	el.width = "7";
	el.height = "5";
	el.src = "/sinoyd/newImages/arrow-convert.jpg";

}