//author: sunceenjoy 
//date	: 2006-09-30
//warnning: just for ie&firefox
window.onerror	= function(){return true;}
function Menu(){
		_this	= this;
	_this.tobeclean		= null;_this.HtmlStr = "";_this.stat = false;_this.main = Array();_this.son = Array();_this.selfheight = 14;
	_this.width			= 640;			//菜单占用的总宽度
	_this.pad			= 1;  			//各主题的间距
	_this.subLeftAdd	= 0;			//子菜单位左右置微调 
	_this.subRightAdd	= 0;
	if(document.all)_this.subRightAdd	= 18;			//子菜单位上下置微调 
	_this.subWidth		= 2;			//子菜单自身宽度微调  
	_this.color1		= "#525252";	//初始菜单颜色
	_this.color2		= "black";		//鼠标经过菜单颜色
	_this.align			= "center";		//菜单排列方位 value:left、center、right
	_this.time			= 300;			//子菜单隐藏延迟时间(毫秒)



	_this.main[0]			= '<a href="index.php" title="首页">首页</a>';	//主菜单的内容
	_this.main[1]			= '<a href="#" title="了解起点">了解起点</a>' ;
	_this.main[2]			= '<a href="#" title="了解起点">课程安排</a>' ;
	_this.main[3]			= '<a href="#" title="了解起点">作品展示</a>' ;
	_this.main[4]			= '<a href="qd_team.php" title="起点团队">起点团队</a>';
	_this.main[5]			= '<a href="class_news.php" title="起点教程">起点教程</a>';
	_this.main[6]			= '<a href="#" title="了解起点">就业指导</a>' ;
	_this.main[7]			= '<a href="#" title="了解起点">联系我们</a>' ;
	_this.main[8]			= '<a href="http://ad.nihaocg.com/index.php?cateid=73" title="学员社区" target="_blank">学员社区</a>';

	_this.howmany		= _this.main.length;
	_this.sonwidth	= (_this.width/_this.howmany)-_this.pad*2-4+_this.subWidth;
	for(t=0;t<_this.howmany;t++)eval("_this.son["+t+"]= Array();");


	_this.son[1][0]		= '<a href="news_more.php" title="起点资讯"><span style="color:#F5DA1B">起点资讯</span></a>';
	_this.son[1][1]		= '<a href="about_us.php?type=jxll" title="教学理念">教学理念</a>';
	_this.son[1][2]		= '<a href="about_us.php?type=jxhj" title="教学环境">教学环境</a>';
	_this.son[1][3]		= '<a href="about_us.php?type=zszz" title="证书资质">证书资质</a>';

	_this.son[2][0]		= '<a href="http://www.cgbegin.com/cgbegin_maya.php">MAYA影视动画</a>';
	_this.son[2][1]		= '<a href="http://www.cgbegin.com/view_study.php?id=28">次世代游戏美术</a>';
	_this.son[2][2]		= '<a href="http://www.cgbegin.com/cgbegin_game.php">游戏角色动画</a>';
	_this.son[2][3]		= '<a href="http://www.cgbegin.com/view_study.php?id=29">CG动画专项</a>';
	_this.son[2][4]		= '<a href="http://www.cgbegin.com/view_study.php?id=32">原画美术设计</a>';
	_this.son[2][5]		= '<a href="http://www.cgbegin.com/cgbegin_work.php">CG再就业班</a>';
	_this.son[2][6]		= '<a href="http://www.cgbegin.com/view_study.php?id=30">CG基础班</a>';

	_this.son[3][0]		= '<a href="cgbegin_yc.php" title="原创天地"><span style="color:#F5DA1B">原创天地</span></a>';
	_this.son[3][1]		= '<a href="view_opus.php?type=teacher" title="老师作品">老师作品</a>';
	_this.son[3][2]		= '<a href="opus_list.php?sort=2" title="学生作品">学生作品</a>';
	_this.son[3][3]		= '<a href="view_opus.php?type=video" title="视频作品">视频作品</a>';

	_this.son[6][0]		= '<a href="cgbegin_jydc.php" title=""><span style="color:#F5DA1B">就业明星</span></a>';
	_this.son[6][1]		= '<a href="about_us.php?type=qdcl" title="">起点承诺</a>';
	_this.son[6][2]		= '<a href="about_us.php?type=qdqfw" title="">学员展台</a>';
	_this.son[6][3]		= '<a href="link.php?type=qdmx" title="合作企业">就业企业</a>';

	_this.son[7][0]		= '<a href="about_us.php?type=lxfs" title="">联系方式</a>';
	_this.son[7][1]		= '<a href="about_us.php?type=sstj" title="">食宿条件</a>';
	_this.son[7][2]		= '<a href="about_us.php?type=yhzc" title="">优惠政策</a>';
	_this.son[7][3]		= '<a href="sign_up.php" title="">在线报名</a>';

	_this.son[8][0]		= '<a href="http://blog.cgbegin.com/" title="" target="_blank">官方博客</a>';
	_this.son[8][1]		= '<a href="http://ad.nihaocg.com/index.php?cateid=73" title="" target="_blank">官方论坛</a>';

	this.show	= function(){
		_this.HtmlStr	= "<div id=\"mm\" align=\""+_this.align+"\">\n";
		_this.HtmlStr+= "<table  width="+_this.width+" >\n";
		_this.HtmlStr+= "<tr>\n";
		every	= "";
		for(i=0;i<_this.howmany;i++){
			every	= _this.main[i];
			id		= "id=\"bbs"+i+"\" style=\"cursor:hand;\"    onmouseover=\"_this.stat=true;this.style.backgroundColor='"+_this.color2+"';mymenu.showon("+i+");\" onmouseout=\"mymenu.showoff("+i+");this.style.backgroundColor='"+_this.color1+"';_this.stat=false;\" ";
			_this.HtmlStr+= "<td width=\""+_this.sonwidth+"\" id=ks"+i+" align=center style=\"font-size:16px;color:white;padding-right :"+_this.pad+"px;padding-left:"+_this.pad+"px\">\n<div "+id+">"+every+"</div>\n</td>\n";
		}
		_this.HtmlStr	+= "</tr>\n<tr>\n";
		for(i=0;i<_this.howmany;i++){
			sun	= addItems(i);
			_this.HtmlStr +="<td>"+sun+"</td>\n";
		}
		_this.HtmlStr	+= "</tr>\n</table>\n";
		_this.HtmlStr += "</div>\n";
		document.write(_this.HtmlStr);
		_this.selfheight	= document.getElementById("ks0").offsetHeight-2 ;
	}
	function addItems(id){
		inhtml	= gethtml(id);
		html="<div id=\"shows"+id+"\"  style=\"position:absolute;width:"+_this.sonwidth+"px;display:;z-index:1;left=0px;top=0px;\">"+inhtml+"</div>\n";
		return html;
	}
	function gethtml(id){
		len	= _this.son[id].length;
		out	= "<table class='cpt-2' border='0' bgcolor="+_this.color1+" id=son"+id+" onmouseover=\"mymenu.cshowon("+i+");\" onmouseout=\"mymenu.showoff("+i+")\" width=100%  border=1 style=\"border-collapse:collapse;display:none;cursor:hand;\">\n";
		for(j=0;j<len;j++)
			out+="<tr class='cpt-1'>\n<td class='cpt-2' onmouseover=\"this.style.backgroundColor='"+_this.color2+"';\" onmouseout=\"_this.stat=false;this.style.backgroundColor='"+_this.color1+"'\" align=\"left\" nowrap=\"nowrap\"> &nbsp;"+_this.son[id][j]+"</td>\n</tr>\n";
		out+="</table>\n";
		return out;
	}
	this.showon	= function(id){
		try{
			_this.obj.style.display	= "none";
			var it	= _this.obj.id.replace(/son/,'');
			if(id!=it){
				document.getElementById("bbs"+it).style.backgroundColor="";
			}
		}catch(e){}
		_this.stat	= true;
		_this.obj	= eval("son"+id);
		theLeft	= totalSum("bbs"+id,"offsetLeft");
		theTop	= totalSum("bbs"+id,"offsetTop");
		objs	= eval("shows"+id);
		objs.style.left	= theLeft+_this.subLeftAdd;
		objs.style.top	= theTop+_this.subRightAdd+_this.selfheight;
		_this.obj.style.display="";

	}
	 this.cshowon = function(id){
		 clearTimeout(_this.handle);
		_this.stat	= true;
		_this.obj	= eval("son"+id);
		_this.obj.t	= id;
		clearTimeout(_this.tobeclean);
		_this.obj.style.display="";
	}
	this.showoff = function (id){
		so	= document.getElementById("son"+id);
		_this.tobeclean	= setTimeout('if(!_this.stat){so.style.display="none";document.getElementById("bbs'+id+'").style.backgroundColor="";}',_this.time);
	}
	function totalSum(idItem, offsetName){
		var totalOffset = 0;
		var item = eval(idItem);
		do{
			totalOffset += eval('item.'+offsetName);
			item = eval('item.offsetParent');
		} while (item != null);
		return totalOffset;
	}
	document.onclick	= function(){
		if(typeof(_this.obj)=="object"){
			_this.obj.style.display	= 'none';
			var it	= _this.obj.id.replace(/son/,'');
			document.getElementById("bbs"+it).style.backgroundColor="";
		}
	}
}