// 職種プルダウン生成
function loadOccupations(form) {
  if (form.occupations == null || form.occupationCategory == null) return;
  var select = form.occupationCategory;
  var selectedOptions = select.options;
  var targetOptions = form.occupations.options;
  var optionTitle = new Array();
  var optionValue = new Array();
  var selectedValue = 0;
  optionTitle[0] = '▼';
  optionValue[0] = '';
  if (selectedOptions.selectedIndex == 1) {
    optionTitle[1] = 'OA事務';
    optionValue[1] = '1010';
    optionTitle[2] = '営業事務';
    optionValue[2] = '1020';
    optionTitle[3] = '貿易事務・国際事務';
    optionValue[3] = '1030';
    optionTitle[4] = '英文事務';
    optionValue[4] = '1040';
    optionTitle[5] = '通訳・翻訳';
    optionValue[5] = '1050';
    optionTitle[6] = '金融事務（銀行・証券）';
    optionValue[6] = '1060';
    optionTitle[7] = '金融事務（生保・損保）';
    optionValue[7] = '1070';
    optionTitle[8] = '金融事務（その他）';
    optionValue[8] = '1080';
    optionTitle[9] = '経理・財務・会計';
    optionValue[9] = '1090';
    optionTitle[10] = '総務・人事・法務';
    optionValue[10] = '1100';
    optionTitle[11] = '広報・宣伝・IR';
    optionValue[11] = '1110';
    optionTitle[12] = '秘書';
    optionValue[12] = '1120';
    optionTitle[13] = '受付';
    optionValue[13] = '1130';
    optionTitle[14] = 'データ入力';
    optionValue[14] = '1140';
    optionTitle[15] = 'OAオペレータ';
    optionValue[15] = '1150';
    optionTitle[16] = '企画・販促・マーケティング・コンサル';
    optionValue[16] = '1160';
    optionTitle[17] = '学校事務';
    optionValue[17] = '1170';
    optionTitle[18] = '特許事務';
    optionValue[18] = '1180';
    optionTitle[19] = 'その他オフィスワーク関連';
    optionValue[19] = '1190';
  }
  if (selectedOptions.selectedIndex == 2) {
    optionTitle[1] = '営業・企画営業・ラウンダー';
    optionValue[1] = '2010';
    optionTitle[2] = '営業アシスタント';
    optionValue[2] = '2020';
    optionTitle[3] = '販売（ファッション・コスメ）';
    optionValue[3] = '2030';
    optionTitle[4] = '販売（家電・携帯電話）';
    optionValue[4] = '2040';
    optionTitle[5] = '販売（その他）';
    optionValue[5] = '2050';
    optionTitle[6] = 'テレマーケティング・テレフォンオペレータ';
    optionValue[6] = '2060';
    optionTitle[7] = 'スーパーバイザー';
    optionValue[7] = '2070';
    optionTitle[8] = '接客・窓口カウンター';
    optionValue[8] = '2080';
    optionTitle[9] = '旅行関連';
    optionValue[9] = '2090';
    optionTitle[10] = 'ホテル・ブライダル関連';
    optionValue[10] = '2100';
    optionTitle[11] = '美容・理容・エステティシャン';
    optionValue[11] = '2110';
    optionTitle[12] = 'その他営業・販売関連';
    optionValue[12] = '2120';
  }
  if (selectedOptions.selectedIndex == 3) {
    optionTitle[1] = 'SE（ビジネスアプリケーション系）';
    optionValue[1] = '3010';
    optionTitle[2] = 'SE（制御系）';
    optionValue[2] = '3020';
    optionTitle[3] = 'SE（データベース系）';
    optionValue[3] = '3030';
    optionTitle[4] = 'SE（Web・モバイル系）';
    optionValue[4] = '3040';
    optionTitle[5] = 'SE（その他）';
    optionValue[5] = '3050';
    optionTitle[6] = 'プログラマ';
    optionValue[6] = '3060';
    optionTitle[7] = 'ネットワークエンジニア';
    optionValue[7] = '3070';
    optionTitle[8] = '運用管理・保守';
    optionValue[8] = '3080';
    optionTitle[9] = 'ユーザーサポート・ヘルプデスク';
    optionValue[9] = '3090';
    optionTitle[10] = 'OAインストラクター';
    optionValue[10] = '3100';
    optionTitle[11] = '研究・開発（IT・技術）';
    optionValue[11] = '3110';
    optionTitle[12] = 'テスト・評価 ';
    optionValue[12] = '3120';
    optionTitle[13] = 'CADオペレータ';
    optionValue[13] = '3130';
    optionTitle[14] = 'CAD設計';
    optionValue[14] = '3140';
    optionTitle[15] = '設計（電子・機械・建築）';
    optionValue[15] = '3150';
    optionTitle[16] = 'その他IT・技術関連';
    optionValue[16] = '3160';
  }
  if (selectedOptions.selectedIndex == 4) {
    optionTitle[1] = 'デザイナー（ファッション）';
    optionValue[1] = '4010';
    optionTitle[2] = 'デザイナー（インテリア・住宅）';
    optionValue[2] = '4020';
    optionTitle[3] = 'Webデザイナー';
    optionValue[3] = '4030';
    optionTitle[4] = 'Web制作・編集';
    optionValue[4] = '4040';
    optionTitle[5] = 'Webディレクター・プロデューサー';
    optionValue[5] = '4050';
    optionTitle[6] = '編集・制作・校正・印刷関連';
    optionValue[6] = '4060';
    optionTitle[7] = 'DTPオペレータ';
    optionValue[7] = '4070';
    optionTitle[8] = '広告デザイン・グラフィックスデザイン';
    optionValue[8] = '4080';
    optionTitle[9] = '映像・音響';
    optionValue[9] = '4090';
    optionTitle[10] = 'その他クリエイティブ関連';
    optionValue[10] = '4100';
  }
  if (selectedOptions.selectedIndex == 5) {
    optionTitle[1] = '医療事務';
    optionValue[1] = '5010';
    optionTitle[2] = '治験関連';
    optionValue[2] = '5020';
    optionTitle[3] = '介護関連';
    optionValue[3] = '5030';
    optionTitle[4] = '看護師・准看護師';
    optionValue[4] = '5040';
    optionTitle[5] = '薬剤師・栄養士';
    optionValue[5] = '5050';
    optionTitle[6] = '保育士';
    optionValue[6] = '5060';
    optionTitle[7] = '研究・開発（バイオ・メディカル他）';
    optionValue[7] = '5070';
    optionTitle[8] = 'その他医療・福祉・介護関連';
    optionValue[8] = '5080';
  }
  if (selectedOptions.selectedIndex == 6) {
    optionTitle[1] = '製造・物流関連';
    optionValue[1] = '6010';
    optionTitle[2] = '軽作業';
    optionValue[2] = '6020';
    optionTitle[3] = 'インストラクター・講師・教師';
    optionValue[3] = '6030';
    optionTitle[4] = 'その他';
    optionValue[4] = '6040';
  }
  targetOptions.length = 0;
  for (i = 0; i < optionTitle.length; i++) {
    targetOptions[i] = new Option(optionTitle[i]);
    targetOptions[i].value = optionValue[i];
  }
  targetOptions[selectedValue].selected=true;
}
// 給与金額プルダウン生成
function loadPayments(form) {
  var select = form.paymentCategory;
  var selectedOptions = select.options;
  var targetOptions = form.payment.options;
  var optionTitle = new Array();
  var optionValue = new Array();
  var selectedValue = 0;
  optionTitle[0] = '給与金額';
  optionValue[0] = '';
  if (selectedOptions.selectedIndex == 1) {
    optionTitle[1] = '800円以上';
    optionValue[1] = '1';
    optionTitle[2] = '850円以上';
    optionValue[2] = '2';
    optionTitle[3] = '900円以上';
    optionValue[3] = '3';
    optionTitle[4] = '950円以上';
    optionValue[4] = '4';
    optionTitle[5] = '1000円以上';
    optionValue[5] = '5';
    optionTitle[6] = '1050円以上';
    optionValue[6] = '6';
    optionTitle[7] = '1100円以上';
    optionValue[7] = '7';
    optionTitle[8] = '1150円以上';
    optionValue[8] = '8';
    optionTitle[9] = '1200円以上';
    optionValue[9] = '9';
    optionTitle[10] = '1250円以上';
    optionValue[10] = '10';
    optionTitle[11] = '1300円以上';
    optionValue[11] = '11';
    optionTitle[12] = '1350円以上';
    optionValue[12] = '12';
    optionTitle[13] = '1400円以上';
    optionValue[13] = '13';
    optionTitle[14] = '1450円以上';
    optionValue[14] = '14';
    optionTitle[15] = '1500円以上';
    optionValue[15] = '15';
    optionTitle[16] = '1550円以上';
    optionValue[16] = '16';
    optionTitle[17] = '1600円以上';
    optionValue[17] = '17';
    optionTitle[18] = '1650円以上';
    optionValue[18] = '18';
    optionTitle[19] = '1700円以上';
    optionValue[19] = '19';
    optionTitle[20] = '1750円以上';
    optionValue[20] = '20';
    optionTitle[21] = '1800円以上';
    optionValue[21] = '21';
    optionTitle[22] = '1850円以上';
    optionValue[22] = '22';
    optionTitle[23] = '1900円以上';
    optionValue[23] = '23';
    optionTitle[24] = '1950円以上';
    optionValue[24] = '24';
    optionTitle[25] = '2000円以上';
    optionValue[25] = '25';
  }
  if (selectedOptions.selectedIndex == 2) {
    optionTitle[1] = '10万円以上';
    optionValue[1] = '26';
    optionTitle[2] = '15万円以上';
    optionValue[2] = '27';
    optionTitle[3] = '20万円以上';
    optionValue[3] = '28';
    optionTitle[4] = '25万円以上';
    optionValue[4] = '29';
    optionTitle[5] = '30万円以上';
    optionValue[5] = '30';
    optionTitle[6] = '35万円以上';
    optionValue[6] = '31';
    optionTitle[7] = '40万円以上';
    optionValue[7] = '32';
  }
  if (selectedOptions.selectedIndex == 3) {
    optionTitle[1] = '4000円以上';
    optionValue[1] = '33';
    optionTitle[2] = '5000円以上';
    optionValue[2] = '34';
    optionTitle[3] = '6000円以上';
    optionValue[3] = '35';
    optionTitle[4] = '7000円以上';
    optionValue[4] = '36';
    optionTitle[5] = '8000円以上';
    optionValue[5] = '37';
    optionTitle[6] = '9000円以上';
    optionValue[6] = '38';
    optionTitle[7] = '10000円以上';
    optionValue[7] = '39';
  }
  targetOptions.length = 0;
  for (i = 0; i < optionTitle.length; i++) {
    targetOptions[i] = new Option(optionTitle[i]);
    targetOptions[i].value = optionValue[i];
  }
  targetOptions[selectedValue].selected=true;
}
// 給与金額プルダウン初期化
function loadSelectedPayments(form) {
}
// 勤務地プルダウン生成
function loadAreas(select) {
  if(select == null) {
    return;
  }
  var selectedOptions = select.options;
  var targetOptions0 = document.f[0].areaMedium.options;
  var optionTitle = new Array();
  var optionValue = new Array();
  var selectedValue = 0;
  optionTitle[0] = '▼';
  optionValue[0] = '';
  for (i = 0; i < selectedOptions.length; i++) {
  if (selectedOptions.selectedIndex == i && selectedOptions[i].value == '080') {
    optionTitle[1] = '全域';
    optionValue[1] = '080099';
  }
  }
  for (i = 0; i < selectedOptions.length; i++) {
  if (selectedOptions.selectedIndex == i && selectedOptions[i].value == '090') {
    optionTitle[1] = '全域';
    optionValue[1] = '090099';
  }
  }
  for (i = 0; i < selectedOptions.length; i++) {
  if (selectedOptions.selectedIndex == i && selectedOptions[i].value == '100') {
    optionTitle[1] = '全域';
    optionValue[1] = '100099';
  }
  }
  for (i = 0; i < selectedOptions.length; i++) {
  if (selectedOptions.selectedIndex == i && selectedOptions[i].value == '110') {
    optionTitle[1] = 'さいたま市';
    optionValue[1] = '110010';
    optionTitle[2] = 'その他埼玉県';
    optionValue[2] = '110099';
  }
  }
  for (i = 0; i < selectedOptions.length; i++) {
  if (selectedOptions.selectedIndex == i && selectedOptions[i].value == '120') {
    optionTitle[1] = '千葉市';
    optionValue[1] = '120010';
    optionTitle[2] = 'その他千葉県';
    optionValue[2] = '120099';
  }
  }
  for (i = 0; i < selectedOptions.length; i++) {
  if (selectedOptions.selectedIndex == i && selectedOptions[i].value == '131') {
    optionTitle[1] = '千代田区・中央区';
    optionValue[1] = '131010';
    optionTitle[2] = '港区・渋谷区';
    optionValue[2] = '131020';
    optionTitle[3] = '新宿区・中野区・杉並区';
    optionValue[3] = '131030';
    optionTitle[4] = '文京区・台東区';
    optionValue[4] = '131040';
    optionTitle[5] = '墨田区・江東区・江戸川区';
    optionValue[5] = '131050';
    optionTitle[6] = '品川区・大田区';
    optionValue[6] = '131060';
    optionTitle[7] = '目黒区・世田谷区';
    optionValue[7] = '131070';
    optionTitle[8] = '豊島区・北区';
    optionValue[8] = '131080';
    optionTitle[9] = '板橋区・練馬区';
    optionValue[9] = '131090';
    optionTitle[10] = '荒川区・足立区・葛飾区';
    optionValue[10] = '131100';
  }
  }
  for (i = 0; i < selectedOptions.length; i++) {
  if (selectedOptions.selectedIndex == i && selectedOptions[i].value == '139') {
    optionTitle[1] = 'その他東京都';
    optionValue[1] = '139099';
  }
  }
  for (i = 0; i < selectedOptions.length; i++) {
  if (selectedOptions.selectedIndex == i && selectedOptions[i].value == '140') {
    optionTitle[1] = '横浜市';
    optionValue[1] = '140010';
    optionTitle[2] = '川崎市';
    optionValue[2] = '140020';
    optionTitle[3] = 'その他神奈川県';
    optionValue[3] = '140099';
  }
  }
  targetOptions0.length = 0;
  for (i = 0; i < optionTitle.length; i++) {
    targetOptions0[i] = new Option(optionTitle[i]);
    targetOptions0[i].value = optionValue[i];
  }
  targetOptions0[selectedValue].selected=true;
}
// 勤務地プルダウン初期化
function loadSelectedAreas() {
}
// 小勤務地チェックを外す
function uncheckAreaSmalls() {
  if(document.f[0].areaSmalls != null) {
    for (i = 0; document.f[0].areaSmalls.length; i++) {
      document.f[0].areaSmalls[i].checked = false;
      document.f[1].areaSmalls[i].checked = false;
    }
  }
}
function loadSelectBox(form) {
  loadOccupations(form);
  loadSelectedPayments(form);
  loadSelectedAreas();
}

function postStep(step) {
  document.formBody.step.value = step;
  document.formBody.begin.value = 0;
  document.formBody.submit();
}

function postBegin(begin) {
  document.formBody.begin.value = begin;
  document.formBody.submit();
}

function postStyle(style) {
  document.formBody.style.value = style;
  document.formBody.submit();
}

function postOrderBy(orderBy) {
  document.formBody.orderBy.value = orderBy;
  document.formBody.submit();
}

function saveQuery() {
  document.f[0].action = '/auth/query/detail_search.html';
  document.f[0].submit();
}

function jobSearch() {
  document.f[0].action = '/job/search.html';
  document.f[0].submit();
}

function postUserFavoriteJob() {
  paramWrite();
  var baseAction = document.formBody.action;
  window.open('', 'user_favorite_job', 'menubar=no,scrollbars=yes,resizable=yes,width=590,height=500');
  document.formBody.action = '/search/user_favorite_job_add.html';
  document.formBody.target = 'user_favorite_job';
  document.formBody.submit();
  // 親ウィンドウのアクションは元に戻す
  document.formBody.action = baseAction;
  document.formBody.target = '_self';
}

function postApplication() {
//  var checkedFlg = isCheckBoxChecked(document.formBody.jobIds);

  var checkedFlg = getArraysLength();
  if(checkedFlg) {
    paramWrite();
    document.getElementById('errorHiddenArea').style.display='none';
    document.formBody.action = '/application/job-application.html';
    document.formBody.submit();
  } else {
    document.getElementById('errorHiddenArea').style.display='block';
  }
}

function isCheckBoxChecked(checkBoxes) {
  var flg = false;
  if(checkBoxes != null) {
    if (checkBoxes.length) {
      for (var i = 0; i < checkBoxes.length; i++) {
        if (checkBoxes[i].checked) {
          flg = true;
        }
      }
    } else {
      if (checkBoxes.checked) {
          flg = true;
      }
    }
  }
  return flg;
}

function init(){
 getOccupationCategory();
 getmPaymentCategory();
 getWorkPeriod();
 getBlock(document.f[0].blockId.options,'勤務地',true);
}

function init2(paymentId){
 getBlock(document.f2.blockId.options,'指定なし',false);
 getPaymentCategory(paymentId,document.f2.payment.options);
 getOccupationAndCategory();
}

function init3(paymentId){
 getBlock(document.f2.blockId.options,'指定なし',false);
 getPaymentCategory(paymentId,document.f2.payment.options);
}

function init_rirekisyo_3(){
 var target = document.f;
 for(var i=0;i<target.length;i++){
  getBlock(target[i].blockId.options,'指定なし',false);
 }
 for(var i=0;i<target.length;i++){
  getPaymentCategory(1,target[i].payment.options);
 }
}

function getBlock(targetOptions,str,selectLargArea){
  var optionTitle = new Array();
  var optionValue = new Array();
  optionTitle[0] = str;
  optionValue[0] = '';
      optionTitle[1] = '北海道';
    optionValue[1] = '5';
      optionTitle[2] = '東北';
    optionValue[2] = '6';
      optionTitle[3] = '甲信越・北陸';
    optionValue[3] = '7';
      optionTitle[4] = '関東';
    optionValue[4] = '1';
      optionTitle[5] = '東海';
    optionValue[5] = '3';
      optionTitle[6] = '関西';
    optionValue[6] = '2';
      optionTitle[7] = '中国・四国';
    optionValue[7] = '8';
      optionTitle[8] = '九州・沖縄';
    optionValue[8] = '9';
    for( var i=0;i<optionTitle.length;i++ ){
    targetOptions[i] = new Option(optionTitle[i]);
    targetOptions[i].value = optionValue[i];
  }

  var cookieArr = document.cookie.split(" ");
  var blockId;
  for( var i=0;i<cookieArr.length;i++){
     var temp = cookieArr[i].split("=");
     if(temp[0]=="blockId"){ blockId = temp[1].charAt(0); }
  }

  if( blockId != null && blockId != "" ){
     for( var i=0;i<targetOptions.length;i++ ){
       if( blockId == targetOptions[i].value ){
         targetOptions[i].selected = true;
       }
     }
     if(selectLargArea){
      getLargeAreaByBlockId(blockId);
     }
  }
}

function getOccupationCategory(){
  var targetOptions = document.f[0].occupationCategory.options;
  var optionTitle = new Array();
  var optionValue = new Array();
  optionTitle[0] = '職種';
  optionValue[0] = '';
      optionTitle[1] = 'オフィスワーク系';
    optionValue[1] = '1';
      optionTitle[2] = '営業・販売系';
    optionValue[2] = '2';
      optionTitle[3] = 'IT・技術系';
    optionValue[3] = '3';
      optionTitle[4] = 'クリエイティブ系';
    optionValue[4] = '4';
      optionTitle[5] = '医療・福祉・介護系';
    optionValue[5] = '5';
      optionTitle[6] = 'その他';
    optionValue[6] = '6';
    for( var i=1;i<optionTitle.length;i++ ){
    targetOptions[i] = new Option('職種 : '+optionTitle[i]);
    targetOptions[i].value = optionValue[i];
  }
}

function getmPaymentCategory(){
  var targetOptions = document.f[0].paymentCategory.options;
  var optionTitle = new Array();
  var optionValue = new Array();
  optionTitle[0] = '給与形態';
  optionValue[0] = '';
      optionTitle[1] = '時給';
    optionValue[1] = '1';
      optionTitle[2] = '月給';
    optionValue[2] = '2';
      optionTitle[3] = '日給';
    optionValue[3] = '3';
    for( var i=1;i<optionTitle.length;i++ ){
    targetOptions[i] = new Option(optionTitle[i]);
    targetOptions[i].value = optionValue[i];
  }
}

function getWorkPeriod(){
  var targetOptions = document.f[0].workPeriod.options;
  var optionTitle = new Array();
  var optionValue = new Array();
  optionTitle[0] = '期間';
  optionValue[0] = '';
      optionTitle[1] = '長期（3カ月以上）';
    optionValue[1] = '1';
      optionTitle[2] = '短期（3カ月未満）';
    optionValue[2] = '2';
      optionTitle[3] = '単発（10日以内）';
    optionValue[3] = '3';
    for( var i=1;i<optionTitle.length;i++ ){
    targetOptions[i] = new Option(optionTitle[i]);
    targetOptions[i].value = optionValue[i];
  }
}


