// JavaScript Document
var startinfo=0;//判断dwr远程调用是否执行完毕
function UserLogin()
	{
	    var userName = document.getElementById("userName").value;
		var passWord = document.getElementById("passWord").value;
		if(userName=="")
		{
		document.getElementById("userinfo").innerHTML="<font color='red'>请输入用户名</font>";
		document.getElementById("result").innerHTML="<font color='red'>&nbsp;</font>";
		document.getElementById("userName").focus();
		return false;
		}
		else if(passWord=="")
		{
		document.getElementById("userinfo").innerHTML="<font color='red'>&nbsp;</font>";
		document.getElementById("result").innerHTML="<font color='red'>请输入密码</font>";
		document.getElementById("passWord").focus();
		return false;
		}
		CorprationLoginService.CorprationLogin(function(data) {
		     if(data==1)
		     {
		     	CorprationLoginService.setHttpSession(function(data){
		     	//var id="corpId="+data;   	
		     	//var name="userName="+userName; 
		     	//var domain="domain="+".cnmaga.com" ;   	
		     		//document.cookie =id;
		     		//document.cookie =domain;
		     		//document.cookie =name;
		     		//document.cookie =domain;
		     		document.cookie ="corpId="+data+";domain="+".cnmaga.com";
		     		document.cookie ="userName="+userName+";domain="+".cnmaga.com";
		     		//alert("登录成功！");
		     		location.href="member/index.shtml";
		     	});
		     }else if(data==2)
		     {
		       location.href='/register.shtml?action=checkEmail&username='+userName;
		     }
		     else
		     {
		        document.getElementById("result").innerHTML="<font color='red'>&nbsp;</font>";
		     	document.getElementById("result").innerHTML="<font color='red'>登录失败可能您的帐号没有审核或密码错误!</font>";
		     	document.getElementById("passWord").value="";
		     }
		},userName,passWord);
	}
	
	function CookieSub(str)
	{
	
	   var allcookie=document.cookie.split("; ");
	   
	   for(var i=0;i<allcookie.length;i++)
	   {
	   
	     var twocookie=allcookie[i].split("=");
	      if(twocookie[0]==str)
	      {
	       return twocookie[1];
	      }
	   }
	}
	
if(userName=="" || userName==null || corpId=="" || corpId==null)
{
document.writeln("<div class=\"login1\" id=\"logininfo\"  >");
document.writeln("		<p class=\"js\">&nbsp;<\/p>");
document.writeln("		<div><p class=\"man\" align=\"center\">用户名：<input name=\"userName\" id=\"userName\" type=\"text\"  style=\"width:150px;\"  \/><\/p></div>");
document.writeln("		<p class=\"js\" align=\"center\" id=\"userinfo\">&nbsp;<\/p>");
document.writeln("		<div><p class=\"man\" align=\"center\">密&nbsp;&nbsp;码：<input name=\"passWord\" id=\"passWord\" type=\"password\"  style=\"width:150px;\"  \/><\/p></div>");
document.writeln("		<p class=\"js\" align=\"center\" id=\"result\">&nbsp<\/p>");
document.writeln("		<p class=\"js\"><\/p>");
document.writeln("		<p class=\"js\" align=\"center\"><a onclick=\"UserLogin();\" target=\"_blank\" style=\"cursor:pointer\"><img src=\"img\/index\/home_006.gif\" width=\"67\" height=\"26\"  border=\"0\"\/> <\/a><a href=\"http://www.cnmaga.com/register.shtml\" target=\"_blank\">免费注册<\/a><\/p>");
document.writeln("		<p class=\"js1\"><\/p>");
document.writeln("		<p class=\"js1\" align=\"center\" style=\"padding-top:25px;\"><a href=\"forgetpwd.shtml\" target=\"_blank\">忘记密码?<\/a>| <a href=\"help\/index.html\" target=\"_blank\">帮助<\/a><\/p>	");
document.writeln("	");
document.writeln("		<\/div>");
}else
{
//userName="supermhw";
var companyName="<strong>公司名称 : <\/strong>";
var classification="<strong>主营行业 : <\/strong>";
var city="<strong>所在地区 : <\/strong>";

CorprationLoginService.getLoginInfo(function(data){
companyName+=data.companyName;
classification+=data.classification.parentClassification.title+" ";
classification+=data.classification.title;
city+=data.city.name;
startinfo=1;
},userName);
document.writeln("		<div class=\"login\" id=\"logininfo\" >");
document.writeln("		<p class=\"text\"><a href=\"member\/index.shtml\">个人信息<\/a><a onclick=\"javascript:return delCookie();\" style=\"cursor:pointer\" class=\"end\">退出<\/a><\/p>");
document.writeln("		<p class=\"man\">"+userName+"<span>欢迎您！<\/span><\/p>");
document.writeln("		  <p class=\"js\" id=\"companyNameInfo\"><\/p>");
document.writeln("		<p class=\"js\" id=\"cityInfo\"><\/p>");
document.writeln("		<p class=\"js\" id=\"classificationInfo\"><\/p>");
document.writeln("		<p class=\"js\" >&nbsp;<\/p>");
document.writeln("		<\/div>");
}
showUserinfo();
function showUserinfo()
{
if(startinfo==1)
{
document.getElementById("companyNameInfo").innerHTML= companyName+"<br  \/>";
document.getElementById("classificationInfo").innerHTML= classification+"<br  \/>";
document.getElementById("cityInfo").innerHTML= city+"<br  \/>";
}else
{
 setTimeout('showUserinfo()',1);
}
}