//
//FIleName
//	js_DR.js
//
//Function
//	医薬品検索画面のJavascript
//
//Arge
//	
//
//Return
//	
//
//Version
//	2002/03/04
//	2003/04/28	副作用一覧表示関数を追加
//
//検索条件候補一覧画面をだす（アカサタナ版）
function showItiran(intFlg,textbox,namecol,sortcol,table,namecol2,table2,numcol){
	var newWin;
	newWin=window.open("asp_showItiran.asp?hidNumFlg="+[intFlg]+"&hidTabFlg=0&hidtextBox="+[textbox]+"&hidnameCol="+[namecol]+"&hidsortcol="+[sortcol]+"&hiddbTB="+[table]+"&hidnameCol2="+[namecol2]+"&hiddbTB2="+[table2]+"&hidnumberCol="+[numcol],[textbox],"location=no,menubar=no,dependent=yes,width=400,height=300,scrollbars=yes,resizable=yes");
}
//検索条件候補一覧画面を出す
function showItiran2(textbox,namecol,table,codecol){
	var newWin;
	newWin=window.open("asp_showItiran2.asp?qtextBox="+[textbox]+"&qnameCol="+[namecol]+"&qdbTB="+[table]+"&qcodeCol="+[codecol],[textbox],"location=no,menubar=no,dependent=yes,width=430,height=220,scrollbars=yes,resizable=yes");
}
//薬効検索画面をだす
function selectYakukou(){
	var newWin;
	newWin = window.open("asp_selectEffect.asp","selectY","location=no,menubar=no,dependent=yes,width=410,height=310,scrollbars=yes,resizable=yes");
}
//検索する
function kensaku(){
	var strS = "0000/00/00";
	var strE = "9999/99/99";
	var str2S = "0000/00/00";
	var str2E = "9999/99/99";
	document.forms[0].hidKensakuFlg.value=1;
	document.forms[0].action="asp_dbDR_idx.asp";

	//2003/05.29 現地で追加	更新情報をサーバに送り返さないように設定する oomura
	document.forms[0].updateInfoarea.disabled="disabled";

	if(document.forms[0].hidDetailMode.value=="1"){
		var era;
		var year;
		var month;
		var day;
		//承認年月日S
		era = document.forms[0].eraS[document.forms[0].eraS.selectedIndex].value;
		if (document.forms[0].yearS.value!=""&&document.forms[0].yearS.value!=null){
			year=zhchange(document.forms[0].yearS.value);
		}else{year="yy";}
		if(year!=-1&&document.forms[0].monthS.value!=""&&document.forms[0].monthS.value!=null){
			month=zhchange(document.forms[0].monthS.value);
		}else{month="mm";}
		if(year!=-1&&month!=-1&&document.forms[0].dayS.value!=""&&document.forms[0].dayS.value!=null){
			day=zhchange(document.forms[0].dayS.value);
		}else{day="dd";}
		strS=dateCheck(era,year,month,day);
		//承認年月日E
		if(strS!=-1){
			era=document.forms[0].eraE[document.forms[0].eraE.selectedIndex].value;
			if (document.forms[0].yearE.value!=""&&document.forms[0].yearE.value!=null){
				year=zhchange(document.forms[0].yearE.value);
			}else{year="yy";}
			if(year!=-1&&document.forms[0].monthE.value!=""&&document.forms[0].monthE.value!=null){
				month=zhchange(document.forms[0].monthE.value);
			}else{month="mm";}
			if(year!=-1&&month!=-1&&document.forms[0].dayE.value!=""&&document.forms[0].dayE.value!=null){
				day=zhchange(document.forms[0].dayE.value);
			}else{day="dd";}
			strE=dateCheckE(era,year,month,day);
			if(strE!=-1){
				if(strS!="0000/00/00"&&strE!="0000/00/00"){
					if(strS>strE){
						alert("承認年月日（自）は承認年月日（至）より前の日付にしてください");
						strS=-1;
						strE=-1;
						document.forms[0].yearS.focus();
						return;
					}
				}
			}else{
				document.forms[0].yearE.focus();
				return;
			}
		}else{
			document.forms[0].yearS.focus();
			return;
		}
		document.forms[0].hidYearS.value=document.forms[0].yearS.value;
		document.forms[0].hidMonthS.value=document.forms[0].monthS.value;
		document.forms[0].hidDayS.value=document.forms[0].dayS.value;
		document.forms[0].hidYearE.value=document.forms[0].yearE.value;
		document.forms[0].hidMonthE.value=document.forms[0].monthE.value;
		document.forms[0].hidDayE.value=document.forms[0].dayE.value;
		document.forms[0].hidEraS.value = document.forms[0].eraS[document.forms[0].eraS.selectedIndex].value;
		document.forms[0].hidEraE.value = document.forms[0].eraE[document.forms[0].eraE.selectedIndex].value;
		//届出年月日S
		era = document.forms[0].era2S[document.forms[0].era2S.selectedIndex].value;
		if (document.forms[0].year2S.value!=""&&document.forms[0].year2S.value!=null){
			year=zhchange(document.forms[0].year2S.value);
		}else{year="yy";}
		if(year!=-1&&document.forms[0].month2S.value!=""&&document.forms[0].month2S.value!=null){
			month=zhchange(document.forms[0].month2S.value);
		}else{month="mm";}
		if(year!=-1&&month!=-1&&document.forms[0].day2S.value!=""&&document.forms[0].day2S.value!=null){
			day=zhchange(document.forms[0].day2S.value);
		}else{day="dd";}
		str2S=dateCheck(era,year,month,day);
		//届出年月日E
		if(str2S!=-1){
			era=document.forms[0].era2E[document.forms[0].era2E.selectedIndex].value;
			if (document.forms[0].year2E.value!=""&&document.forms[0].year2E.value!=null){
				year=zhchange(document.forms[0].year2E.value);
			}else{year="yy";}
			if(year!=-1&&document.forms[0].month2E.value!=""&&document.forms[0].month2E.value!=null){
				month=zhchange(document.forms[0].month2E.value);
			}else{month="mm";}
			if(year!=-1&&month!=-1&&document.forms[0].day2E.value!=""&&document.forms[0].day2E.value!=null){
				day=zhchange(document.forms[0].day2E.value);
			}else{day="dd";}
			str2E=dateCheckE(era,year,month,day);
			if(str2E!=-1){
				if(str2S!="0000/00/00"&&str2E!="0000/00/00"){
					if(str2S>str2E){
						alert("届出年月日（自）は届出年月日（至）より前の日付にしてください");
						str2S=-1;
						str2E=-1;
						document.forms[0].year2S.focus();
						return;
					}
				}
			}else{
				document.forms[0].year2E.focus();
				return;
			}
		}else{
			document.forms[0].year2S.focus();
			return;
		}
		document.forms[0].hidYear2S.value=document.forms[0].year2S.value;
		document.forms[0].hidMonth2S.value=document.forms[0].month2S.value;
		document.forms[0].hidDay2S.value=document.forms[0].day2S.value;
		document.forms[0].hidYear2E.value=document.forms[0].year2E.value;
		document.forms[0].hidMonth2E.value=document.forms[0].month2E.value;
		document.forms[0].hidDay2E.value=document.forms[0].day2E.value;
		document.forms[0].hidEra2S.value = document.forms[0].era2S[document.forms[0].era2S.selectedIndex].value;
		document.forms[0].hidEra2E.value = document.forms[0].era2E[document.forms[0].era2E.selectedIndex].value;
	}	
	document.forms[0].hidDrug.value=document.forms[0].drug.value;
	document.forms[0].hidMaker.value=document.forms[0].maker.value;
	document.forms[0].hidAnimal.value=document.forms[0].animal.value;
	document.forms[0].hidCompo.value=document.forms[0].compo.value;
	document.forms[0].hidEffect.value=document.forms[0].effect.value;
	if(document.forms[0].hidDetailMode.value=="1"){
		document.forms[0].hidIppan.value=document.forms[0].ippan.value;
		document.forms[0].hidAppdiv.value=document.forms[0].appdiv.value;
		document.forms[0].hidPrepdiv.value=document.forms[0].prepdiv.value;
		document.forms[0].hidFormdiv.value=document.forms[0].formdiv.value;
		document.forms[0].hidRegdiv.value=document.forms[0].regdiv.value;
		document.forms[0].hidAdmroute.value=document.forms[0].admroute.value;
		document.forms[0].hidEffeff.value=document.forms[0].effeff.value;
		document.forms[0].hidDosadm.value=document.forms[0].dosadm.value;
		document.forms[0].hidBiko.value=document.forms[0].biko.value;
		document.forms[0].hidSennin.value=document.forms[0].sennin.value;
		document.forms[0].hidRumdiv.value=document.forms[0].rumdiv[document.forms[0].rumdiv.selectedIndex].value;
		document.forms[0].hidRumname.value=document.forms[0].rumname.value;
		document.forms[0].hidRumanimalname.value=document.forms[0].rumanimalname.value;
		document.forms[0].hidRumorgan.value=document.forms[0].rumorgan.value;
		document.forms[0].hidDateS.value=strS;
		document.forms[0].hidDateE.value=strE;
		document.forms[0].hidDate2S.value=str2S;
		document.forms[0].hidDate2E.value=str2E;
	}else{
		document.forms[0].hidYearS.value="";
		document.forms[0].hidMonthS.value="";
		document.forms[0].hidDayS.value="";
		document.forms[0].hidYearE.value="";
		document.forms[0].hidMonthE.value="";
		document.forms[0].hidDayE.value="";
		document.forms[0].hidYear2S.value="";
		document.forms[0].hidMonth2S.value="";
		document.forms[0].hidDay2S.value="";
		document.forms[0].hidYear2E.value="";
		document.forms[0].hidMonth2E.value="";
		document.forms[0].hidDay2E.value="";
		document.forms[0].hidIppan.value="";
		document.forms[0].hidAppdiv.value="";
		document.forms[0].hidPrepdiv.value="";
		document.forms[0].hidFormdiv.value="";
		document.forms[0].hidRegdiv.value="";
		document.forms[0].hidAdmroute.value="";
		document.forms[0].hidEffeff.value="";
		document.forms[0].hidDosadm.value="";
		document.forms[0].hidBiko.value="";
		document.forms[0].hidSennin.value="";
		document.forms[0].hidRumdiv.value="";
		document.forms[0].hidRumname.value="";
		document.forms[0].hidRumanimalname.value="";
		document.forms[0].hidRumorgan.value="";
		document.forms[0].hidDateS.value="";
		document.forms[0].hidDateE.value="";
		document.forms[0].hidDate2S.value="";
		document.forms[0].hidDate2E.value="";
	}
	if (strS!="-1" && strE!="-1" && str2S!="-1" && str2E!="-1"){
		document.forms[0].submit();
	}else{
		return;
	}
}
//詳細をみせる
function showDetail(code){
	var newWin;
	newWin = window.open("asp_showDetail_DR.asp"+"?argeCode="+code,"dr_"+[code],"width=680,height=500,scrollbars=yes,resizable=yes,menubar=yes,location=no");
}
//副作用一覧をみせる  //20030327
function showSE(code,nameDrug){
	var newWin;
	newWin = window.open("se_list.asp"+"?argeCode="+code+"&argeName="+nameDrug,"se_list_"+[code],"width=680,height=500,scrollbars=yes,resizable=yes,menubar=yes,location=no");
}
//ページを移動する
function movePage(move,now){
	if (move == 0){
		document.forms[0].hidRollPage.value = 1;
	}else if (move == 1){
		document.forms[0].hidRollPage.value = -1;
	}
	document.forms[0].hidKensakuFlg.value = 2;
	document.forms[0].action = "asp_dbDR_idx.asp";
	document.forms[0].submit();
}
//並び替え
function sort_click(col,mode,order){
	document.forms[0].hidSortcol.value = col;
	document.forms[0].hidSortmode.value = mode;
	document.forms[0].hidSortFlg.value=order;
	document.forms[0].action = "asp_dbDR_idx.asp";
	document.forms[0].hidKensakuFlg.value = 1;
	document.forms[0].submit();
}
//検索条件詳細指定
function detailspecify(code){
	document.forms[0].hidDetailMode.value=code;
	document.forms[0].action ="asp_dbDR_idx.asp";
	document.forms[0].hidDetailFlg.value=4;
	
	document.forms[0].submit();
}
//検索条件リセット
function kensaku_reset(){
	document.forms[0].drug.value="";
	document.forms[0].maker.value="";
	document.forms[0].animal.value="";
	document.forms[0].compo.value="";
	document.forms[0].effect.value="";
	if(document.forms[0].hidDetailMode.value=="1"){
		document.forms[0].yearS.value="";
		document.forms[0].monthS.value="";
		document.forms[0].dayS.value="";
		document.forms[0].yearE.value="";
		document.forms[0].monthE.value="";
		document.forms[0].dayE.value="";
		document.forms[0].year2S.value="";
		document.forms[0].month2S.value="";
		document.forms[0].day2S.value="";
		document.forms[0].year2E.value="";
		document.forms[0].month2E.value="";
		document.forms[0].day2E.value="";
		document.forms[0].ippan.value="";
		document.forms[0].appdiv.value="";
		document.forms[0].prepdiv.value="";
		document.forms[0].formdiv.value="";
		document.forms[0].regdiv.value="";
		document.forms[0].admroute.value="";
		document.forms[0].effeff.value="";
		document.forms[0].dosadm.value="";
		document.forms[0].biko.value="";
		document.forms[0].sennin.value="";
		document.forms[0].rumdiv.value="0";
		document.forms[0].rumname.value="";
		document.forms[0].rumanimalname.value="";
		document.forms[0].rumorgan.value="";
	}
}
//テキストエリアが改変されたら
function input_change(tagname){
	var strtag = "hid" + tagname + "CodeF";
	if (document.forms[0].elements[strtag].value == "1"){
		document.forms[0].elements[strtag].value = "0";
	}
	return;
}