/**
 * jQuery.openContainer
 *  2010.06.17 h.yamagu
 *
 **/
(function($) {
    $.fn.openContainer = function(target, speed, def) {

        var id     = "#" + $(this).attr('id');
        var opened = false;
        var nowImg = $(id + " .icon").attr("src");

        $(id).click(function(){
            if (checkOpened() == false) {
                close(speed);
            } else {
                open(speed);
            }
        });

        var open = function(myspeed){
            $(target).show(myspeed);
        }

        var close = function(myspeed){
            $(target).hide(myspeed);
        }

        var checkOpened = function(){
            // for IE 8
            return ( $(target).css('display') == 'none');

//            return ( $(target).is(':hidden') ) ;
//            return ( $(target+":hidden").length > 0 );
        }

        if ( def == "CLOSE" ) {
            close();
        } else {
            open()
        }

    }
})(jQuery);

