!function(t){t.prompt=function(o,p){t.prompt.options=t.extend({},t.prompt.defaults,p),t.prompt.currentPrefix=t.prompt.options.prefix,t.prompt.currentStateName="";var e=t(document.body),i=t(window);t.prompt.options.classes=t.trim(t.prompt.options.classes),""!=t.prompt.options.classes&&(t.prompt.options.classes=" "+t.prompt.options.classes);var r='
';r+=t.prompt.options.useiframe&&t("object, applet").length>0?'':'
',r+='
X
',r+="
",t.prompt.jqib=t(r).appendTo(e),t.prompt.jqi=t.prompt.jqib.children("."+t.prompt.options.prefix),t.prompt.jqif=t.prompt.jqib.children("."+t.prompt.options.prefix+"fade"),o.constructor==String&&(o={state0:{title:t.prompt.options.title,html:o,buttons:t.prompt.options.buttons,position:t.prompt.options.position,focus:t.prompt.options.focus,submit:t.prompt.options.submit}});var n="";t.each(o,function(p,e){e=t.extend({},t.prompt.defaults.state,e),o[p]=e;var i="",r="";null!==e.position.arrow&&(i='
'),e.title&&""!==e.title&&(r='
'+e.title+"
"),n+='"}),t.prompt.states=o,t.prompt.jqi.find("."+t.prompt.options.prefix+"states").html(n).children("."+t.prompt.options.prefix+"state:first").css("display","block"),t.prompt.jqi.find("."+t.prompt.options.prefix+"buttons:empty").css("display","none"),t.each(o,function(o,p){var e=t.prompt.jqi.find("#"+t.prompt.options.prefix+"state_"+o);""===t.prompt.currentStateName&&(t.prompt.currentStateName=o),e.bind("promptsubmit",p.submit),e.children("."+t.prompt.options.prefix+"buttons").children("button").click(function(){var i=t(this),r=e.children("."+t.prompt.options.prefix+"message"),n=p.buttons[i.text()]||p.buttons[i.html()];if(void 0==n)for(var s in p.buttons)(p.buttons[s].title==i.text()||p.buttons[s].title==i.html())&&(n=p.buttons[s].value);"object"==typeof n&&(n=n.value);var a={};t.each(t.prompt.jqi.find("."+t.prompt.options.prefix+"states :input").serializeArray(),function(t,o){void 0===a[o.name]?a[o.name]=o.value:typeof a[o.name]==Array||"object"==typeof a[o.name]?a[o.name].push(o.value):a[o.name]=[a[o.name],o.value]});var m=new t.Event("promptsubmit");m.stateName=o,m.state=e,e.trigger(m,[n,r,a]),m.isDefaultPrevented()||t.prompt.close(!0,n,r,a)}),e.find("."+t.prompt.options.prefix+"buttons button:eq("+p.focus+")").addClass(t.prompt.options.prefix+"defaultbutton")});var s=function(){if(t.prompt.options.persistent){var o=t.prompt.options.top.toString().indexOf("%")>=0?i.height()*(parseInt(t.prompt.options.top,10)/100):parseInt(t.prompt.options.top,10),p=parseInt(t.prompt.jqi.css("top").replace("px",""),10)-o;t("html,body").animate({scrollTop:p},"fast",function(){var o=0;t.prompt.jqib.addClass(t.prompt.options.prefix+"warning");var p=setInterval(function(){t.prompt.jqib.toggleClass(t.prompt.options.prefix+"warning"),o++>1&&(clearInterval(p),t.prompt.jqib.removeClass(t.prompt.options.prefix+"warning"))},100)})}else t.prompt.close(!0)},a=function(o){var p=window.event?event.keyCode:o.keyCode;if(27==p&&s(),9==p){var e=t(":input:enabled:visible",t.prompt.jqib),i=!o.shiftKey&&o.target==e[e.length-1],r=o.shiftKey&&o.target==e[0];if(i||r)return setTimeout(function(){if(e){var t=e[r===!0?e.length-1:0];t&&t.focus()}},10),!1}};return t.prompt.position(),t.prompt.style(),t.prompt.jqif.click(s),i.resize({animate:!1},t.prompt.position),t.prompt.jqi.find("."+t.prompt.options.prefix+"close").click(t.prompt.close),t.prompt.jqib.bind("keydown keypress",a).bind("promptloaded",t.prompt.options.loaded).bind("promptclose",t.prompt.options.close).bind("promptstatechanging",t.prompt.options.statechanging).bind("promptstatechanged",t.prompt.options.statechanged),t.prompt.jqif.fadeIn(t.prompt.options.overlayspeed),t.prompt.jqi[t.prompt.options.show](t.prompt.options.promptspeed,function(){t.prompt.jqib.trigger("promptloaded")}),t.prompt.jqi.find("."+t.prompt.options.prefix+"states ."+t.prompt.options.prefix+"state:first ."+t.prompt.options.prefix+"defaultbutton").focus(),t.prompt.options.timeout>0&&setTimeout(t.prompt.close,t.prompt.options.timeout),t.prompt.jqib},t.prompt.defaults={prefix:"jqi",classes:"",title:"",buttons:{Ok:!0},loaded:function(){},submit:function(){},close:function(){},statechanging:function(){},statechanged:function(){},opacity:.6,zIndex:999,overlayspeed:"slow",promptspeed:"fast",show:"fadeIn",focus:0,useiframe:!1,top:"15%",position:{container:null,x:null,y:null,arrow:null,width:null},persistent:!0,timeout:0,state:{title:"",html:"",buttons:{Ok:!0},focus:0,position:{container:null,x:null,y:null,arrow:null,width:null},submit:function(){return!0}}},t.prompt.currentPrefix=t.prompt.defaults.prefix,t.prompt.currentStateName="",t.prompt.setDefaults=function(o){t.prompt.defaults=t.extend({},t.prompt.defaults,o)},t.prompt.setStateDefaults=function(o){t.prompt.defaults.state=t.extend({},t.prompt.defaults.state,o)},t.prompt.position=function(o){var p=t.fx.off,e=t(window),i=t(document.body).outerHeight(!0),r=t(window).height(),n=(t(document).height(),i>r?i:r),s=parseInt(e.scrollTop(),10)+(t.prompt.options.top.toString().indexOf("%")>=0?r*(parseInt(t.prompt.options.top,10)/100):parseInt(t.prompt.options.top,10)),a=t.prompt.states[t.prompt.currentStateName].position;if(void 0!==o&&o.data.animate===!1&&(t.fx.off=!0),t.prompt.jqib.css({position:"absolute",height:n,width:"100%",top:0,left:0,right:0,bottom:0}),t.prompt.jqif.css({position:"absolute",height:n,width:"100%",top:0,left:0,right:0,bottom:0}),a&&a.container){var m=t(a.container).offset();t.isPlainObject(m)&&void 0!==m.top&&(t.prompt.jqi.css({position:"absolute"}),t.prompt.jqi.animate({top:m.top+a.y,left:m.left+a.x,marginLeft:0,width:void 0!==a.width?a.width:null}),s=m.top+a.y-(t.prompt.options.top.toString().indexOf("%")>=0?r*(parseInt(t.prompt.options.top,10)/100):parseInt(t.prompt.options.top,10)),t("html,body").animate({scrollTop:s},"slow","swing",function(){}))}else a&&a.width?(t.prompt.jqi.css({position:"absolute",left:"50%"}),t.prompt.jqi.animate({top:a.y||s,left:a.x||"50%",marginLeft:a.width/2*-1,width:a.width})):t.prompt.jqi.css({position:"absolute",top:s,left:"50%",marginLeft:t.prompt.jqi.outerWidth()/2*-1});void 0!==o&&o.data.animate===!1&&(t.fx.off=p)},t.prompt.style=function(){t.prompt.jqif.css({zIndex:t.prompt.options.zIndex,display:"none",opacity:t.prompt.options.opacity}),t.prompt.jqi.css({zIndex:t.prompt.options.zIndex+1,display:"none"}),t.prompt.jqib.css({zIndex:t.prompt.options.zIndex})},t.prompt.getStateContent=function(o){return t("#"+t.prompt.currentPrefix+"state_"+o)},t.prompt.getCurrentState=function(){return t("."+t.prompt.currentPrefix+"state:visible")},t.prompt.getCurrentStateName=function(){var o=t.prompt.getCurrentState().attr("id");return o.replace(t.prompt.currentPrefix+"state_","")},t.prompt.goToState=function(o,p){var e=new t.Event("promptstatechanging");t.prompt.jqib.trigger(e,[t.prompt.currentStateName,o]),e.isDefaultPrevented()||(t.prompt.currentStateName=o,t("."+t.prompt.currentPrefix+"state").slideUp("slow").find("."+t.prompt.currentPrefix+"arrow").fadeOut(),t("#"+t.prompt.currentPrefix+"state_"+o).slideDown("slow",function(){var e=t(this);e.find("."+t.prompt.currentPrefix+"defaultbutton").focus(),e.find("."+t.prompt.currentPrefix+"arrow").fadeIn("slow"),"function"==typeof p&&t.prompt.jqib.bind("promptstatechanged.tmp",p),t.prompt.jqib.trigger("promptstatechanged",[o]),"function"==typeof p&&t.prompt.jqib.unbind("promptstatechanged.tmp")}),t.prompt.position())},t.prompt.nextState=function(o){var p=t("#"+t.prompt.currentPrefix+"state_"+t.prompt.currentStateName).next();t.prompt.goToState(p.attr("id").replace(t.prompt.currentPrefix+"state_",""),o)},t.prompt.prevState=function(o){var p=t("#"+t.prompt.currentPrefix+"state_"+t.prompt.currentStateName).prev();t.prompt.goToState(p.attr("id").replace(t.prompt.currentPrefix+"state_",""),o)},t.prompt.close=function(o,p,e,i){t.prompt.jqib.fadeOut("fast",function(){o&&t.prompt.jqib.trigger("promptclose",[p,e,i]),t.prompt.jqib.remove(),t("window").unbind("resize",t.prompt.position)})},t.fn.extend({prompt:function(o){void 0==o&&(o={}),void 0==o.withDataAndEvents&&(o.withDataAndEvents=!1),t.prompt(t(this).clone(o.withDataAndEvents).html(),o)}})}(jQuery);