﻿ sfHover = function() {
var sfEls = document.getElementById("nav").getElementsByTagName("li");
for (var i=0; i<sfEls.length; i++) {
	sfEls[i].onmouseover=function() {
		this.className+=" sfhover";
	}
	sfEls[i].onmouseout=function() {
		this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
	    }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function addLoadEvent(func){
	var oldonload = window.onload;
	if(typeof window.onload !='function'){
		//alert("execute here 1254ADD");
		window.onload = func;
	}else{
		window.onload = function(){
			oldonload();
			func();
		}
	}
} 


var curIndex = -1;	// 
var iOnePage = 10 ; // 每一页显示的条数
function setSubTitle()
{

	// 文件地址
	var oUl = document.getElementById("breadcrumbs").childNodes[0];

	var str = "";
	for(var i = 0 ; i<midtitle.length  ; i++)
	{
		var s = "<li><a "+ ( (i==0)?   "class=\"first\"" : ""  )+" href=\""+midlinks[i]+"\">"+midtitle[i]+"</a></li>";
		str += s;
	}

	oUl.innerHTML = str;
	// 本栏
	var oDiv = document.getElementById("subTitleDiv");
	oDiv.getElementsByTagName("h3")[0].innerHTML = title;

	str = "";
	var bbold = true;
	if( curIndex< 1 ||   curIndex > subtitle.length) 
	{
		curIndex = 1;
		bbold = false;
	}
	var iCurPage = Math.ceil(  curIndex / iOnePage ) ; // 根据标题,计算出该打印第向页的内容

	for(var i = 10*(iCurPage-1) ; i < 10 * iCurPage ; i++ )
	{
		if( i>=  subtitle.length) break;
		var s1 = subtitle[i];
		if ( bbold &&  curIndex == (i+1) )
		{
			s1 = "<b>" + subtitle[i] + "</b>";
		}
		var s = "<ul><li style='font-size:12px;'>"+(i+1)+":<a class=\"special\" href=\""+sublinks[i]+"\">"+ s1 +"</a></li></ul>";
		str += s;
	}
	oDiv.childNodes[1].innerHTML = str;
	oDiv.innerTHML = "<h3>"+title+"</h3><ul>"+str+"</ul>";
	//alert(oDiv.innerTHML);

	if(!bbold)  curIndex = -1;
	if(subtitle.length <=10) return;

	// 当栏目多于10 个时,显示导航栏 <div id="tilNav" curPage="1"></div>
	oDiv = document.getElementById("tilNav");

	if(oDiv == null)
	{
		//alert("该页缺少\ntilNav\n元素,请补充!");
		oDiv = document.createElement ("div");
		oDiv.setAttribute("id" ,"tilNav");
		oDiv.setAttribute("curPage",iCurPage);
		//oDiv.style.textAlign = 'center';
		document.getElementById("subTitleDiv").appendChild(oDiv);
	}

	oDiv.setAttribute("curPage","1"); // 当前显示第一页

	var iCount = Math.ceil(  subtitle.length / 10  ) ;
	str = "";
	str += "<a href='javascript:void(0)' onclick='GoSomePage(\"-\")'>-</a>&nbsp;";
	for(var i = 1 ; i<=iCount ; i++  )
	{
		var b = curIndex <= i*10  & curIndex > (i-1) * 10;
		var s = "<a href='javascript:void(0)' onclick='GoSomePage(\""+i+"\")'>"+((b)? "<b><u>":"")+i+((b)? "</u></b>":"")+"</a>&nbsp;";
		str += s;
	}
	str += "&nbsp;<a href='javascript:void(0)' onclick='GoSomePage(\"+\")'>+</a>";
	oDiv.innerHTML = str;
}
// 分页导航显示
function GoSomePage(str)
{
	var oDiv		= document.getElementById("tilNav");
	var iCurPage	= parseInt( oDiv.getAttribute("curPage") );

	if (str =="-")
	{
		if ( iCurPage ==1)
		{
			return;
		}else 
		{
			iCurPage--;
		}
	}else if (str == "+")
	{
		if ( iCurPage ==  pageCount  )
		{
			return;
		}else
		{
			iCurPage++;
		}
	}else
	{
		iCurPage = parseInt( str );
	}

	oDiv.setAttribute("curPage",iCurPage) ;

	//alert(iCurPage);
	//alert(iCurPage); 重新打印子栏日
	str = "";
	for(var i = 10*(iCurPage-1) ; i < 10 * iCurPage ; i++ )
	{
		if( i>=  subtitle.length) break;

		var s1 = subtitle[i];
		if (  curIndex == (i+1) )
		{
			s1 = "<b>" + subtitle[i] + "</b>";
		}
		var s = "<ul><li style='font-size:12px;'>"+(i+1)+":<a class=\"special\" href=\""+sublinks[i]+"\">"+s1+"</a></li></ul>";
		str += s;
	}
	oDiv = document.getElementById("subTitleDiv");
	oDiv.childNodes[1].innerHTML = str;
}



  function xianshi(){
document.getElementById("box").style.display="block"; 
  }
  function xiaoshi(){
document.getElementById("box").style.display="none"; 
  }



function secBoard(elementID,listName,n) {
var elem = document.getElementById(elementID);
var elemlist = elem.getElementsByTagName("span");
for (var i=0; i<elemlist.length; i++) {
elemlist[i].className = "normal";
var m = i+1;
document.getElementById(listName+"_"+m).className = "normal";
}
elemlist[n-1].className = "current";
document.getElementById(listName+"_"+n).className = "current";
}


