function check_toroku_form() {
	// check 内容
	if(window.confirm('登録してよろしいですか？')){ // 確認ダイアログを表示
		return true; // 「OK」時は送信を実行
	}
	else{ // 「キャンセル」時の処理
		window.alert('キャンセルされました'); // 警告ダイアログを表示
		return false; // 送信を中止
	}
}

function check_update_form() {
	// check 内容
	if(window.confirm('修正してよろしいですか？')){ // 確認ダイアログを表示
		return true; // 「OK」時は送信を実行
	}
	else{ // 「キャンセル」時の処理
		window.alert('キャンセルされました'); // 警告ダイアログを表示
		return false; // 送信を中止
	}
}

var flg_h2 = false;
var flg_h3_1 = false;
var flg_h3_2 = false;
var flg_h4_1 = false;
var flg_h4_2 = false;

function change_sytle(val) {
  if('h2' == val ) {
    if (flg_h2) {
        document.getElementById("h2_div").style.visibility = "hidden";
        document.getElementById("h2_div").style.position = "absolute";
        flg_h2 = false;
        document.getElementById("h3-1_div").style.visibility = "hidden";
        document.getElementById("h3-1_div").style.position = "absolute";
        flg_h3_1 = false;
        
        document.getElementById("h3-2_div").style.visibility = "hidden";
        document.getElementById("h3-2_div").style.position = "absolute";
        flg_h3_2 = false;
        
        document.getElementById("h4-1_div").style.visibility = "hidden";
        document.getElementById("h4-1_div").style.position = "absolute";
        flg_h4_1 = false;
        document.getElementById("h4-2_div").style.visibility = "hidden";
        document.getElementById("h4-2_div").style.position = "absolute";
        flg_h4_2 = false;
        
    } else {
        document.getElementById("h2_div").style.visibility = "visible";
        document.getElementById("h2_div").style.position = "relative";          
        flg_h2 = true;
    }
  }      
  if('h3_1' == val ) {
    if (flg_h3_1) {
        document.getElementById("h3-1_div").style.visibility = "hidden";
        document.getElementById("h3-1_div").style.position = "absolute";
        flg_h3_1 = false;
        
        document.getElementById("h4-1_div").style.visibility = "hidden";
        document.getElementById("h4-1_div").style.position = "absolute";
        flg_h4_1 = false;
        
        document.getElementById("h4-2_div").style.visibility = "hidden";
        document.getElementById("h4-2_div").style.position = "absolute";
        flg_h4_2 = false;
        
    } else {
        document.getElementById("h3-1_div").style.visibility = "visible";
        document.getElementById("h3-1_div").style.position = "relative";
        flg_h3_1 = true;          
    }
  }
  if('h3_2' == val ) {
    if (flg_h3_2) {
        document.getElementById("h3-2_div").style.visibility = "hidden";
        document.getElementById("h3-2_div").style.position = "absolute";
        flg_h3_2 = false;
    } else {
        document.getElementById("h3-2_div").style.visibility = "visible";
        document.getElementById("h3-2_div").style.position = "relative";
        flg_h3_2 = true;          
    }
  }
  if('h4_1' == val ) {
    if (flg_h4_1) {
        document.getElementById("h4-1_div").style.visibility = "hidden";
        document.getElementById("h4-1_div").style.position = "absolute";
        flg_h4_1 = false;
    } else {
        document.getElementById("h4-1_div").style.visibility = "visible";
        document.getElementById("h4-1_div").style.position = "relative";
        flg_h4_1 = true;
    }
  }
  if('h4_2' == val ) {
    if (flg_h4_2) {
        document.getElementById("h4-2_div").style.visibility = "hidden";
        document.getElementById("h4-2_div").style.position = "absolute";
        flg_h4_2 = false;
    } else {
        document.getElementById("h4-2_div").style.visibility = "visible";
        document.getElementById("h4-2_div").style.position = "relative";
        flg_h4_2 = true;          
    }
	}   
}

function check_form(){
	var err="";
	var err_msg=document.getElementById("err_msg");		
	document.getElementById("td_name").style.color="";
	document.getElementById("td_furigana").style.color="";
	document.getElementById("td_email").style.color="";
	document.getElementById("td_birth").style.color="";	
	document.getElementById("td_shinrishi").style.color="";	
	document.getElementById("td_post").style.color="";
	document.getElementById("td_address1").style.color="";	
	document.getElementById("td_tel").style.color="";	
	document.getElementById("td_fax").style.color="";
	document.getElementById("td_kinmu").style.color="";	
	document.getElementById("td_jobKind").style.color="";		
	document.getElementById("td_kpost").style.color="";	
	document.getElementById("td_kaddress").style.color="";
	document.getElementById("td_ktel").style.color="";
	document.getElementById("td_kfax").style.color="";
	
	if ((document.form.name1.value == "")||(document.form.name2.value == "")) {
		err +="<font color='red'>お名前を入力してください。</font><br>";
		err_msg.innerHTML=err;		
		document.getElementById("td_name").style.color="red";
	}
	
	if ((document.form.furigana1.value == "")||(document.form.furigana2.value == "")) {
		err +="<font color='red'>ふりがなを入力してください。</font><br>";
		err_msg.innerHTML=err;		
		document.getElementById("td_furigana").style.color="red";		
	}
	
	if (document.form.email.value == "") {
		err +="<font color='red'>E-mailを入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_email").style.color="red";				
	}　else {
		str = document.form.email.value;
		var tmp = str.match("^[0-9A-Za-z._-]+@[0-9A-Za-z.-]+$");
		if (tmp != str){
		err +="<font color='red'>ご入力頂いたE-mailに誤りがあります。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_email").style.color="red";						
		} 
	}
	
	if ((document.form.year.value == "")||(document.form.month.value == "")||(document.form.day.value == "")) {
		err +="<font color='red'>生年月日を入力してください。</font><br>";
		err_msg.innerHTML=err;		
		document.getElementById("td_birth").style.color="red";		
	} else if ( !hankaku_num (document.form.year.value) || !hankaku_num (document.form.month.value) || !hankaku_num (document.form.day.value)){
		err +="<font color='red'>生年月日を数字のみ入力してください。</font><br>";
		err_msg.innerHTML=err;		
		document.getElementById("td_birth").style.color="red";	
	}
	
	if ((document.getElementsByName("shinrishi")[1].checked == true)&&(document.form.shinrishiNum.value == "")) {
		err +="<font color='red'>臨床心理士資格を入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_shinrishi").style.color="red";				
	}
	
	if (document.form.post.value == "") {
		err +="<font color='red'>郵便番号を入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_post").style.color="red";				
	} else if (!hankaku_num(document.form.post.value)) {
		err +="<font color='red'>郵便番号を半角で入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_post").style.color="red";
	}
	
	if (document.form.address1.value == "") {
		err +="<font color='red'>ご住所を入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_address1").style.color="red";				
	}	
	
	if (document.form.tel.value == "") {
		err +="<font color='red'>電話番号を入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_tel").style.color="red";				
	} else if (!hankaku_num(document.form.post.value)) {
		err +="<font color='red'>電話番号を半角で入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_tel").style.color="red";
		
	}
	if ("" !=document.form.fax.value && !hankaku_num(document.form.fax.value)) {
		err +="<font color='red'>faxを半角で入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_fax").style.color="red";
	}
	if (document.form.kinmu.value == "") {
		err +="<font color='red'>勤務先名称を入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_kinmu").style.color="red";				
	}
	
	if (document.form.jobKind.value == "") {
		err +="<font color='red'>職種を入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_jobKind").style.color="red";				
	}	
	if (document.form.kpost.value == "") {
		err +="<font color='red'>勤務先〒を入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_kpost").style.color="red";				
	}else if (!hankaku_num(document.form.kpost.value)) {
		err +="<font color='red'>勤務先〒を半角数字と「-」のみで入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_kpost").style.color="red";
		
	}
	if (document.form.kaddress.value == "") {
		err +="<font color='red'>勤務先住所を入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_kaddress").style.color="red";				
	}
	if ("" != document.form.ktel.value && !hankaku_num(document.form.ktel.value)) {
		err +="<font color='red'>勤務先電話番号を半角数字と「-」のみで入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_ktel").style.color="red";
		
	}
	if ("" != document.form.kfax.value && !hankaku_num(document.form.kfax.value)) {
		err +="<font color='red'>勤務先FAX番号を半角数字と「-」のみで入力してください。</font><br>";
		err_msg.innerHTML=err;
		document.getElementById("td_kfax").style.color="red";
	}
	
	if (err == "") {
		document.getElementById("td_name").style.color="";		
		document.getElementById("td_furigana").style.color="";
		document.getElementById("td_email").style.color="";
		document.getElementById("td_birth").style.color="";		
		document.getElementById("td_shinrishi").style.color="";	
		document.getElementById("td_post").style.color="";
		document.getElementById("td_address1").style.color="";	
		document.getElementById("td_tel").style.color="";
		document.getElementById("td_fax").style.color="";
		document.getElementById("td_kinmu").style.color="";	
		document.getElementById("td_jobKind").style.color="";		
		document.getElementById("td_kpost").style.color="";	
		document.getElementById("td_kaddress").style.color="";
		document.getElementById("td_ktel").style.color="";
		document.getElementById("td_kfax").style.color="";
		
		document.form.submit();		
	} else {
		err +="<br>";
		err_msg.innerHTML=err;
	}

}
function gf_Hankaku(obj){
    str = obj;
    var tmp=str.match(/[0-9a-zA-Z\+\-\/\*\,\. ]+/g);
    if (tmp!=str){
        return false;
    }else{
        return true;
    }
}

function hankaku_num(aVal){  
	if(aVal.match(/[^0-9._-]+/) == null){    
		return true;  
	}else{    
		return false;  
	}
}

