// JavaScript Document
//交互菜单设置
function changeMenu(v1,v2){
	for(k=1;k<2;k++){
		if(v1==k){
		for(i=1;i<3;i++){
			if(i==v2){
			g("td"+k+i).className='PlaceHeadBG1';
			g("d"+k+i).style.display='block';
			}else{
			g("td"+k+i).className='PlaceHeadBG2';
			g("d"+k+i).style.display='none';
			}
		}
		}
	}	
}

var nn;
nn=1;
setTimeout('change_img()',6000);
function change_img()
{
 if(nn>5) nn=1
 setTimeout('setFocus1('+nn+')',6000);
 nn++;
 tt=setTimeout('change_img()',6000);
}
function setFocus1(i)
{
 selectLayer1(i);
}
function selectLayer1(i)
{
 switch(i)
 {
 case 1:
 g("focusPic0").style.display="block";
 g("focusPic1").style.display="none";
 g("focusPic2").style.display="none";
 g("focusPic3").style.display="none";
 g("focusPic4").style.display="none";
 g("ppt_menu_1").className="ppt_menu_on";
 g("ppt_menu_2").className="ppt_menu_off";
 g("ppt_menu_3").className="ppt_menu_off";
 g("ppt_menu_4").className="ppt_menu_off";
 g("ppt_menu_5").className="ppt_menu_off";
 break;
 case 2:
 g("focusPic0").style.display="none";
 g("focusPic1").style.display="block";
 g("focusPic2").style.display="none";
 g("focusPic3").style.display="none";
 g("focusPic4").style.display="none";
 g("ppt_menu_1").className="ppt_menu_off";
 g("vmenu_2").className="ppt_menu_on";
 g("ppt_menu_3").className="ppt_menu_off";
 g("ppt_menu_4").className="ppt_menu_off";
 g("ppt_menu_5").className="ppt_menu_off";
 break;
 case 3:
 g("focusPic0").style.display="none";
 g("focusPic1").style.display="none";
 g("focusPic2").style.display="block";
 g("focusPic3").style.display="none";
 g("focusPic4").style.display="none";
 g("ppt_menu_1").className="ppt_menu_off";
 g("ppt_menu_2").className="ppt_menu_off";
 g("ppt_menu_3").className="ppt_menu_on";
 g("ppt_menu_4").className="ppt_menu_off";
 g("ppt_menu_5").className="ppt_menu_off";
 break;
  case 4:
 g("focusPic0").style.display="none";
 g("focusPic1").style.display="none";
 g("focusPic2").style.display="none";
 g("focusPic3").style.display="block";
 g("focusPic4").style.display="none";
 g("ppt_menu_1").className="ppt_menu_off";
 g("ppt_menu_2").className="ppt_menu_off";
 g("ppt_menu_3").className="ppt_menu_off";
 g("ppt_menu_4").className="ppt_menu_on";
 g("ppt_menu_5").className="ppt_menu_off";
 break;
  case 5:
 g("focusPic0").style.display="none";
 g("focusPic1").style.display="none";
 g("focusPic2").style.display="none";
 g("focusPic3").style.display="none";
 g("focusPic4").style.display="block";
 g("ppt_menu_1").className="ppt_menu_off";
 g("ppt_menu_2").className="ppt_menu_off";
 g("ppt_menu_3").className="ppt_menu_off";
 g("ppt_menu_4").className="ppt_menu_off";
 g("ppt_menu_5").className="ppt_menu_on";
 break;
 }
}
//--------------------------AJAX function-----------------------------
var http_request = false;
function getmyxml(url) {
	http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		window.alert('浏览器无法正确获得XML对象！');
		return false;
	}
	http_request.onreadystatechange = WriteContents;
	http_request.open('GET', url, true);
	http_request.send(null);

}
function WriteContents() {
	var htmlbody='';
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var xmldoc = http_request.responseXML;
			var sess = xmldoc.getElementsByTagName('sess').item(0);
			var user = xmldoc.getElementsByTagName('user').item(0);
			var img = xmldoc.getElementsByTagName('img').item(0);
			var mess = xmldoc.getElementsByTagName('mess').item(0);
			 if (sess!=null){
					if(sess.firstChild.data!=0){
						htmlbody ='<table width="100%" border="0" cellspacing="0" cellpadding="0">';
						htmlbody+='		<tr>';
						htmlbody+='			<td width="60" rowspan="2" align="center" valign="middle"><a href="/myspace/member/user_otherinfo.php"  style="color:blue;" title="单击此处可以修改您的头像"><img src="'+img.firstChild.data+'" width="48" height="48"  border="0"/></a></td>';
						htmlbody+='			<td height="30">&nbsp;欢迎您，'+user.firstChild.data+' ! </td>';
						htmlbody+='		</tr>';
						htmlbody+='		<tr>';
						if (mess.firstChild.data==0){
							htmlbody+='			<td height="30">&nbsp;<img src="/images/mess02.gif" width="12" height="12" /> 您有<strong style="font-family:Arial;">'+mess.firstChild.data+'</strong>条未读消息!&nbsp;[<a href="/myspace/member/changepwd.php"  style="color:blue;">密码</a> <a href="/myspace/reg/logout.php" style="color:red;">注销</a>]</td>';
						}else{
							htmlbody+='			<td height="30">&nbsp;<img src="/images/mess02.gif" width="12" height="12" /> <a href="/myspace/member/user_message.php" target="_blank">您有<strong style="font-family:Arial;">'+mess.firstChild.data+'</strong>条未读消息!</a>&nbsp;[<a href="/myspace/member/changepwd.php"  style="color:blue;">密码</a> <a href="/myspace/reg/logout.php" style="color:red;">注销</a>]</td>';
						}
						htmlbody+='		</tr>';
						htmlbody+='		<tr>';
						htmlbody+='			<td height="15" colspan="2" background="/images/line.gif"></td>';
						htmlbody+='		</tr>';
						htmlbody+='</table>';	
						g('space_login').innerHTML= htmlbody;	
					}else{
						htmlbody ='<form name="login" id="login" method="post" action="" onsubmit="userlogin(); return false;" style="margin:0px; padding:0px;">';
						htmlbody+='<iframe name="UserLogin" src="" frameborder="0" marginheight="0" marginwidth="0" id="UserLogin" width="0" height="0" scrolling="no" ></iframe>';
						htmlbody+='<table width="100%" border="0" cellspacing="0" cellpadding="0">';
						htmlbody+='<input name="reurl" type="hidden" id="reurl" value="/" />';
						htmlbody+='  <tr>';
						htmlbody+='	<td width="50%" height="30"><input name="username" type="text" id="username" style="width:120px; font-size:9pt; font-family:tahoma,Verdana,Arial; background:url(/images/username.gif) no-repeat left center;" value="" onFocus="initlogin(this.value,0);" onBlur="editlogin(this.value,0);"/></td>';
						htmlbody+='	<td><label  for="remember_me"  style="cursor:pointer;"><input name="remember_me" type="checkbox" id="remember_me" value="0" checked/>记住我</label> <a href="http://www.eefocus.com/myspace/reg/index.php" target="_blank" style="color:blue;">获取通行证</a></td>';
						htmlbody+='  </tr>';
						htmlbody+='  <tr>';
						htmlbody+='	<td height="30"><input name="password" type="password" id="password" style="width:120px; font-size:9pt; font-family:tahoma,Verdana,Arial; background:url(/images/password.gif) no-repeat left center;" value="" onFocus="initlogin(this.value,1);"  onBlur="editlogin(this.value,1);"/></td>';
						htmlbody+='	<td style="padding-left:4px;" id="loginbtn"><input type="image" name="submitbtn" src="/images/btn_login02.gif"></td>';
						htmlbody+='  </tr>';
						htmlbody+='  <tr>';
						htmlbody+='	<td height="15" colspan="2" background="/images/line.gif"></td>';
						htmlbody+='  </tr>';
						htmlbody+='</table>';
						htmlbody+='</form>';	
						g('space_login').innerHTML= htmlbody;
						if (user.firstChild.data!=0)
						{
							g('username').style.background='';
							g('username').value=user.firstChild.data;
						}
					}										
			 } else {
				alert('无法建立与服务器通讯的 XMLHTTP 实例 !');
			 }
		}
	}
}

function userlogin(){
	filePath=g('UserLogin').src;
	fileName = ((filePath.indexOf('/') > -1) ? filePath.substring(filePath.lastIndexOf('/')+1,filePath.length) : filePath.substring(filePath.lastIndexOf('\\')+1,filePath.length));
	src=fileName.substring(fileName.lastIndexOf('/')+1,fileName.length);

	if (src!="UserLogin2.php"){		
		g('UserLogin').src="/member/UserLogin2.php";
	}else{
		UserLogin.forlogin();
	}
}


//辅助性函数
function g(sid){
	return document.getElementById(sid);
}
//用户接口
function changebtn(bs){
	if(bs==1){
		g('loginbtn').innerHTML='<img src="/images/ajax-loader.gif" width="15" height="15" hspace="3" />&nbsp;&nbsp;登录中请稍候……';
	}else{
		g('loginbtn').innerHTML='<input type="image" name="submitbtn" src="/images/btn_login02.gif">';
	}
}
//初始表单的检查
function initlogin(value, lb){
	if(lb==0){
		if (value==''){
			g('username').style.background='';
		}
	}
	if(lb==1){
		if (value==''){
			g('password').style.background='';
		}
	}
}
function editlogin(value, lb){
	if(lb==0){
		if(value==''){
			g('username').style.background='url(/images/username.gif) no-repeat left center';
		}
	}
	if(lb==1){
		if(value==''){
			g('password').style.background='url(/images/password.gif) no-repeat left center';
		}
	}
}

            ////晴空输入匡
var clickCount = 0;
function clearCommentContent(oObject) {
	clickCount++;
	if (clickCount == 1) {
		oObject.value = "";
	}
}
