﻿loginBOX = new function(){
	this.clearForm	= function(){
		if(window.document.loginform.userID.value.match(/[^\x01-\x7E]/)){
			window.document.loginform.userID.value	= '';
		}else{
		}
	}
	
	this.makeLoginForm	= (function(){
		var	_RETURN_URL	= '/';
		var	_SIZE	= 230;
		var _HTML='<FORM name="loginform" method="post" action="https://www.sourcenext.com/users/action/login">\
		<INPUT type="hidden" name="location" value="@@/returnURL/@@" />\
		<INPUT type="hidden" name="mail" value="" />\
		<INPUT type="hidden" name="head" value="" />\
		<INPUT type="hidden" name="tail" value="" />\
		<INPUT type="hidden" name="backflg" value="" />\
		<INPUT type="hidden" name="zenrinId" value="" />\
		<div><input type="text" ID="userID" name="userID" maxlength="128" value="" style="width:@@/SIZE/@@px; margin:5px auto;" onclick="void(loginBOX.chkLoginForm1(true));" onfocus="loginBOX.chkLoginForm1(true)" onblur="loginBOX.chkLoginForm1()" /></div>\
		<div><INPUT type="password" ID="passwd" name="passwd" maxlength="16" style="width:@@/SIZE/@@px; margin:5px auto; display:none;" onblur="loginBOX.setPass(false);" />\
		<INPUT type="text" ID="_passwd_" name="_passwd_" maxlength="16" style="width:@@/SIZE/@@px; margin:5px auto; color:#999" value="パスワード（英数半角4～16文字）" onfocus="loginBOX.setPass(true);" onclick="loginBOX.setPass(true);" /></div>\
		<!--p class="kome">※メールアドレスもユーザーIDとしてご使用いただけます。 </p-->\
		<div onClick="loginBOX.clearForm();">@@/BTN/@@</div>\
		</FORM>';
		var _BTN	='<INPUT type="IMAGE" name="" src="/img/common/btn_mylogin.gif" width="110" height="28" border="0" alt="ログイン" title="ログイン" />';
		return function(_returnURL,_btn,_method,size){
			_RETURN_URL	=(_returnURL)?	_returnURL:_RETURN_URL;
			_SIZE	=(size)?	size:_SIZE;
			_BTN		=(_btn)?		_btn:_BTN;
			_HTML	= _HTML.replace(/@@\/returnURL\/@@/g,_RETURN_URL);
			_HTML	= _HTML.replace(/@@\/BTN\/@@/g,_BTN);
			_HTML	= _HTML.replace(/@@\/SIZE\/@@/g,_SIZE);
			if(_method=='return'){
				return	_HTML;
			}else{
				document.write(_HTML);
				this.chkLoginForm1();
			}
			this.chkLoginForm1();
		};
	})();

	this.chkLoginForm1	=(function(){
		var _userID		= 'メールアドレス（ユーザーID）';
		var _colorOFF	= '#999';
		var _colorON	= '#000';
		return	function(_chk,_obj){
			if(_chk){
				if($('userID').value==''||$('userID').value==_userID){
					$('userID').value		='';
					$('userID').style.color	=_colorON;
				}
			}else{
				if($('userID').value==''||$('userID').value==_userID){
					$('userID').value		=_userID;
					$('userID').style.color	=_colorOFF;
				}else{
					$('userID').style.color	=_colorON;
				}
			}
		};
	})();

	this.setPass	=(function(){
		return function(tgl){
			if(tgl){
				$('_passwd_').style.display='none';
				$('passwd').style.display='inline';
				$('passwd').focus();
			}else{
				if($('passwd').value==""){
					$('_passwd_').style.display='inline';
					$('passwd').style.display='none';
				}
			}
		};
	})();
}

