(function(a){var l={buttons:{button1:{text:"OK",danger:!1,onclick:function(){a.fallr("hide")}}},icon:"check",content:"Hello",position:"top",closeKey:!1,closeOverlay:!1,duration:300,fadespeed:0,easingIn:"swing",easingOut:"swing",bgcolor:"#52554e",height:"auto",width:"360px",zIndex:9999},d,f=a(window),h={hide:function(c,j,g){if(e.isActive()){a("#fallr-wrapper").stop(!0,!0);var b=a("#fallr-wrapper"),c=b.css("position"),i=0;switch(d.position){case "bottom":case "center":i=(c==="fixed"?f.height():b.offset().top+
b.height())+10;break;default:i=(c==="fixed"?-1*b.outerHeight():b.offset().top)-10}b.animate({top:i},d.duration,d.easingOut,function(){a.browser.msie?a("#fallr-overlay").css("display","none"):a("#fallr-overlay").fadeOut(d.fadespeed);b.remove();typeof j==="function"&&j.call(g)});a(document).unbind("keydown",e.enterKeyHandler).unbind("keydown",e.closeKeyHandler).unbind("keydown",e.tabKeyHandler)}},resize:function(c,d,g){var b=a("#fallr-wrapper"),f=parseInt(c.width,10),k=parseInt(c.height,10),c=Math.abs(b.outerWidth()-
f),m=Math.abs(b.outerHeight()-k);if(e.isActive()&&(c>3||m>3))b.animate({width:f},function(){a(this).animate({height:k},function(){e.fixPos()})}),a("#fallr").animate({width:f-94},function(){a(this).animate({height:k-131},function(){typeof d==="function"&&d.call(g)})})},show:function(c,j,g){if(e.isActive())a.error("Can't create new message with content: \""+c.content+'", past Fallr instance with content "'+d.content+'"is still active');else{d=a.extend({},l,c);a('<div id="fallr-wrapper"></div>').appendTo("body");
var b=a("#fallr-wrapper"),i=a("#fallr-overlay");b.css({background:d.bgcolor,width:d.width,height:d.height,position:"absolute",top:"-9999px",left:"-9999px"}).html('<div id="fallr-icon"></div><div id="fallr"></div><div id="fallr-buttons"></div>').find("#fallr-icon").addClass("icon-"+d.icon).end().find("#fallr").html(d.content).css({height:d.height=="auto"?"auto":b.height()-131,width:b.width()-94}).end().find("#fallr-buttons").html(function(){var b="",a;for(a in d.buttons)d.buttons.hasOwnProperty(a)&&
(b=b+'<a href="#" class="fallr-button '+(d.buttons[a].danger?"fallr-button-danger":"")+'" id="fallr-button-'+a+'">'+d.buttons[a].text+"</a>");return b}()).find(".fallr-button").bind("click",function(){var b=a(this).attr("id").substring(13);if(typeof d.buttons[b].onclick==="function"&&d.buttons[b].onclick!=!1){var c=document.getElementById("fallr");d.buttons[b].onclick.apply(c)}else h.hide();return!1});i.css({"z-index":d.zIndex}).fadeIn(d.fadespeed,function(){b.show();var a=(f.width()-b.outerWidth())/
2+f.scrollLeft(),c,e,h=f.height()>b.height()&&f.width()>b.width()?"fixed":"absolute";switch(d.position){case "bottom":c=h==="fixed"?f.height():f.scrollTop()+f.height();e=c-b.outerHeight();break;case "center":c=h==="fixed"?-1*b.outerHeight():i.offset().top-b.outerHeight();e=c+b.outerHeight()+(f.height()-b.outerHeight())/2;break;default:e=h==="fixed"?0:f.scrollTop(),c=e-b.outerHeight()}b.css({left:a,position:h,top:c,"z-index":d.zIndex+1}).animate({top:e},d.duration,d.easingIn,function(){typeof j===
"function"&&j.call(g)})});a(document).bind("keydown",e.enterKeyHandler).bind("keydown",e.closeKeyHandler).bind("keydown",e.tabKeyHandler);a("#fallr-buttons").children().eq(-1).bind("focus",function(){a(this).bind("keydown",e.tabKeyHandler)});b.find(":input").bind("focus",function(){a(document).unbind("keydown",e.enterKeyHandler).unbind("keydown",e.tabKeyHandler)})}},set:function(c,a,e){for(var b in c)c.hasOwnProperty(b)&&(l[b]=c[b],d[b]=c[b]);typeof a==="function"&&a.call(e)}},e={blink:function(){a("#fallr-wrapper").fadeOut(d.fadespeed,
function(){a(this).fadeIn(d.fadespeed)})},fixPos:function(){var c=a("#fallr-wrapper"),e=c.css("position");if(f.width()>c.outerWidth()&&f.height()>c.outerHeight()){var g=(f.width()-c.outerWidth())/2,b=f.height()-c.outerHeight();switch(d.position){case "center":b/=2;break;case "bottom":break;default:b=0}e=="fixed"?c.animate({left:g},function(){a(this).animate({top:b})}):c.css({position:"fixed",left:g,top:b})}else g=(f.width()-c.outerWidth())/2+f.scrollLeft(),b=a("#fallr-overlay").offset().top,e!="fixed"?
c.animate({left:g},function(){a(this).animate({top:b})}):c.css({position:"absolute",top:b,left:g>0?g:0})},isActive:function(){return!!(a("#fallr-wrapper").length>0)},enterKeyHandler:function(c){c.keyCode===13&&(a("#fallr-buttons").children().eq(0).focus(),a(document).unbind("keydown",e.enterKeyHandler),a(document).unbind("keydown",e.tabKeyHandler))},tabKeyHandler:function(c){c.keyCode===9&&(a("#fallr-wrapper").find(":input, .fallr-button").eq(0).focus(),a(document).unbind("keydown",e.enterKeyHandler),
a(document).unbind("keydown",e.tabKeyHandler),c.preventDefault())},closeKeyHandler:function(a){a.keyCode===27&&d.closeKey&&h.hide()}};a(document).ready(function(){a("body").append('<div id="fallr-overlay"></div>');a("#fallr-overlay").bind("click",function(){d.closeOverlay?h.hide():e.blink()})});a(window).resize(function(){e.isActive()&&e.fixPos()});a.fallr=function(c,d,e){var b=window;typeof c==="object"&&(d=c,c="show");h[c]?(typeof d==="function"&&(e=d,d=null),h[c](d,e,b)):a.error('Method "'+c+'" does not exist in $.fallr')}})(jQuery);
