function  showTime(position)  {
	tick  =  new  Date();
	hours  =  tick.getHours();
	minutes  =  tick.getMinutes();
	seconds  =  tick.getSeconds();
	day  =  tick.getDay();
	month  =  tick.getMonth()+1;
	date  =  tick.getDate();
	year  =  tick.getYear();
	
	current  =  year+'年'+month+'月'+date+'日' ;

	if(day==0){var  weekday  =  "  星期日"}
	if(day==1){var  weekday  =  "  星期一"}
	if(day==2){var  weekday  =  "  星期二"}
	if(day==3){var  weekday  =  "  星期三"}
	if(day==4){var  weekday  =  "  星期四"}
	if(day==5){var  weekday  =  "  星期五"}
	if(day==6){var  weekday  =  "  星期六"}
	current  += weekday ;
	document.getElementById(position).innerHTML = current;
	setTimeout("showTime('"+position+"')",1000);
}

function nTabs(thisObj,Num){

	if (Num == 0)
		{
			document.getElementById('more').href = "aesma_newsList.php";
		}else if(Num == 1) {
							document.getElementById('more').href = "aesma_newsList.php?catalog=64";
		}else if(Num == 2) {
							document.getElementById('more').href = "aesma_newsList.php?catalog=65";
		}
	if(thisObj.className == "active")return;
	var tabObj = thisObj.parentNode.id;
	var tabList = document.getElementById(tabObj).getElementsByTagName("li");
	for(i=0; i <tabList.length-1; i++)
	{
	if (i == Num)
		{
   			thisObj.className = "active"; 
      			document.getElementById(tabObj+"_Content"+i).style.display = "block";
		}else{
 			  	tabList[i].className = "normal"; 
   				document.getElementById(tabObj+"_Content"+i).style.display = "none";
			 }
	} 
}

function nTabs2(thisObj,Num){
		if (Num == 0){
			document.getElementById('more2').href = "aesma_newscenter.php?menu=6";
		}else if(Num == 1) {
							document.getElementById('more2').href = "aesma_newsList.php?catalog=50";
		}else if(Num == 2) {
							document.getElementById('more2').href = "aesma_newsList.php?catalog=52";
		}else if(Num == 3) {
							document.getElementById('more2').href = "aesma_newsList.php?catalog=51";
		}else if(Num == 4) {
							document.getElementById('more2').href = "aesma_newsList.php?catalog=53";
		}

	if(thisObj.className == "active")return;
	var tabObj = thisObj.parentNode.id;
	var tabList = document.getElementById(tabObj).getElementsByTagName("li");
	for(i=0; i <tabList.length-1; i++)
	{
	if (i == Num)
		{
   			thisObj.className = "active"; 
      			document.getElementById(tabObj+"_Content"+i).style.display = "block";
		}else{
 			  	tabList[i].className = "normal"; 
   				document.getElementById(tabObj+"_Content"+i).style.display = "none";
			 }
	} 
}

function nTabs3(thisObj,Num){
		if (Num == 0){
			document.getElementById('more3').href = "aesma_newscenter.php?menu=7";
		}else if(Num == 1){
			document.getElementById('more3').href = "aesma_newsList.php?catalog=55";
		}else if(Num == 2) {
							document.getElementById('more3').href = "aesma_newsList.php?catalog=54";
		}else if(Num == 3) {
							document.getElementById('more3').href = "aesma_comments.php";
		}
	if(thisObj.className == "active")return;
	var tabObj = thisObj.parentNode.id;
	var tabList = document.getElementById(tabObj).getElementsByTagName("li");
	for(i=0; i <tabList.length-1; i++)
	{
	if (i == Num)
		{
   			thisObj.className = "active"; 
      			document.getElementById(tabObj+"_Content"+i).style.display = "block";
		}else{
 			  	tabList[i].className = "normal"; 
   				document.getElementById(tabObj+"_Content"+i).style.display = "none";
			 }
	} 
}

function nTabs4(thisObj,Num){
		if (Num == 0){
			document.getElementById('more4').href = "aesma_newsList.php?catalog=71";
		}else if(Num == 1){
			document.getElementById('more4').href = "aesma_newsList.php?catalog=72";
		}else if(Num == 2) {
							document.getElementById('more4').href = "aesma_newsList.php?catalog=73";
		}else if(Num == 3) {
							document.getElementById('more4').href = "aesma_newsList.php?catalog=74";
		}
	if(thisObj.className == "active")return;
	var tabObj = thisObj.parentNode.id;
	var tabList = document.getElementById(tabObj).getElementsByTagName("li");
	for(i=0; i <tabList.length-1; i++)
	{
	if (i == Num)
		{
   			thisObj.className = "active"; 
      			document.getElementById(tabObj+"_Content"+i).style.display = "block";
		}else{
 			  	tabList[i].className = "normal"; 
   				document.getElementById(tabObj+"_Content"+i).style.display = "none";
			 }
	} 
}

function nTabs5(thisObj,Num){
	if(thisObj.className == "active")return;
	var tabObj = thisObj.parentNode.id;
	var tabList = document.getElementById(tabObj).getElementsByTagName("li");
	for(i=0; i <tabList.length-1; i++)
	{
	if (i == Num)
		{
   			thisObj.className = "active"; 
      			document.getElementById(tabObj+"_Content"+i).style.display = "block";
		}else{
 			  	tabList[i].className = "normal"; 
   				document.getElementById(tabObj+"_Content"+i).style.display = "none";
			 }
	} 
}

function showRegister() {
	
	showFloatLayer('',458,600); 
	
	cDiv = document.getElementById("floatLayerContent") ;
	
	cDiv.style.textAlign = 'left' ;
	
	var innerHTML = '<form id=registerForm ><div style="margin:36px 0px 8px 16px;font-size:18px;font-weight:bold;text-align:center">欢迎注册亚洲应急科学管理协会！</div>' ;
	innerHTML += '<hr class=line style="margin:4px 18px 4px 18px;"/>' ;
	innerHTML += '<div style="margin:8px"><div class=regCapt>用户名：</div><div><input name="userName" dataType="Require" msg="用户名必须填写"></div></div>' ;
	innerHTML += '<div style="margin:8px"><div class=regCapt>您的姓名：</div><div><input name="name" dataType="Require" msg="真实姓名必须填写"></div></div>' ;	
	innerHTML += '<div style="margin:8px"><div class=regCapt>性别：</div><div><input type="radio" name="sex" value="男" checked/>男 <input type="radio" name="sex" value="女" />女</div></div>' ;
	innerHTML += '<hr class=line style="margin:4px 18px 4px 18px;"/>' ;
	innerHTML += '<div style="margin:8px"><div class=regCapt>工作单位：</div><div><input name="work" dataType="Require" msg="工作单位必须填写"></div></div>' ;
	innerHTML += '<div style="margin:8px"><div class=regCapt>联系方式：</div><div><input name="contact" dataType="Require" msg="联系方式必须填写"></div></div>' ;
	innerHTML += '<div style="margin:8px"><div class=regCapt>联系地址：</div><div><input name="address" dataType="Require" msg="联系地址必须填写"></div></div>' ;	
	innerHTML += '<hr class=line style="margin:4px 18px 4px 18px;"/>' ;
	innerHTML += '<div style="margin:8px;width:100%"><div class=regCapt>您的 Email：</div><div style="width:0px"><input name="email" dataType="Email" require="true" msg="请填写合法的电子邮件地址"></div></div>' ;
	innerHTML += '<div style="margin:8px"><div class=regCapt>请设置您的密码：</div><div><input type=password name="password" dataType="Require" msg="口令必须填写" ></div></div>' ;
	innerHTML += '<div style="margin:8px;"><div class=regCapt>再输入一次密码：</div><div><input type=password name="confirmPassword" dataType="Repeat" require="true" to="password" msg="两次输入的密码不一致" ></div></div>' ;
	innerHTML += '<hr class=line style="margin:4px 18px 4px 18px;"/>' ;
	innerHTML += '<div style="margin:8px"><div class=regCapt>验证码：</div><div><input size=10 name=checkCode dataType="Require" msg="请输入验证码。"> <img valign=absmiddle src="checkCode.php"></div></div>' ;
	innerHTML += '<div style="margin:8px;margin-top:18px;text-align:center;width:100%"><input type=button value="立即注册" onClick="if(Validator.Validate(this.form,1)) registerIt(this.form);">&nbsp;<input type=button value="放弃" onClick="hideFloatLayer();"></div>' ;
//	innerHTML += '<div style="margin:8px;margin-top:18px;;text-align:center;width:100%"> <a href="/reg.html">亚洲应急协会服务及隐私保护协议</a> <a onClick="hideFloatLayer();">【放弃】</a></div>' ;
	innerHTML += '</form>' ;

	cDiv.innerHTML = innerHTML ;
	
}

function registerIt(form) {
	var url = '/dynamicScript.php?method='+encodeURIComponent("register") ;
	if ( form.sex ) url += "&sex="+encodeURIComponent(inputValue_(form.sex[0])) ;		
	if ( form.userName ) url += "&userName="+encodeURIComponent(form.userName.value) ;
	if ( form.name ) url += "&name="+encodeURIComponent(form.name.value) ;

	if ( form.work ) url += "&work="+encodeURIComponent(form.work.value) ;
	if ( form.contact ) url += "&contact="+encodeURIComponent(form.contact.value) ;	
	if ( form.address ) url += "&address="+encodeURIComponent(form.address.value) ;	
	if ( form.email ) url += "&email="+encodeURIComponent(form.email.value) ;
	if ( form.password ) url += "&password="+encodeURIComponent(form.password.value) ;
	if ( form.checkCode ) url += "&checkCode="+encodeURIComponent(form.checkCode.value) ;
	
//	form.innerHTML += url ;
	document.getElementById('dynamicScript').src = url ;
}

function showFloatLayer(method,width,height) {
	
	aDiv = document.getElementById("floatLayerFrame") ;
	aDiv.style.left = 0 ;
	aDiv.style.top = document.body.scrollTop; //0 ;
	aDiv.style.position = "absolute" ;
	aDiv.style.height = document.body.clientHeight ;
	aDiv.style.width = document.body.clientWidth ;
	aDiv.style.backgroundColor = "#003366";
	aDiv.style.filter = "alpha(opacity=66)"; aDiv.style.MozOpacity = "0.33";
	aDiv.style.display = "" ;
	
	bDiv = document.getElementById("floatLayerShadow") ;
	bDiv.style.height = height ;
	bDiv.style.width = width ;
	bDiv.style.top = document.body.scrollTop+(document.body.clientHeight-height)/2+12;
	bDiv.style.left = (document.body.clientWidth-width)/2+12;
	bDiv.style.backgroundColor = "#003366";
	bDiv.style.filter = "alpha(opacity=44)"; aDiv.style.MozOpacity = "0.33";
	bDiv.style.display = "" ;
	
	cDiv = document.getElementById("floatLayerContent") ;
	cDiv.style.top = document.body.scrollTop+(document.body.clientHeight-height)/2;
	cDiv.style.left = (document.body.clientWidth-width)/2 ;
	cDiv.style.height = height ;
	cDiv.style.width = width ;
	cDiv.style.padding = 6 ;
	cDiv.style.display = "" ;
	cDiv.innerHTML = '' ;
	
	window.attachEvent('onscroll',floatLayerContent) ;
	if ( method ) document.getElementById('dynamicScript').src= '/dynamicScript.php?method='+method+'&div=floatLayerContent' ;
}

function hideFloatLayer() {

	aDiv = document.getElementById("floatLayerFrame") ;
	aDiv.style.display="none" ;
	aDiv = document.getElementById("floatLayerShadow") ;
	aDiv.style.display="none" ;
	aDiv = document.getElementById("floatLayerContent") ;
	aDiv.style.display="none" ;
}

function inputValue_( input )
{
	type = input.type ;
	switch ( type ) {
		case "checkbox" :
		inputValue = input.checked ? input.value : 0 ;
		break ;
		case "select-one" :
		if ( input.selectedIndex==-1 || input.selectedIndex>input.options.length-1 || ! input.options[input.selectedIndex] )
		input.selectedIndex = 0 ;
		inputValue = input.options[input.selectedIndex].value ;
		break ;
		case "select-multiple" :
		inputValue = "" ;
		for(j=0; j<input.options.length; j++) {
			if ( input.options[j].selected && input.options[j].value) {
				inputValue += input.options[j].value+"|" ;
			}
		}
		if ( inputValue != "" ) inputValue = '|'+ inputValue ;
		break ;
		case "radio" :
		name = input.name ;
		form = input.form ;
		inputValue = "" ;
		if ( form[name].length ) {
			for( j=0; j<form[name].length; j++ ) {
				if ( form[name][j].checked ) inputValue = form[name][j].value ;
			}
		} else {
			if ( form[name].checked ) inputValue = form[name].value ;
		}
		break ;
		case "text" :
		if ( input.GeValue ) inputValue = input.GeValue ;
		else if ( input.value_prefix ) inputValue = input.value_prefix + input.value ;
		else inputValue = input.value ;
		break ;
		default :
		inputValue = input.value
	}
	return  inputValue ;
}

function logon(userName,password,checkbox){
	document.getElementById('dynamicScript').src= "/dynamicScript.php?method=logon&checkbox="+encodeURIComponent(checkbox)+'&userName='+encodeURIComponent(userName)+'&password='+encodeURIComponent(password) ;
}

function quesstion()
{
	var userName = GetCookie('userName') ;
	var html = null ;	

	if (userName ){
		html = '<form id=\"form2\" method=\"POST\" ><div class=\"\"  style=\"width:650px;height:140px\"><div class=\"Nname\" id=\"NnameQ\"><font style="color:#023D8C;font-weight:bold;">'+userName+'</font>提问：</div><div class=\"inputbd\"><label><textarea name=\"title\" cols=\"50\" rows=\"8\"></textarea></label></div></div><div class=\"inputbd2\"><input class=\"input\" name=\"submit\" type=\"submit\" value=\"提交\">&nbsp&nbsp&nbsp&nbsp<input class=\"input\" type=\"reset\" value=\"重填\"></div></form>';
	} else {
		html = '<div style=\"width:100%;height:31;float:left;text-align:center;\" class=\"comments\"><font style="font-weight:bold;">如需提问，请先<a href="/" ><font style="color:#023D8C;font-weight:bold;">登陆</font></a>。</font></div>';
	}
	document.getElementById("NnameQ").innerHTML = html ;
}

function logonBar()
{
	var userId = GetCookie('userId') ;
	var userName = GetCookie('userName') ;
//	alert( document.cookie) ;
	var html = null ;
	if ( userId && userName  ) {
		html = '<div style="margin-top:8px;margin-left:16px;height:30px;"><font style="color:#023D8C;font-weight:bold;">'+userName+'</font>您好！</div><div style="margin-top:0px;margin-left:16px;height:26px;">亚洲应急科学管理协会欢迎您。</div><div style="margin-top:10px;margin-left:16px;height:30px;">【<a href="" onClick="logoff()">退出</a>】 | <a href="aesma_myhome.php">我的账户</a></div>' ;
	} else {
		html = '<form name=mumber action=\'\' method=post ><div style="width:100%; height:30; margin-top:4px; float:left;"><span style="width:26%; height:28; float:left; text-align:right;">用户名：</span><span style="width:74%; float:left;"><label><input type="text" name="mName" style="width:160px;"/></label></span></div><div style="width:100%; float:left; "><span style="width:26%; height:28; float:left; text-align:right;">密   码：</span><span style="width:74%; float:left;"><input type="password" name="mPassword" style="width:160px;"/></span></div><div style="margin-top:4px; width:100%; float:left;"><span style="width:55%; height:25; float:left; text-align:center;"><input type="checkbox" name="checkboxJ" />记住登录</span><span style="width:44%; float:left; text-align:left;"><input class="a_input2" type="button" name="Submit2" value="登录" onClick="logon(mName.value,mPassword.value,checkboxJ.checked)"/></span></div><div style="width:100%; float:left;"><span style="width:55%; float:left; text-align:center;"><a onclick="showRegister()">注册</a></span><span style="width:44%; float:left; text-align:left;"><a onClick="showGetPassword()">忘了密码</a></span></div></form>';
	}
	document.getElementById("logonBar").innerHTML = html ; //+ "<div class=\"right_gray\"><a>介绍好友得积分</a> | <a onClick=\"window.external.AddFavorite(window.location,document.title);\" >收藏本站</a></div>" ;
}
/* 找回密码 */
function showGetPassword() {
	showFloatLayer('',400,228); 
	
	cDiv = document.getElementById("floatLayerContent") ;
	cDiv.style.textAlign = 'left' ;
	var innerHTML = '<form id=getPasswordForm ><div style="margin:8px;padding:8px;padding-top:18px;border-bottom:1px solid #999999;font-size:18px;font-weight:bolder">找回密码</div>' ;
	innerHTML += '<div style="width:100%;height:32px;line-height:32px"><font style="width:128px;text-align:right;float:left">您的 Email： </font><input name="email" dataType="Email" require="true" msg="请填写注册时使用的电子邮件地址"></div>' ;
	innerHTML += '<div style="width:100%;height:32px;line-height:32px"><font style="width:128px;text-align:right;float:left">验证码： </font><input size=10 name=checkCode dataType="Require" msg="请输入验证码，看不清请点击验证码图片更换验证码。"> <img valign=absmiddle src="checkCode.php"></div>' ;
	innerHTML += '<div style="width:100%;text-align:center;margin-top:18px;line-height:px"><input type=button value="发送新口令" onClick="if(Validator.Validate(this.form,1)) getPassword(this.form);">&nbsp;<input type=button value="放弃" onClick="hideFloatLayer();"></div>' ;
//	innerHTML += '<div style="margin:8px;margin-top:18px;padding-left:72px"> <a href="/reg.html">亚洲应急协会服务及隐私保护协议</a> <a onClick="hideFloatLayer();">【放弃】</a></div>' ;
	innerHTML += '</form>' ;
	cDiv.innerHTML = innerHTML ;
}

function getPassword(form) {
	var url = '/dynamicScript.php?method='+encodeURIComponent("getPassword") ;
	if ( form.email ) url += "&email="+encodeURIComponent(form.email.value) ;
	if ( form.checkCode ) url += "&checkCode="+encodeURIComponent(form.checkCode.value) ;
	
	//form.innerHTML += url ;
	document.getElementById('dynamicScript').src= url ;
}


function logoff(){
	ClearCookie('userId') ;
	ClearCookie('userName') ;
	logonBar() ;
}

function hideFloatLayer() {

	aDiv = document.getElementById("floatLayerFrame") ;
	aDiv.style.display="none" ;
	aDiv = document.getElementById("floatLayerShadow") ;
	aDiv.style.display="none" ;
	aDiv = document.getElementById("floatLayerContent") ;
	aDiv.style.display="none" ;
}

function ClearCookie(name)
{
	var ThreeDays=3*24*60*60*1000;
	var expDate = new Date();
	expDate.setTime(expDate.getTime()-ThreeDays);
	document.cookie=name+"=;expires="+expDate.toGMTString();
}

function GetCookie(name)
{
	var result = null;
	var myCookie = document.cookie + ";";
	var searchName = name + "=";
	var startOfCookie = myCookie.indexOf(searchName);
	var endOfCookie;
	if (startOfCookie != -1)
	{
		startOfCookie += searchName.length;
		endOfCookie = myCookie.indexOf(";",startOfCookie);
		result = decodeURIComponent(myCookie.substring(startOfCookie, endOfCookie));
		//result = myCookie.substring(startOfCookie, endOfCookie);
	}
	return result;
}