jQuery.fn.extend({captify:function(b){var b=$.extend({speedOver:"fast",speedOut:"normal",hideDelay:500,animation:"fade",prefix:"",className:"caption"},b);$(this).each(function(){var a=this;$(this).load(function(){$this=a;if(this.hasInit){return false}this.hasInit=true;var u=false;var n=false;var r=$("#"+$(this).attr("rel"));var w=!r.length?$(this).attr("title"):r.html();var s=!w.length?$(this).attr("alt"):w;r.remove();var q=this.parent&&this.parent.tagName=="a"?this.parent:$(this);var v=q.wrap("<div></div>").parent();v.css({overflow:"hidden",padding:0,fontSize:0.1});v.addClass("caption-wrapper");v.width($(this).width());v.height($(this).height());$.map(["top","right","bottom","left"],function(c){$.map(["style","width","color"],function(e){var d="border-"+c+"-"+e;v.css(d,$(a).css(d))})});$(a).css({border:"0 none"});$.map(["top","right","bottom","left"],function(d){var c="margin-"+d;v.css(c,$(a).css(c))});var m=$("div:last",v.append("<div></div>")).addClass(b.className);var o=$("div:last",v.append("<div></div>")).addClass(b.className).append(b.prefix).append(s);$("*",v).css({margin:0}).show();var p=jQuery.browser.msie?"static":"relative";m.css({zIndex:1,position:p});o.css({position:p,zIndex:2,background:"none",border:"0 none",opacity:1});m.width(o.outerWidth());m.height(o.outerHeight());o.css({marginTop:-m.outerHeight()});var t=function(){if(!u&&!n){m.animate({marginTop:0},b.speedOut)}};$(this).hover(function(){n=true;if(!u){m.animate({marginTop:-m.height()},b.speedOver)}},function(){n=false;window.setTimeout(t,b.hideDelay)});$("div",v).hover(function(){u=true},function(){u=false;window.setTimeout(t,b.hideDelay)})});if(this.complete||this.naturalWidth>0){$(a).trigger("load")}})}});
