/*
 * 必須ライブラリ　jquery-1.2.6-pack.js
 * 検索条件選択
 */

/**************************************
 * 初期状態ではこだわり条件は閉じ
 **************************************/
function initBtnAdv(){
    $("#btn-advopen").click();
}
$(document).ready(
    function(){
        //折りたたみ
        $("#btn-advopen").click( function(){
            $("#advance table").toggle();
            $("#advance .search-allclear").toggle();
            return false;
        });
        //初期状態折りたたみ
        initBtnAdv();
        
        //こだわり条件 全ての条件をクリア
        $("#js31_clear").click( function(){
            $("#heyakankyo :radio").removeAttr("disabled");  //部屋階数のdisableを解除
            $("#advance input:checkbox").removeAttr("checked");
            $("#advance input:radio[value=0]").attr('checked', 'checked');
            return false;
        });
        // 入居形態
        $("#nyukyokeitai_all").click( function(){
            $("#nyukyokeitai input:checkbox[name^=data]").attr('checked', this.checked);
        });
        // 室外設備
        $("#shitsugai_setsubi_all").click( function(){
            $("#shitsugai_setsubi input:checkbox[name^=data]").attr('checked', this.checked);
        });
        // セキュリティ
        $("#security_all").click( function(){
            $("#security input:checkbox[name^=data]").attr('checked', this.checked);
        });
        // 通信
        $("#tsushin_all").click(
            function(){ $("#tsushin input:checkbox[name^=data]").attr('checked', this.checked);
        });
        // 開口
        $("#kaiko_all").click(
            function(){ $("#kaiko input:checkbox[name^=data]").attr('checked', this.checked);
        });
        // 物件設備
        $("#bukken_setsubi_all").click( function(){
            $("#bukken_setsubi input:checkbox[name^=data]").attr('checked', this.checked);
        });
        $("#bukken_other_all").click( function(){
            $("#bukken_other input:checkbox[name^=data]").attr('checked', this.checked);
        });
        // バス・キッチン
        $("#bath_kitchen_all").click( function(){
            $("#bath_kitchen input:checkbox[name^=data]").attr('checked', this.checked);
        });
        //　バス・トイレ
        $("#bath_toilet_all").click( function(){
            $("#bath_toilet input:checkbox[name^=data]").attr('checked', this.checked);
        });
        //　その他
        $("#bath_other_all").click( function(){
            $("#bath_other input:checkbox[name^=data]").attr('checked', this.checked);
        });
        
        //建物環境　階層　平屋選択時
        $("#kaidate_1").click( function(){
           $("#heyakankyo_0").attr('checked', 'checked');
           $("#heyakankyo :radio[id!='heyakankyo_0']").attr("disabled", "disabled");
        });
        //建物環境　階層　平屋以外を選択時
        $("#kaidate :radio[id!='kaidate_1']").click( function(){
            $("#heyakankyo :radio").removeAttr("disabled");
        });
        
        /*********************************************************************
         * 全選択　チェック時のオフ処理
         *********************************************************************/
        //入居形態　チェックオフ
        $("#nyukyokeitai td[class!='checkall'] :checkbox").click( function(){
            if ( $("#nyukyokeitai_all").is(":checked") ) {
                $("#nyukyokeitai_all").removeAttr("checked");
            }
        });
        //建物環境　設備　チェックオフ
        $("#shitsugai_setsubi td[class!='checkall'] :checkbox").click( function(){
            if ( $("#shitsugai_setsubi_all").is(":checked") ) {
                $("#shitsugai_setsubi_all").removeAttr("checked");
            }
        });
        //建物環境　セキュリティ　チェックオフ
        $("#security td[class!='checkall'] :checkbox").click( function(){
            if ( $("#security_all").is(":checked") ) {
                $("#security_all").removeAttr("checked");
            }
        });
        //建物環境　放送・通信　チェックオフ
        $("#tsushin td[class!='checkall'] :checkbox").click( function(){
            if ( $("#tsushin_all").is(":checked") ) {
                $("#tsushin_all").removeAttr("checked");
            }
        });
        //部屋環境　設備　チェックオフ
        $("#bukken_setsubi td[class!='checkall'] :checkbox").click( function(){
            if ( $("#bukken_setsubi_all").is(":checked") ) {
                $("#bukken_setsubi_all").removeAttr("checked");
            }
        });
        //バス・キッチン　キッチン　チェックオフ
        $("#bath_kitchen td[class!='checkall'] :checkbox").click( function(){
            if ( $("#bath_kitchen_all").is(":checked") ) {
                $("#bath_kitchen_all").removeAttr("checked");
            }
        });
        //バス・キッチン　バス･トイレ　チェックオフ
        $("#bath_toilet td[class!='checkall'] :checkbox").click( function(){
            if ( $("#bath_toilet_all").is(":checked") ) {
                $("#bath_toilet_all").removeAttr("checked");
            }
        });
        //バス・キッチン　バス･トイレ　チェックオフ
        $("#bath_other td[class!='checkall'] :checkbox").click( function(){
            if ( $("#bath_other_all").is(":checked") ) {
                $("#bath_other_all").removeAttr("checked");
            }
        });
    }
);