//from 28,OCT,2005
//script used by JavaScript

//---デザイン会社が作ったJavaScript(Start)---
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
//---デザイン会社が作ったJavaScript(End)---

// --------------------------------------------------------------------------
// ブラウザサイズ取得（高さ）
// --------------------------------------------------------------------------
function getINNERHEIGHT(){
  var pageHEIGHT = 0;
  _dom = document.all ? ( document.getElementById ? 2 : 1 ) : ( document.getElementById ? 4 : ( document.layers ? 3 : 0 ) );

  if( _dom == 4 || _dom == 3 ) pageHEIGHT = window.innerHeight; //NN
  if( _dom == 2 || _dom == 1 ) pageHEIGHT = document.body.clientHeight; //IE

 return pageHEIGHT;
}

// --------------------------------------------------------------------------
// ブラウザサイズ取得（幅）
// --------------------------------------------------------------------------
function getINNERWIDTH(){
  var pageWIDTH = 0;

  _dom = document.all ? ( document.getElementById ? 2 : 1 ) : ( document.getElementById ? 4 : ( document.layers ? 3 : 0 ) );

  if( _dom == 4 || _dom == 3 ) pageWIDTH = window.innerWidth; //NN
  if( _dom == 2 || _dom == 1 ) pageWIDTH = document.body.clientWidth; //IE

  return pageWIDTH;
}

// ----------------------------------------------------------
// 画面遷移用スクリプト（94_template.htm→D103への遷移専用）
// 【書式】
// 　　function tranPg_94toD103( $mode, $name, $val )
// 【引数】
// 　　$mode　　：　　遷移先画面ID
// 　　$name　　：　　パラメータ名（複数指定時はカンマ区切り）
// 　　$val 　　：　　パラメータ値（複数選択時はカンマ区切り）
// 【戻り値】
// 　　なし
// 【使用例】
// 　　tranPg_94toD103('F002', '', '');
// 　　tranPg_94toD103('F002', 'hdnArea', '10');
// 【備考】
// 　　なし
// ----------------------------------------------------------
function tranPg_94toD103( $mode, $name, $val ) {

  // 時刻とウィンドウサイズの取得
  dd = new Date();
  $t = dd.getTime();
  $h = getINNERHEIGHT();
  $w = getINNERWIDTH() - 10;
  $sh = screen.availHeight - 30;
  $sw = screen.availWidth - 200;
  var $tmp = "";
  var $tmp2 = "";

  var $tmpVal  = new Array();
  var $tmpName   = new Array();

  var $strSetAreacd = ""; // エリアコード       getパラメータ付加用変数
  var $strSetDcolor = ""; // 色コード           getパラメータ付加用変数
  var $strSetDtpflg = ""; // 個別派遣会社フラグ getパラメータ付加用変数
  var $strSetPub    = ""; // 仕事掲載区分       getパラメータ付加用変数
  var $numFlg = 0;        // 内部で使用するフラグ

  // 引数値の分解＆再構成
  if ( $name != "" ) {
    $tmpName = $name.split(",");
  }
  if ( $val != "" ) {
    $tmpVal = $val.split(",");
  }
  var $count = 1;
  for ( $i = 0; $i < $tmpVal.length; $i++ ) {
    if ( $tmpName[$i] == "" || $tmpName.length <= $i ) {
      $tmp = $tmp + "&id" + $count + "=" + $tmpVal[$i];
      $count++;
    } else if ( $tmpName[$i] == "#" ) {
      // #が渡されてきたらページ内リンクを設定する。
      $tmp2 = $tmpName[$i] + $tmpVal[$i];
    } else {
      $tmp = $tmp + "&" + $tmpName[$i] + "=" + $tmpVal[$i];
    }
  }

  $url_my = document.URL;
  $url_secStatus = '';
  if ( $url_my.match("https:\/\/") ) {
    $url_secStatus = '1';
  }
  else {
    $url_secStatus = '0';
  }
  $url_staff = '';
  if ( !$url_my.match("\/staff\/") ) {
    $url_staff = 'staff/';
  }
  $url_sp = $url_my.split( '/' );
  $cnt = $url_sp.length;
  $url_path = $url_sp.slice( 0, $cnt - 3 );
  $url_dir = $mode.substring( 0, 1 );

  //---- urlの設定
  $url = $strDomainName + $url_staff + $url_dir + "/" + $mode + "/";

  //---- getパラメータの設定
  //-- areacdの設定（全国区指定の場合は設定しない）
  if($getPara_areacd != ""){

    //値が99の場合→地域選択項目が非表示
    if($getPara_areacd == "99"){
      $getPara_areacd = "";
    }
    //hiddenパラメータによるareacd[]は単数入力だと配列と認識されないので処理を分ける
    if(document.bisco.elements["areacd[]"]){
      //areacd[]単数入力時
      if(document.bisco.elements["areacd[]"].length == undefined){
        $strSetAreacd = $strSetAreacd + "&areacd[]=" + document.bisco.elements["areacd[]"].value;
      }
      //areacd[]複数入力時
      else{
        for(i = 0; i < document.bisco.elements["areacd[]"].length; i++){
          $strSetAreacd = $strSetAreacd + "&areacd[]=" + document.bisco.elements["areacd[]"][i].value;
        }
      }
      $numFlg = 1;
    }
    //画面上の選択項目から入力時
    if(document.bisco.chiikicd){
      $strSetAreacd = $strSetAreacd + "&areacd[]=" + $getPara_areacd;
    }
  }

  //--色コードの設定
  //POSTデータを取得してGETパラメータとして付加する
  if(document.bisco.dcolor){
    if(document.bisco.dcolor.value != ""){
      $strSetDcolor = "&dcolor=" + document.bisco.dcolor.value;
    }
  }
  //--個別派遣会社フラグの設定
  //POSTデータを取得してGETパラメータとして付加する
  if(document.bisco.dtpflg){
    if(document.bisco.dtpflg.value != ""){
      $strSetDtpflg = "&dtpflg=" + document.bisco.dtpflg.value;
    }
  }

  //--仕事掲載区分の設定
  //POSTデータを取得してGETパラメータとして付加する
  if(document.bisco.pub){
    if(document.bisco.pub.value != ""){
      $strSetPub = "&pub=" + document.bisco.pub.value;
    }
  }

  //getパラメータの設定
  $prm = "?t=" + $t + "&h=" + $h + "&w=" + $w + "&sh=" + $sh + "&sw=" + $sw + "&s=" + $url_secStatus
       + $tmp + $tmp2 + $strSetAreacd + $strSetDcolor + $strSetDtpflg + $strSetPub;

  //urlにgetパラメータの付加
  $url = $url + $prm;

  this.document.bisco.action = $url;
  this.document.bisco.target = "_self";
  this.document.bisco.submit();
  
  return true;
}

// ↑下記 f_chk() の処理が正常に終了した時に処理される↑     //
// --------------------------------------------------------- //
// ↓「上記条件で検索」ボタン押下時に処理を行う↓            //

// ----------------------------------------------------------
// 「上記条件で検索」ボタン押下時に入力チェックを行う
// 【書式】
// 　　function f_chk()
// 【引数】
// 　　なし
// 【戻り値】
// 　　なし
// 【備考】
// 　　なし
// ----------------------------------------------------------
function f_chk(){

  //エラーカウント
  var err = 0;
  //性別未入力判定のカウントフラグ
  var sx  = 0;
  //エラーメッセージ文格納用文字列
  var msg ="";
  //エリア選択項目インデックス取得用フラグ
  var flag;

  // 性別 Select Check
  //性別選択項目がhiddenではない状態で画面上に表示してあり、且つ
  //intCheckGender が 1 の場合のみ入力チェックを行う
  if(document.bisco.elements["gendkb[]"] && 
     document.bisco.elements["gendkb[]"].type != "hidden" &&
     intCheckGender == 1){
    for( i=0; i < document.bisco.elements["gendkb[]"].length ; i++){
      //チェック結果がfalseだった場合、sxカウントフラグをインクリメントする
      if(document.bisco.elements["gendkb[]"][i].checked == false){
        sx++;
      }
    }
    //どちらの性別ともに入力がなかった場合
    if(sx == document.bisco.elements["gendkb[]"].length){
      err++;
      msg+="性別を選択して下さい\n";
    }
  }

  // エリア Select Check
  //※エリア選択項目がない場合には入力チェックをしない
  if(document.bisco.chiikicd){
    flag = document.bisco.chiikicd.selectedIndex;
    if(document.bisco.chiikicd.options[flag].value == "@"){
      err++;
      msg+="希望する地域（エリア）を選択して下さい\n";
    }
  }

  //上記チェックでエラーになった場合、alertを表示しfalseを返す
  if(err != 0){
    alert(msg);
    return false;
  }
  //上記チェックで正常である場合、
  //chiikicdのnameを変更して（f_ChangeAreaCdName()の処理）、
  //trueを返す
  else{

    if(document.bisco.chiikicd){
      f_ChangeAreaCdName();
    }
    return true;
  }
}

// ----------------------------------------------------------
// chiikicdを仕事情報検索条件に適応する配列名に変更
// 【書式】
// 　　function f_ChangeAreaCdName()
// 【引数】
// 　　なし
// 【戻り値】
// 　　なし
// 【備考】
// 　　なし
// ----------------------------------------------------------
function f_ChangeAreaCdName(){

  var flag   = document.bisco.chiikicd.selectedIndex;
  var val    = document.bisco.chiikicd.options[flag].value;
  var subStr = "";

  //地域コードの先頭にあるアルファベットを取得
  subStr = val.substring(0,1);

  //未選択の場合、falseを返す
  if(subStr == "@"){
    return false;

  //大分類
  }else if(subStr == "A"){
    //地域コードの数字のみを格納し、nameを大分類用に変更する
    document.bisco.chiikicd.options[flag].value = val.substring(5,10);
    document.bisco.chiikicd.name = "prefcd[]";
    //getパラメータに渡すareacdを定数に代入する
    $getPara_areacd = val.substring(2,4);

  //中分類
  }else if(subStr == "B"){
    //地域コードの数字のみを格納し、nameを中分類用に変更する
    document.bisco.chiikicd.options[flag].value = val.substring(5,10);
    document.bisco.chiikicd.name = "ctalcd[]";
    //getパラメータに渡すareacdを定数に代入する
    $getPara_areacd = val.substring(2,4);

  //小分類
  }else if(subStr == "C"){
    //地域コードの数字のみを格納し、nameを小分類用に変更する
    document.bisco.chiikicd.options[flag].value = val.substring(5,10);
    document.bisco.chiikicd.name = "ctpccd[]";
    //getパラメータに渡すareacdを定数に代入する
    $getPara_areacd = val.substring(2,4);

  //エリア分類
  }else if(subStr == "Y"){
    //地域コードの指定はしない、ただし全国区と区別させる為nameを変更する
    document.bisco.chiikicd.name = "c_blank";
    //getパラメータに渡すareacdを定数に代入する
    $getPara_areacd = val.substring(2,4);

  //全国区
  }else if(subStr == "Z"){
    //getパラメータに渡すareacdに空文字列を指定
    $getPara_areacd = "";
  }
}

// ↑「上記条件で検索」ボタン押下時に処理を行う↑            //
// --------------------------------------------------------- //
// ↓画面上にある特定項目の入力直後に処理を行う↓            //

// ----------------------------------------------------------
// 職種チェックボックス制御用スクリプト
// 【書式】
// 　　ccb(chkbox, $checktype, $chkParent)
// 【引数】
// 　　chkbox　　：　自分自身のインスタンス
// 　　$checktype：　チェックされたオブジェクトのタイプ(true:親 / false:子）
// 　　$chkParent：　職種大分類の要素名
// 　　$chkChild ：　職種中分類の要素名
// 【戻り値】
// 　　なし
// 【使用例】
// 　　ccb(this,true, 'jgmxcd[]','jgmdcd[]');
// 　　ccb(this,false,'jgmxcd[]','jgmdcd[]');
// 【備考】
// 　　ccb: Change CheckBox, copied from common.js
// ----------------------------------------------------------
function ccb( chkbox, $checktype, $chkParent, $chkChild){

  var $base = chkbox.value.substr(0,1);
  if ($checktype) {
    if(document.bisco.elements[$chkChild]){
      if(document.bisco.elements[$chkChild].length){
        for (i = 0;i < document.bisco.elements[$chkChild].length;i ++) {
          if (document.bisco.elements[$chkChild][i].value.substr(0,1) == $base) {
            document.bisco.elements[$chkChild][i].checked = false;
          }
        }
      }else{
         if (document.bisco.elements[$chkChild].value.substr(0,1) == $base) {
            document.bisco.elements[$chkChild].checked = false;
         }
      }
    }
  }
  else {
    if(document.bisco.elements[$chkParent]){
      if(document.bisco.elements[$chkParent].length){
        for (i = 0;i < document.bisco.elements[$chkParent].length;i ++) {
          if (document.bisco.elements[$chkParent][i].value.substr(0,1) == $base) {
            document.bisco.elements[$chkParent][i].checked = false;
         }
        }
      }else{
         if (document.bisco.elements[$chkParent].value.substr(0,1) == $base) {
            document.bisco.elements[$chkParent].checked = false;
         }
      }
    }
  }

  //trueを返す
  return true;
}

// ----------------------------------------------------------
// 給与プルダウン制御スクリプト1(給与-セットする配列を判定)
// 【書式】
// 　　function CreateSaryList()
// 【戻り値】
// 　　なし
// 【使用例】
// 　　CreateSaryList();
// 【備考】
// 　　なし
// ----------------------------------------------------------
function CreateSaryList()
{

  var SelectValue = document.bisco.srkbmstr.value;

  if(SelectValue == "00"){
    CreateSaryItem(strPay0,strPay0CD);
  } else if (SelectValue == "10"){
    CreateSaryItem(strPay1,strPay1CD);
  } else if (SelectValue == "20"){
    CreateSaryItem(strPay2,strPay2CD);
  } else if (SelectValue == "30"){
    CreateSaryItem(strPay3,strPay3CD);
  } else{
    //ブランクのプルダウンを表示
    f_areaItem1(strBlank, strBlankCD);
  }
}

// ----------------------------------------------------------
// 給与プルダウン制御スクリプト1(給与コンボ内容作成)
// 【書式】
// 　　function CreateSaryItem(objArray, objArrayCD)
// 【戻り値】
// 　　なし（画面上に連携プルダウンが無い場合、処理をせずにtrueを返す）
// 【使用例】
// 　　CreateSaryItem(array, array);
// 【備考】
// 　　なし
// ----------------------------------------------------------
function CreateSaryItem(objArray, objArrayCD)
{
  //画面上に給与の金額プルダウンが無い場合、処理を無効化する
  if(!document.bisco.sarymstr){
    return true;
  }

  var nMax = objArray.length;
  var nLoop = 0;

  //オプション数を設定
  document.bisco.sarymstr.length=nMax;

  //全ての選択項目の表示値と検索条件に使用する値を設定する
  for (nLoop = 0; nLoop < nMax; nLoop++)
  {
    document.bisco.sarymstr.options[nLoop].text = objArray[nLoop];
    document.bisco.sarymstr.options[nLoop].value = objArrayCD[nLoop];
  }
  document.bisco.sarymstr.options[0].selected = true;
}

