function checkAllTypeForSearch (fn,ch,en,start,num) {
  var fn;
	var en;
	var num;
    with (document.forms[fn]) {
        if (elements[ch].checked) {
            for (i=start; i<(start+num); i++) {
                elements[en + "_" + i + "]"].checked = true;
            }
        } else {
            for (i=start; i<(start+num); i++) {
                elements[en + "_" + i + "]"].checked = false;
            }
        }
    }
}

function save_search_cond (fn) {
    document.forms[fn].method = 'post';
    document.forms[fn].action = '/staff/orders/save_search_cond';
    document.forms[fn].submit();
}


function all_submit(action) {
  	if(action == '/staff/order_bookmarks/entries') {
	  res = window.confirm('一括お気に入りしますか?');
	  if(res == false){
	  	return;
	  }
	}
    document.forms["actionform"].method = 'post';
    document.forms["actionform"].action = action;
    document.forms["actionform"].submit();
}

/*
 * お仕事条件保存の確認メッセージ
 */
function submit_confirm(action) {
  	if(action.match =(/\/staff\/orders\/delete_search_cond/)) {
	  res = window.confirm('この検索条件を削除しますか?');
	  if(res == false){
	  	return;
	  }
	}
    location.href = action;
}

function show_address(p_action, form_name, next_action_name) {
    win = window.open("", "show_address", "height=340,width=450,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,top=0,left=0");
    document.forms[form_name].method = "post";
    document.forms[form_name].action = p_action;
    document.forms[form_name].target = "show_address";
    document.forms[form_name].submit();
    document.forms[form_name].target = "";
    document.forms[form_name].action = next_action_name;
    win.focus();
}

function show_search_condition_name(p_action, form_name, next_action_name) {
		var dlg_width = 450;
		var dlg_height = 230;
		var dlg_top = (getWindowHeight() - dlg_height) / 2;
		var dlg_left = (getWindowWidth() - dlg_width) / 2;
    var win = window.open("", "search_condition_name", "height=" + dlg_height + ",width=" + dlg_width + ",scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,top=" + dlg_top + ",left=" + dlg_left);
		document.forms[form_name].method = "post";
    document.forms[form_name].action = p_action;
    document.forms[form_name].target = "search_condition_name";
    document.forms[form_name].submit();
    document.forms[form_name].target = "";
    document.forms[form_name].action = next_action_name;
    win.focus();
}

/* inputするとき、ボタンではなくリンクにしたい場合
 例：
  <% form_tag({:action => "index"}, :name => 'back') do %>～～～<% end %>
  <a href="javascript:input_form('back')">入力画面に戻る</a>
*/
function input_form(formName){ document.forms[formName].submit(); }

function submit_with_fn(fn, meth, action) {
    document.forms[fn].method = meth;
    document.forms[fn].action = action;
    document.forms[fn].submit();
}

function changeSelectValue(t) {
    if(t == document.forms['actionform'].elements['sort_cond_bottom']){
        if(document.forms['actionform'].elements['search_sort_cond'].selectedIndex != t.selectedIndex) {
            document.forms['actionform'].elements['search_sort_cond'].selectedIndex = t.selectedIndex;
         }
    } else {
        if(document.forms['actionform'].elements['sort_cond_bottom'].selectedIndex != t.selectedIndex) {
            document.forms['actionform'].elements['sort_cond_bottom'].selectedIndex = t.selectedIndex;
        }
    }
   document.forms['actionform'].elements['page'].value = '1';
   document.forms['actionform'].method = "post";
   document.forms['actionform'].submit();
}


function submit_with_fn_page_no(fn, meth, action, page_no) {
    document.forms[fn].method = meth;
    document.forms[fn].action = action;
    document.forms[fn].elements['page'].value = page_no;
    document.forms[fn].submit();
}

function draw_railroad_mst_id_name(name) {
	document.getElementById('railroad_mst_id_name').innerHTML = name;
}

function draw_railroad_mst_id_name_2(name) {
	document.getElementById('railroad_mst_id_name_2').innerHTML = name;
}

function getWindowHeight(){
  if(window.self && self.innerHeight){
    return self.innerHeight;
  }
  if(document.documentElement && document.documentElement.clientHeight){
    return document.documentElement.clientHeight;
  }
  return 0;
}

function getWindowWidth(){
  if(window.self && self.innerWidth){
    return self.innerWidth;
  }
  if(document.documentElement && document.documentElement.clientWidth){
    return document.documentElement.clientWidth;
  }
  return 0;
}
/* 
 * 沿線クリアボタン用 (仮登録および登録情報変更)
 * 第一引数/フォーム名称
 * 第二引数/沿線 1 or 2
*/
function railroadClearBtn(fn,i) {
	if(i == 2){
    draw_railroad_mst_id_name_2('');
    document.forms[fn].elements['staff[h_railroad_info_2]'].value='';
    document.forms[fn].elements['staff[railroad_mst_id_2]'].value='';
    /*
    document.forms[fn].elements['staff[station_name_2]'].value='';
    document.forms[fn].elements['staff[commute_type_kbn_2]'].value='';
    document.forms[fn].elements['staff[commute_time_2]'].value='';
    */
  }else{
    draw_railroad_mst_id_name('');
    document.forms[fn].elements['staff[h_railroad_info]'].value='';
    document.forms[fn].elements['staff[railroad_mst_id]'].value='';
    /*
    document.forms[fn].elements['staff[station_name]'].value='';
    document.forms[fn].elements['staff[commute_type_kbn]'].value='';
    document.forms[fn].elements['staff[commute_time]'].value='';
    */
  }
}

/* 
 * 詳細情報作成時ダブルクリック禁止
*/

function disableImgDblClick(url) {
    var obj=document.getElementById("pre_register_detail_img");
    obj.innerHTML="<img src=\"/images/staff/entry/btn_detail_entry_off.gif\" class=\"btn\"><br/>処理中です"; 
    location.href=url;
}
