// JavaScript Document

/* ログイン*/
function f_login(kind){
	if(kind=="key_jutyu"){
		val=document.frmJutyu.pssJutyu.value;
		if(val==""){
			alert("パスワードを入力して下さい");
		}
		else{
			
			flag=document.frmJutyu.chkJutyu.checked;
			if(flag){
				f_setCookie(kind,val);
			}
			else{
				f_delCookie("key_jutyu");
			}
			window.open(val+".html","sample");
		}
	}
}


function f_calcDay(){
	var day=3600;
	var setDay=new Date();
	setDay.setTime(setDay.getTime()+(day*1000*60*60*24));
	expDay=setDay.toGMTString();
	return(expDay);
}


function f_delCookie(kind){
	if(document.cookie!=""){
		tmpCookie=document.cookie.split(";");
		expireDate=new Date();
		expireDate.setYear(expireDate.getYear()-1);
		for(i=0; i<tmpCookie.length;i++){
			cName=tmpCookie[i].split("=")[0];
			if(cName==kind){
				document.cookie=cName+"=;expires="+expireDate.toGMTString();
			}
		}
	}
}


function f_getCookie(kind){
	var start,end,val;
	var tmp=document.cookie+";";
	var keyposition=tmp.indexOf(kind,0);
	if(keyposition!=-1){
		tmp=tmp.substring(keyposition,tmp.length);
		start=tmp.indexOf("=",0)+1;
		end=tmp.indexOf(";",start);
		val=unescape(tmp.substring(start,end));
		f_setValCheck(kind,val,true);
	}
	else{
		f_setValCheck(kind,"",false);
	}
}


function f_setCookie(kind,val){
	var tmp=kind+"="+escape(val)+";";
	tmp+="expires="+f_calcDay();
	document.cookie=tmp;
	return true;
}


function f_setValCheck(kind,val,boolean){
	if(kind=="key_jutyu"){
		frmJutyu.pssJutyu.value=val;
		frmJutyu.chkJutyu.checked=boolean;
	}
	else if(kind=="key_company"){
		frmCompany.pssCompany.value=val;
		frmCompany.chkCompany.checked=boolean;
	}
	else if(kind=="key_diary"){
		frmDiary.pssDiary.value=val;
		frmDiary.chkDiary.checked=boolean;
	}
}

