
document.observe('dom:loaded', function () {
	$('js_work').value = 1;
	$('hidTitle1').style.display = "none";
	$('hidTitle2').style.display = "none";

	if($('status').value != "submit"){
		$('pBlock').className="txtArea3";
		courseSelect();
	}

	$('fCourse').onchange = function(){courseSelect();};
	for(var i = 1; i<7; i++){
		$('fP_date' + i + '_ym').onchange = function(){ymSelect(this);};
	}
});

function courseSelect(){
		var course = $('fCourse').options[$('fCourse').selectedIndex].value;
		if(course == "0"){
			$('rBlock').style.display = "block";
			$('pBlock').style.display = "none";
		}else if(course == "1"){
			$('rBlock').style.display = "none";
			$('pBlock').style.display = "block";
			
		}else{
			$('rBlock').style.display = "none";
			$('pBlock').style.display = "none";
		}
}

function ymSelect(select){
	//var ym_id = select.options[select.selectedIndex].value;
	var target_id = select.name.replace("p_date","");
	target_id = target_id.replace("_ym","");
	
	var a = target_id < 4 ? 0 : 1;
	var b = select.selectedIndex;
	var array = optionArray[a][b];
	createSelect($('fP_date' + target_id + '_d'), array);
}

function createSelect(target, array){
	target.length = 0;
	addOption(target, "", " ");
	for( var i=0; i < array.length; i++)
	{
		addOption (target, i, array[i]);
	}
}

function addOption(target, optValue, optText){
	target.length++;
	target.options[ target.length - 1].value = optValue ;
	target.options[ target.length - 1].text  = optText;
}

