var mmenus=new Array();
var misShow=new Boolean(); 
misShow=false;
var misdown=new Boolean();
misdown=false;
var musestatus=false;
var mpopTimer=0;

mmenucolor='#FFC763'; //菜单背景/项目单元格颜色
mfontcolor='#000000'; //子菜单文字颜色
mMainfontcolor='#000000'; //主菜单文字颜色
mmenuoutcolor='#ffffff'; //菜单移出颜色
mmenuincolor='#FFEACC'; //菜单移入颜色
mmenuoutbordercolor='#F45921'; //菜单亮边框颜色
mmenuinbordercolor='#F45921'; //菜单暗边框颜色
mmidoutcolor='#F45921'; //子菜单亮边框颜色
mmidincolor='#F45921'; //子菜单暗边框颜色
mmenuovercolor='#000000'; //鼠标在子菜单悬停时的文字颜色
mMainmenuovercolor='#000000'; //鼠标在主菜单悬停时的文字颜色
mitemedge='0'; //主菜单项目单元格边框宽度
msubedge='1'; //子菜单项目单元格边框宽度
mmenuunitwidth=100; //菜单单元格宽度
mmenuitemwidth=85; //子菜单表格宽度
mmenuheight=30; //菜单表格高度（最小高度由系统根据文字大小、间距、边距自动计算得出）
mmenuwidth='100%'; //菜单表格宽度
mmenuadjust=0; //子菜单水平位置偏移
mmenuadjustV=0; //子菜单竖直位置偏移
mfonts='font-size: 16px; color: #ff0000; '; //子菜单文字样式
mMainfonts='font-size: 5px; color: #ffffff;font-weight:bold;font-family: "宋体"; '; //主菜单文字样式
mcursor='hand'; //菜单鼠标模式
mmenupadding=0; //菜单对齐表格边距
mmenuspacing=0; //菜单对齐表格间距
mmenubgimg='/img/cbj.jpg'; //主菜单背景图片，当设置主菜单背景图片时，原主菜单编筐、背景色自动失效

//清除错误信息
function stoperror() {
	return true;
}
window.onerror=stoperror;

//设置菜单延迟关闭时间
function mpopOut() {
	mpopTimer = setTimeout('mallhide()', 500);
}

//获取符合指定要求的上一级对象引用
function getReal(el, type, value) {
	temp = el;
	while ((temp != null) && (temp.tagName != "BODY")) {
		if (eval("temp." + type) == value) {
			el = temp;
			return el;
		}
		temp = temp.parentElement;
	}
	return el;
}

//动态调整菜单项目数组，被mMenu调用
function mMenuRegister(menu) {
	mmenus[mmenus.length] = menu
	return (mmenus.length - 1)
}

//菜单项目对象（标题，命令，框架目标，是否为分割线，状态栏文本，图标，X方向尺寸，Y方向尺寸，背景图模式）
function mMenuItem(caption,command,target,isline,statustxt,img,sizex,sizey,pos){
	this.caption=caption;
	this.command=command;
	this.target=target;
	this.isline=isline;
	this.statustxt=statustxt;
	this.img=img;
	this.sizex=sizex;
	this.sizey=sizey;
	this.pos=pos;
}

//菜单对象（标题，命令，框架目标，图标，X方向尺寸，Y方向尺寸，背景图模式）
function mMenu(caption,command,target,img,sizex,sizey,pos){
	this.items = new Array();
	this.caption=caption;
	this.command=command;
	this.target=target;
	this.img=img;
	this.sizex=sizex;
	this.sizey=sizey;
	this.pos=pos;
	this.id=mMenuRegister(this);
}

//增加菜单项目
function mMenuAddItem(item) {
	this.items[this.items.length] = item
	item.parent = this.id;
	this.children=true;
}

//设置mMenu对象的addItem方法
mMenu.prototype.addItem = mMenuAddItem;

//设置菜单鼠标移出后的样式
function mtoout(src) {
	src.style.borderLeftColor=mmenuoutbordercolor;
	src.style.borderRightColor=mmenuinbordercolor;
	src.style.borderTopColor=mmenuoutbordercolor;
	src.style.borderBottomColor=mmenuinbordercolor;
	src.style.backgroundColor=mmenuoutcolor;
	if (src.width==mmenuunitwidth) {
		src.style.color=mMainmenuovercolor;
	}
	else {
		src.style.color=mmenuovercolor;
	}
}

//设置菜单被点亮（鼠标移入）后的样式
function mtoin(src) {
	src.style.borderLeftColor=mmenuinbordercolor;
	src.style.borderRightColor=mmenuoutbordercolor;
	src.style.borderTopColor=mmenuinbordercolor;
	src.style.borderBottomColor=mmenuoutbordercolor;
	src.style.backgroundColor=mmenuincolor;
	if (src.width==mmenuunitwidth) {
		src.style.color=mMainmenuovercolor;
	}
	else {
		src.style.color=mmenuovercolor;
	}
}

//恢复菜单默认样式
function mnochange(src) {
	src.style.borderLeftColor=mmenucolor;
	src.style.borderRightColor=mmenucolor;
	src.style.borderTopColor=mmenucolor;
	src.style.borderBottomColor=mmenucolor;
	src.style.backgroundColor='';
	if (src.width==mmenuunitwidth) {
		src.style.color=mMainfontcolor;
	}
	else {
		src.style.color=mfontcolor;
	}
}

//关闭所有菜单
function mallhide() {
	for(var nummenu=0;nummenu<mmenus.length;nummenu++) {
		var themenu=document.all['mMenu'+nummenu]
		var themenudiv=document.all['mmenudiv'+nummenu]
		mnochange(themenu);
		mmenuhide(themenudiv);
	}
}

//隐藏子菜单层
function mmenuhide(menuid) {
	menuid.style.visibility='hidden';
	misShow=false;
}

//显示指定子菜单
function mmenushow(menuid,pid) {
	menuid.style.left=mposflag.offsetLeft+pid.offsetLeft+mmenuadjust;
	menuid.style.top=mposflag.offsetTop+mmenutable.offsetHeight+mmenuadjustV;
	if(mmenuitemwidth+parseInt(menuid.style.left)>document.body.clientWidth+document.body.scrollLeft) menuid.style.left=document.body.clientWidth+document.body.scrollLeft-mmenuitemwidth;
	menuid.style.visibility='visible';
	misShow=true;
}

//改变鼠标在菜单上的项目位置
function mmenu_over(menuid,x) {
	toel = getReal(window.event.toElement, "className", "coolButton");
	fromel = getReal(window.event.fromElement, "className", "coolButton");
	if (toel == fromel) return;
	if(x==0) {
		misShow = false;
		mallhide();
		mtoout(eval("mMenu"+x));
	}
	else{
		mallhide();
		mtoin(eval("mMenu"+x));
		mmenushow(menuid,eval("mMenu"+x));
	}
	clearTimeout(mpopTimer);
}

//鼠标移出菜单
function mmenu_out(x) {
	toel = getReal(window.event.toElement, "className", "coolButton");
	fromel = getReal(window.event.fromElement, "className", "coolButton");
	if (toel == fromel) return;
	if (misShow){
		mtoin(eval("mMenu"+x));
	}
	else{
		mnochange(eval("mMenu"+x));
	}
	mpopOut();
}

//在菜单上按下鼠标
function mmenu_down(menuid,x) {
	if(misShow){
		mmenuhide(menuid);
		mtoout(eval("mMenu"+x));
	}
	else{
		mtoin(eval("mMenu"+x));
		mmenushow(menuid,eval("mMenu"+x));
		misdown=true;
	}
}

//在菜单上抬起鼠标
function mmenu_up() {
	misdown=false;
}

//鼠标指向某菜单项目
function mmenuitem_over(x,i){
	srcel = getReal(window.event.srcElement, "className", "coolButton");
	if(misdown){
		mtoin(srcel);
	}
	else {
		mtoout(srcel);
	}
	mthestatus = mmenus[x].items[i].statustxt;
	if(mthestatus!=""){
		musestatus=true;
		window.status=mthestatus;
	}
	clearTimeout(mpopTimer);
}

//鼠标从菜单项目移开
function mmenuitem_out(){
	srcel = getReal(window.event.srcElement, "className", "coolButton");
	mnochange(srcel);
	if(musestatus)window.status="";
	mpopOut()
}

//鼠标在菜单项目上被按下
function mmenuitem_down(){
	srcel = getReal(window.event.srcElement, "className", "coolButton");
	mtoin(srcel)
	misdown=true;
}

//鼠标在菜单项目上被抬起
function mmenuitem_up(){
	srcel = getReal(window.event.srcElement, "className", "coolButton");
	mtoout(srcel)
	misdown=false;
}

//执行菜单命令（跳转到对应的网址）
function mexec2(x){
	var cmd;
	if(mmenus[x].target=="blank"){
		cmd = "window.open('"+mmenus[x].command+"')";
	}
	else{
		cmd = mmenus[x].target+".location=\""+mmenus[x].command+"\"";
	}
	eval(cmd);
}

//执行菜单项目命令（跳转到对应的网址）
function mexec(x,i){
	var cmd;
	if(mmenus[x].items[i].target=="blank"){
		cmd = "window.open('"+mmenus[x].items[i].command+"')";
	}else{
		cmd = mmenus[x].items[i].target+".location=\""+mmenus[x].items[i].command+"\"";
	}
	eval(cmd);
}

//鼠标单击后检测是否需要关闭菜单
function mbody_click(){
	if (misShow){
		srcel = getReal(window.event.srcElement, "className", "coolButton");
		for(var x=0;x<=mmenus.length;x++){
			if(srcel.id=="mMenu"+x)
			return;
		}
		mallhide();
	}
}

document.onclick=mbody_click;

//将菜单数据转换为HTML语句输出
function mwritetodocument() {
	var mwb=1; //菜单边框宽度
	
	//输出主菜单开始
	var stringx='<div id="mposflag" style="position:absolute;"></div>'+
	'<table id=mmenutable border=0 cellpadding='+mmenupadding+' cellspacing='+mmenuspacing+
	' width='+mmenuwidth+' height='+mmenuheight+
	' onselectstart="event.returnValue=false"'
	if (mmenubgimg=='') {
		stringx += ' bgcolor='+mmenucolor+' style="cursor:'+mcursor+';'+mfonts+
		' border-left: '+mwb+'px solid '+mmenuoutbordercolor+';'+
		' border-right: '+mwb+'px solid '+mmenuinbordercolor+';'+
		' border-top: '+mwb+'px solid '+mmenuoutbordercolor+';'+
		' border-bottom: '+mwb+'px solid '+mmenuinbordercolor+';'+
		' padding:0px"><tr>'
	}
	else {
		stringx += ' background="'+mmenubgimg+'"; border=0; style="cursor:'+mcursor+';'+mMainfonts+' padding:0px"><tr>'
	}
	//输出主菜单项目
	for(var x=0;x<mmenus.length;x++) {
		var thismenu=mmenus[x];
		var imgsize="";
		if (thismenu.sizex!="0"||thismenu.sizey!="0") imgsize=" width="+thismenu.sizex+" height="+thismenu.sizey;
		var ifspace="";
		if (thismenu.caption!="") ifspace="&nbsp;";
		stringx += "<td nowrap class=coolButton id=mMenu"+x+" style='border: "+mitemedge+"px solid "+mmenucolor+"' width="+mmenuunitwidth+
		"px onmouseover=mmenu_over(mmenudiv"+x+","+x+") onmouseout=mmenu_out("+x+") onmousedown=mmenu_down(mmenudiv"+x+","+x+")";
		//判断菜单项目是否对应超链接
		if(thismenu.command!=""){
			stringx += " onmouseup=mmenu_up();mexec2("+x+");";
		}
		else{
			stringx += " onmouseup=mmenu_up()";
		}
		//判断菜单图标模式：0在左侧；1在右侧；2为背景图；其他为没有图标
		if(thismenu.pos=="0"){
			stringx += " align=center><img align=absmiddle src='"+thismenu.img+"'"+imgsize+">"+ifspace+thismenu.caption+"</td>";	
		}
		else if(thismenu.pos=="1"){
			stringx += " align=center>"+thismenu.caption+ifspace+"<img align=absmiddle src='"+thismenu.img+"'"+imgsize+"></td>";	
		}
		else if(thismenu.pos=="2"){
			stringx += " align=center background='"+thismenu.img+"'>&nbsp;"+thismenu.caption+"&nbsp;</td>";	
		}
		else{
			stringx += " align=center>&nbsp;"+thismenu.caption+"&nbsp;</td>";
		}
		stringx += "";
	}
	//菜单最右端扩展功能预留接口
	stringx+="<td width=*>&nbsp;</td>";
	stringx+="</tr></table>";
	//输出主菜单结束
	
	//输出子菜单开始
	for(var x=0;x<mmenus.length;x++){
		thismenu=mmenus[x];
		if(x==0){
			stringx+='<div id=mmenudiv'+x+' style="visiable:none"></div>';
		}
		else{
			stringx+='<div id=mmenudiv'+x+
			' style="cursor:'+mcursor+';position:absolute;'+
			' width:'+mmenuitemwidth+'px; z-index:'+(x+100);
			if(mmenuinbordercolor!=mmenuoutbordercolor&&msubedge=="0"){
				stringx+=';border-left: 1px solid '+mmidoutcolor+';border-top: 1px solid '+mmidoutcolor;
			}
			stringx+=';border-right: 1px solid '+mmenuinbordercolor+';border-bottom: 1px solid '+mmenuinbordercolor+
			';visibility:hidden" onselectstart="event.returnValue=false">\n'+
			'<table  width="100%" border="0" height="100%" align="center" cellpadding="0" cellspacing="2" '+
			'style="'+mfonts+' border-left: 1px solid '+mmenuoutbordercolor;
			if(mmenuinbordercolor!=mmenuoutbordercolor&&msubedge=="0"){
				stringx+=';border-right: 1px solid '+mmidincolor+';border-bottom: 1px solid '+mmidincolor;
			}
			stringx+=';border-top: 1px solid '+mmenuoutbordercolor+';padding: 4px" bgcolor='+mmenucolor+'>\n'
			//输出子菜单项目
			for(var i=0;i<thismenu.items.length;i++) {
				var thismenuitem=thismenu.items[i];
				var imgsize="";
				if (thismenuitem.sizex!="0"||thismenuitem.sizey!="0") imgsize=" width="+thismenuitem.sizex+" height="+thismenuitem.sizey;
				var ifspace="";
				if (thismenu.caption!="") ifspace="&nbsp;";
				if (!thismenuitem.isline) {
					stringx += "<tr><td class=coolButton style='border: "+mitemedge+"px solid "+mmenucolor+
					"' width=100% height=15px onmouseover=\"mmenuitem_over("+x+","+i+
					");\" onmouseout=mmenuitem_out(); onmousedown=mmenuitem_down(); onmouseup=";
					stringx += "mmenuitem_up();mexec("+x+","+i+"); ";
					if(thismenuitem.pos=="0"){
						stringx += "><img align=absmiddle src='"+thismenuitem.img+"'"+imgsize+">"+ifspace+thismenuitem.caption+"</td></tr>";	
					}
					else if(thismenuitem.pos=="1"){
						stringx += ">"+thismenuitem.caption+ifspace+"<img align=absmiddle src='"+thismenuitem.img+"'"+imgsize+"></td></tr>";	
					}
					else if(thismenuitem.pos=="2"){
						stringx += "background='"+thismenuitem.img+"'>"+thismenuitem.caption+"</td></tr>";	
					}
					else{
						stringx += ">"+thismenuitem.caption+"</td></tr>";
					}
				}
				else{
					stringx+='<tr><td height="1" background="hr.gif" onmousemove="clearTimeout(mpopTimer);"><img height="1" width="1" src="none.gif" border="0"></td></tr>\n';
				}
			}
			stringx+='</table>\n</div>'
		}
		
	}
	//子菜单输出完毕
	
	//正式显示菜单
	document.write("<div align='center'>"+stringx+"</div>");
}

//手工创建菜单
mpmenu1=new mMenu(' 首 &nbsp;页│','../index.asp','self','','','','');
mpmenu2=new mMenu('校院概览│','','self','','','','');
mpmenu2.addItem(new mMenuItem('校院简介','../gailan/jianjie.asp','self','','','',''));
mpmenu2.addItem(new mMenuItem('现任领导','../gailan/lingdao.asp','self','','','',''));
mpmenu2.addItem(new mMenuItem('机构设置','../gailan/jigou.asp','self','','','',''));
mpmenu3=new mMenu('教学科研│','../view.asp?id=131','self','','','','');
mpmenu3.addItem(new mMenuItem('教学动态','../list.asp?id=132','self','','','',''));
mpmenu3.addItem(new mMenuItem('培训动态','../list.asp?id=133','self','','','',''));
mpmenu3.addItem(new mMenuItem('科研动态','../list.asp?id=134','self','','','',''));
mpmenu3.addItem(new mMenuItem('主体班课程','../list.asp?id=156','self','','','',''));
mpmenu4=new mMenu('行政后勤│','../view.asp?id=149','self','','','','');
mpmenu4.addItem(new mMenuItem('规章制度','../list.asp?id=151','self','','','',''));
mpmenu4.addItem(new mMenuItem('工作动态','../list.asp?id=152','self','','','',''));

mpmenu5=new mMenu('函授教育│','../view1.asp?id=115','self','','','','');
mpmenu5.addItem(new mMenuItem('函授通知','../list.asp?id=116','self','','','',''));
mpmenu5.addItem(new mMenuItem('函授动态','../list.asp?id=117','self','','','',''));
mpmenu5.addItem(new mMenuItem('函授课表','../list.asp?id=124','self','','','',''));
mpmenu5.addItem(new mMenuItem('招生信息','../list.asp?id=118','self','','','',''));
mpmenu5.addItem(new mMenuItem('考试成绩','../list.asp?id=120','self','','','',''));
mpmenu5.addItem(new mMenuItem('政策咨询','../list.asp?id=121','self','','','',''));
mpmenu6=new mMenu('党建园地│','../view.asp?id=150','self','','','','');
mpmenu6.addItem(new mMenuItem('工作动态','../list.asp?id=153','self','','','',''));
mpmenu6.addItem(new mMenuItem('党建博览','../list.asp?id=154','self','','','',''));
mpmenu6.addItem(new mMenuItem('党风廉政','../list.asp?id=155','self','','','',''));
mpmenu7=new mMenu('校内文件│','../view.asp?id=142','self','','','','');

mpmenu8=new mMenu('五五普法│','../view.asp?id=171','self','','','','');
mpmenu8.addItem(new mMenuItem('相关文件','../list.asp?id=172','self','','','',''));
mpmenu8.addItem(new mMenuItem('普法活动','../list.asp?id=173','self','','','',''));
mpmenu8.addItem(new mMenuItem('普法知识','../list.asp?id=174','self','','','',''));

mwritetodocument();



