
function Display(id){

var hide = new Image(0,0);
var show = new Image(0,0);
	show.src = "img/route/bt2_close_on.gif";

	if(id=="start"){
		hide.src = "img/route/rooth_start_on.gif";
	}else if(id=="goal"){
		hide.src = "img/route/rooth_goal_on.gif";
	}else if(id=="keiyu0"){
		hide.src = "img/route/bt2_keiyutituika_on.gif";
	}else{
		hide.src = "img/route/rooth_keiyu_on.gif";
	}

	if(document.all || document.getElementById){	//IE4,N6以降
		if(document.all){
			obj = document.all(id).style;
		}else if(document.getElementById){
			obj = document.getElementById(id).style;
		}

		if(obj.display == "block"){
			obj.display = "none";		//未表示にする
			document.images["rooth_"+id].src = hide.src;
			document.frm.elements["show_"+id].value =0;
		}else if(obj.display == "none"){
			obj.display = "block";		//表示にする
			document.images["rooth_"+id].src = show.src;
			document.frm.elements["show_"+id].value =1;
		}
	}

}

function moveItem(iVal)
{
 	object = document.frm.sorts;
 	idx = object.selectedIndex;
 	if(idx != -1)
 	{
	 	cText   = object.options[idx].text;
	 	cValue  = object.options[idx].value;
	 	if(idx>0 && iVal==0)
	 	{
			//上へ
	 		object.options[idx].text    = object.options[idx-1].text;
	 		object.options[idx].value   = object.options[idx-1].value;
	 		object.options[idx-1].text  = cText;
	 		object.options[idx-1].value = cValue;
	 		object.selectedIndex--;
	 	}
	 	else if(idx<object.length-1 && iVal==1)
	 	{
			//下へ
	 		object.options[idx].text    = object.options[idx+1].text;
	 		object.options[idx].value   = object.options[idx+1].value;
	 		object.options[idx+1].text  = cText;
	 		object.options[idx+1].value = cValue;
	 		object.selectedIndex++;
	 	}
	 	else if(idx<object.length && iVal==2)
	 	{
			//削除
			if(object.length<=2)
			{
			 	//alert("地点が２ヶ所の場合は削除できません。");
			} else {
				cnt = object.length - idx - 1;
				for (i=idx; i<idx+cnt; i++) {
			 		object.options[i].text    = object.options[i+1].text;
		 			object.options[i].value   = object.options[i+1].value;
				}
		 		object.options[idx+cnt] = null;
			}
	 	}
		//順序情報の編集
		cnt = object.length;
		str = '';
		for (j=0; j<cnt; j++) {
			str = str + object.options[j].value + ',';
		}
		str = str.substr(0,str.length-1);
		document.frm.P_SEQ_ATO.value = str;
 	}
 	return false;
}

sent = false;
function send_check(){
     if(sent){
         return false;
      }else{
         sent = true;
         return true;
      }
}


ent = false;
function btn_ent(url){
     if(ent){
      }else{
        ent = true;
        window.location.href = url;
      }
}

function tollinfo() {
	showModelessDialog("tollinfo.htm",window,"status:no;dialogWidth:420px;dialogHeight:200px;center:yes;edge:sunken;help:no;resizable:no;scroll:yes;status:no;unadorned:yes");
}

function helpshow(url) {
	showModelessDialog(url,window,"status:false;dialogWidth:520px;dialogHeight:400px");
}

function CheckDel(mode) {
	if (mode==0) {
		myCnt=0;
		limit = document.frm.delspot.length;
		if (isNaN(limit)) {
			if (document.frm.delspot.checked == true) {
				myCnt++;
			}
		} else {
			for(i=0; i<limit; i++){
				if (document.frm.delspot[i].checked == true) {
					myCnt++;
				}
			}
		}
		if (myCnt<=0) {
			return false;
		}
	}

	if (confirm("本当に削除しますか?")) {
		return true;
	} else {
		return false;
	}

}

function AllCheck(check){
	var count;
	limit = document.frm.delspot.length;
	if (isNaN(limit)) {
		document.frm.delspot.checked = check;	//チェックボックスをON/OFFにする
	} else {
		for(count = 0; count < limit; count++){
			document.frm.delspot[count].checked = check;	//チェックボックスをON/OFFにする
		}
	}
	return false;
}

function getCookie(key) {
    tmp1 = " " + document.cookie + ";";
    xx1 = xx2 = 0;
    len = tmp1.length;
    while (xx1 < len) {
        xx2 = tmp1.indexOf(";", xx1);
        tmp2 = tmp1.substring(xx1 + 1, xx2);
        xx3 = tmp2.indexOf("=");
        if (tmp2.substring(0, xx3) == key) {
            return(unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)));
        }
        xx1 = xx2 + 1;
    }
    return("");
}

function clearCookie(key) {
    document.cookie = key + "=" + "xx; expires=Tue, 1-Jan-1980 00:00:00;";
}

function topselected() {
	var sn = document.frm.P_DEPA.selectedIndex;
    stval  = document.frm.P_DEPA.options[sn].value;
	var en = document.frm.P_DEST.selectedIndex;
    edval  = document.frm.P_DEST.options[en].value;
	clearCookie('cwroute_s');
	setCookie('cwroute_s', stval);
	clearCookie('cwroute_e');
	setCookie('cwroute_e', edval);
}

function chgSelected(nm) {

	if(nm=='P_DEPA'){
		var n = document.frm.P_DEPA.selectedIndex;
	    selval  = document.frm.P_DEPA.options[n].value;
		cnm = 'cwroute_s';
	}else
	if(nm=='P_DEST'){
		var n = document.frm.P_DEST.selectedIndex;
	    selval  = document.frm.P_DEST.options[n].value;
		cnm = 'cwroute_e';
	}
	clearCookie(cnm);
	setCookie(cnm, selval);

	return false;
}

function CheckCondition(){

	//要素定義
    var wyy    = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 29);
    var wyn    = document.frm.y1.selectedIndex;
    var wYear  = document.frm.y1.options[wyn].value;
    var wmn    = document.frm.mm.selectedIndex;
    var wMonth = document.frm.mm.options[wmn].value;
    //var wMChk  = parseInt(wMonth);
    var wMChk  = wMonth - 0;

    var wdn    = document.frm.dd.selectedIndex;
    var wDay   = document.frm.dd.options[wdn].value;
    var whn    = document.frm.hh.selectedIndex;
    var wHour  = document.frm.hh.options[whn].value;
    var wm1n   = document.frm.m1.selectedIndex;
    var wMinute = document.frm.m1.options[wm1n].value;

	//出発・到着区分の値を取得
	tkbn="";
	for (i = 0; i < document.frm.timekbn.length; i++) {
		if (document.frm.timekbn[i].checked) {
			tkbn = document.frm.timekbn[i].value;
		}
	}

	if(tkbn==""){
		//時間指定なしの場合
		document.frm.P_TIMEKBN.value="";
	}else{
		//時刻指定がある場合
	    // 年の範囲検証
	    if (!(wYear >= 2000 && wYear <= 2030)) {
			window.alert("年を選択してください");
			document.frm.y1.focus();
	   	    return false;
	    }
	    // 月の範囲検証
	    if (!(wMonth >= 1 && wMonth <= 12)) {
			window.alert("月を選択してください");
			document.frm.mm.focus();
	   	    return false;
	   	}
	    // 閏年の判定
   		if (!(wYear % 4) && wMonth==2) {
	       	wMChk = 12;     // 閏年テーブル
   		    if (!(wYear % 100)) {
       		    if (wYear % 400) {
           		    wMChk = 1;      // non閏年テーブル
	            }
   		    }
		} else {
   		    wMChk--;
		}
   		// 日の範囲検証
		if (wDay=="-") {
			window.alert("日を選択してください");
			document.frm.dd.focus();
    	   	return false;
	    }

		if (!(1 <= wDay && wyy[wMChk] >= wDay)) {
			window.alert("不正な日付です");
			document.frm.dd.focus();
    	   	return false;
	    }
	    // 時の範囲検証
	    if (!(wHour >= 0 && wHour <= 23)) {
			window.alert("時を選択してください");
			document.frm.hh.focus();
	   	    return false;
	   	}
	    // 分の範囲検証
	    if (wMinute=="-") {
			window.alert("分を選択してください");
			document.frm.m1.focus();
	   	    return false;
	   	}

		//パラメータ作成
		document.frm.P_TIMEKBN.value = "" + tkbn + wYear + wMonth + wDay + wHour + wMinute; 

	}
	//window.alert("P_TIMEKBN = "+document.frm.P_TIMEKBN.value);
	//window.alert("チェックOK");
	return true;
}


