﻿function showsubmenu(sid)
{
	whichEl = eval("submenu" + sid);
	if (whichEl.style.display == "none")
	{
		eval("submenu" + sid + ".style.display=\"\";");
	}
	else
	{
		eval("submenu" + sid + ".style.display=\"none\";");
	}
}

//设默认按钮
function document.onkeydown()     
{
  var e=event.srcElement;
  //判断是否按下回车键
  if(event.keyCode==13)
  {
	  //搜索焦点
	  if ((e==document.getElementById("Top_Search_Key")) ||(e==document.getElementById("Top_Search_Field")))
	  {
		  if (document.getElementById("Top_Search_Btn")!=null)
		  {
			  ChkSearch();
			  document.getElementById("Top_Search_Btn").click();
			  return false;
		  }
	  }
	  
	  //登录焦点
	  if ((e==document.getElementById("Login_UserID")) ||(e==document.getElementById("Login_Password")) || (e==document.getElementById("Login_CodeStr")))
	  {
		  if (document.getElementById("Login_Login")!=null)
		  {
			  ChkLogin();
			  document.getElementById("Login_Login").click();
			  return false;
		  }
	  }
	  
	  //注册焦点
	  if ((document.getElementById("UserID")!=null) && (document.getElementById("QuestionID")!=null)) //判断用户ID控件是否存在，存在则判断为注册页面
	  {
		  if (document.getElementById("Add_Btn")!=null)
		  {
			  ChkCompany(document.getElementById("form1"));
			  document.getElementById("Add_Btn").click();
			  return false;
		  }
	  }
	  
	  //登录焦点/会员区
	  if ((e==document.getElementById("UserID")) ||(e==document.getElementById("Password")) || (e==document.getElementById("CodeStr")))
	  {
		  if (document.getElementById("Login")!=null)
		  {
			  ChkMLogin();
			  document.getElementById("Login").click();
			  return false;
		  }
	  }
  }
}

//检测用户登录
function ChkLogin()
{
	if (document.getElementById("Login_UserID").value=="")
	{
		alert("请输入登录帐号！");
		document.getElementById("Login_UserID").focus();
		return false;
	}
	
	if (document.getElementById("Login_Password").value=="")
	{
		alert("请输入登录帐号密码！");
		document.getElementById("Login_Password").focus();
		return false;
	}
	
	if (document.getElementById("Login_CodeStr").value=="")
	{
		alert("请填写验证码！");
		document.getElementById("Login_CodeStr").focus();
		return false;
	}
}


//检测登录/会员区
function ChkMLogin()
{
	if (document.getElementById("UserID").value=="")
	{
		alert("请输入登录帐号！");
		document.getElementById("UserID").focus();
		return false;
	}
	
	if (document.getElementById("Password").value=="")
	{
		alert("请输入登录帐号密码！");
		document.getElementById("Password").focus();
		return false;
	}
	
	if (document.getElementById("CodeStr").value=="")
	{
		alert("请填写验证码！");
		document.getElementById("CodeStr").focus();
		return false;
	}
}

//检测搜索关键字
function ChkSearch()
{
	if (document.getElementById("Top_Search_Key").value=="")
	{
		alert("请输入查询关键字！");
		document.getElementById("Top_Search_Key").focus();
		return false;
	}
}

//检测企业用户录入/编辑字段
function ChkCompany(form)
{
	Hidden();
	if (XMLEncode(form.UserID)=="")
	{
		alert("请填写用户登录ID！");
		SetFocus(form.UserID);
		Show();
		return false;
	}
	
	if(!userid_re.test(form.UserID.value))
	{
		alert("用户登录ID格式错误，用户名应该由不区分大小写“a-z 0-9 ._-”字符组成！");
		SetFocus(form.UserID);
		Show();
		return false;
	}
	
	if (form.UserID.value.length<6 || form.UserID.value.length>18 )
	{
		alert("用户ID长度必须介于 6-18个字符之间！");
		SetFocus(form.UserID);
		Show();
		return false;
	}
	
	if (XMLEncode(form.Password)=="")
	{
		alert("请填写用户登录密码！");
		SetFocus(form.Password);
		Show();
		return false;
	}
	
	if (XMLEncode(form.ChkPwd)=="")
	{
		alert("请再次输入登录密码进行确认！");
		SetFocus(form.ChkPwd);
		Show();
		return false;
	}
	
	if (XMLEncode(form.ChkPwd)!=XMLEncode(form.Password))
	{
		alert("两次密码不一致，请重新输入！");
		SetFocus(form.Password);
		Show();
		return false;
	}
	
	if (form.QuestionID.value!="0")
	{
		if (XMLEncode(form.Answer)=="")
		{
			alert("请填写密码提示问题！");
			SetFocus(form.Answer);
			Show();
			return false;
		}
	}
	
	if (XMLEncode(form.E_Mail)=="")
	{
		alert("邮箱地址不能为空！请重新填写！");
		SetFocus(form.E_Mail);
		Show();
		return false;
	}
	
	if (XMLEncode(form.Person)=="")
	{
		alert("请填写联系人姓名！");
		SetFocus(form.Person);
		Show();
		return false;
	}
	
	if (XMLEncode(form.Phone)=="")
	{
		alert("请填写联系电话！");
		SetFocus(form.Phone);
		Show();
		return false;
	}
//	else
//	{
//		if(!phone_reg.test(form.Phone))
//		{
//		alert("联系电话格式错误！请重新填写！");
//		SetFocus(form.Phone);
//		Show();
//		return false;
//		}
//	}
	
	if (XMLEncode(form.Fax)=="")
	{
		alert("请填写公司传真号码！");
		SetFocus(form.Fax);
		Show();
		return false;
	}
	
//	else
//	{
//		if(!phone_reg.test(form.Fax))
//		{
//		alert("传真号码格式出错！请重新填写！");
//		SetFocus(form.Fax);
//		Show();
//		return false;
//		}
//	}
	
	if (XMLEncode(form.City)=="")
	{
		alert("请选择公司所在地区！");
		form.Province.focus();
		Show();
		return false;
	}
	
	if (XMLEncode(form.Address)=="")
	{
		alert("请填写公司详细地址！");
		SetFocus(form.Address);
		Show();
		return false;
	}
	
	if (XMLEncode(form.Company)=="")
	{
		alert("请填写公司名称！");
		SetFocus(form.Company);
		Show();
		return false;
	}
	
	if (form.BeLongID.value=="")
	{
		alert("请选择公司行业！");
		form.BeLongID.focus();
		Show();
		return false;
	}
	
	if (form.Employee_Num.value=="")
	{
		alert("请选择公司规模！");
		form.Employee_Num.focus();
		Show();
		return false;
	}
	
	if (XMLEncode(form.Busi_Scope)=="")
	{
		alert("请填写公司主营业务！");
		SetFocus(form.Busi_Scope);
		Show();
		return false;
	}

	return false;
}
