// JavaScript Document
// <![CDATA[


function Filter() {

    //internal vars
    divholderArray = new Array(); // array to hold all current packshots   
    var clearAllChkBx = $('#ck1');

    this.init = init;
    this.setupSlider = setupSlider;
    this.setupCheckBoxes = setupCheckBoxes;
    this.setupHolders = setupHolders;
    this.clearAllCheckboxes = clearAllCheckboxes;
    this.checkAllCheckboxes = checkAllCheckboxes;



    function init() {

        //put all element sinto array, and store for manipulation
        setupHolders();
        setupSlider();
        setupCheckBoxes();

        // remove checkboxes on load - debugging only
        clearAllCheckboxes();
    }


    function setupHolders() {
        holderArray = $(".crHolder");

        $(".crHolder").each(function (i) {
            this.dyid = i + 1;
            holderArray[i] = this;
        });

    }


    function clearAllCheckboxes() {
        $.each(holderArray, function (i, val) {
            if ($(i).is(":checked")) {
                $this.removeAttr('checked');
            }
        });
    }


    function checkAllCheckboxes() {
        $.each(holderArray, function (i, val) {});
    }


    function hideElement(ele) {
        ele.hide('slow');
    }


    function showElement(ele) {
        ele.show('slow');
    }


    function setupCheckBoxes() {

        $(".ckBox").click(function () {
            $(".rgefiltUL li input").each(function (i) {

                // if show all elements is checked, uncheck it	
                if ($(this).id != clearAllChkBx.id) {
                    if (clearAllChkBx.is(":checked")) {
                        clearAllChkBx.removeAttr('checked');
                    }

                    if (this.is(":checked")) {
                        this.removeAttr('checked');
                    } else {
                        $(this).attr('checked', 'checked');
                    }

                    if (this.id == "ck1") {
                        checkAllCheckboxes();

                    } else if (this.id == "ck2") {

                    } else if (this.id == "ck3") {

                        $("#1").toggle(800);
                        $()

                    } else {
                        $("#contentArea").hide("slow");
                    }

                    return false;


                }
            });
        });


        $("#ck1").click(function () {});


        $("#ck2").click(function () {
            if ($("#ck2").is(":checked")) {
                $(".opt1").show(800);
            } else {
                $(".opt1").hide(800);
            }
        });


    }




    function setupSlider() {
        var bedMinMinVal = 0;
        var bedMinMaxVal = 50;
        var bedMaxMinVal = 70;
        var bedMaxMaxVal = 100;
        var bedStepsCount = 5;

        $('#rangeslider').slider({
            range: true,
            values: [25, 75]
        });

        $('.ui-slider').each(function () {
            $('.ui-slider-handle:first', this).addClass('rangeslider-handle-left')
            $('.ui-slider-handle:last', this).addClass('rangeslider-handle-right')
        });
    }
}

// ]]> 