//
//	JavaScript空席照会処理
//
//-------------------------
//-------------------------
//	プルダウンの絞り込み
//-------------------------
function ChangeSelect(){
	var sym = document.form1.ship_month.value;
	var sdd = document.form1.ship_day.value;
	var spt = document.form1.port_from.value;
	if(spt){
		var type = document.form1.type.value;
/*
		var param = "type=" + type + "&execmode=vew&mode=get_arrival_port&ship_month=" + sym + "&ship_day=" + sdd + "&port_from=" + spt;
 */
		var param = "type=" + type + "&execmode=vew&mode=get_arrival_port2&ship_month=" + sym + "&ship_day=" + sdd + "&port_from=" + spt;
		var obj = new Ajax.Request(
				'/rpc.php',
				{
					method: 'get',
					parameters: param,
					onComplete: ExecDrawSelect
				}
				);
	}
}
//-------------------------
//	到着港プルダウン描画
//-------------------------
function ExecDrawSelect(xObj){
	var xml = xObj.responseXML;
//alert("res=" + xObj.responseText);
	var optc = '';
	if(xObj.responseText){
		var root = xml.documentElement;
		for(var i=0;i<root.childNodes.length;i++){
			var elm = root.childNodes[i];
			if(elm.nodeType == 1){
				if(elm.nodeName == "port"){
					optc += '<option value="' + elm.getAttribute("value") + '">' + elm.firstChild.nodeValue + '</option>';
				}
			}
		}
	}
	if(optc == ''){
		optc = '<option value="">（該当する便がありません）</option>';
	} else {
		//optc = '<option value="">選択してください</option>' + optc;
	}
	var tagc = '<select name="port_to">' + optc + '</select>';
	if($("sel_toport"))	$("sel_toport").innerHTML = tagc;
}
//-------------------------
//	カレンダー表示
//-------------------------
function ShowCalendar(){
	window.open("/index.php?type=calendar","_blank","width=680,height=340");
}
//-------------------------
//	カレンダーからの日付セット
//-------------------------
function AssignDate(val){
	var ar = val.split("/");
	var ym = ar[0] + "" + ar[1];
	var dd = ar[2];
	for(var i=0;i<document.form1.ship_month.options.length;i++){
		if(document.form1.ship_month.options[i].value == ym){
			document.form1.ship_month.selectedIndex = i;
			break;
		}
	}
	for(var i=0;i<document.form1.ship_day.options.length;i++){
		if(document.form1.ship_day.options[i].value == dd){
			document.form1.ship_day.selectedIndex = i;
			break;
		}
	}
}
