function $(id) {
    return document.getElementById(id);
}

function showMenu (baseID, divID) {
    baseID = $(baseID);
    divID  = $(divID);
    if (showMenu.timer) clearTimeout(showMenu.timer);
	hideCur();
    divID.style.display = 'block';
	showMenu.cur = divID;

    if (! divID.isCreate) {
        divID.isCreate = true;
        //divID.timer = 0;
        divID.onmouseover = function () {
            if (showMenu.timer) clearTimeout(showMenu.timer);
			hideCur();
            divID.style.display = 'block';
        };

        function hide () {
            showMenu.timer = setTimeout(function () {divID.style.display = 'none';}, 400);
        }

        divID.onmouseout = hide;
        baseID.onmouseout = hide;
    }
	function hideCur () {
		showMenu.cur && (showMenu.cur.style.display = 'none');
	}
}


function searchBlur(obj){
    if(obj.value == ""){
        obj.value = "本站搜索：";        
        obj.style.color = "#cccccc";
    }
}

function searchFocus(obj){
    if(obj.value == "本站搜索："){        
        obj.value = "";
        obj.style.color = "#000000";
    }
}

function validateSearch(){
    var obj = $('searchKw');
    if(obj.value == '' || obj.value == '搜索：'){
        alert("请输入搜索的内容");
        obj.focus();
        return false;
    }
    return true;
}

function goSearch(){
    if(validateSearch())
    {
        var obj = $('searchKw');
        window.location.href='/search.aspx?kw=' + escape(obj.value);
    }
}

function checkLogin(){
    if($("tName").value.indexOf("'") != -1 || $("tPassword").value.indexOf("'") != -1){
        alert("登陆失败");
        return false;
    }
    else if ($("tName").value == "" ||  $("tPassword").value == ""){
        alert("请输入用户名和密码");
        return false;
    }
    return true;
}

function goReset()
{
    $("tName").value = "";
    $("tPassword").value = "";
}



function searchBlurSource(obj){
    if(obj.value == ""){
        obj.value = "输入教师姓名或者资源名：";        
        obj.style.color = "#cccccc";
    }
}

function searchFocusSource(obj){
    if(obj.value == "输入教师姓名或者资源名："){        
        obj.value = "";
        obj.style.color = "#000000";
    }
}

function validateSearchSource(){
    var obj = $('searchKw');
    if(obj.value == '' || obj.value == '输入教师姓名或者资源名：'){
        alert("请输入搜索的内容");
        obj.focus();
        return false;
    }
    return true;
}



function goSearchSource(){
    if(validateSearchSource())
    {
        var obj = $('searchKw');
        window.location.href='/sourceCenter.aspx?kw=' + escape(obj.value);
    }
}

function searchBlurDown(obj){
    if(obj.value == ""){
        obj.value = "输入材料名：";        
        obj.style.color = "#cccccc";
    }
}

function searchFocusDown(obj){
    if(obj.value == "输入材料名："){        
        obj.value = "";
        obj.style.color = "#000000";
    }
}

function validateSearchDown(){
    var obj = $('searchKw');
    if(obj.value == '' || obj.value == '输入材料名：'){
        alert("请输入搜索的内容");
        obj.focus();
        return false;
    }
    return true;
}

function goSearchDown(){
    if(validateSearchDown())
    {
        var obj = $('searchKw');
        window.location.href='/Down.aspx?kw=' + escape(obj.value);
    }
}



function goSearchStudent(){
    if(validateSearchSource())
    {
        var obj = $('searchKw');
        window.location.href='/Down.aspx?kw=' + escape(obj.value);
    }
}

function searchBlurStudent(obj){
    if(obj.value == ""){
        obj.value = "搜索：";        
        obj.style.color = "#336e9a";
    }
}

function searchFocusStudent(obj){
    if(obj.value == "搜索："){        
        obj.value = "";
        obj.style.color = "#000000";
    }
}

function validateSearchStudent(){
    var obj = $('searchKw');
    if(obj.value == '' || obj.value == '搜索：'){
        alert("请输入搜索的内容");
        obj.focus();
        return false;
    }
    return true;
}

function goSearchStudent(){
    if(validateSearchStudent())
    {
        var obj = $('searchKw');
        window.location.href='/student/search.aspx?kw=' + escape(obj.value);
    }
}

function XMLHTTPCreate()
{//创建XMLHTTP对象
        var xmlhttp = null;
        if (window.XMLHttpRequest) 
        {
            xmlhttp = new XMLHttpRequest();
            return xmlhttp;
        }
        else if (window.ActiveXObject) 
        {
            var version = ['MSXML2.XMLHTTP 6.0','MSXML2.XMLHTTP 3.0','MSXML2.XMLHTTP'];
            for(var i=0;i<version.length;i++)
            {
                try
                {
                    xmlhttp = new ActiveXObject(version[i]);
                    return xmlhttp;
                }
                catch(e){}
            }
        }
}

xmlhttp =XMLHTTPCreate();

function selectNotice()
{
    var selectType = $("sl_Notice").options[$("sl_Notice").selectedIndex].value;
    //alert(selectType);
    xmlhttp.open("get","notice.aspx?type="+selectType+"",true);
    xmlhttp.onreadystatechange = noticeChange;
    xmlhttp.send(null);
}

function noticeChange()
{
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
        //alert(xmlhttp.responseText);
        $("noticeContent").innerHTML = xmlhttp.responseText;
    }
}




var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf('msie')!=-1) && (agt.indexOf('opera')==-1));
var is_gecko= (navigator.product == "Gecko");
var is_ns = (document.layers);
var is_w3 = (document.getElementById && !is_ie);
var sch = 0;
var guides = {
        '考研服务':{
            '考研服务':{
                        'info_0' : ['硕士点简介','/Admissions/majorintr.aspx'],
                        'info_1' : ['招生流程','/Admissions/showList.aspx?typeid=270'],
                        'info_2':['成绩查询','/Admissions/showList.aspx?typeid=271'],
                        'info_3':['调剂信息','/Admissions/showList.aspx?typeid=272'],
                        'info_4':['录取名单','/Admissions/showList.aspx?typeid=273'],
                        'info_5':['历年招生资讯','/Admissions/showList.aspx?typeid=254'],
                        'info_6':['历年考题','/Admissions/showList.aspx?typeid=256'],        
                        'info_7':['考试大纲','/Admissions/showList.aspx?typeid=274']
                        }
                  },
          '规章制度':{
            '规章制度':{
                        'info_1' : ['招生制度','/info/showList.aspx?typeid=260'],
                        'info_2':['培养制度','/info/showList.aspx?typeid=262'],
                        'info_3':['学位制度','/info/showList.aspx?typeid=261'],
                        'info_4':['学科制度','/info/showList.aspx?typeid=269'],
                        'info_5':['学生制度','/info/showList.aspx?typeid=268']
                        }
                  },
          '表格下载':{
            '表格下载':{
                        'info_1' : ['招生表格','/info/showList.aspx?typeid=263'],
                        'info_2':['培养表格','/info/showList.aspx?typeid=265'],
                        'info_3':['学位表格','/info/showList.aspx?typeid=264'],
                        'info_4':['学科表格','/info/showList.aspx?typeid=267'],
                        'info_5':['学生表格','/info/showList.aspx?typeid=266']
                        }
                  }        
            }
//document.getElementById('mainright');
function showguide(id){
    if (showguide.timer) clearTimeout(showguide.timer);
	var obj = document.getElementById('showmenu');
	var guide = guides[id];
	var html  = '<dl>';
	for(i in guide){
		var subs = guide[i];
		html += '<dd>';
		for(j in subs){
			var sub = subs[j];
			html += '<a href="'+sub[1]+'">'+sub[0]+'</a>';
		}
		html += '</dd>';
	}
	obj.innerHTML = html + '</dl>';
	var obj1  = document.getElementById(id);
	var left  = findPosX(obj1) + getLeft();
	var top   = findPosY(obj1) + getTop() + 32;
	obj.style.display = "";
	obj.style.top	= top + 'px';
	obj.style.left	= left + 'px';
	addEvent(document,"mouseover",doc_mouseover);
	addEvent(document,"mouseout",doc_mouseout);
}
function closeguide(){
	var obj = document.getElementById('showmenu');
	obj.style.display = "none";
	removeEvent(document,"mouseout",doc_mouseout);
	removeEvent(document,"mouseover",doc_mouseover);
	
}
function upleft(t){
	var obj  = document.getElementById('left');
	var objli = obj.getElementsByTagName('li');
	var obja = obj.getElementsByTagName('a');
	for(var i=0;i<obja.length;i++){
		objli[i].className = obja[i].id==t ? 'one' : '';
	}
}
function showleft(id,t,url){
	cate = id;
	var obj = document.getElementById('left');
	
	var html = '';
	var guide = guides[id];
	url = typeof url != 'undefined' ? url : '';
	type = typeof t != 'undefined' ? t : '';

	for(i in guide){
		var subs = guide[i];
		html += '<h1>' + titles[i] + '</h1><div class="cc"></div><ul>';
		for(j in subs){
			var sub = subs[j];
			html += '<li><a id="'+j+'" href="#" onclick="return initguide(\''+id +'\',\''+j+'\')">'+sub[0]+'</a></li>';
			if(url==''){
				if(type == ''){
					url = sub[1];
					type = j;
				} else if(j == type){
					url = sub[1];
				}
				action = i;
			}
		}
		html += '</ul>';
		if (i=='diy') {
			html += '<h2 style="cursor:pointer" onclick="return initguide(\'common\',\'diy\')">常用功能定制</h2>';
		}
	}
	obj.innerHTML = html;
	upleft(type);
	if (is_ie && sch>0) sch = 0;
	parent.main.location = url;
	return false;
}
function showtitle(){
	var obj = document.getElementById('guide');
	var guide = guides[cate];
	var html = '';
	if (cate && action && type) {
		if (cate=='common') {
			html += '<div class="wei fl"><a href="/default.aspx">首页</a> &raquo; <a href="#" onclick="return initguide(cate,type,\'home/admin.aspx\')">'+titles[action]+'</a> &raquo; <a href="#">'+guide[action][type][0]+'</a></div>';
		} else {
			html += '<div class="wei fl"><a href="/default.aspx">首页</a> &raquo; <a href="#" onclick="return initguide(\''+cate+'\')">'+titles[action]+'</a> &raquo; <a href="#" onclick="return initguide(\''+cate+'\',\''+type+'\')">'+guide[action][type][0]+'</a></div>';
		}
	}
	html += '<ul class="fr"><li class="home">用户名：<%=olinfo.UserName %></li><li>级别：<%=olinfo.RoleName %></li><li><a class="s0" style="cursor:pointer" onclick="parent.main.location.reload();" title="刷新主页面">刷新</a></li><li><a class="s0" style="cursor:pointer" onclick="parent.main.history.go(-1);" title="后退到前一页">后退</a></li><li><a href="syslogin.aspx?Action=quit">注销</a></li></ul>';
//	if (is_ie || is_ns || is_w3 && agt.indexOf('opera')==-1) {
//		html += '<div class="value fr"><input type="text" class="input" id="schstring" onfocus="document.getElementById(\'schbt\').disabled = false;" onclick="this.select();" />&nbsp;<input class="btn" type="button" id="schbt" value="查找下一个" onclick="PwFindInPage();" /></div>';
//	}
	obj.innerHTML = html;
}
function initguide(id,t,url){
	//showleft(id,t,url);
	//showtitle();
	return false;
}

function toguide(id,t){
	closemenu();
	initguide(id,t);
	return false;
}

function doc_mouseover(e){
    var e = is_ie ? event: e;
	obj	= document.getElementById("showmenu");
	_x	= is_ie ? e.x : e.pageX;
	_y	= is_ie ? e.y + getTop() : e.pageY;
	_x1 = is_ie ?obj.offsetLeft-100:obj.offsetLeft;
	_x2 = obj.offsetLeft + obj.offsetWidth;
	_y1 = is_ie ?obj.offsetTop-130:obj.offsetTop - 20;
	_y2 = obj.offsetTop + obj.offsetHeight;

    //alert("over"+"_x"+_x+"_y"+_y+"_x1"+_x1+"_x2"+_x2+"_y1"+_y1+"_y2"+_y2);

	if(_x<_x1 || _x>_x2 || _y<_y1 || _y>_y2){
	   if (showguide.timer) clearTimeout(showguide.timer);
	}

}
function doc_mousedown(e){
	var e = is_ie ? event: e;
	obj	= document.getElementById("menu");
	_x	= is_ie ? e.x : e.pageX;
	_y	= is_ie ? e.y + getTop() : e.pageY;
	_x1 = is_ie ?obj.offsetLeft-100:obj.offsetLeft;
	_x2 = obj.offsetLeft + obj.offsetWidth;
	_y1 = is_ie ?obj.offsetTop-130:obj.offsetTop - 20;
	_y2 = obj.offsetTop + obj.offsetHeight;

	if(_x<_x1 || _x>_x2 || _y<_y1 || _y>_y2){
	   closemenu();
	}
}
function doc_mouseout(e){
	var e = is_ie ? event: e;
	obj	= document.getElementById("showmenu");
	_x	= is_ie ? e.x : e.pageX;
	_y	= is_ie ? e.y + getTop() : e.pageY;
	_x1 = is_ie ?obj.offsetLeft-100:obj.offsetLeft;
	_x2 = obj.offsetLeft + obj.offsetWidth;
	_y1 = is_ie ?obj.offsetTop-130:obj.offsetTop - 20;
	_y2 = obj.offsetTop + obj.offsetHeight;

	if(_x<_x1 || _x>_x2 || _y<_y1 || _y>_y2){
	    showMenu.timer = setTimeout(closeguide, 10);
		//closeguide();
	}
}
function IsElement(id){
	return document.getElementById(id)!=null ? true : false;
}
function addEvent(el,evname,func){
	if(is_ie){
		el.attachEvent("on" + evname,func);
	} else{
		el.addEventListener(evname,func,true);
	}
};
function removeEvent(el,evname,func){
	if(is_ie){
		el.detachEvent("on" + evname,func);
	} else{
		el.removeEventListener(evname,func,true);
	}
};
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft - getLeft();
}
function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y){
		curtop += obj.y;
	}
	return curtop - getTop();
}
function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
function getTop() {
	return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:ietruebody().scrollTop;
}
function getLeft() {
	return (typeof window.pageXOffset != 'undefined' ? window.pageXOffset:ietruebody().scrollLeft)
}
function keyCodes(id,e){
	if (e.keyCode==27) {
		if (IsElement(id) && document.getElementById(id).style.display=='') {
			closemenu();
		} else {
			try{
				showmenu();
			} catch(e){}
		}
	} else if (is_ie && (e.keyCode==116 || (e.ctrlKey && e.keyCode==82))) {
		e.keyCode = 0;
		e.returnValue = false;
		parent.main.location.reload();
	}
	return false;
}
function getPageHeight(){
	if (self.innerHeight) {
		return self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientHeight;
	} else if (document.body) {
		return document.body.clientHeight;
	}
}
//initguide(cate,type,'<%=url %>');