(function($){
 
	$.fn.holes=function(){
		return this.each(function(){
			$(this).bind('click',function(event){
				var target=event.target;
				var id = target.id;
			});
                        return this;
		});
	};

        $.fn.holeHandler=function(){
            return this.each(function(){
                $(this).click(function(){
                    
                    $(".hole").unbind("click");
                    $(".hole").holeClose();
                    var id = this.id || false;
                    re = /(\d)+$/;
                    
                    if(id) {
                        cls = re.exec(id);
                        $(".hole").addClass("detail"+cls[0]);
                        $(".hole").center();
                        $(".hole").fadeIn('slow');
                        $(".hole").bind('click',function(){$(this).holeClose();})
                        
                    }
                    else {
                        //alert('Ahtung minen! ' + ii);
                        return true;
                    }

                    return false;
                });
            });
        };

        $.fn.holeClose=function(){
            return this.each(function() {
               if('none' != $(this).css('display')) {
                 $(this).fadeOut('fast',function(){
                   var cls = $(this).attr("class");
                   var re = /(detail[\d]+)+/;
                   cls = cls.replace(re, '');
                   $(this).attr("class",cls);
                 });
               }
               
            });
        };
 
})(jQuery);
 
jQuery(function(){    
    jQuery(".hole").hide();
    jQuery(".act").holeHandler();

});

