/*   street.js  */
    var xmlHttp = createXmlHttpRequestObject();
    var last_modified = "Thu, 01 Jun 1970 00:00:00 GMT";
    

function createXmlHttpRequestObject() {

    if( window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }else if( window.ActiveXObject) {
        try {
            xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
        }
        catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    if( !xmlHttp) {
        alert("Error creating the XMLHttpRequest object.");
    }
    return xmlHttp;
}

function change_area(form_name) {
    var area = document.forms[form_name].area.value;

    if(area) {
        //document.forms[form_name].action = "/" + area + "/index.html";
        document.forms[form_name].action = "/" + area + "/index.htm";
    }
}

function change_rr_area() {
    var rr_name = encodeURIComponent(document.form1.rr_name.value);
    var line_cd = document.form1.line_cd.value;
    try {
        url = "/common/rrarea/job.html?rr_name="+rr_name+"&line_cd="+line_cd;
        xmlHttp.open("GET", url , true);
        xmlHttp.setRequestHeader("If-Modified-Since",last_modified);
        xmlHttp.onreadystatechange = change_rr_area_end;
        xmlHttp.send(null);
    } catch (e) {
       alert("Can't connect to server !" + e.toString());
    }
}
function change_rr_area_end() {
    setInterval("timeoutError()",60000);
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        var p = eval("("+xmlHttp.responseText+")");
        if(p != null){
            var area = p[0].area_name;
            //document.form1.action = "/" + area + "/index.html";
            document.form1.action = "/" + area + "/index.htm";
        }
    }
}


/* エリアから探す ここから*/
function change_pref(){
    var optionIndex0 = document.form1.ward_cd.options.length; //OPTION数取得

    for ( i=0 ; i <= optionIndex0 ; i++ ){
        document.form1.ward_cd.options[0]=null;
    }    
    document.form1.ward_cd.options[0] = new Option("市区町村を選択",""); //OPTIONを空に

    var option0 = document.form1.pref_cd.options.length; //OPTION数取得
    for ( i=0 ; i <= option0 ; i++ ){
        document.form1.pref_cd.options[0]=null;
    }                                  
    document.form1.pref_cd.options[0] = new Option("都道府県を選択",""); //OPTIONを空に

    try {
        var area = document.form1.area.value;
        url = "/common/area/job.html?area="+area;
        xmlHttp.open("GET", url , true);
        xmlHttp.setRequestHeader("If-Modified-Since",last_modified);
        xmlHttp.onreadystatechange = change_pref_end;
        xmlHttp.send(null);
    } catch (e) {
       alert("Can't connect to server !" + e.toString());
    }
}

function change_pref2(){
  try {
    var area = document.form2.area.value;
    url = "/common/area/job.html?area="+area;
    xmlHttp.open("GET", url , true);
    xmlHttp.setRequestHeader("If-Modified-Since",last_modified);
    xmlHttp.onreadystatechange = change_pref_end2;
    xmlHttp.send(null);
    } catch (e) {
       alert("Can't connect to server !" + e.toString());
    }
}

function change_pref_end() {
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        p = eval("("+xmlHttp.responseText+")");
        var optionIndex0 = document.form1.pref_cd.options.length; //沿線のOPTION数取得

        for ( i=0 ; i <= optionIndex0 ; i++ ){
            document.form1.pref_cd.options[0]=null;
        } //沿線削除
    
        document.form1.pref_cd.options[0] = new Option("都道府県を選択",""); //駅OPTIONを空に

        if(p != null){
            document.form1.pref_cd.options[0] = new Option("都道府県を選択",""); //OPTION1番目はNull
            for( i=0; i<p.length; i++){
                ii = i + 1 ;    //OPTIONは2番目から表示
                var op_pref_name = p[i].pref_name;
                var op_pref_cd = p[i].pref_cd;
                
                document.form1.pref_cd.options[ii] = new Option(op_pref_name,op_pref_cd);
            }
        }
    }

}
function change_pref_end2() {
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        p = eval("("+xmlHttp.responseText+")");
        var optionIndex0 = document.form2.pref_cd.options.length;

        for ( i=0 ; i <= optionIndex0 ; i++ ){
            document.form2.pref_cd.options[0]=null;
        } //沿線削除
    
        document.form2.pref_cd.options[0] = new Option("都道府県を選択",""); //駅OPTIONを空に

        if(p != null){
            document.form2.pref_cd.options[0] = new Option("都道府県を選択",""); //OPTION1番目はNull
            for( i=0; i<p.length; i++){
                ii = i + 1 ;    //OPTIONは2番目から表示
                var op_pref_name = p[i].pref_name;
                var op_pref_cd = p[i].pref_cd;
                
                document.form2.pref_cd.options[ii] = new Option(op_pref_name,op_pref_cd);
            }
        }
    }
}
function change_ward(){
  try {
    var pref_cd = document.form1.pref_cd.value;
    url = "/common/prefecture/job.html?prefecture_cd="+pref_cd;
    xmlHttp.open("GET", url , true);
    xmlHttp.setRequestHeader("If-Modified-Since",last_modified);
    xmlHttp.onreadystatechange = change_ward_end;
    xmlHttp.send(null);
    } catch (e) {
       alert("Can't connect to server !" + e.toString());
    }
}

function change_ward_end() {
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        p = eval("("+xmlHttp.responseText+")");
        var optionIndex0 = document.form1.ward_cd.options.length; //沿線のOPTION数取得
        for ( i=0 ; i <= optionIndex0 ; i++ ){
            document.form1.ward_cd.options[0]=null;
        } //沿線削除
    
        document.form1.ward_cd.options[0] = new Option("市区町村を選択",""); //駅OPTIONを空に
        if(p != null){
            document.form1.ward_cd.options[0] = new Option("市区町村を選択",""); //OPTION1番目はNull
            for( i=0; i<p.length; i++){
                ii = i + 1 ;    //OPTIONは2番目から表示
                var op_ward_name = p[i].ward_name;
                var op_ward_cd = p[i].ward_cd;
                
                document.form1.ward_cd.options[ii] = new Option(op_ward_name,op_ward_cd);
            }
        }
    }
}

function change_ward2(){
  try {
    var pref_cd = document.form2.pref_cd.value;
    url = "/common/prefecture/job.html?prefecture_cd="+pref_cd;
    xmlHttp.open("GET", url , true);
    xmlHttp.setRequestHeader("If-Modified-Since",last_modified);
    xmlHttp.onreadystatechange = change_ward_end2;
    xmlHttp.send(null);
    } catch (e) {
       alert("Can't connect to server !" + e.toString());
    }
}

function change_ward_end2() {
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        p = eval("("+xmlHttp.responseText+")");
        var optionIndex0 = document.form2.ward_cd.options.length; //沿線のOPTION数取得
        for ( i=0 ; i <= optionIndex0 ; i++ ){
            document.form2.ward_cd.options[0]=null;
        } //沿線削除
    
        document.form2.ward_cd.options[0] = new Option("市区町村を選択",""); //駅OPTIONを空に
        if(p != null){
            document.form2.ward_cd.options[0] = new Option("市区町村を選択",""); //OPTION1番目はNull
            for( i=0; i<p.length; i++){
                ii = i + 1 ;    //OPTIONは2番目から表示
                var op_ward_name = p[i].ward_name;
                var op_ward_cd = p[i].ward_cd;
                
                document.form2.ward_cd.options[ii] = new Option(op_ward_name,op_ward_cd);
            }
        }
    }
}

/* エリアから探す ここまで*/
/* 駅・路線から探す ここから*/
function change_line(areatab){
    var optionIndex0 = document.form1.station_g_cd.options.length; //沿線のOPTION数取得
    for ( i=0 ; i <= optionIndex0 ; i++ ){
        document.form1.station_g_cd.options[0]=null;
    } //沿線削除
    document.form1.station_g_cd.options[0] = new Option("駅を選択",""); //駅OPTIONを空に

    if(document.form1.station_g_cd_2) {
        var optionIndex0 = document.form1.station_g_cd_2.options.length; //沿線のOPTION数取得
        for ( i=0 ; i <= optionIndex0 ; i++ ){
            document.form1.station_g_cd_2.options[0]=null;
        } //沿線削除
        document.form1.station_g_cd_2.options[0] = new Option("駅を選択",""); //駅OPTIONを空に
    }
    var option0 = document.form1.line_cd.options.length; //沿線のOPTION数取得
    for ( i=0 ; i <= option0 ; i++ ){
        document.form1.line_cd.options[0]=null;
    } //沿線削除
    document.form1.line_cd.options[0] = new Option("路線を選択",""); //駅OPTIONを空に
    try {
        var rr_name = encodeURIComponent(document.form1.rr_name.value);
        url = "/common/line/job.html?rr_name="+rr_name+"&areatab="+areatab;
        xmlHttp.open("GET", url , true);
        xmlHttp.setRequestHeader("If-Modified-Since",last_modified);
        xmlHttp.onreadystatechange = change_line_end;
        xmlHttp.send(null);
    } catch (e) {
       alert("Can't connect to server !" + e.toString());
    }
}

function change_line_end() {
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        p = eval("("+xmlHttp.responseText+")");
        var optionIndex0 = document.form1.line_cd.options.length; //沿線のOPTION数取得

        for ( i=0 ; i <= optionIndex0 ; i++ ){
            document.form1.line_cd.options[0]=null;
        } //沿線削除
    
        document.form1.line_cd.options[0] = new Option("路線を選択",""); //駅OPTIONを空に

        if(p != null){
            document.form1.line_cd.options[0] = new Option("路線を選択",""); //OPTION1番目はNull
            for( i=0; i<p.length; i++){
                ii = i + 1 ;    //OPTIONは2番目から表示
                var op_line_name = p[i].line_name;
                var op_line_cd = p[i].line_cd;
                document.form1.line_cd.options[ii] = new Option(op_line_name,op_line_cd);
            }
        }
    }

}

function change_station_g_cd(){
  try {
    var line_cd = document.form1.line_cd.value;
    url = "/common/station/job.html?flg=2&line_cd="+line_cd;
    xmlHttp.open("GET", url , true);
    xmlHttp.setRequestHeader("If-Modified-Since",last_modified);
    xmlHttp.onreadystatechange = change_station_g_cd_end;
    xmlHttp.send(null);
    } catch (e) {
       alert("Can't connect to server !" + e.toString());
    }
}

function change_station_g_cd_end() {
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        p = eval("("+xmlHttp.responseText+")");
        var optionIndex0 = document.form1.station_g_cd.options.length; //沿線のOPTION数取得

        for ( i=0 ; i <= optionIndex0 ; i++ ){
            document.form1.station_g_cd.options[0]=null;
        } //沿線削除
        document.form1.station_g_cd.options[0] = new Option("駅を選択",""); //駅OPTIONを空に
        if(p != null){
            document.form1.station_g_cd.options[0] = new Option("駅を選択",""); //OPTION1番目はNull
            for( i=0; i<p.length; i++){
                ii = i + 1 ;    //OPTIONは2番目から表示
                var op_station_name = p[i].station_name;
                var op_station_g_cd = p[i].station_g_cd;
                
                document.form1.station_g_cd.options[ii] = new Option(op_station_name,op_station_g_cd);
            }
        }
        if (document.form1.station_g_cd_2) {
            var optionIndex = document.form1.station_g_cd_2.options.length; //沿線のOPTION数取得                      
            for ( i=0 ; i <= optionIndex ; i++ ){
                document.form1.station_g_cd_2.options[0]=null;
            }
            document.form1.station_g_cd_2.options[0] = new Option("駅を選択",""); //駅OPTIONを空に
            if(p != null){
                document.form1.station_g_cd_2.options[0] = new Option("駅を選択",""); //OPTION1番目はNull
                for( i=0; i<p.length; i++){
                    ii = i + 1 ;    //OPTIONは2番目から表示
                    var op_station_name = p[i].station_name;
                    var op_station_g_cd = p[i].station_g_cd;
                    document.form1.station_g_cd_2.options[ii] = new Option(op_station_name,op_station_g_cd);
                }   
            }
        }
    }

}
/* 駅・路線から探す ここまで*/
/* 職種から探す ここから*/
function change_business_type(){
    var optionIndex0 = document.form1.occupational_category.options.length; //OPTION数取得

    for ( i=0 ; i <= optionIndex0 ; i++ ){
        document.form1.occupational_category.options[0]=null;
    } //沿線削除
    
    document.form1.occupational_category.options[0] = new Option("職種詳細を選択",""); //OPTIONを空に

    var option0 = document.form1.business_type.options.length; //OPTION数取得
    for ( i=0 ; i <= option0 ; i++ ){
        document.form1.business_type.options[0]=null;
    } //沿線削除
                                  
    document.form1.business_type.options[0] = new Option("職種を選択",""); //OPTIONを空に
 
    try {
        var genre_cd = document.form1.genre_cd.value;
        url = "/common/business/job.html?genre_cd="+genre_cd;
        xmlHttp.open("GET", url , true);
        xmlHttp.setRequestHeader("If-Modified-Since",last_modified);
        xmlHttp.onreadystatechange = change_business_type_end;
        xmlHttp.send(null);
    } catch (e) {
       alert("Can't connect to server !" + e.toString());
    }
}

function change_business_type_end() {
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        p = eval("("+xmlHttp.responseText+")");
        var optionIndex0 = document.form1.business_type.options.length; //沿線のOPTION数取得

        for ( i=0 ; i <= optionIndex0 ; i++ ){
            document.form1.business_type.options[0]=null;
        } //沿線削除
    
        document.form1.business_type.options[0] = new Option("職種を選択",""); //駅OPTIONを空に

        if(p != null){
            document.form1.business_type.options[0] = new Option("職種を選択",""); //OPTION1番目はNull
            for( i=0; i<p.length; i++){
                ii = i + 1 ;    //OPTIONは2番目から表示
                var op_business_name = p[i].business_name;
                var op_business_type = p[i].business_type;
                
                document.form1.business_type.options[ii] = new Option(op_business_name,op_business_type);
            }
        }
    }

}
function change_occupational_category(){
  try {
    var business_type = document.form1.business_type.value;
    url = "/common/occupational/job.html?flg=2&business_type="+business_type;
    xmlHttp.open("GET", url , true);
    xmlHttp.setRequestHeader("If-Modified-Since",last_modified);
    xmlHttp.onreadystatechange = change_occupational_category_end;
    xmlHttp.send(null);
    } catch (e) {
       alert("Can't connect to server !" + e.toString());
    }
}

function change_occupational_category_end() {
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        p = eval("("+xmlHttp.responseText+")");
        var optionIndex0 = document.form1.occupational_category.options.length; //沿線のOPTION数取得

        for ( i=0 ; i <= optionIndex0 ; i++ ){
            document.form1.occupational_category.options[0]=null;
        } //沿線削除
    
        document.form1.occupational_category.options[0] = new Option("職種詳細を選択",""); //駅OPTIONを空に

        if(p != null){
            document.form1.occupational_category.options[0] = new Option("職種詳細を選択",""); //OPTION1番目はNull
            for( i=0; i<p.length; i++){
                ii = i + 1 ;    //OPTIONは2番目から表示
                var op_occupational_name = p[i].occupational_name;
                var op_occupational_cd = p[i].occupational_cd;
                
                document.form1.occupational_category.options[ii] = new Option(op_occupational_name,op_occupational_cd);
            }
        }
    }

}
/* 職種から探す ここまで*/

function changeBox(boxName){
    var areabox = document.getElementById('areaBox');
    var workbox = document.getElementById('workBox');
    var stationbox = document.getElementById('stationBox');
    var areabtn = document.getElementById("areaBtn");
    var jobbtn = document.getElementById("jobBtn");
    var stationbtn = document.getElementById("stationBtn");

    if(boxName == "area") {
        //フォーム
        areabox.style.display = "block";
        workbox.style.display = "none";
        stationbox.style.display = "none";
        areabtn.src = "/images/arbeit_btn_toparea_fix.gif";
        jobbtn.src = "/images/arbeit_btn_topjob_off.gif";
        stationbtn.src = "/images/arbeit_btn_topstation_off.gif";
        areabtn.style.cursor = "default";
        jobbtn.style.cursor = "pointer";
        stationbtn.style.cursor = "pointer";
    }else if(boxName == "work") {
        //フォーム
        areabox.style.display = "none";
        workbox.style.display = "block";
        stationbox.style.display = "none";
        areabtn.src = "/images/arbeit_btn_toparea_off.gif";
        jobbtn.src = "/images/arbeit_btn_topjob_fix.gif";
        stationbtn.src = "/images/arbeit_btn_topstation_off.gif";
        areabtn.style.cursor = "pointer";
        jobbtn.style.cursor = "default";
        stationbtn.style.cursor = "pointer";
    }else if(boxName == "station") {
        //フォーム
        areabox.style.display = "none";
        workbox.style.display = "none";
        stationbox.style.display = "block";
        areabtn.src = "/images/arbeit_btn_toparea_off.gif";
        jobbtn.src = "/images/arbeit_btn_topjob_off.gif";
        stationbtn.src = "/images/arbeit_btn_topstation_fix.gif";
        areabtn.style.cursor = "pointer";
        jobbtn.style.cursor = "pointer";
        stationbtn.style.cursor = "default";
    }
    smartRollover();
}

