(function(a){a.alerts={verticalOffset:-10,horizontalOffset:0,repositionOnResize:!0,overlayOpacity:.01,overlayColor:"#FFF",draggable:!0,okButton:__("OK"),cancelButton:__("Cancel"),dialogClass:null,alert:function(b,d,e){null==d&&(d="Alert");a.alerts._show(d,b,null,"alert",function(a){e&&e(a)})},confirm:function(b,d,e,f){null==d&&(d="Confirm");a.alerts._show(d,b,f,"confirm",function(a,b){e&&e(a,f,b)})},prompt:function(b,d,e,f){null==e&&(e="Prompt");a.alerts._show(e,b,d,"prompt",function(a){f&&f(a)})},
_show:function(b,d,e,f,g){a.alerts._hide();a.alerts._overlay("show");a("BODY").append('<div id="popup_container"><h1 id="popup_title"></h1><div id="popup_content"><div id="popup_message"></div></div></div>');a.alerts.dialogClass&&a("#popup_container").addClass(a.alerts.dialogClass);var h=a.browser.msie&&6>=parseInt(a.browser.version)?"absolute":"fixed";a("#popup_container").css({position:h,zIndex:99999,padding:0,margin:0});a("#popup_title").text(b);a("#popup_content").addClass(f);a("#popup_message").text(d);
a("#popup_message").html(a("#popup_message").text().replace(/\n/g,"<br />"));a("#popup_container").css({minWidth:a("#popup_container").outerWidth(),maxWidth:a("#popup_container").outerWidth()});a.alerts._reposition();a.alerts._maintainPosition(!0);switch(f){case "alert":a("#popup_message").after('<div class="popup_panel" class="ui-dialog-buttonpane"><button id="popup_ok">'+a.alerts.okButton+"</button></div>");a("#popup_ok").click(function(){a.alerts._hide();g(!0)});a("#popup_ok").button().keypress(function(b){13!=
b.keyCode&&27!=b.keyCode||a("#popup_ok").trigger("click")});setTimeout(function(){a("#popup_ok").focus()},100);break;case "confirm":a("#popup_message").after('<div class="popup_panel" class="ui-dialog-buttonpane"><button id="popup_ok">'+a.alerts.okButton+'</button><button id="popup_cancel">'+a.alerts.cancelButton+"</button></div>");""!=e&&a("#popup_message").after('<div class="popup_panel"><input type="checkbox" id="popup_check" /><label class="right" for="popup_check">'+__("Confirm and do not ask me again about this choice")+
"</label></div>");a("#popup_ok").button().click(function(){c=a("#popup_check").prop("checked");a.alerts._hide();g&&g(!0,c)});a("#popup_cancel").button().click(function(){a.alerts._hide();g&&g(!1,!1)});a("#popup_ok, #popup_cancel").keypress(function(b){13==b.keyCode&&a("#popup_ok").trigger("click");27==b.keyCode&&a("#popup_cancel").trigger("click")});setTimeout(function(){a("#popup_ok").focus()},100);break;case "prompt":a("#popup_message").after('<div class="popup_panel" class="ui-dialog-buttonpane"><button id="popup_ok">'+
a.alerts.okButton+'</button><button id="popup_cancel">'+a.alerts.cancelButton+"</button></div>"),a("#popup_message").after('<div class="popup_panel"><input type="text" id="popup_prompt" class="text ui-widget-content" /></div>'),a("#popup_prompt").width(a("#popup_message").width()),a("#popup_ok").button().click(function(){var b=a("#popup_prompt").val();a.alerts._hide();g&&g(b)}),a("#popup_cancel").button().click(function(){a.alerts._hide();g&&g(null)}),a("#popup_prompt, #popup_ok, #popup_cancel").keypress(function(b){13==
b.keyCode&&a("#popup_ok").trigger("click");27==b.keyCode&&a("#popup_cancel").trigger("click")}),e&&a("#popup_prompt").val(e),setTimeout(function(){a("#popup_prompt").focus().select()},100)}if(a.alerts.draggable)try{a("#popup_container").draggable({handle:a("#popup_title")}),a("#popup_title").css({cursor:"move"})}catch(k){}},_hide:function(){a("#popup_container").remove();a.alerts._overlay("hide");a.alerts._maintainPosition(!1)},_overlay:function(b){switch(b){case "show":a.alerts._overlay("hide");
a("BODY").append('<div id="popup_overlay"></div>');a("#popup_overlay").css({position:"absolute",zIndex:99998,top:"0px",left:"0px",width:"100%",height:a(document).height(),background:a.alerts.overlayColor,opacity:a.alerts.overlayOpacity});break;case "hide":a("#popup_overlay").remove()}},_reposition:function(){var b=a(window).height()/2-a("#popup_container").outerHeight()/2+a.alerts.verticalOffset,d=a(window).width()/2-a("#popup_container").outerWidth()/2+a.alerts.horizontalOffset;0>b&&(b=0);0>d&&(d=
0);a.browser.msie&&6>=parseInt(a.browser.version)&&(b+=a(window).scrollTop());a("#popup_container").css({top:b+"px",left:d+"px"});a("#popup_overlay").height(a(document).height())},_maintainPosition:function(b){if(a.alerts.repositionOnResize)switch(b){case !0:a(window).bind("resize",a.alerts._reposition);break;case !1:a(window).unbind("resize",a.alerts._reposition)}}};jAlert=function(b,d,e){a.alerts.alert(b,d,e)};jConfirm=function(b,d,e,f){a.alerts.confirm(b,d,e,f)};jPrompt=function(b,d,e,f){a.alerts.prompt(b,
d,e,f)}})(jQuery);
