//个人和企业登陆，非ajax
//domainName：指定通过哪个域名登陆
//isNormalLogin 1 不用ajax方式登陆,其他值用ajax登陆(教育培训例外)
//isAjax 1:使用一个层并通过ajax登陆,登陆后用ajax提交之前的动作
var isClick=0;
function resetIsClick(){
  isClick=0;	
}
function isAllowClick(){
  if(isClick==0){
    isClick++;
    return true;
  }else{
    return false;	
  }	
}
	
function loginchecknormal(theform,domainName){
//if(areaId=="63") domainName="zs.job001.cn";
if(!isAllowClick()){
  return false;	
}

if(theform.flag[0].checked!=true&&theform.flag[1].checked!=true){
resetIsClick();
alert('请选择会员类型！');
theform.flag[0].focus();
return false;
}
if(theform.name.value==''){
resetIsClick();
alert('请输入账号！');
theform.name.focus();
return false;
}
if(theform.pwd.value==''){
resetIsClick();
alert('请输入密码！');
theform.pwd.focus();
return false;
}

if(theform.flag[0].checked==true){//个人登陆
  url='/channel.do?handle=LoginView_personLogin';
}

if(theform.flag[1].checked==true){//企业登陆
  url='/channel.do?handle=LoginView_companyLogin';
}
//if(domainName!='') url="http://"+domainName+url;

theform.action=url;
theform.submit();
return false;	
}

//个人和企业登陆
//domainName：指定的域名，由于ajax不能跨域访问，目前没用
function logincheck(theform,domainName){
if(!isAllowClick()){
  return false;	
}	
if(theform.flag[0].checked!=true&&theform.flag[1].checked!=true){
resetIsClick();	
alert('请选择会员类型！');
theform.flag[0].focus();
return false;
}
if(theform.name.value==''){
resetIsClick();
alert('请输入账号！');
theform.name.focus();
return false;
}
if(theform.pwd.value==''){
resetIsClick();
alert('请输入密码！');
theform.pwd.focus();
return false;
}

if(theform.flag[0].checked==true){//个人登陆
  url='/channel.do?handle=LoginView_personLogin&name='+escapeParam(theform.name.value)+'&pwd='+escapeParam(theform.pwd.value)+'&url='+theform.url.value+'&isAjax='+getIsAjax(theform);
  runScriptByPOST(url);
  return false;
}

if(theform.flag[1].checked==true){//企业登陆
  url='/channel.do?handle=LoginView_companyLogin&name='+escapeParam(theform.name.value)+'&pwd='+escapeParam(theform.pwd.value)+'&url='+theform.url.value+'&isAjax='+getIsAjax(theform);
  runScriptByPOST(url);
  return false;
}
return false;
}

//首页注册调用
function jumpToReg(theform){
	if(theform.flag[0].checked!=true&&theform.flag[1].checked!=true){
		alert('请选择会员类型！');
		theform.flag[0].focus();
	}
	else {
		if(theform.flag[0].checked==true){
			regPerson();
		}else{
			regCompany();
		}	
	}
}

//跳到个人注册页面
function regPerson(){
	window.open("/director.do?action=jobSeekReg&doFlag=reg_step1");	
}

//跳到企业注册页面
function regCompany(){
   window.open("/director.do?action=companyReg&doFlag=reg_step1");
}

//个人登陆
//domainName：指定的域名，由于ajax不能跨域访问，目前没用
function personLogin(theform,domainName){
if(!isAllowClick()){
  return false;	
}	
if(theform.name.value==''){
resetIsClick();
alert('请输入账号！');
theform.name.focus();
return false;
}
if(theform.pwd.value==''){
resetIsClick();
alert('请输入密码！');
theform.pwd.focus();
return false;
}

var  paramUrl= escapeParam( theform.url.value );
url='/channel.do?handle=LoginView_personLogin&name='+escapeParam(theform.name.value)+'&pwd='+escapeParam(theform.pwd.value)+'&url='+paramUrl+'&isAjax='+getIsAjax(theform);
runScriptByPOST(url);
return false;
}

//个人登陆不对隐藏域的url进行编码，因为已经编码了
//domainName：指定的域名，由于ajax不能跨域访问，目前没用
function personLoginUnEscape(theform,domainName){
if(!isAllowClick()){
  return false;	
}	
if(theform.name.value==''){
resetIsClick();
alert('请输入账号！');
theform.name.focus();
return false;
}
if(theform.pwd.value==''){
resetIsClick();
alert('请输入密码！');
theform.pwd.focus();
return false;
}

var  paramUrl=theform.url.value;
url='/channel.do?handle=LoginView_personLogin&name='+escapeParam(theform.name.value)+'&pwd='+escapeParam(theform.pwd.value)+'&url='+paramUrl+'&isAjax='+getIsAjax(theform);
runScriptByPOST(url);
return false;
}

/**企业登陆不对隐藏域的url进行编码，因为已经编码了
*/
function companyLoginUnEscape(theform,domainName){
if(!isAllowClick()){
  return false;	
}		
if(theform.name.value==''){
  resetIsClick();
  alert('请输入账号！');
  theform.name.focus();
  return false;
}
if(theform.pwd.value==''){
  resetIsClick();	
  alert('请输入密码！');
  theform.pwd.focus();
  return false;
}

var  paramUrl= theform.url.value;
url='/channel.do?handle=LoginView_companyLogin&name='+escapeParam(theform.name.value)+'&pwd='+escapeParam(theform.pwd.value)+
    '&url='+paramUrl+'&isAjax='+getIsAjax(theform);

runScriptByPOST(url);
return false;
}

/**企业登陆
*/
function companyLogin(theform,domainName){
if(!isAllowClick()){
  return false;	
}		
if(theform.name.value==''){
  resetIsClick();	
  alert('请输入账号！');
  theform.name.focus();
  return false;
}
if(theform.pwd.value==''){
  resetIsClick();
  alert('请输入密码！');
  theform.pwd.focus();
  return false;
}

var  paramUrl= escapeParam( theform.url.value );
url='/channel.do?handle=LoginView_companyLogin&name='+escapeParam(theform.name.value)+'&pwd='+escapeParam(theform.pwd.value)+
    '&url='+paramUrl+'&isAjax='+getIsAjax(theform);

runScriptByPOST(url);
return false;
}

/**专场登陆
*/
function companySpecialLogin(theform,domainName){
if(!isAllowClick()){
  return false;	
}		
if(theform.name.value==''){
  resetIsClick();	
  alert('请输入账号！');
  theform.name.focus();
  return false;
}
if(theform.pwd.value==''){
  resetIsClick();
  alert('请输入密码！');
  theform.pwd.focus();
  return false;
}

var  paramUrl= escapeParam( theform.url.value );
url='/channel.do?handle=LoginView_companySpecialLogin&name='+escapeParam(theform.name.value)+'&pwd='+escapeParam(theform.pwd.value)+
    '&url='+paramUrl+'&isAjax='+getIsAjax(theform)+'&specialId=1';

runScriptByPOST(url);
return false;
}

//找回密码（首页--个人和企业）
function foundPassword(theform){
   if(theform.flag[0].checked!=true&&theform.flag[1].checked!=true){
	  alert("请选择会员类型！");
	  theform.flag[0].focus();
	  return;
	}
  var url;
  if(theform.flag[0].checked==true){
	 foundPasswordPerson();
  }
  if(theform.flag[1].checked==true){
	 foundPasswordCompany();
  }
}

//找回密码（企业）
function foundPasswordCompany(){
	 var url = '/channel.do?handle=IndexView_getPwdForm&flag=0';
     window.open(url,'取回密码','width=302,height=176')
}

//找回密码（个人)
function foundPasswordPerson(){
	var url = '/channel.do?handle=IndexView_getPwdForm&flag=1';
     window.open(url,'取回密码','width=302,height=176')
}

//找回密码（教育培训）
function foundPasswordEdu(){
	 var url = '/channel.do?handle=IndexView_getPwdForm&flag=34';  //培训机构
     window.open(url,'取回密码','width=312,height=190')
}
//个人登陆
function loginFindJobPage(){
if(!isAllowClick()){
  return false;	
}		
	
		if(theform.name.value==''){
			  resetIsClick();
			alert('请输入账号！');
			theform.name.focus();
			return false;
		}
		if(theform.pwd.value==''){
			  resetIsClick();
			alert('请输入密码！');
			theform.pwd.focus();
			return false;
		}
  		url='/channel.do?handle=LoginView_personLogin&name='+escapeParam(theform.name.value)+'&pwd='+escapeParam(theform.pwd.value)+'&url='+theform.url.value;
  		runScriptByPOST(url);
  		return false;
	}

/*
//企业登陆(从找人才页面登陆)
function loginFindResumePage(theform){

	if(theform.name.value==''){
		alert('请输入账号！');
		theform.name.focus();
		return false;
	}
	if(theform.pwd.value==''){
		alert('请输入密码！');
		theform.pwd.focus();
		return false;
	}

  	url='/channel.do?handle=LoginView_companyLogin&name='+theform.name.value+'&pwd='+theform.pwd.value+'&url=';
 	runScriptByPOST(url);

  return false;
}
*/
//教育培训登陆
function loginEducatecheck(){
	if(theform.flag[0].checked!=true&&theform.flag[1].checked!=true){
		alert('请选择会员类型！');
		theform.flag[0].focus();
		return false;
		}
		var flag = '';
	if( theform.flag[0].checked==true ) {
			flag =2;
		}
	if( theform.flag[1].checked==true ){
			flag = 3;
		}
	if(theform.name.value==''){
		alert('请输入账号！');
		theform.name.focus();
		return false;
		}
	if(theform.pwd.value==''){
		alert('请输入密码！');
		theform.pwd.focus();
		return false;
		}
	url='/channel.do?handle=LoginView_educateLogin&name='+escapeParam(theform.name.value)+'&pwd='+escapeParam(theform.pwd.value)+'&flag='+flag;
	runScriptByPOST(url);
	return false;
	}
//教育培训注册按钮事件
function educateReg(){
		theform.action='/educate.do?handle=EducateView_regForm'
		theform.target='_blank';
		theform.submit();
	}

//返回登陆后是否使用ajax提交登陆框的url：返回0不使用，直接跳转；1使用ajax提交
function getIsAjax(theform){
   var isAjax=0;//等于1时，登陆完后用ajax提交
   if(theform.isAjax!=null){
      isAjax=theform.isAjax.value;	
   }
   return isAjax;
}

//在密码框或账号框回车进行登陆操作
function input_onkeydown(theform,url){
if (window.event.keyCode==13) {return loginchecknormal(theform,url);}	
}

//在密码框或账号框回车进行登陆操作
function input_onkeydown_Dress(theform,url){
if (window.event.keyCode==13) {return companySpecialLogin(theform,url);}	
}
