// JavaScript Document
	// This function is used for the Suckerfish (flyout) menus

sfHover = function() {
	try{
		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"), "");
			}
		}
	}catch(e){ }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



// menuExpandable.js - implements an expandable menu based on a HTML list
// Author: Dave Lindquist (http://www.gazingus.org)

if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeMenu(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (menu == null || actuator == null) return;

    //if (window.opera) return; // I'm too tired

   actuator.parentNode.style.background = "url(img/arrow-down-sm.gif) 90% 10px no-repeat";
    actuator.onclick = function() {
        var display = menu.style.display;
        this.parentNode.style.background =
            (display == "block") ? "url(img/arrow-down-sm.gif) 90% 10px no-repeat" : "url(img/arrow-up-sm.gif) 90% 10px no-repeat";
        menu.style.background = "url(/images/square.gif)";
        menu.style.display = (display == "block") ? "none" : "block";

        return false;
    }
}


// Preload images

function Preload() {
 	var args = simplePreload.arguments;
	document.imageArray = new Array(args.length);
	for(var i=0; i<args.length; i++) {
		document.imageArray[i] = new Image;
		document.imageArray[i].src = args[i];
	}
   }
//关闭局部窗口的JAVASCRIPT
function closeBar(id,obj_id){
var oBar = document.getElementById(id);
var displayStatus = document.getElementById(obj_id);
	if(oBar.style.display == "block")
	{
		oBar.style.display = "none";
		displayStatus.innerText = "展开此栏";
	}
	else
	{
		oBar.style.display = "block";
		displayStatus.innerText = "关闭此栏";
	}
}

// 刷新弹出窗口中的“mainframe”的src
function changeLocation(url,top_url,main_url){
var win = open(url,"","");
	document.getElementById("top_url").value = top_url;
	document.getElementById("main_url").value = main_url;
}

function searchButton(obj1_src,obj2_src,obj3_src){
var obj1 = document.getElementById("obj1");		// 当前选项
var obj2 = document.getElementById("Image1");
var obj3 = document.getElementById("obj3");

	obj1.src = obj1_src;	// 当前选项的链接
	obj2.src = obj2_src;
	obj3.src = obj3_src;
}

// 5秒后显示另外一个图层
var time;
function fiveSecondDisplayBar(LoadGroup_id,Group_id,LoadTags_id,Tags_id){
	if(status_group){
		LoadGroup_id.style.display = "none";
		Group_id.style.display = "block";
		clearInterval(time);
	}
	if(status_tags){
		LoadTags_id.style.display = "none";
		Tags_id.style.display = "block";
		clearInterval(time);
	}
}

function autoDisplayBar(LoadGroup_id,Group_id,LoadTags_id,Tags_id){
	time = setInterval("fiveSecondDisplayBar("+LoadGroup_id+","+Group_id+","+LoadTags_id+","+Tags_id+")",5000);
}

// 弹出定制窗口
function popWin(url,width,height){
var win = open(url,"","width="+width+",height="+height+",resizable=no");
}

// 增加资源
function addResource(id){
var resource = document.getElementById(id);
var divs = document.createElement("div");
var autoResource = document.createElement("input");		// 上传文件
var deleteButton = document.createElement("input");		// 删除按扭


	autoResource.type = "file";
	autoResource.style.width = "303px";
	autoResource.className = "InputStyle";

	deleteButton.type ="button";
	deleteButton.value ="删 除";
	deleteButton.style.color ="#C65700";

	divs.style.marginLeft = "68px";

	divs.appendChild(autoResource);
	divs.appendChild(deleteButton);
	resource.appendChild(divs);
}

// 鼠标放上时改变颜色
function changeBg(id,className){
var obj = document.getElementById(id);

	 obj.className = className;
}

// 用户注册页面中的选择信息级联功能
var gradeSchool = ["小学一年级","小学二年级","小学三年级","小学四年级","小学五年级","小学六年级","其他"];	// 小学
var juniorHighSchool = ["初中一年级","初中二年级","初中三年级","其他"];	// 初中
var highSchool = ["高中一年级","高中二年级","高中三年级","其他"];	// 高中
var reSchool = ["无年级"];	// 学前阶段
var education = ["专科","本科","研究生","其他"];	// 高等教育
var others = ["无年级"];		// 其他
var def = [""];
function autoChangeSelect(S_id){
var Sobj = document.getElementById(S_id);	// 学段
var Svalue = Sobj.options[Sobj.selectedIndex].value;
	//alert("Svalue" + Svalue);
	switch(Svalue){
		case "":	chioceSelect(def); break;
		case '101':	chioceSelect(reSchool); break;
		case '102':	chioceSelect(gradeSchool); break;
		case '103':	chioceSelect(juniorHighSchool); break;
		case '104':	chioceSelect(highSchool); break;
		case '105':	chioceSelect(education); break;
		case '106':	chioceSelect(others); break;
	}
}

function chioceSelect(obj){
var oSelect = document.getElementById("Grade");		// ????
var selectValue = document.getElementById("grades");

	oSelect.options.length = 0;
	for(var i = 0; i < obj.length; i++){
		var grade = new Option(obj[i],obj[i]);
		oSelect.options[oSelect.options.length] = grade;
	}
	selectValue.value = oSelect.options[oSelect.selectedIndex].value;
}

function load_XueDuan(S_id){
var Sobj = document.getElementById(S_id);	// 学段
	Sobj.options[0].selected = true;
}

/***** 在中国区搜索中调用 *****/
var hiddenDivs = ["Resource","Blog","Subject","News","Bookmark",
						  "User","WorkRoom","WorkGroup","School","Community"];
function $(id_hidden){
	var obj_hidden = document.getElementById(id_hidden);
	return obj_hidden;
}

var values = [];
var obj;
function getObject_block_load(){
var num = document.body.getElementsByTagName("div");
    for(var i = 0; i < num.length; i++){
      if(num[i].style.display == "block"){
        obj = num[i];
        break;
      }
    }
}
function init(){
    document.getElementById("grade").value = "";
    document.getElementById("study").value = "";
    document.getElementById("areacode").value = "";
    document.getElementById("resTypeCode").value = "";
}
function changeDivStyle(menu,ID){
var currentID = document.getElementById(ID);
    currentID.value = menu;
	if($(menu + "_hidden").style.display == "block"){
          return;
	}
        else{
           for(var i = 0; i < hiddenDivs.length; i++){
 		if(menu == hiddenDivs[i] && $(hiddenDivs[i]+"_hidden").style.display == "none"){
			$(hiddenDivs[i]).parentElement.style.color = "white";
			$(hiddenDivs[i]).parentElement.style.fontWeight = "bold";
			$(hiddenDivs[i]).parentElement.style.backgroundColor = "#9C352E";
			$(hiddenDivs[i]+"_hidden").style.display = "block";
                       obj = $(hiddenDivs[i]+"_hidden");
		}
		else{
			$(hiddenDivs[i]+"_hidden").style.display = "none";
			$(hiddenDivs[i]).parentElement.style.color = "#9C352E";
			$(hiddenDivs[i]).parentElement.style.fontWeight = "";
			$(hiddenDivs[i]).parentElement.style.backgroundColor = "";
		}
	    }
        }
}

function changeGrade(){
var selectValue = document.getElementById("grades");
var oSelect = document.getElementById("Grade");		// ????
	selectValue.value = oSelect.options[oSelect.selectedIndex].value;
	//alert(selectValue.value+" #####");

}

function changePage(pageId,statusSelect,roleSelect){
var page = document.getElementById("page");
var pre_next_Page = document.getElementById(pageId);
var currentPage = document.getElementById("currentPage");
var goPage = document.getElementById("goPage");

var oStatusSelect = document.getElementById(statusSelect);
var oRoleSelect = document.getElementById(roleSelect);

	if(pre_next_Page.innerText == "上一页" && page.innerText > 1){
		page.innerText--;
	}
	else if(pre_next_Page.innerText == "下一页"){
		page.innerText++;
	}
	else if(pre_next_Page.innerText == "首页"){
		page.innerText = 1;
	}
	else if(pre_next_Page.id == "go"){
		page.innerText = goPage.value;
	}
	currentPage.value = page.innerText;

	document.usermanage.submit();
}


