// JavaScript Document++++++++++++++++++++++++++++

//HTTP Request
function createXMLHttpRequest() {
   return this.XMLHttpRequest ? 
      new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
}


function httpRequest(target_url,funcitonReference){

	var request = createXMLHttpRequest();

	request.open("GET",target_url,true);
	request.onreadystatechange = function(){
		if (request.readyState == 4) {
			funcitonReference(request.responseText);
		}
	}
	request.send(null);
}

//report

function checkExaminationPrice($mainForm){
	a = $mainForm.owner_school_id;
	b = $mainForm.business_year;
	c = $mainForm.center_division;
	var $c = null;
	for(i = 0; i < c.length; i++){
		if(c[i].checked == true){
			$c = c[i].value;
		}
	}
	if(a.value == ''){
		alert('入学形態を選択して下さい。');
		return false;
	}else if(b.value == ''){
		alert('受験年度を選択して下さい。');
		return false;
	}else if($c == ''){
		alert('入学形態を選択して下さい。');
		return false;
	} 
		var funcRef = function(text){
		document.getElementById("fee").value = text;
	}
	httpRequest('lib/inc/setExamination.php?owner_school_id='+a.value+'&business_year='+b.value+'&center_division='+$c,funcRef);
	
}

function setSelectCente($mainForm,$center_division,$lesson_center_id){
	a = $mainForm.owner_school_id;
		var funcRef = function(text){
		document.getElementById("center_field").innerHTML = text;
	}
	httpRequest('lib/inc/setCenter.php?owner_school_id='+a.value+'&center_division='+$center_division+'&lesson_center_id='+$lesson_center_id,funcRef);
	
}

function setSelectScholarship($mainForm,$scholarship_id){
	a = $mainForm.owner_school_id;
	b = $mainForm.business_year;
		var funcRef = function(text){
		document.getElementById("scholarship_field").innerHTML = text;
	}
	httpRequest('lib/inc/setScholarship.php?owner_school_id='+a.value+'&business_year='+b.value+'&scholarship_id='+$scholarship_id,funcRef);
	
}
function setSelectCampus($mainForm,$campus_id){

	a = $mainForm.owner_school_id;
		var funcRef = function(text){
		document.getElementById("campus_field").innerHTML = text;
	}
	httpRequest('lib/inc/setCampus.php?owner_school_id='+a.value+'&campus_id='+$campus_id,funcRef);
	
}

function setSelectCourse($mainForm,$course_id){
	a = $mainForm.owner_school_id;
		var funcRef = function(text){
		document.getElementById("course_field").innerHTML = text;
	}
	httpRequest('lib/inc/setCourse.php?owner_school_id='+a.value+'&course_id='+$course_id,funcRef);
	
}

function set_branch($bank_id) {
		//処理を実行するための関数リファレンスを定義
		var funcRef = function(text){
			document.getElementById("branch_field").innerHTML = text;
		}
		httpRequest('admin/master/demand/bankBranch/setSelectBranch.php?bank_id='+$bank_id,funcRef);
}
function setSelectCategory($searchForm) {
		a = $searchForm.technical_course_id;
		//処理を実行するための関数リファレンスを定義
		var funcRef = function(text){
			document.getElementById("select_category_field").innerHTML = text;
		}
		httpRequest('admin/lms/report/setSelectCategory.php?technical_course_id='+a.value,funcRef);
}
function setSelectSubject($val,$searchForm,$zissikai) {
		document.getElementById('select_subject_field').style.display='block';
		//処理を実行するための関数リファレンスを定義
		a = $val;
		b = $searchForm.subject_year;
		var funcRef = function(text){
			document.getElementById("select_subject_field").innerHTML = text;
		}
		httpRequest('admin/lms/report/setSelectSubject.php?category_id='+$val+'&subject_year='+b.value + '&zissikai=' + $zissikai,funcRef);
}

function setSelectSubjectForApprove($mainForm) {
		document.getElementById('select_subject_field').style.display='block';
		a = $mainForm.category_id;
		b = $mainForm.education_process_id;
		c = $mainForm.person_id;
		var funcRef = function(text){
			document.getElementById("select_subject_field").innerHTML = text;
		}
		httpRequest('admin/master/publication/subjectPublication/setSelectSubjectForApprove.php?category_id='+a.value+'&education_process_id=' + b.value+ '&person_id=' + c.value,funcRef);
		
}
function setSelectApprove() {
		document.getElementById('select_approve_field').style.display='block';
		a = document.getElementById('subject_id');
		var funcRef = function(text){
			document.getElementById("select_approve_field").innerHTML = text;
		}
		httpRequest('admin/master/publication/subjectPublication/setSelectApprove.php?subject_id='+a.value,funcRef);
}
function setApproveCredit() {

		a = document.getElementById('subject_id');
		b = document.getElementById('approve_id');
		var funcRef = function(text){
			eval(text);
		}
		httpRequest('admin/master/publication/subjectPublication/setApproveCredit.php?credit=document.mainForm.credit&subject_id='+a.value+'&approve_id='+b.value,funcRef);
}
function setSearchSchooling($searchForm) {
		a = $searchForm.business_year;
		b = $searchForm.schooling_id;
		c = $searchForm.schooling_date_id;
		b.value = '';
		c.value = '';
		//処理を実行するための関数リファレンスを定義
		var funcRef = function(text){
			document.getElementById("select_schooling_field").innerHTML = text;
		}
		httpRequest('admin/master/schooling/schooling/setSelectSchooling.php?business_year='+a.value,funcRef);
}
function setSearchSchoolingDate($searchForm) {
		a = $searchForm.schooling_id;
		c = $searchForm.schooling_date_id;
		c.value = '';
		if(a.value > 0){
		//処理を実行するための関数リファレンスを定義
		var funcRef = function(text){
			document.getElementById("schooling_date_field").innerHTML = text;
		}
		httpRequest('admin/master/schooling/schooling/setSelectSchoolingDate.php?schooling_id='+a.value,funcRef);
		}else{
			alert(a.length);
		}
}

function setSelectSubjectForPublication($mainForm) {
		document.getElementById('select_subject_field').style.display='block';
		a = $mainForm.category_id;
		b = $mainForm.education_process_id;
		c = $mainForm.school_id;
		var funcRef = function(text){
			document.getElementById("select_subject_field").innerHTML = text;
		}
		httpRequest('admin/master/publication/subjectPublication/setSelectSubject.php?category_id='+a.value+'&education_process_id=' + b.value,funcRef);
		
}

function setSelectSubjectForPublication2($mainForm) {
		document.getElementById('select_subject_field').style.display='block';
		a = $mainForm.category_id;
		b = $mainForm.education_process_id;
		c = $mainForm.school_id;
		var funcRef = function(text){
			document.getElementById("select_subject_field").innerHTML = text;
		}
		httpRequest('mypage/schedule/setSelectSubject.php?category_id='+a.value+'&education_process_id=' + b.value,funcRef);
		
}
function setSelectPublication($mainForm) {
		document.getElementById('select_publication_field').style.display='block';
		a = $mainForm.publisher_id;
		b = $mainForm.category_id;
		var funcRef = function(text){
			document.getElementById("select_publication_field").innerHTML = text;
		}
		httpRequest('admin/master/publication/subjectPublication/setSelectPublication.php?publisher_id=' + a.value + '&category_id=' + b.value,funcRef);
}

function setSelectSubjectPublication($mainForm) {
		document.getElementById('select_publication_field').style.display='block';
		a = $mainForm.publisher_id;
		b = $mainForm.category_id;
		c = $mainForm.subject_id;
		d = $mainForm.business_year;
		var funcRef = function(text){
			document.getElementById("select_publication_field").innerHTML = text;
		}
		httpRequest('admin/publication/publicationOrder/setSelectSubjectPublication.php?publisher_id=' + a.value + '&category_id=' + b.value + '&subject_id=' + c.value  + '&business_year=' + d.value,funcRef);
}

function setSelectSubjectForOrder($mainForm) {
		document.getElementById('select_subject_field').style.display='block';
		a = $mainForm.category_id;
		b = $mainForm.education_process_id;
		var funcRef = function(text){
			document.getElementById("select_subject_field").innerHTML = text;
		}
		httpRequest('admin/publication/publicationOrder/setSelectSubjectForOrder.php?category_id='+a.value+'&education_process_id=' + b.value,funcRef);
		
}

function setSelectSubject_for_require($val,$searchForm) {
		document.getElementById('select_subject_field').style.display='block';
		//処理を実行するための関数リファレンスを定義
		a = $val;
		b = $searchForm.subject_year;
		var funcRef = function(text){
			document.getElementById("select_subject_field").innerHTML = text;
		}
		httpRequest('admin/master/lesson/subjectRequire/setSelectSubject.php?category_id='+$val+'&subject_year='+b.value,funcRef);
}
function setSelectSubject_for_relate($val) {
		a = $val;
		var funcRef = function(text){
			document.getElementById("select_subject_field").innerHTML = text;
		}
		httpRequest('admin/master/lesson/subjectRelate/setSelectSubject.php?pre_category_id='+$val,funcRef);
}
function setSelectSubject_for_pre_lecture_result($val) {
		a = $val;
		var funcRef = function(text){
			document.getElementById("select_pre_subject_field").innerHTML = text;
		}
		httpRequest('admin/lecture/lectureEntry/setSelectSubject.php?pre_category_id='+a,funcRef);
}
function setSelectSubjectForP($val,$searchForm) {
		document.getElementById('select_subject_field').style.display='block';
		//処理を実行するための関数リファレンスを定義
		a = $val;
		b = $searchForm.subject_year;
		var funcRef = function(text){
			document.getElementById("select_subject_field").innerHTML = text;
		}
		httpRequest('admin/demand/demandRegist/setSelectSubject.php?category_id='+$val+'&subject_year='+b.value,funcRef);
}
function setSelectPublicationForP($val,$mainForm) {
		a = $val;
		b = $mainForm.category_id.value;
		//処理を実行するための関数リファレンスを定義
		var funcRef = function(text){
			document.getElementById("select_publication_field").innerHTML = text;
		}
		httpRequest('admin/demand/demandRegist/setSelectPublication.php?subject_id=' + a + '&category_id='+b,funcRef);
}

function setSelectZissikai($searchForm) {
		document.getElementById('select_number_field').style.display='block';
		//処理を実行するための関数リファレンスを定義
		a = $searchForm.business_year;
		b = $searchForm.subject_id;
		c = $searchForm.entrance_term;
		var funcRef = function(text){
			document.getElementById("select_number_field").innerHTML = text;
		}
		httpRequest('admin/result/reportResult/setZissikai.php?business_year='+ a.value + '&subject_id=' + b.value + '&entrance_term=' + c.value, funcRef);
}
function setSelectSchoolingNumber($val,$mainForm){

		a = $mainForm.business_year.value;
		if(document.getElementById('belong_division1').checked == true){
			b = 1;
			c = 0;
		}else if(document.getElementById('belong_division3').checked == true){
			b = 3;
			c = $val;
		}else if(document.getElementById('belong_division4').checked == true){
			b = 4;
			c = $val;
		}
		//処理を実行するための関数リファレンスを定義
		var funcRef = function(text){
			document.getElementById("select_schooling_id").innerHTML = text;
			
		}
		httpRequest('admin/master/schooling/schoolingSchedule/setSelectSchoolingId.php?business_year='+a+'&belong_division='+b+'&belong_school_id='+c,funcRef);
}
function setSelectSchoolingDate($val){
		//処理を実行するための関数リファレンスを定義
		var funcRef = function(text){
			document.getElementById("select_schooling_date_id").innerHTML = text;
			
		}
		httpRequest('admin/master/schooling/schoolingSchedule/setSelectSchoolingDate.php?schooling_id='+$val,funcRef);
}
function setSelectSchoolingHall($val){
		//処理を実行するための関数リファレンスを定義
		var funcRef = function(text){
			document.getElementById("select_schooling_hall_id").innerHTML = text;
			
		}
		httpRequest('admin/master/schooling/schoolingSchedule/setSelectSchoolingHall.php?schooling_date_id='+$val,funcRef);
}

function setSelectSchooling($val,$searchForm) {
		//処理を実行するための関数リファレンスを定義
		a = $val;
		var funcRef = function(text){
			document.getElementById("select_schooling_field").innerHTML = text;
		}
		httpRequest('admin/variousEntry/schoolingEntry/setSelectSchooling.php?business_year='+a,funcRef);
}
function setSelectSchooling2($val,$searchForm) {
		//処理を実行するための関数リファレンスを定義
		a = $val;
		var funcRef = function(text){
			document.getElementById("select_schooling_field").innerHTML = text;
		}
		httpRequest('admin/variousEntry/schoolingEntry/setSelectSchooling2.php?business_year='+a,funcRef);
}
function setSelectSchooling3($val,$searchForm) {
		//処理を実行するための関数リファレンスを定義
		a = $val;
		var funcRef = function(text){
			document.getElementById("select_schooling_field").innerHTML = text;
		}
		httpRequest('admin/demand/schoolingDemand/setSelectSchooling.php?business_year='+a,funcRef);
}

//期間
function setTerm($person_id,$business_year) {
	//処理を実行するための関数リファレンスを定義
	a = $person_id;
	b = $business_year;
	var funcRef = function(text){
		eval(text);
	}
	httpRequest('admin/student/student/setTerm.php?pos='+ a +'&business_year='+ b +'&start_date=document.mainForm.start_date&end_date=document.mainForm.end_date',funcRef);
}


//郵便番号
function sendPost() {
		if (document.mainForm.zip_cd.value.length >= 7) {
			//処理を実行するための関数リファレンスを定義
			var funcRef = function(text){
				eval(text);
			}
			httpRequest('admin/master/else/zip/setAddr.php?pos='+document.mainForm.zip_cd.value+'&pref=document.mainForm.prefecture_cd&addr1=document.mainForm.address1&addr2=document.mainForm.address2',funcRef);
		}else if (document.mainForm.zip_cd.value.length==0) {
			alert('郵便番号を入力してください。');
			document.mainForm.zip_cd.focus();
		}
}

//郵便番号
function sendPost2() {
		if (document.mainForm.emergency_zip_cd.value.length>=7) {
			//処理を実行するための関数リファレンスを定義
			var funcRef = function(text){
				eval(text);
			}
			httpRequest('admin/master/else/zip/setAddr.php?pos='+document.mainForm.emergency_zip_cd.value+'&pref=document.mainForm.emergency_prefecture_cd&addr1=document.mainForm.emergency_address1&addr2=document.mainForm.emergency_address2',funcRef);
		}else if (document.mainForm.emergency_zip_cd.value.length==0) {
			alert('郵便番号を入力してください。');
			document.mainForm.emergency_zip_cd.focus();
		}
}

//郵便番号
function sendPost3() {
		if (document.mainForm.zip_cd.value.length>=7) {
			//処理を実行するための関数リファレンスを定義
			var funcRef = function(text){
				eval(text);
			}
			httpRequest('admin/master/school/corporation/setAddr.php?pos='+document.mainForm.zip_cd.value+'&pref=document.mainForm.prefecture_cd&addr=document.mainForm.address',funcRef);
		}else if (document.mainForm.zip_cd.value.length==0) {
			alert('郵便番号を入力してください。');
			document.mainForm.zip_cd.focus();
		}
}

//郵便番号
function sendPost10() {
		if (document.mainForm.zip_cd.value.length >= 7) {
			//処理を実行するための関数リファレンスを定義
			var funcRef = function(text){
				eval(text);
			}
			httpRequest('admin/master/else/zip/setAddr.php?pos='+document.mainForm.zip_cd.value+'&pref=document.mainForm.prefecture_cd&addr1=document.mainForm.address',funcRef);
		}else if (document.mainForm.zip_cd.value.length==0) {
			alert('郵便番号を入力してください。');
			document.mainForm.zip_cd.focus();
		}
}
function sendPostParent() {
		if (document.mainForm.parent_zip_cd.value.length >= 7) {
			//処理を実行するための関数リファレンスを定義
			var funcRef = function(text){
				eval(text);
			}
			httpRequest('admin/master/else/zip/setAddr.php?pos='+document.mainForm.parent_zip_cd.value+'&pref=document.mainForm.parent_prefecture_cd&addr1=document.mainForm.parent_address1&addr2=document.mainForm.parent_address2',funcRef);
		}else if (document.mainForm.parent_zip_cd.value.length == 0) {
			alert('郵便番号を入力してください。');
			document.mainForm.parent_zip_cd.focus();
		}
}function sendPostParent2() {
		if (document.mainForm.parent_work_zip_cd.value.length >= 7) {
			//処理を実行するための関数リファレンスを定義
			var funcRef = function(text){
				eval(text);
			}
			httpRequest('admin/master/else/zip/setAddr.php?pos='+document.mainForm.parent_work_zip_cd.value+'&pref=document.mainForm.parent_work_prefecture_cd&addr1=document.mainForm.parent_work_address1&addr2=document.mainForm.parent_work_address2',funcRef);
		}else if (document.mainForm.parent_work_zip_cd.value.length == 0) {
			alert('郵便番号を入力してください。');
			document.mainForm.parent_work_zip_cd.focus();
		}
}
function sendPostPreparatory() {
		if (document.mainForm.preparatory_zip_cd.value.length >= 7) {
			//処理を実行するための関数リファレンスを定義
			var funcRef = function(text){
				eval(text);
			}
			httpRequest('admin/master/else/zip/setAddr.php?pos='+document.mainForm.preparatory_zip_cd.value+'&pref=document.mainForm.preparatory_prefecture_cd&addr1=document.mainForm.preparatory_address1&addr2=document.mainForm.preparatory_address2',funcRef);
		}else if (document.mainForm.preparatory_zip_cd.value.length == 0) {
			alert('郵便番号を入力してください。');
			document.mainForm.preparatory_zip_cd.focus();
		}
}

function setStudentNameSearch($mainForm) {
		a = $mainForm.student_number;
		var funcRef = function(text){
			eval(text);
		}
		httpRequest('admin/publication/publicationOrder/setStudentNameSearch.php?student_number='+a.value,funcRef);
}

function setSelectSchoolingDay($val,$searchForm) {
		//処理を実行するための関数リファレンスを定義
		a = $val;
		var funcRef = function(text){
			document.getElementById("select_schooling_day_field").innerHTML = text;
		}
		httpRequest('admin/demand/schoolingDemand/setSelectSchoolingDay.php?schooling_id='+a,funcRef);
}

function setSelectReportTest($val1,$val2,$val3,$searchForm) {
		//処理を実行するための関数リファレンスを定義
		a = $val1;
		b = $val2;
		c = $val3;
		var funcRef = function(text){
			document.getElementById("select_report_test_field").innerHTML = text;
		}
		httpRequest('admin/variousEntry/reportEntry/setSelectReportTest.php?lesson_business_year='+a+'&entrance_term='+b+'&number='+c,funcRef);
}

function setSelectSchoolingCurriculum($val1,$val2) {
		//処理を実行するための関数リファレンスを定義
		a = $val1;
		b = $val2;
		var funcRef = function(text){
			document.getElementById("select_schooling_subject_field").innerHTML = text;
		}
		
		httpRequest('admin/result/schoolingResultPerson/setSelectCurriculum.php?schooling_id='+b+'&period='+a,funcRef);
}

function setSelectLine($searchForm) {
		a = $searchForm.rr_cd;
		//処理を実行するための関数リファレンスを定義
		var funcRef = function(text){
			document.getElementById("select_line_field").innerHTML = text;
		}
		httpRequest('admin/master/else/station/setSelectLine.php?rr_cd='+a.value,funcRef);
}
function setSelectStation($searchForm) {
		a = $searchForm.line_cd;
		//処理を実行するための関数リファレンスを定義
		var funcRef = function(text){
			document.getElementById("select_station_field").innerHTML = text;
		}
		httpRequest('admin/master/else/station/setSelectStation.php?line_cd='+a.value,funcRef);
}
function station_search($searchForm) {
		a = $searchForm.search_station;
		b = $searchForm.about_flag;
		//処理を実行するための関数リファレンスを定義
		var funcRef = function(text){
			document.getElementById("select_station_field").innerHTML = text;
		}
		httpRequest('admin/master/else/station/setSelectStation2.php?search_station='+encodeURI(a.value)+'&about_flag='+b.checked,funcRef);
}
function handleKeyPress(e){
	if(e == 40){
		document.mainForm.station_cds.focus();
		document.mainForm.station_cds.options[0].selected=true;
	}
}
