<!------------------------------------------------------QUESTION DISABLE START -------------------------------------------------->
<script language="javascript" type="text/javascript" charset="utf-8">
<!--
window.onload = function () {
	$("input[type=text], input[type=date], textArea[type=text]").each(function(){
		if ($(this).prop("disabled")) {
			$(this).val("");
			$(this).textinput().textinput("disable");
			if ($(this).prop("type") == "date") {
				$(this).next().hide();
			}
		}
	});
}
// -->
</script>
#foreach($question  in  $!enqueteForm.questionList)
	#foreach($answer in $question.answerList)
<script language="javascript" type="text/javascript" charset="utf-8">
<!--
function radioOrCheckboxEvent(id, isDisable) {
	if (isDisable) {
		$("." + id).prop("checked", false);
		$("." + id).checkboxradio('refresh').checkboxradio('disable');
		$("." + id).trigger("click");
	} else {
		$("." + id).checkboxradio("enable").checkboxradio('refresh');
	}
}
function dateEvent(id, isDisable) {
	if (isDisable) {
		$("." + id).val("");
		$("." + id).textinput("disable");
		$("." + id).next().hide();
	} else {
		$("." + id).textinput("enable");
		$("." + id).next().show();
	}
}
function selectEvent(id, isDisable) {
	if (isDisable) {
		$("." + id).selectmenu("refresh").selectmenu("disable");
		$("." + id).val("").trigger("change");
	} else {
		$("." + id).selectmenu("enable");
	}
}
function textEvent(id, isDisable) {
	if (isDisable) {
		$("." + id).val("");
		$("." + id).textinput("disable");
	} else {
		$("." + id).textinput("enable");
	}
}
$(function() {
	//条件付必須チェック(セレクトメニュー)
	 $('select').change(function() {
		var selectQuestionId = $(this).attr("class");
		var selectAnswerId = $(this).val();
		
		//表示、非表示対象
    	if (${question.condRequiredQuestionNo} && ${question.condRequiredQuestionNo} == selectQuestionId) {
    		//グレーアウト対象
    		if ("${question.condRequiredAnswer}".split(",").indexOf(selectAnswerId) < 0) {
    			if ("${question.controlId}" == "0" || "${question.controlId}" == "1") {
    				radioOrCheckboxEvent("${answer.answerId}", true);
    				//自由入力欄
    				if ("${answer.freeTextFlg}" == "1" || "${answer.freeTextFlg}" == "2") {
    					textEvent("${answer.answerId}_ft", true);
    				}
    			} else if ( "${question.controlId}" == "2" 
    					 || "${question.controlId}" == "3" 
    					 || "${question.controlId}" == "4" 
    					 || "${question.controlId}" == "5" 
    					 || "${question.controlId}" == "6") {
   					if ("${question.controlId}" == "2" || "${question.controlId}" == "6") {
						selectEvent("${question.questionId}", true);
					} else if ("${question.controlId}" == "3" || "${question.controlId}" == "4") {
						textEvent("${question.questionId}", true);
					} else if ("${question.controlId}" == "5") {
						dateEvent("${question.questionId}", true);
					}
    			}
    		//グレーアウト解除
    		} else {
    			if ("${question.controlId}" == "0" || "${question.controlId}" == "1") {
    				radioOrCheckboxEvent("${answer.answerId}", false);
    				//自由入力欄
    				if ("${answer.freeTextFlg}" == "1" || "${answer.freeTextFlg}" == "2") {
    					textEvent("${answer.answerId}_ft", false);
    				}
    			} else if ("${question.controlId}" == "2" 
    					|| "${question.controlId}" == "3" 
    					|| "${question.controlId}" == "4" 
    					|| "${question.controlId}" == "5" 
    					|| "${question.controlId}" == "6") {
   					if ("${question.controlId}" == "2" || "${question.controlId}" == "6") {
						selectEvent("${question.questionId}", false);
					} else if ("${question.controlId}" == "3" || "${question.controlId}" == "4") {
						textEvent("${question.questionId}", false);
					} else if ("${question.controlId}" == "5") {
						dateEvent("${question.questionId}", false);
					}
    			}
    		}
    	}
	});
	//条件付必須チェック(ラジオボタン、チェックボックス)
    $("input[type=radio], input[type=checkbox]").click(function () {
    	var thisQuestionId = $(this).attr("class").split(" ")[0];
    	var thisAnswerId = $(this).attr("class").split(" ")[1];
    	
    	//表示、非表示対象
    	if (${question.condRequiredQuestionNo} && ${question.condRequiredQuestionNo} == thisQuestionId) {
    		//グレーアウト対象
    		if ("${question.condRequiredAnswer}".split(",").indexOf(thisAnswerId) < 0) {
    			if ($(this).attr("type") == "radio" 
    		   && ("${question.controlId}" == "0" || "${question.controlId}" == "1")) {
    				if ($(this).is(":checked")) {
    					radioOrCheckboxEvent("${answer.answerId}", true);
    					//自由入力欄
	    				if ("${answer.freeTextFlg}" == "1" || "${answer.freeTextFlg}" == "2") {
	    					textEvent("${answer.answerId}_ft", true);
	    				}
    				} else {
        				var array = "${question.condRequiredAnswer}".split(",");
    					var judgeDisable = true;
    					for (let i in array) {
    						if ($("#" + array[i]).is(":checked")) {
    							judgeDisable = false;
    							break;
    						}
    					}
    					if (judgeDisable) {
    						radioOrCheckboxEvent("${answer.answerId}", true);
    						//自由入力欄
		    				if ("${answer.freeTextFlg}" == "1" || "${answer.freeTextFlg}" == "2") {
		    					textEvent("${answer.answerId}_ft", true);
		    				}
    					}
    				}
    			} else if ( "${question.controlId}" == "2" 
    					 || "${question.controlId}" == "3" 
    					 || "${question.controlId}" == "4" 
    					 || "${question.controlId}" == "5" 
    					 || "${question.controlId}" == "6") {
    				if ("${question.controlId}" == "2" || "${question.controlId}" == "6") {
						$("." + "${question.questionId}").val("").trigger("change");
					}
    				if ($(this).attr("type") == "radio") {
    					if ($(this).is(":checked")) {
        					var array = "${question.condRequiredAnswer}".split(",");
        					var judgeDisable = true;
        					for (let i in array) {
        						if ($("#" + array[i]).is(":checked")) {
        							judgeDisable = false;
        							break;
        						}
        					}
	    					if (judgeDisable) {
	    						if ("${question.controlId}" == "2" || "${question.controlId}" == "6") {
	                   				selectEvent("${question.questionId}", true);
	    						} else if ("${question.controlId}" == "3" || "${question.controlId}" == "4") {
	    							textEvent("${question.questionId}", true);
	    						} else if ("${question.controlId}" == "5") {
	    							dateEvent("${question.questionId}", true);
	    						}
	    					}
	    				} else {
	    					if ("${question.controlId}" == "2" || "${question.controlId}" == "6") {
	                   			selectEvent("${question.questionId}", false);
							} else if ("${question.controlId}" == "3" || "${question.controlId}" == "4") {
								textEvent("${question.questionId}", false);
							} else if ("${question.controlId}" == "5") {
								dateEvent("${question.questionId}", false);
							}
	    				}
	    			}
    			}
    		//グレーアウト解除
    		} else {
    			if ("${question.controlId}" == "0" || "${question.controlId}" == "1") {
    				if ($(this).is(":checked")) {
    					radioOrCheckboxEvent("${answer.answerId}", false);
    					//自由入力欄
	    				if ("${answer.freeTextFlg}" == "1" || "${answer.freeTextFlg}" == "2") {
	    					textEvent("${answer.answerId}_ft", false);
	    				}
    					
    				} else {
        				var array = "${question.condRequiredAnswer}".split(",");
    					var judgeDisable = true;
    					for (let i in array) {
    						if ($("#" + array[i]).is(":checked")) {
    							judgeDisable = false;
    							break;
    						}
    					}
    					if (judgeDisable) {
    						radioOrCheckboxEvent("${answer.answerId}", true);
    						//自由入力欄
		    				if ("${answer.freeTextFlg}" == "1" || "${answer.freeTextFlg}" == "2") {
		    					textEvent("${answer.answerId}_ft", true);
		    				}
    					}
    				}
    			} else if ("${question.controlId}" == "2" 
    					|| "${question.controlId}" == "3" 
    					|| "${question.controlId}" == "4" 
    					|| "${question.controlId}" == "5" 
    					|| "${question.controlId}" == "6") {
    				if ("${question.controlId}" == "2" || "${question.controlId}" == "6") {
						$("." + "${question.questionId}").val("").trigger("change");
					}
    				if ($(this).is(":checked")) {
    					if ("${question.controlId}" == "2" || "${question.controlId}" == "6") {
    						selectEvent("${question.questionId}", false);
    					} else if ("${question.controlId}" == "3" || "${question.controlId}" == "4") {
    						textEvent("${question.questionId}", false);
    					} else if ("${question.controlId}" == "5") {
    						dateEvent("${question.questionId}", false);
    					}
    				} else {
    					var array = "${question.condRequiredAnswer}".split(",");
    					var judgeDisable = true;
    					for (let i in array) {
    						if ($("#" + array[i]).is(":checked")) {
    							judgeDisable = false;
    							break;
    						}
    					}
    					if (judgeDisable) {
               				if ("${question.controlId}" == "2" || "${question.controlId}" == "6") {
    							selectEvent("${question.questionId}", true);
	    					} else if ("${question.controlId}" == "3" || "${question.controlId}" == "4") {
	    						textEvent("${question.questionId}", true);
	    					} else if ("${question.controlId}" == "5") {
	    						dateEvent("${question.questionId}", true);
	    					}
    					}
    				}
    			}
    		}
    	}
    });
});
	// -->
</script>
	#end
#end
<!------------------------------------------------------QUESTION DISABLE END-------------------------------------------------->