function keyCode(e){
	if(document.all)
		return  e.keyCode;
	else if(document.getElementById)
		return (e.keyCode)? e.keyCode: e.charCode;
	else if(document.layers)
		return  e.which;
}

function windowOpen(link){
	window.open(link,"policy","width=700,height=500,left=60,top=40,toolbar=no,location=no,directories=0,status=1,menubar=no,scrollbars=1,resizable=1");
}

function windowOpen2(form, value, link, action){
	var submitValue = document.forms[form].submitValue;
	submitValue.value = value;

	obj = window.open("","popup","width=700,height=500,left=60,top=40,toolbar=no,location=no,directories=0,status=1,menubar=no,scrollbars=1,resizable=1");
	document.forms[form].target = "popup"; // フォームのターゲットをポップアップ先にする
	document.forms[form].action = link; // アクションURLの指定
	obj.focus(); // ポップアップ先をフォーカス
	document.forms[form].submit(); // 送信する
	document.forms[form].action = action;
	document.forms[form].target = "";
}

function windowOpen3(form, value, link, action){
	var submitValue = document.forms[form].submitValue;
	submitValue.value = value;

	obj = window.open("","popup2","width=900,height=500,left=60,top=40,toolbar=no,location=no,directories=0,status=1,menubar=no,scrollbars=1,resizable=1");
	document.forms[form].target = "popup2"; // フォームのターゲットをポップアップ先にする
	document.forms[form].action = link; // アクションURLの指定
	obj.focus(); // ポップアップ先をフォーカス
	document.forms[form].submit(); // 送信する
	document.forms[form].action = action;
	document.forms[form].target = "";
}

function setChangeColor(obj,num) {
	switch (num) {
	case 0: //onBlur
		obj.style.backgroundColor = "#ffffff";
		break;
	case 1: //onFocus
		obj.style.backgroundColor = "#bbffbb";
		break;
	}
}



function submitType(form, type, value){

	var submitFlg = document.forms[form].submitFlg;
	var submitValue = document.forms[form].submitValue;

	submitFlg.value = type;
	submitValue.value = value;
	document.forms[form].submit();
}

function chDisabled(value,ch){
	var obj=document.all && document.all(ch) || document.getElementById && document.getElementById(ch);
	if(obj && obj.style){
		if(value == '9999999999'){
			obj.disabled = true;
		} else {
			obj.disabled = false;
		}
	}
}

function loadImage(imgId){
	//ターゲットを読み込み中画像に差し替える
	var targetImg = document.getElementById(imgId);
	targetImg.style.visibility = "visible";
}

function changeValue(object1,id){
	var object2 = document.getElementById(id);
	object2.value = object1.value;
}

function disableButton(b,flg,disableFlg){
	if (b == null || b == ""){
		return;
	}
	if (disableFlg == undefined) {
		disableFlg = false;
	}

	if (disableFlg){
		b.disabled = true;
	}


	var submitFlg = b.form.submitFlg;
	submitFlg.value = flg

	b.form.submit();

}


function crateYMD(iYearObj, iMonthObj, iDayObj, yearRange){
	iYearObj = document.getElementById(iYearObj);
	iMonthObj = document.getElementById(iMonthObj);
	iDayObj = document.getElementById(iDayObj);

	if (iYearObj == null || iMonthObj == null || iDayObj == null){
		return;
	}

	getYear(iYearObj, yearRange);
	getMonth(iMonthObj);
	changeDay(iYearObj.value, iMonthObj.value, iDayObj);

}

function changeDate(iYearObj, iMonthObj, iDayObj){
	iYearObj = document.getElementById(iYearObj);
	iMonthObj = document.getElementById(iMonthObj);
	iDayObj = document.getElementById(iDayObj);

	changeDay(iYearObj.value, iMonthObj.value, iDayObj);

}

function changeDay(iYear, iMonth, iDayObj){
	value = iDayObj.value;
	var day = getDaysInMonth(iYear, iMonth);
	iDayObj.options.length = 0;
	iDayObj.options[0] = new Option( "--", "" );
	for( i=1; i<=day; i++ ){
		woption = new Option( i, i );
		iDayObj.options[i] = woption;
		if (value == i){
			iDayObj.options[i].selected = true;
		}
	}
}

function getDaysInMonth(iYear, iMonth){
	var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	if ( ((iYear % 4 == 0) && (iYear % 100 != 0)) || (iYear % 400 == 0) ){
		daysInMonth[1] = 29;
	}
	return daysInMonth[iMonth - 1];
}

function getYear(iYearObj, yearRange){
	nowYear = new Date().getYear();
	nowYear4 = (nowYear < 2000) ? nowYear+1900 : nowYear ;
	value = iYearObj.value;
	iYearObj.options[0] = new Option( "--", "" );
	for( i = (nowYear4 - yearRange); i<=nowYear4 - yearRange + 45; i++ ){
		woption = new Option( i, i );
		iYearObj.options[i - (nowYear4 - yearRange) + 1] = woption;
		if (value == i)
		{
			iYearObj.options[i - (nowYear4 - yearRange) + 1].selected = true;
		}
	}
}

function getMonth(iMonthObj){
	value = iMonthObj.value;
	iMonthObj.options[0] = new Option( "--", "" );
	for( i = 1; i<=12; i++ ){
		woption = new Option( i, i );
		iMonthObj.options[i] = woption;
		if (value == i){
			iMonthObj.options[i].selected = true;
		}
	}
}

