$(document).ready( function() {
    $(".opt-multi-container").css("position","absolute");
    $(".opt-multi-container").css("top","-999em");
    $(".opt-multi-container").fadeOut();
    var i = 0;
    $(".opt-inputs").click( function() {
        if($(this).find('input').attr("checked")==false) {
            $(this).find('input').attr("checked",true);
            $(this).css("background-color","#FBF7D4");
            i++;
            $(".opt-selected-message").text(i);
        } else {
            $(this).find('input').attr("checked",false);
            $(this).css("background-color","#ffffff");
            i--;
            $(".opt-selected-message").text(i);
            //Select All
            //$(".opt-inputs input").attr("checked","checked");
        }
    });
    $(".opt-select-none-btn").click( function() {
            $(".opt-inputs").find("input").attr("checked",false);
            $(".opt-inputs").css("background-color","#ffffff");
            $(".opt-selected-message").text(0);
            i = 0;
        
    });
    $(".opt-select-all-btn").click( function() {
            $(".opt-inputs").find("input").attr("checked",true);
            $(".opt-inputs").css("background-color","#FBF7D4");
            $(".opt-selected-message").text("All");
            i = 18;
        
    });
    $(".opt-inputs input").click( function() {
        if($(this).attr("checked")==false) {
            $(this).attr("checked",true);
        } else {
            $(this).attr("checked",false);
            
            //Select All
            //$(".opt-inputs input").attr("checked","checked");
        }
    });
    $(".trigger").click( function() {

        if($('.hidden-trigger').text()=="hide") {
            $('.hidden-trigger').text("show");
            /*
             $(".opt-multi-container").animate({
             top: '+=1120'
             });
             */
            $(".opt-multi-container").css("top","auto");
            $(".opt-multi-container").fadeIn();

        } else {

            $('.hidden-trigger').text("hide");

            $(".opt-multi-container").fadeOut(1, function() {

            });
            /*
             $(".opt-multi-container").animate({
             top: '-=1120'
             },1);*/
            $(".opt-multi-container").css("top","-999em");

        }

        $(".opt-multi-container").mouseleave( function() {
            if($('.hidden-trigger').text()!="hide")
                $(".trigger").click();
        });
    });
    
      
});
