/*显示菜单*/
function turnit(n)
{
	if (getObject("bb"+n).style.visibility == "hidden") {
		getObject("bb"+n).style.visibility="visible"
			if (n==1) {
				var tmp = getObject('menutxt'+n).value
					menulogin(tmp)
			}
	}
	else
	{
		getObject("bb"+n).style.visibility="hidden"
	}

}

/*移到菜单区*/
function over1 (n){
	 getObject("bb"+n).style.visibility="visible"
}

/*选中选项*/
function sele(n,m)
{
var tmpstr = ""
var ss = getObject('t'+n+"_"+m).innerHTML
var k = ss.replace(" ","")
//alert(m);
getObject('menutxt'+n).value=k;
getObject('login').utype.value=m;
menulogin(k)
}
function seleSearch(n,m)
{
var tmpstr = ""
var ss = getObject('t'+n+"_"+m).innerHTML
//var k = ss.replace(" ","")

getObject('menutxt'+n).value=ss;
if( m == 3)
	getObject('searchFM').action = "http://search.chinaren.com/alusearch/school_search.jsp";
else if(m == 2)
	getObject('searchFM').action = "http://search.chinaren.com/alusearch/class_search.jsp";
else if(m == 1)
	getObject('searchFM').action = "http://search.chinaren.com/alusearch/cm_search.jsp";
}
function seleProv(n,m)
{
	$('provid').innerHTML = m;
	getObject('searchFM').action = getObject('searchFM').action+'?provid='+$('provid').innerHTML + '&year=' +$('year').innerHTML;
	getObject('searchFM').submit();
}
function seleYear(n,m)
{
	$('year').innerHTML = m;
	getObject('searchFM').action = getObject('searchFM').action+'?provid='+$('provid').innerHTML + '&year=' +$('year').innerHTML;
	getObject('searchFM').submit();
}
/*移动上选项上*/
function over(n,m){
getObject('t'+n+"_"+m).className='ss'
}
/*离开选项上*/
function out1(n,m){
getObject('t'+n+"_"+m).className=''
}
/*离开菜单区*/
function out(cont)
{ 	 
	var i=1;
	if (cont==2) i=1;
	if (cont==3) i=2;
	for (;i<=cont;i++) {
	getObject('bb'+i).style.visibility="hidden"
	}
}

/*用户登录区菜单*/
function menulogin(n){
	var menuOpt = new Array ("ChinaRen用户","搜狐用户","手机用户")
	var tmpstr = ""
	for (var i=0;i<3;i++) {
		if (menuOpt[i]!=n) {
			tmpstr+="<li style='cursor:pointer;height:17px;padding-top:3px;text-indent:4px' id='t1_"+i+"' onmouseover =over(1,"+i+") onclick=sele(1,"+i+") onmouseout=out1(1,"+i+")>"+menuOpt[i]+"</li>"
		}
	}
	var start = "<ul style='width:100%;margin:0;padding:0'>"
	var end = "</ul>"
	var str = start + tmpstr + end
	getObject("bb1").innerHTML = str
}


/*=============搜索菜单选项================*/

	function sn(n)
	{
		for (i=2;i<=8;i+=2) {
			if (i == n) {
			getObject("z1_"+i).className="xyl4 lh22 bg01";
			getObject("z1_"+(i-1)).style.display="none"
			getObject("z1_"+(i+1)).style.display="none"
			if(n!=2) getObject("z1_1").style.display=""
			}
			else
			{
			getObject("z1_"+i).className="xyl1 lh22";
			getObject("z1_"+(i+1)).style.display=""
			}
		}
		if( n == 2)
			getObject('searchFM').action = "/alusearch/school_search.jsp";
		else if(n == 4)
			getObject('searchFM').action = "/alusearch/class_search.jsp";
		else if(n == 6)
			getObject('searchFM').action = "/alusearch/cm_search.jsp";
		else
			getObject('searchFM').action = "/alusearch/msg_search.jsp";
		
	}
	function getObject(objectId) {
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
}

	function menu(n) {
		var menutab = new Array ("menutab1","menutab2","menutab3")
		var mt = new Array ("mt1","mt2","mt3")
		for (var i=0;i<=3;i++) {
			if (i==n) {
				getObject(mt[i]).className="menubg a"
				getObject(menutab[i]).style.display=""
			}else
			{
				getObject(mt[i]).className="b"
				getObject(menutab[i]).style.display="none"
			}
		}
		
	}

function highlight(which,color){
	if (document.all||document.getElementById)
	which.style.backgroundColor=color
}

function extmenu(menuname,id){
	{   if ( menuname.style.display=="none" )
		{  menuname.style.display=""
			eval("peak"+id+".src='http://images.chinaren.com/product/alumni4/images/peak2_5.gif'")
		}
		else
		{  menuname.style.display="none"
			eval("peak"+id+".src='http://images.chinaren.com/product/alumni4/images/peak2_5a.gif';")
		}
	}
}

function showLifes(parentid) {
	var lifesDiv = getObject('lifesDiv');
	if(lifesDiv.style.display == 'none'){
		var lifesImg = getObject(parentid);	
		lifesDiv.style.left = (findPosX(lifesImg)-80)+"px";
		lifesDiv.style.top = (findPosY(lifesImg)+5)+"px";
		lifesDiv.style.display = '';
	}else{
		lifesDiv.style.display = 'none';	
	}
}
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;
}   
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;
}
function openwindow(url,name,w,h) {
	window.open(url,name,"top=150,left=300,width="+w+",height="+h+",toolbar=no,menubar=no,titlebar=no,scrollbars=no,resizable=no,center:yes");
}

function browserDetect(){
	var sUA = navigator.userAgent.toLowerCase();
	var sIE = sUA.indexOf("msie");
	var sOpera = sUA.indexOf("opera");
	var sMoz = sUA.indexOf("gecko");
	if (sOpera != -1) return "opera";
	if (sIE != -1){
		nIeVer = parseFloat(sUA.substr(sIE + 5));
		if (nIeVer >= 7) return "ie7";
		else if (nIeVer >= 6) return "ie6";
		else if (nIeVer >= 5.5) return "ie55";
		else if (nIeVer >= 5 ) return "ie5";
	}
	if (sMoz != -1)	return "moz";
	return "other";
};
function isIE(){return browserDetect().indexOf('ie') > -1;};
function isIE7(){return browserDetect().indexOf('ie7') > -1;};
function isOpera(){return browserDetect().indexOf('opera') > -1;};

var Browser = new Object();
Browser.isIE = window.ActiveXObject ? true : false;

function openDialog(url,name,width,height) {
	if(Browser.isIE) {
		//return window.showModalDialog(url,window,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;dialogTop:100;dialogLeft:200;help:off;status:no;scroll:off;");
		window.open(url, name, "Top=100, Left=200, width="+width+",height="+height+",help=off,status=yes,scroll=off,scrollbars=no,status=no,modal=yes");
	} else {
		alert("抱歉:您目前不是IE浏览器，请更换到IE浏览器下更改个人头像!");
		//window.open(url, name, "width="+width+",height="+height+",help=off,status=yes,scroll=off,scrollbars=no,status=no,modal=yes");
	}
}

function getIcon() {
	var ret = openDialog('http://classpic.chinaren.com/icon/my/upload/uploadicon.jsp','upicon','440','490');
	if(ret!=undefined) {
		$('iconimg').src  = ret + "?v=" + Math.floor(100 * Math.random() + 1);
	}
}

function openChat(classuuid){
	window.open('http://cchat.chinaren.com/class/class_chat.jsp?classuuid='+classuuid,'','top=0,left=0,toolbar=0,status=1,location=0,menubar=0,scrollbars=1,resizable=1,width='+(screen.availWidth-10)+',height='+(screen.availHeight-50));
}
function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1 ;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}
function getClassCookie()
{
	username=getCookie('class_search');
	if (username!=null && username!=""){
		var classuuid = username.split(",");
		for(var i=0;i<classuuid.length;i++){
			if(classuuid[i]!='null')
				document.write(classuuid[i]+"<br>");
		}
	}
}
function setClassCookie(cid)
{
	if(cid == '') return;
	username=getCookie('class_search');
	var v = cid;
	if (username!=null && username!=""){
		if(username.indexOf(","+cid)>=0) return;
		var classuuid = username.split(",");
		for(var i=0;i<classuuid.length && i < 9 ;i++){
			v += "," + classuuid[i] ;
		}
	}
	setCookie('class_search',v,3000);
}
function adjustImg(src) {try{ var iw=400; if(screen.width==1024) iw=450; if(src.width>iw) src.width=iw;}catch(e){}}

function logout() {
	top.document.location = "http://profile.chinaren.com/zhs/backdoor.jsp?group=alumni&url=http%3A//www.chinaren.com/";
}
