$(document).ready(function(){
/*****菜单*****/
	$("#nav>ul>li").each(function(i){
		$("#nav>ul>li").eq(i).hover(
		function(){
			$("#nav>ul>li").eq(i).children('ul').css("display","block");
			$("#nav>ul>li").eq(i).children("a").css("color","#FFFFCC");
		},
		function(){
			$("#nav>ul>li").eq(i).children('ul').css("display","none");
			$("#nav>ul>li").eq(i).children("a").css("color","");
		});
		$("#nav>ul>li").eq(i).children("ul").hover(function(){$("#nav>ul>li").eq(i).children('ul').css("display","block");},function(){$("#nav>ul>li").eq(i).children('ul').css("display","none");});
		
	});
	
	$("#nav>ul>li>ul>li").each(function(i){
		$("#nav>ul>li>ul>li").eq(i).hover(
		function(){
			$("#nav>ul>li>ul>li").eq(i).children('ul').css("display","block");
			$("#nav>ul>li>ul").css("height",$('#nav>ul>li>ul>li').eq(i).children('ul').height());
			$("#nav>ul>li>ul>li").eq(i).children("a").css("color","#FFFFCC");
		},
		function(){
			$("#nav>ul>li>ul>li").eq(i).children('ul').css("display","none");
			$("#nav>ul>li>ul>li").eq(i).children("a").css("color","");
		});
		$("#nav>ul>li>ul>li").eq(i).children("ul").hover(function(){$("#nav>ul>li>ul>li").eq(i).children('ul').css("display","block");},function(){$("#nav>ul>li>ul>li").eq(i).children('ul').css("display","none");});
		
	});		
	
	$("#nav ul li ul li ul li a").hover(
	function(){
		$(this).css("background","#3CB3EC");
	},
	function(){
		$(this).css("background","#A3E0F9");
	}
	);
	
	$("#nav ul li ul li:last-child").css({border:"0px",background:"url(/images/aesma_ngo/navmenuBG_down1.gif) no-repeat bottom left"});
	$("#nav ul li ul li:last-child a").hover(
	function(){
		$(this).css("background","");
		$(this).parent().css("background","url(/images/aesma_ngo/navmenuBG_down2.gif) no-repeat bottom left");		
	},
	function(){		
		$(this).parent().css("background","url(/images/aesma_ngo/navmenuBG_down1.gif) no-repeat bottom left");
	}
	);
	
	$("#nav ul li ul li ul li:first-child").css("background","url(/images/aesma_ngo/navmenuBG_top1.gif) no-repeat top left");
	$("#nav ul li ul li ul li:first-child a").hover(
	function(){
		$(this).css("background","");
		$(this).parent().css("background","url(/images/aesma_ngo/navmenuBG_top2.gif) no-repeat top left");		
	},
	function(){		
		$(this).css("background","");
		$(this).parent().css("background","url(/images/aesma_ngo/navmenuBG_top1.gif) no-repeat top left");
	}
	);
	
	$("#nav ul li ul li ul li:last-child").css({border:"0px",background:"url(/images/aesma_ngo/navmenuBG_down1.gif) no-repeat bottom left"});
	$("#nav ul li ul li ul li:last-child a").hover(
	function(){
		$(this).css("background","");
		$(this).parent().css("background","url(/images/aesma_ngo/navmenuBG_down2.gif) no-repeat bottom left");		
	},
	function(){	
		$(this).css("background","");	
		$(this).parent().css("background","url(/images/aesma_ngo/navmenuBG_down1.gif) no-repeat bottom left");
	}
	);
	
/*************首页left1************************/
	$("#zixun2").css("display","block");
	
	$("#gnzx a").mouseover(function(){
		$("#gnzx").addClass("menu");
		$("#gjzx").removeClass("menu");
		$("#zixun2").css("display","block");
		$("#zixun3").css("display","none");
		$("#zxMore").attr("href","aesma_ngoPD_newsList.php?catalog=64");
	});
	$("#gjzx a").mouseover(function(){
		$("#gjzx").addClass("menu");
		$("#gnzx").removeClass("menu");
		$("#zixun3").css("display","block");
		$("#zixun2").css("display","none");
		$("#zxMore").attr("href","aesma_ngoPD_newsList.php?catalog=65");
	});
	
/***************首页center2******************************/
	$("#yjkx1").css("display","block");
	$("#kxcx a").mouseover(function(){
		$("#kxcx").addClass("menu");
		$("#kxff").removeClass("menu");
		$("#yjpx").removeClass("menu");
		$("#yjkx1").css("display","block");
		$("#yjkx2").css("display","none");
		$("#yjkx3").css("display","none");
		$("#yjkxMore").attr("href","aesma_ngoPD_newsList.php?catalog=52");
	});
	$("#kxff a").mouseover(function(){
		$("#kxcx").removeClass("menu");
		$("#kxff").addClass("menu");
		$("#yjpx").removeClass("menu");
		$("#yjkx1").css("display","none");
		$("#yjkx2").css("display","block");
		$("#yjkx3").css("display","none");
		$("#yjkxMore").attr("href","aesma_ngoPD_newsList.php?catalog=48");
	});
	$("#yjpx a").mouseover(function(){
		$("#kxcx").removeClass("menu");
		$("#kxff").removeClass("menu");
		$("#yjpx").addClass("menu");
		$("#yjkx1").css("display","none");
		$("#yjkx2").css("display","none");
		$("#yjkx3").css("display","block");
		$("#yjkxMore").attr("href","aesma_ngoPD_newsList.php?catalog=62");
	});
	
/**************首页center3****************************/
	$("#yjzs1").css("display","block");
	$("#zssh a").mouseover(function(){
		$("#zssh").addClass("menu");
		$("#zsxy").removeClass("menu");
		$("#zsqy").removeClass("menu");
		$("#yjzs1").css("display","block");
		$("#yjzs2").css("display","none");
		$("#yjzs3").css("display","none");
		$("#zsMome").attr("href","aesma_ngoPD_newsList.php?catalog=59");
	});
	$("#zsxy a").mouseover(function(){
		$("#zssh").removeClass("menu");
		$("#zsxy").addClass("menu");
		$("#zsqy").removeClass("menu");
		$("#yjzs1").css("display","none");
		$("#yjzs2").css("display","block");
		$("#yjzs3").css("display","none");
		$("#zsMome").attr("href","aesma_ngoPD_newsList.php?catalog=61");
	});
	$("#zsqy a").mouseover(function(){
		$("#zssh").removeClass("menu");
		$("#zsxy").removeClass("menu");
		$("#zsqy").addClass("menu");
		$("#yjzs1").css("display","none");
		$("#yjzs2").css("display","none");
		$("#yjzs3").css("display","block");
		$("#zsMome").attr("href","aesma_ngoPD_newsList.php?catalog=60");
	});
	
/***************应急产业ngoCY**************************************/
	$("#yjcp1").css("display","block");
	$("#yjcpzr a").click(function(){
		$("#yjcpzr").addClass("selection");
		$("#yjcpgg").removeClass("selection");
		$("#yjcpty").removeClass("selection");
		$("#yjcpsh").removeClass("selection");
		$("#yjcpsg").removeClass("selection");
		$("#yjcp1").css("display","block");
		$("#yjcp2").css("display","none");
		$("#yjcp3").css("display","none");
		$("#yjcp4").css("display","none");
		$("#yjcp5").css("display","none");
	});
	$("#yjcpgg a").click(function(){
		$("#yjcpzr").removeClass("selection");
		$("#yjcpgg").addClass("selection");
		$("#yjcpty").removeClass("selection");
		$("#yjcpsh").removeClass("selection");
		$("#yjcpsg").removeClass("selection");
		$("#yjcp1").css("display","none");
		$("#yjcp2").css("display","block");
		$("#yjcp3").css("display","none");
		$("#yjcp4").css("display","none");
		$("#yjcp5").css("display","none");
	});
	$("#yjcpty a").click(function(){
		$("#yjcpzr").removeClass("selection");
		$("#yjcpgg").removeClass("selection");
		$("#yjcpty").addClass("selection");
		$("#yjcpsh").removeClass("selection");
		$("#yjcpsg").removeClass("selection");
		$("#yjcp1").css("display","none");
		$("#yjcp2").css("display","none");
		$("#yjcp3").css("display","block");
		$("#yjcp4").css("display","none");
		$("#yjcp5").css("display","none");
	});
	$("#yjcpsh a").click(function(){
		$("#yjcpzr").removeClass("selection");
		$("#yjcpgg").removeClass("selection");
		$("#yjcpty").removeClass("selection");
		$("#yjcpsh").addClass("selection");
		$("#yjcpsg").removeClass("selection");		
		$("#yjcp1").css("display","none");
		$("#yjcp2").css("display","none");
		$("#yjcp3").css("display","none");
		$("#yjcp4").css("display","block");
		$("#yjcp5").css("display","none");		
	});
	$("#yjcpsg a").click(function(){
		$("#yjcpzr").removeClass("selection");
		$("#yjcpgg").removeClass("selection");
		$("#yjcpty").removeClass("selection");
		$("#yjcpsh").removeClass("selection");
		$("#yjcpsg").addClass("selection");		
		$("#yjcp1").css("display","none");
		$("#yjcp2").css("display","none");
		$("#yjcp3").css("display","none");
		$("#yjcp4").css("display","none");
		$("#yjcp5").css("display","block");		
	});
	
	$("#yjqy1").css("display","block");
	$("#yjqyzr a").click(function(){
		$("#yjqyzr").addClass("selection");
		$("#yjqygg").removeClass("selection");
		$("#yjqyty").removeClass("selection");
		$("#yjqysh").removeClass("selection");
		$("#yjqysg").removeClass("selection");
		$("#yjqy1").css("display","block");
		$("#yjqy2").css("display","none");
		$("#yjqy3").css("display","none");
		$("#yjqy4").css("display","none");
		$("#yjqy5").css("display","none");
	});
	$("#yjqygg a").click(function(){
		$("#yjqyzr").removeClass("selection");
		$("#yjqygg").addClass("selection");
		$("#yjqyty").removeClass("selection");
		$("#yjqysh").removeClass("selection");
		$("#yjqysg").removeClass("selection");
		$("#yjqy1").css("display","none");
		$("#yjqy2").css("display","block");
		$("#yjqy3").css("display","none");
		$("#yjqy4").css("display","none");
		$("#yjqy5").css("display","none");
	});
	$("#yjqyty a").click(function(){
		$("#yjqyzr").removeClass("selection");
		$("#yjqygg").removeClass("selection");
		$("#yjqyty").addClass("selection");
		$("#yjqysh").removeClass("selection");
		$("#yjqysg").removeClass("selection");
		$("#yjqy1").css("display","none");
		$("#yjqy2").css("display","none");
		$("#yjqy3").css("display","block");
		$("#yjqy4").css("display","none");
		$("#yjqy5").css("display","none");
	});
	$("#yjqysh a").click(function(){
		$("#yjqyzr").removeClass("selection");
		$("#yjqygg").removeClass("selection");
		$("#yjqyty").removeClass("selection");
		$("#yjqysh").addClass("selection");
		$("#yjqysg").removeClass("selection");		
		$("#yjqy1").css("display","none");
		$("#yjqy2").css("display","none");
		$("#yjqy3").css("display","none");
		$("#yjqy4").css("display","block");
		$("#yjqy5").css("display","none");		
	});
	$("#yjqysg a").click(function(){
		$("#yjqyzr").removeClass("selection");
		$("#yjqygg").removeClass("selection");
		$("#yjqyty").removeClass("selection");
		$("#yjqysh").removeClass("selection");
		$("#yjqysg").addClass("selection");		
		$("#yjqy1").css("display","none");
		$("#yjqy2").css("display","none");
		$("#yjqy3").css("display","none");
		$("#yjqy4").css("display","none");
		$("#yjqy5").css("display","block");		
	});
	
/**************应急管理ngoGL*****************************************/
	$("#yjya1").css("display","block");
	$("#yjyazt a").click(function(){
		$("#yjyazt").addClass("selection");
		$("#yjyazx").removeClass("selection");
		$("#yjyabm").removeClass("selection");
		$("#yjyadf").removeClass("selection");
		$("#yjya1").css("display","block");
		$("#yjya2").css("display","none");
		$("#yjya3").css("display","none");
		$("#yjya4").css("display","none");
	});
	$("#yjyazx a").click(function(){
		$("#yjyazt").removeClass("selection");
		$("#yjyazx").addClass("selection");
		$("#yjyabm").removeClass("selection");
		$("#yjyadf").removeClass("selection");
		$("#yjya1").css("display","none");
		$("#yjya2").css("display","block");
		$("#yjya3").css("display","none");
		$("#yjya4").css("display","none");
	});
	$("#yjyabm a").click(function(){
		$("#yjyazt").removeClass("selection");
		$("#yjyazx").removeClass("selection");
		$("#yjyabm").addClass("selection");
		$("#yjyadf").removeClass("selection");
		$("#yjya1").css("display","none");
		$("#yjya2").css("display","none");
		$("#yjya3").css("display","block");
		$("#yjya4").css("display","none");
	});
	$("#yjyadf a").click(function(){
		$("#yjyazt").removeClass("selection");
		$("#yjyazx").removeClass("selection");
		$("#yjyabm").removeClass("selection");
		$("#yjyadf").addClass("selection");
		$("#yjya1").css("display","none");
		$("#yjya2").css("display","none");
		$("#yjya3").css("display","none");
		$("#yjya4").css("display","block");
	});
	$("#flfg1").css("display","block");
	$("#flfggg a").click(function(){
		$("#flfggg").addClass("selection");
		$("#flfgsh").removeClass("selection");
		$("#flfgzr").removeClass("selection");
		$("#flfgsg").removeClass("selection");
		$("#flfg1").css("display","block");
		$("#flfg2").css("display","none");
		$("#flfg3").css("display","none");
		$("#flfg4").css("display","none");
	});
	$("#flfgsh a").click(function(){
		$("#flfggg").removeClass("selection");
		$("#flfgsh").addClass("selection");
		$("#flfgzr").removeClass("selection");
		$("#flfgsg").removeClass("selection");
		$("#flfg1").css("display","none");
		$("#flfg2").css("display","block");
		$("#flfg3").css("display","none");
		$("#flfg4").css("display","none");
	});
	$("#flfgzr a").click(function(){
		$("#flfggg").removeClass("selection");
		$("#flfgsh").removeClass("selection");
		$("#flfgzr").addClass("selection");
		$("#flfgsg").removeClass("selection");
		$("#flfg1").css("display","none");
		$("#flfg2").css("display","none");
		$("#flfg3").css("display","block");
		$("#flfg4").css("display","none");
	});
	$("#flfgsg a").click(function(){
		$("#flfggg").removeClass("selection");
		$("#flfgsh").removeClass("selection");
		$("#flfgzr").removeClass("selection");
		$("#flfgsg").addClass("selection");
		$("#flfg1").css("display","none");
		$("#flfg2").css("display","none");
		$("#flfg3").css("display","none");
		$("#flfg4").css("display","block");
	});

/*************首页会员登录后**********************/
	var userId = GetCookie('userId') ;
	var userName = GetCookie('userName');
	if(userName){
		$("#logoin").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>");
	}
	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;
	}
	
	$("#closeLogin").click(function(){
		ClearCookie('userName') ;
		window.location.reload();
	
	});
	
	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();
	}
/************除首页的会员登录**********************/
	if (userName) {
		$("#logonBar2").html("<font style=\"color:#023D8C;font-weight:bold;\">"+userName+"</font>您好！亚洲应急科学管理协会欢迎您。&nbsp;&nbsp;【<a href=\"\" onClick=\"logoff()\">退出</a>】 | <a href=\"aesma_myhome.php\">我的账户</a>");
	} else {
		$("#logonBar2").html("<form name=loginForm id=loginForm method=post >用户名：<input name=\"userName\" type=\"text\" size=\"15\" />&nbsp;&nbsp;密码：<input name=\"password\" type=\"password\" size=\"15\" />&nbsp;<img src=\"images/aesma_ngo/denglv.jpg\" onClick=\"loginPost();\"/>&nbsp;<a href=\"#\" onclick=\"loginWin();\">新用户注册</a> <a href=\"#\" onClick=\"showGetPassword()\">忘了密码？</a></form>");
	}		
/*************aesma_ngoPD_commentsList.php答疑解惑*************************************/	
	if(userName){
		$("#NnameCom").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 {
		$("#NnameCom").html("<div style=\"width:100%;height:31;float:left;text-align:center;\" class=\"comments\"><font style=\"font-weight:bold;\">如需提问，请先<font style=\"color:#023D8C;font-weight:bold;\">登陆</font>。</font></div>");
	}
	
});
/**********************************************************************************************************************************************/

/**************首页登录***********************************************/
	function loginlog(){
		var loginlog;
		var loginForm = document.getElementById('loginForm') ;
		if ( loginForm.userName ) loginlog += "&userName="+encodeURIComponent(loginForm.userName.value) ;
		if ( loginForm.password ) loginlog += "&password="+encodeURIComponent(loginForm.password.value) ;
		if ( loginForm.checkboxJ ) loginlog += "&checkboxJ="+encodeURIComponent(loginForm.checkboxJ.checked) ;
		return loginlog;
	}
	function loginPost(){
		$.ajax({
			type:"POST",
			url:"setLogin.php",
			data:loginlog(),
			success:function(data){
				alert (decodeURI(data));
				if(data=="登陆成功！"){
					window.location.reload();
				}	
	
			}
		});
	}	

/*****************首页注册*********************************************************/
function loginWin() {
	$("#bgblack").css({"height":$(document).height(),"opacity":"0.7","display":"block"});
	$("#loginBox").fadeIn("slow",function(){$(this).css({"left":($(window).width()/2-300>20?$(window).width()/2-300:20),"top":($(window).height()/2-270>30?$(window).height()/2-270:30),"display":"block"});});
}
function closeLoginWin() {
	$("#bgblack").css("display","none");
	$("#loginBox").fadeOut("slow",function(){$(this).css("display","none");});
}

function createLogin(){
	var card = $("input:checked").attr("value");
	var createLogin;
	var createLoginForm = document.getElementById('createLoginForm') ;
	if ( createLoginForm.userName ) createLogin += "&userName="+encodeURIComponent(createLoginForm.userName.value) ;
	if ( createLoginForm.name ) createLogin += "&name="+encodeURIComponent(createLoginForm.name.value) ;
	createLogin += "&sex="+card ;
	if ( createLoginForm.work ) createLogin += "&work="+encodeURIComponent(createLoginForm.work.value) ;
	if ( createLoginForm.contact ) createLogin += "&contact="+encodeURIComponent(createLoginForm.contact.value) ;
	if ( createLoginForm.address ) createLogin += "&address="+encodeURIComponent(createLoginForm.address.value) ;
	if ( createLoginForm.email ) createLogin += "&email="+encodeURIComponent(createLoginForm.email.value) ;
	if ( createLoginForm.password ) createLogin += "&password="+encodeURIComponent(createLoginForm.password.value) ;
	if ( createLoginForm.checkCode ) createLogin += "&checkCode="+encodeURIComponent(createLoginForm.checkCode.value) ;
	return createLogin;
}
function createLoginPost(){
	var P1=$("#confirmPassword").attr("value");
	var P2=$("#password").attr("value");
	if(P1 != P2) {return alert("2次输入的密码不一致。");}
	$.ajax({
		type:"POST",
		url:"setCreateLogin.php",
		data:createLogin(),
		success:function(data){
			alert (decodeURI(data));
			if(data=="注册成功！"){
				$("#bgblack").css("display","none");
				$("#loginBox").fadeOut("slow",function(){$(this).css("display","none");});
				window.location.reload();
			}
		}
	});
}




/*******时间显示********************************/
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 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;">如需提问，请先<font style="color:#023D8C;font-weight:bold;">登陆</font>。</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 ><tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="29%" height="26" align="right">用户名：</td><td width="61%" height="26"><input name="mName" type="text" size="18" /></td><td width="10%" height="26">&nbsp;</td></tr><tr><td height="26" align="right">密&nbsp;&nbsp;码：</td><td height="26"><input type="password" name="mPassword" size="18" /></td><td height="26">&nbsp;</td></tr><tr><td height="30">&nbsp;</td><td height="30"><input type="checkbox" name="checkboxJ"/>记住登录&nbsp;<img src="images/aesma_ngo/denglv.jpg" onClick="logon(mName.value,mPassword.value,checkboxJ.checked)"/></td><td height="30">&nbsp;</td></tr></table></td></tr><tr><td><div class="loginGest"><a href="#" onclick="showRegister()">新用户注册</a> <a href="#" onClick="showGetPassword()">忘了密码？</a></div></td></tr></form>';
	}
	document.getElementById("logonBar").innerHTML = html ; //+ "<div class=\"right_gray\"><a>介绍好友得积分</a> | <a onClick=\"window.external.AddFavorite(window.location,document.title);\" >收藏本站</a></div>" ;
}
function logonBar2()
{
	var userId = GetCookie('userId') ;
	var userName = GetCookie('userName') ;
//	alert( document.cookie) ;
	var html = null ;
	if ( userId && userName  ) {
		html = '<font style="color:#023D8C;font-weight:bold;">'+userName+'</font>您好！亚洲应急科学管理协会欢迎您。&nbsp;&nbsp;【<a href="" onClick="logoff()">退出</a>】 | <a href="aesma_myhome.php">我的账户</a>' ;
	} else {
		html = '<form name=mumber action=\'\' method=post >用户名：<input name="mName" type="text" size="15" />&nbsp;&nbsp;密码：<input name="mPassword" type="password" size="15" />&nbsp;<input type="image" name="imageField" src="images/aesma_ngo/denglv.jpg" onClick="logon(mName.value,mPassword.value)"/>&nbsp;<a href="#" onclick="showRegister()">新用户注册</a> <a href="#" onClick="showGetPassword()">忘了密码？</a></form>';
	}
	document.getElementById("logonBar2").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;
}


