/*
 * This file is part of EC-CUBE
 *
 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
// 親ウィンドウの存在確認.
function fnIsopener() {
    var ua = navigator.userAgent;
    if( !!window.opener ) {
        if( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) {
            return !window.opener.closed;
        } else {
        	return typeof window.opener.document == 'object';
        }
	} else {
		return false;
	}
}

// 郵便番号入力呼び出し.
function fnCallAddress(php_url, tagname1, tagname2, input1, input2) {
	zip1 = document.form1[tagname1].value;
	zip2 = document.form1[tagname2].value;
	
	if(zip1.length == 3 && zip2.length == 4) {
		url = php_url + "?zip1=" + zip1 + "&zip2=" + zip2 + "&input1=" + input1 + "&input2=" + input2;
		window.open(url,"nomenu","width=500,height=350,scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no");
	} else {
		alert("郵便番号を正しく入力して下さい。");
	}
}

// 郵便番号から検索した住所を渡す.
function fnPutAddress(input1, input2) {
	// 親ウィンドウの存在確認。.
	if(fnIsopener()) {
		if(document.form1['state'].value != "") {
			// 項目に値を入力する.
			state_id = document.form1['state'].value;
			town = document.form1['city'].value + document.form1['town'].value;
			window.opener.document.form1[input1].selectedIndex = state_id;
			window.opener.document.form1[input2].value = town;
		}
	} else {
		window.close();
	}		
}

function fnOpenNoMenu(URL) {
	window.open(URL,"nomenu","scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no");
}

function fnOpenWindow(URL,name,width,height) {
	window.open(URL,name,"width="+width+",height="+height+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=no");
}

function fnSetFocus(name) {
	if(document.form1[name]) {
		document.form1[name].focus();
	}
}

// セレクトボックスに項目を割り当てる.
function fnSetSelect(name1, name2, val) {
	sele1 = document.form1[name1]; 
	sele2 = document.form1[name2];
	
	if(sele1 && sele2) {
		index=sele1.selectedIndex;
		
		// セレクトボックスのクリア	
		count=sele2.options.length
		for(i = count; i >= 0; i--) {
			sele2.options[i]=null;
		}
		
		// セレクトボックスに値を割り当てる。
		len = lists[index].length
		for(i = 0; i < len; i++) {
			sele2.options[i]=new Option(lists[index][i], vals[index][i]);
			if(val != "" && vals[index][i] == val) {
				sele2.options[i].selected = true;
			}
		}
	}
}

// Enterキー入力をキャンセルする。(IEに対応)
function fnCancelEnter()
{
	if (gCssUA.indexOf("WIN") != -1 && gCssUA.indexOf("MSIE") != -1) {
		if (window.event.keyCode == 13)
		{
			return false;
		}
	}
	return true;
}

// モードとキーを指定してSUBMITを行う。
function fnModeSubmit(mode, keyname, keyid) {
	switch(mode) {
	case 'delete_category':
		if(!window.confirm('選択したカテゴリとカテゴリ内のすべてのカテゴリを削除します')){
			return;
		}
		break;
	case 'delete':
		if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか？')){
			return;
		}
		break;
	case 'delete_order':
		if(!window.confirm('在庫数は手動で戻してください。\n一度削除したデータは、元に戻せません。\n削除しても宜しいですか？')){
			return;
		}
		break;
	case 'confirm':
		if(!window.confirm('登録しても宜しいですか')){
			return;
		}
		break;
	case 'delete_all':
		if(!window.confirm('検索結果をすべて削除しても宜しいですか')){
			return;
		}
		break;
	case 'status_change_active':
	case 'status_change_delete':
		if(!window.confirm('ステータスを変更しても宜しいですか')){
			return;
		}
		break;
	default:
		break;
	}
	document.form1['mode'].value = mode;
	if(keyname != "" && keyid != "") {
		document.form1[keyname].value = keyid;
	}
	document.form1.submit();
}

function fnFormModeSubmit(form, mode, keyname, keyid) {
	switch(mode) {
	case 'delete':
		if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか？')){
			return;
		}
		break;
	case 'confirm':
		if(!window.confirm('登録しても宜しいですか')){
			return;
		}
		break;
	case 'regist':
		if(!window.confirm('登録しても宜しいですか')){
			return;
		}
		break;		
	default:
		break;
	}
	document.forms[form]['mode'].value = mode;
	if(keyname != "" && keyid != "") {
		document.forms[form][keyname].value = keyid;
	}
	document.forms[form].submit();
}

function fnSetFormSubmit(form, key, val) {
	document.forms[form][key].value = val;
	document.forms[form].submit();
	return false;
}

function fnSetFormVal(form, key, val) {
	document.forms[form][key].value = val;
}

function fnChangeAction(url) {
	document.form1.action = url;
}

function fnChangeActionForm(form, url) {
	document.forms[form].action = url;
}

function fnChngActnFormSubmit(url, name, value) {
	document.form1.action = url;
	if(name != "" && value != "") {
		document.form1.name.value = value;
	}
	document.form1.submit();
}


// ページナビで使用する。
function fnNaviPage(pageno) {
	document.form1['pageno'].value = pageno;
	if(document.form1.action.indexOf("?") != -1){
		//document.form1.action+="&pagemove=" +pageno ;
	}else{
		document.form1.action+="?pagemove=" +pageno ;
	}
	document.form1.submit();
}

function fnSearchPageNavi(pageno) {
	document.form1['pageno'].value = pageno;
	document.form1['mode'].value = 'search';
	document.form1.submit();
	}

	function fnSubmit(){
	document.form1.submit();
}

// ポイント入力制限。
function fnCheckInputPoint() {
	if(document.form1['point_check']) {
		list = new Array(
						'use_point'
						);
	
		if(!document.form1['point_check'][0].checked) {
			color = "#dddddd";
			flag = true;
		} else {
			color = "";
			flag = false;
		}
		
		len = list.length
		for(i = 0; i < len; i++) {
			if(document.form1[list[i]]) {
				document.form1[list[i]].disabled = flag;
				document.form1[list[i]].style.backgroundColor = color;
			}
		}
	}
}

// 別のお届け先入力制限。
function fnCheckInputDeliv() {
	if(!document.form1) {
		return;
	}
	if(document.form1['deliv_check']) {
		list = new Array(
						'deliv_name01',
						'deliv_name02',
						'deliv_kana01',
						'deliv_kana02',
						'deliv_pref',
						'deliv_zip01',
						'deliv_zip02',
						'deliv_addr01',
						'deliv_addr02',
						'deliv_tel01',
						'deliv_tel02',
						'deliv_tel03'
						);
	
		if(!document.form1['deliv_check'].checked) {
			fnChangeDisabled(list, '#dddddd');
		} else {
			fnChangeDisabled(list, '');
		}
	}
}


// 購入時会員登録入力制限。
function fnCheckInputMember() {
	if(document.form1['member_check']) {
		list = new Array(
						'password',
						'password_confirm',
						'reminder',
						'reminder_answer'
						);

		if(!document.form1['member_check'].checked) {
			fnChangeDisabled(list, '#dddddd');
		} else {
			fnChangeDisabled(list, '');
		}
	}
}

// 最初に設定されていた色を保存しておく。
var g_savecolor = new Array();

function fnChangeDisabled(list, color) {
	len = list.length;
	
	for(i = 0; i < len; i++) {
		if(document.form1[list[i]]) {
			if(color == "") {
				// 有効にする。
				document.form1[list[i]].disabled = false;
				document.form1[list[i]].style.backgroundColor = g_savecolor[list[i]];
			} else {
				// 無効にする。
				document.form1[list[i]].disabled = true;
				g_savecolor[list[i]] = document.form1[list[i]].style.backgroundColor;
				document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0";	
			}			
		}
	}
}


// ログイン時の入力チェック
function fnCheckLogin(formname) {
	var lstitem = new Array();
	
	if(formname == 'login_mypage'){
	lstitem[0] = 'mypage_login_email';
	lstitem[1] = 'mypage_login_pass';
	}else{
	lstitem[0] = 'login_email';
	lstitem[1] = 'login_pass';
	}
	var max = lstitem.length;
	var errflg = false;
	var cnt = 0;
	
	//　必須項目のチェック
	for(cnt = 0; cnt < max; cnt++) {
		if(document.forms[formname][lstitem[cnt]].value == "") {
			errflg = true;
			break;
		}
	}
	
	// 必須項目が入力されていない場合	
	if(errflg == true) {
		alert('メールアドレス/パスワードを入力して下さい。');
		return false;
	}
}
	
// 時間の計測.
function fnPassTime(){
	end_time = new Date();
	time = end_time.getTime() - start_time.getTime();
	alert((time/1000));
}
start_time = new Date();

//親ウィンドウのページを変更する.
function fnUpdateParent(url) {
	// 親ウィンドウの存在確認
	if(fnIsopener()) {
		window.opener.location.href = url;
	} else {
		window.close();
	}		
}

//特定のキーをSUBMITする.
function fnKeySubmit(keyname, keyid) {
	if(keyname != "" && keyid != "") {
		document.form1[keyname].value = keyid;
	}
	document.form1.submit();
}

//文字数をカウントする。
//引数1：フォーム名称
//引数2：文字数カウント対象
//引数3：カウント結果格納対象
function fnCharCount(form,sch,cnt) {
	document.forms[form][cnt].value= document.forms[form][sch].value.length;
}


// テキストエリアのサイズを変更する.
function ChangeSize(button, TextArea, Max, Min, row_tmp){
	
	if(TextArea.rows <= Min){
		TextArea.rows=Max; button.value="小さくする"; row_tmp.value=Max;
	}else{
		TextArea.rows =Min; button.value="大きくする"; row_tmp.value=Min;
	}
}

function changeImg(imgid, imgsrc) {
 document.getElementById(imgid).src = imgsrc;
 }
function changeCap(capid, captxt) {
	 document.getElementById(capid).innerHTML = captxt;
}


// 駅の取得
function changeStationSlection(train_line_id, selectionId, selectionId2, station_id, station_id2){
	var json ="";
  $.get(".././ajax.php", {train_line_id : train_line_id, method : "get_stations"}, function(json){
		var	node = window.document.getElementById(selectionId);
		var	node2 = window.document.getElementById(selectionId2);
		if(node != null && node2 != null) {
		   if (json.length>0){
			  var data = eval( '('+json+')' );
			  node.options.length = 0;  
			  node2.options.length = 0;  
			  node.options[0] = new Option("指定なし", "");
			  node2.options[0] = new Option("指定なし", "");
			  var index = 1;
			  for (var key in data) {
			    node.options[index] = new Option(data[key], key);
				node2.options[index] = new Option(data[key], key);
				if(station_id != '' && key == station_id){
					var station1_index = index;
				}
     			if(station_id2 != '' && key == station_id2){
					var station2_index = index;
				}
				index++;
	     	  }
		   }
   		   if(station1_index != ''){
				node.selectedIndex = station1_index;
		   }else{
				node.selectedIndex = 0;
		   }
   		   if(station2_index != ''){
				node2.selectedIndex = station2_index;
		   }else{
				node2.selectedIndex = 0;
		   }
		}
      });
} 

function changeSchoolByArea(area_ids, target_id, class_name, form_name, school_kind, imgpath) {
  if (area_ids == null || area_ids.length < 1) {
  	$("#" + target_id).html("");
  }	else {
	var empty = true;
	for(i = 0; i < area_ids.length; i++){
		if (area_ids[i] != '') {
			empty = false;
			break;
		}
	}
	if(!empty) {
		$("#" + target_id).html("<p style=\"text-align: center;\"><img src=" + imgpath + " alt=\"\" align=\"middle\"/></p>");
		var json ="";
		$.get("../../ajax.php", {area_id: area_ids, kind: school_kind,	add_count: true, method: "get_school_by_area"}, function(json){
			if (json.length > 0) {
				var data = eval('(' + json + ')');
				var elem = "";
				for (var key in data) {
					elem += '<p class="' + class_name + '"><input type="checkbox" name="' + form_name + '[]" value="' + key + '" id="' + school_kind + key + '"/><label for="' + school_kind + key + '">' + data[key] + '</label></p>';
				}
				$("#" + target_id).html(elem);
			} else {
		  	$("#" + target_id).html("");
			}
		});
	} else {
	  	$("#" + target_id).html("");
	}
  }
}

function changeSchoolByArea2(area_ids, target_id, form_name, school_kind, imgpath) {
  if (area_ids == null || area_ids.length < 1) {
  	$("#" + target_id).html("");
  }	else {
	var empty = true;
	for(i = 0; i < area_ids.length; i++){
		if (area_ids[i] != '') {
			empty = false;
			break;
		}
	}
	if(!empty) {
		$("#" + target_id).html("<p style=\"text-align: center;\"><img src=" + imgpath + " alt=\"\" align=\"middle\"/></p>");
		var json ="";
		$.get("../../ajax.php", {area_id: area_ids, kind: school_kind,	add_count: true, method: "get_school_by_area"}, function(json){
			if (json.length > 0) {
				var data = eval('(' + json + ')');
				var elem = "";
				for (var key in data) {
					elem += '<span><input type="checkbox" name="' + form_name + '[]" value="' + key + '" id="' + school_kind + key + '"/><label for="' + school_kind + key + '"">' + data[key] + '</label></span>';
				}
				$("#" + target_id).html(elem);
			} else {
		  	$("#" + target_id).html("");
			}
		});
	} else {
	  	$("#" + target_id).html("");
	}
  }
}
function changeSchoolByArea3(area_ids, target_id, class_name, form_name, school_kind, imgpath, ids) {
  if (area_ids == null || area_ids.length < 1) {
  	$("#" + target_id).html("");
  }	else {
	var empty = true;
	for(i = 0; i < area_ids.length; i++){
		if (area_ids[i] != '') {
			empty = false;
			break;
		}
	}
	if(!empty) {
		$("#" + target_id).html("<p style=\"text-align: center;\"><img src=" + imgpath + " alt=\"\" align=\"middle\"/></p>");
		var json ="";
		$.get("../../ajax.php", {area_id: area_ids, kind: school_kind,	method: "get_school_by_area"}, function(json){
			if (json.length > 0) {
				var data = eval('(' + json + ')');
				var elem = "";
				for (var key in data) {
					var isChecked = false;
				for (var i = 0; i < ids.length; i ++) {
				  	if(key == ids[i]) {
						elem += '<p class="' + class_name + '"><input type="checkbox" name="' + form_name + '[]" value="' + key + '" id="' + school_kind + key + '  checked="checked" "/><label for="' + school_kind + key + '">' + data[key] + '</label></p>';
						isChecked = true;
						break;
					}
				  }
				  if(!isChecked) {
						elem += '<p class="' + class_name + '"><input type="checkbox" name="' + form_name + '[]" value="' + key + '" id="' + school_kind + key + '"/><label for="' + school_kind + key + '">' + data[key] + '</label></p>';
				  }
				}
				$("#" + target_id).html(elem);
			} else {
		  	$("#" + target_id).html("");
			}
		});
	} else {
	  	$("#" + target_id).html("");
	}
  }
}


function lfDispChange(){
	for (i = 0; i < arguments.length; i++) {
		$('#' + arguments[i]).toggle();
	}
}

function getRequiredTime(object_station_code, text_id, selection_id, caution_id, timefield, mode){
	// 前回値削除
    $('#' + timefield).html('　');
	lfDispChange(caution_id);
	$('#caution1').html('');
	// 検索値の取得
	var station_name;
	if(mode == 'name') {
	  station_name = $('#' + text_id).val(); 
	selection_node2 = window.document.getElementById(selection_id);
    selection_node2.options.length = 0;
	} else {
	  station_name = $('#' + selection_id).val(); 
	}
	// リクエストの発行
	var json ="";
  $.get("../../../ajax.php", {station_from_name : station_name, station_to : object_station_code, method : "get_require_time", mode : mode}, function(json){
	if (json.length > 0){
		var data = eval( '('+json+')' );
			selection_node = window.document.getElementById(selection_id);
			if(mode == 'code') {
				    $('#' + timefield).html(data['time']);
					var display_name = selection_node.options[selection_node.selectedIndex].text;
					$('#' + text_id).val(display_name);  
				 // テキストボックス表示、ほかを非表示
				 lfDispChange('ekitaninput', 'ekitaninput2');
			} else {
				if('time' in data) {
				    $('#' + timefield).html(data['time']);
					$('#caution1').toggle();
				} else {
					// 検索結果が複数あります
				  var index = 0;
				  for (var key in data) {
				    selection_node.options[index] = new Option(data[key], key);
					if(data[key] != '' && data[key] == station_name){
						//　送信した駅名を選択中にするためのindex
						var station_index = index;
					}
					index++;
		     	  }
				if(station_index != ''){
					selection_node.selectedIndex = station_index;
				 }else{
					selection_node.selectedIndex = 0;
				 }
				$('#' + text_id).val('');
			    $('#caution2').html('※候補が複数あります');
				 // テキストボックス非表示、ほかを表示
				 lfDispChange('ekitaninput', 'ekitaninput2');
				}
			}
   } else {
   	// 値が取得できない場合は駅名が不正
	     $('#caution1').html('※駅名を正しく入力してください');
   }

  }) 
}

function getCandidateStation(text_id, hidden_id, selection_id, caution_id, bloc, bloc2){
 $('#' + caution_id).html('');
 var station_name = $('#' + text_id).val(); 

 if(station_name != null && station_name != '') {
	// リクエストの発行
		var json ="";
	$.get("../../../ajax.php", {station_name : station_name,  method : "get_candidate_station"}, function(json){
	if (json.length > 0){
		var data = eval( '('+json+')' );
			selection_node = window.document.getElementById(selection_id);
				  var index = 0;
				  var hidden_name = '';
				  for (var key in data) {
				  	// textフィールドに代入
				    $('#' + text_id).html(data[key]);
				    $('#' + hidden_id).val(key);
					// セレクトオプション作成
				    selection_node.options[index] = new Option(data[key], key);
					if(data[key] != '' && data[key] == station_name){
						//　送信した駅名を選択中にするためのindex
						var station_index = index;
					}
					index++;
		     	  }
				if(station_index != ''){
					selection_node.selectedIndex = station_index;
				 }else{
					selection_node.selectedIndex = 0;
				 }
				 if(index == 1) {
				 // 候補が一つだけの場合
				    selection_node.options[0] = new Option('', '');
				 } else {
				    $('#' + text_id).val('');
				    $('#' + hidden_id).val('');
				    $('#' + bloc).toggle();
				    $('#' + bloc2).toggle();
				 }
   } else {
   	// 値が取得できない場合は駅名が不正
	     $('#' + caution_id).html('※駅名を正しく入力してください');
   }
  }) 
 }
}


function researchProductsAjax(showtarget_id, countvar_id) {
	var formval = {};
         $("#search_form :input")  
      .filter(":enabled")
      .each(
        function(){
            var name = $(this).attr('name');
            var val  = $(this).val();
 
            if( $(this).is(":checkbox") ){
                if($(this).is(":checked")){
                    if( ! formval[name] ) formval[name] = [];
                  	formval[name].push(val);
                 }
            } else if($(this).is(":radio") ){
                if($(this).is(":checked")){
                  	formval[name] = val;
               }
			} else {
               formval[name] = val;
           }
        }
    );
     var searchtrainstation = document.getElementsByName("searchtrainstation[]") ;
    if(searchtrainstation){
    	formval['searchtrainstation'] = {};
    	 for(var k = 0; k < searchtrainstation.length; k++){
    		 formval['searchtrainstation'][k] = searchtrainstation[k].value;
    	 }
     }
     var linesearchpage = document.getElementById("linesearchpage") ;
     if(linesearchpage){
     	 formval['linesearchpage'] = linesearchpage.value;
     }
     var searchareatag = document.getElementById("searchareatag") ;
     if(searchareatag){
   	formval['searcharea'] = searchareatag.value;
     }
     var searchtrainstationtag = document.getElementById("searchtrainstationtag") ;
     if(searchtrainstationtag){
   	formval['searchtrainstation'] = searchtrainstationtag.value;
     }
     var searchstationtag = document.getElementById("searchstationtag") ;
     if(searchstationtag){
   	formval['searchstation'] = searchstationtag.value;
     }
     var searchschoolelementarytag = document.getElementById("searchschoolelementarytag") ;
     if(searchschoolelementarytag){
   	formval['searchschoolelementary'] = searchschoolelementarytag.value;
     }
     var searchschooljuniorhightag = document.getElementById("searchschooljuniorhightag") ;
     if(searchschooljuniorhightag){
   	formval['searchschooljuniorhigh'] = searchschooljuniorhightag.value;
     }
	formval['method'] = 'count';
	var json ="";
	$.get("../../../ajax.php", formval, function(json){
	if (json.length > 0){
		 point = json.indexOf('{"count"',0);
		var data = eval( '('+json.substr(point,100)+')' );
		  for (var key in data) {
			if(key != '' && key == 'count'){
				$('#' + countvar_id).html(data[key]);
				$('#' + showtarget_id).show();
			}
     	  }
   } else {
   	
   }
  })	
    formval = {};
	
}	
function makeJSON(hash){
	  var init = true;
	  var str = '{';
	  for(var i in hash){
	    if(!init) str += ',';
	    str += '"' + i.replace('"', '\\"', 'g') + '":"';
	    str += hash[i].replace('"', '\\"', 'g') + '"';
	    init = false;
	  }
	  str += '}';
	  return str;
	}

//駅の取得
function changeStationSlection2(train_line_id, selectionId, station_id){
	
	$.ajax({
		type: "GET",
		url: ".././ajax.php",
		async: false,
		data: {train_line_id : train_line_id, method : "get_stations"},
		success: function(json){
			var node = window.document.getElementById(selectionId);
			if (node != null) {
				if (json.length > 0) {
					var data = eval('(' + json + ')');
					node.options.length = 0;
					var index = 0;
					for (var key in data) {
						node.options[index] = new Option(data[key], key);
						if (station_id != '' && key == station_id) {
							var station_index = index;
						}
						index++;
					}
				}
				if (station_index != '') {
					node.selectedIndex = station_index;
				}
				else {
					node.selectedIndex = 0;
				}
			}
		}
	});
}


// 駅探コードの取得
function getEkitanCode2(source, selectionId, textbox, caution, ekitan_code) {
	// hiddenの値をリセット
	$('#' + textbox).val('');
	var	node = window.document.getElementById(source);
	if(node != null) {
		var station_id = node.value;
		if(station_id != null && station_id != '') {
			$.get("../../ajax.php", {station_id : station_id, method : "get_ekitan_code"}, function(json){
			var	targetnode = window.document.getElementById(selectionId);
			
				if (targetnode != null) {
					if (json.length > 0) {
						var data = eval('(' + json + ')');
						targetnode.options.length = 0;
						var index = 0;
						for (key in data) {
						if (ekitan_code != '' && key == ekitan_code) {
							var ekitan_index = index;
						}
							targetnode.options[index] = new Option(data[key], key);
							index++;
						}
						if(index > 1) {
				     		$('#' + selectionId).show();
				     		$('#' + caution).show();
				     		$('#' + textbox).val('');
						} else {
				     		$('#' + selectionId).hide();
				     		$('#' + caution).hide();
				     		$('#' + textbox).val(targetnode.options[0].value);
						}
					}
					if (ekitan_index != '') {
						targetnode.selectedIndex = ekitan_index;
					}
					else {
						targetnode.selectedIndex = 0;
					}
				}
			});
		}else {
	   		$('#' + selectionId).hide();
     		$('#' + textbox).val('');
    		$('#' + caution).hide();
		}
	} else {
	   		$('#' + selectionId).hide();
	   		$('#' + textbox).val('');
     		$('#' + caution).hide();
		}
	}

function getRequiredTime2(object_station_code, customer_station_code, timefield){
  $.get("../../../ajax.php", {station_from : customer_station_code, station_to : object_station_code, method : "get_require_time2"}, function(json){
	if (json.length > 0){
		var data = eval( '('+json+')' );
				if('time' in data) {
				    $('#' + timefield).html(data['time']);
				}
	} else {
   	// 値が取得できない場合は駅名が不正
	    $('#' + timefield).html('?');
   }

  }) 
}

function showPreferredSelectBloc(blockid){
	viewObj = new Array(3);
	viewObj[1] = document.getElementById("selectblock1");
	viewObj[2] = document.getElementById("selectblock2");
	viewObj[1].style.display = "none" ;
	viewObj[2].style.display = "none" ;
	if(viewObj[blockid]){
		viewObj[blockid].style.display = "" ;
	}
		
}





