function changeBgColor(obj){
    var len=obj.value.length; /* 入力された文字列の長さ */
    if(len > 0){
        obj.style.backgroundColor = "#FFFFFF";
        if(obj.style.color == "#999"){
            obj.style.color = "black";
        }
    }else{
        obj.style.backgroundColor = "#FFE5E6";
    }
    
    if(obj.name == "user_name" && obj.value == obj.title){
        obj.style.backgroundColor = "#FFE5E6";
    }
    if(obj.name == "user_name_kana" && obj.value == obj.title){
        obj.style.backgroundColor = "#FFE5E6";
        obj.style.color = "#999";
    }
    formCheck();
}

function changeSelBgColor(obj){
    if(obj[0].selected == false){
        obj.style.backgroundColor = "#FFFFFF";
    }else{
        obj.style.backgroundColor = "#FFE5E6";
    }
    formCheck();
}

function changeRadBgColor(){
    var cnt = 0;
    var flag = false;
    while (cnt < document.form1.sex.length) {
        if (document.form1.sex[cnt].checked == true) {
            flag = true;
        }
        cnt++;
    }
    cnt = 0;
    if(flag){
        document.getElementById("sexBox").style.backgroundColor = "#FFFFFF";
        while (cnt < document.form1.sex.length) {
            document.form1.sex[cnt].style.backgroundColor = "#FFFFFF";
            cnt++;
        }
    }else{
        document.getElementById("sexBox").style.backgroundColor = "#FFE5E6";
        while (cnt < document.form1.sex.length) {           
            document.form1.sex[cnt].style.backgroundColor = "#FFE5E6";   
            cnt++;
        }
    }
    formCheck();
}

function changeCkBgColor(){
    if(document.form1.check_agree.checked){
        document.getElementById("agreeBox").style.backgroundColor = "#FFFFFF";
        document.form1.check_agree.style.backgroundColor = "#FFFFFF";
    }else{
        document.getElementById("agreeBox").style.backgroundColor = "#FFE5E6";
        document.form1.check_agree.style.backgroundColor = "#FFE5E6";
    }
    formCheck();
}

function formCheck(){
    var indisImg = document.getElementById("indis_img");
    var submitImg = document.getElementById("entry_btn");
    radioCnt = 0;
    checkedCnt = 0;
    while (radioCnt < document.form1.sex.length) {
        if (document.form1.sex[radioCnt].checked == true) {
            checkedCnt++;
        }
        radioCnt++;
    }

    if(document.form1.user_name.value == "" ||
document.form1.user_name_kana.value == "" ||
document.form1.user_name.value == document.form1.user_name.title ||
document.form1.user_name_kana.value == document.form1.user_name_kana.title ||
checkedCnt == 0 ||
document.form1.birth_y.value == "" ||
document.form1.birth_m.value == "" ||
document.form1.birth_d.value == "" ||
document.form1.mail_address.value == "" ||
document.form1.school_type[0].selected == true ||
document.form1.phone.value == "" ||
document.form1.kojin_confirm.checked == false
){
        indisImg.style.display = 'block';
        submitImg.src="/commons/arbeit_btn_confirm_gray.gif";
        submitImg.disabled = true; 
    }else{
        indisImg.style.display = 'none';
        submitImg.src="/commons/arbeit_btn_confirm.gif";
        submitImg.disabled = false; 
    }
}

    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 ad_save(ad_id){
        try {
            url = "/common/adsave/job.html?ad_id="+ad_id;
            xmlHttp.open("GET", url , true);
            xmlHttp.setRequestHeader("If-Modified-Since",last_modified);
            xmlHttp.onreadystatechange = ad_save_end;
            xmlHttp.send(null);
        } catch (e) {
            alert("Can't connect to server !" + e.toString());
        }
    }

    function ad_save_end(){
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
            p = eval("("+xmlHttp.responseText+")");
            save1 = document.getElementById('save_btn_1');
            save2 = document.getElementById('save_btn_2');
            save3 = document.getElementById('save_btn_3');
            save1.innerHTML = '';
            if(save2){
                save2.innerHTML = '';
            }
            if(save3){
                save3.innerHTML = '';
            }
        }
    }
    

      function selectYoubi(indexNo, zipcode, pref, ward, area) {
         try{
             if(indexNo==1) {
                 document.form1.zip_code.value=zipcode;
                 document.form1.address_1.value=ward + "  " + area;
                 document.form1.prefecture.value=pref;
             }
             if(indexNo==2) {
                 document.form1.zip_code_for_bill.value=zipcode;
                 document.form1.address_1_for_bill.value=ward + "  " + area;
                 document.form1.prefecture_for_bill.value=pref;
             }
             if(indexNo==3) {
                 document.form1.zip_code_for_headquarters.value=zipcode;
                 document.form1.address_1_for_headquarters.value=ward + "  " + area;
                 document.form1.prefecture_for_headquarters.value=pref;
             }
         }catch(err){
             alert(err.description);
         }
     }
     
     function youbinShow(ind,url) 
     {
         try{
             popwin = window.open(url + '?ind='+ind ,'youbinselect', 'toolbar=no,location=no,address=no,menubar=no,scrollbars=yes,width=650,height=500'); 
         }catch(err){
             alert(err.description);
         }
     }
     

    
    
function send_submit(){
   var ob = document.sendsubmit;
   ob.method="POST";
   ob.submit();
}
function send_back(){
   var ob = document.sendback;
   ob.method="POST";
   ob.submit();
}


