STREAMNET.validate={};


function selfFocus(thisForm){
thisForm.user_name.focus();
}

//forgot password
/////////////////////////////////


function forgotValidate12(thisForm)
{

thisForm.user_name.value = trim(thisForm.user_name.value);
thisForm.email.value = trim(thisForm.email.value);

if (isBlank(trim(thisForm.user_name.value))&&(isBlank(trim(thisForm.email.value))))
{
  alert('ユーザ名か電子メールアドレスを入力してください。');
  thisForm.user_name.focus();
  return (false);
}

else if(invalidUserNameNew11(trim(thisForm.user_name.value)))
{
 alert('有効なユーザー名を入力してください。');
 thisForm.user_name.value="";
 thisForm.email.value="";
  thisForm.user_name.focus();
  return (false);
}
//else if( !isBlank(thisForm.email.value) && (thisForm.email.value).indexOf('@')== -1)
else if( !isBlank(thisForm.email.value) && (!isValidEmailId(trim(thisForm.email.value))))
{
 alert('Ｅメールアドレスが無効です。');
 thisForm.email.value="";
  thisForm.email.focus();
  return (false);
}
else
 {
	STREAMNET.validate.checkUser(thisForm);
	 if(thisForm.errMsg.value!=''){
	  return (false);
	  }else{
		return (true);
	  } 
 }
}


/************************************************************************/

STREAMNET.validate.checkUser=function(frm)
{
	
	frm.errMsg.value='';	

var ajaxUserId = trim(frm.user_name.value);
var ajaxEmailId = trim(frm.email.value);
var data="userId="+ajaxUserId+"&emailId="+ajaxEmailId+"&lang=ja&country=JP";
STREAMNET.Ajax.makeRequest("/idrivee/jsp/validateForgotPassUser.jsp",data,false,"POST",STREAMNET.validate.getResponse);
}


STREAMNET.validate.getResponse=function(http_request)
{
 if(http_request.readyState==4)
 {
	if(http_request.status==200)
  {

	 var resp = http_request.responseText;
		
		if(resp.indexOf("fail")!=-1){
		document.getElementById("errMsg").value="fail";
		alert("提供された電子メールアドレスがが不正確です。");

			if(document.form1.user_name.value!=""){
				document.form1.user_name.value="";
				document.form1.email.value="";
				document.form1.user_name.focus();
			}else if(document.form1.email.value!=""){
				document.form1.email.value="";
				document.form1.email.focus();
			}
		}else if(resp.indexOf("success")!=-1){
		}else {	
		document.getElementById("errMsg").value="fail";
		alert("問題がありました。再度実行してください。");
      }
  }
 }
}

/***************************************************************************/

   function invalidUserNameNew11(Str)
 {
	 var alloweduser = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_@.";

	 for(var count = 0; count < Str.length; count++)
	 {
		if(alloweduser.indexOf(Str.substring(count, count + 1)) == -1)
		{
			return(true);
		}
	 }
 }




