function Boxy(a,b){this.boxy=jQuery(Boxy.WRAPPER);jQuery.data(this.boxy[0],"boxy",this);this.visible=false;this.options=jQuery.extend({},Boxy.DEFAULTS,b||{});if(this.options.modal){this.options=jQuery.extend(this.options,{center:true,draggable:false})}if(this.options.actuator){jQuery.data(this.options.actuator,"active.boxy",this)}this.setContent(a||"
");this._setupTitleBar();this.boxy.css("display","none").appendTo(document.body);this.toTop();if(this.options.fixed){if(Boxy.IE6){this.options.fixed=false}else{this.boxy.addClass("fixed")}}if(this.options.center&&Boxy._u(this.options.x,this.options.y)){this.center()}else{this.moveTo(Boxy._u(this.options.x)?Boxy.DEFAULT_X:this.options.x,Boxy._u(this.options.y)?Boxy.DEFAULT_Y:this.options.y)}if(this.options.show)this.show()}jQuery.fn.boxy=function(a){a=a||{};return this.each(function(){var b=this.nodeName.toLowerCase(),c=this;if(b=="a"){jQuery(this).click(function(){var b=Boxy.linkedTo(this),c=this.getAttribute("href"),d=jQuery.extend({actuator:this,title:this.title},a);if(c.match(/(&|\?)boxy\.modal/))d.modal=true;if(b){b.show()}else if(c.indexOf("#")>=0){var e=jQuery(c.substr(c.indexOf("#"))),f=e.clone(true);e.remove();d.unloadOnHide=false;new Boxy(f,d)}else if(c.match(/\.(jpe?g|png|gif|bmp)($|\?)/i)){d.unloadOnHide=true;Boxy.loadImage(this.href,d)}else{if(!d.cache)d.unloadOnHide=true;Boxy.load(this.href,d)}return false})}else if(b=="form"){jQuery(this).bind("submit.boxy",function(){Boxy.confirm(a.message||"Please confirm:",function(){jQuery(c).unbind("submit.boxy").submit()});return false})}})};Boxy.EF=function(){};Boxy.PS=function(){if(typeof mi4pFrame==="object"&&mi4pFrame&&typeof targetWindow==="object"&&targetWindow&&targetWindow.postMessage){targetWindow.postMessage({'type':'grayout'},'*');}};Boxy.AAH=function(){if(typeof mi4pFrame==="object"&&mi4pFrame&&typeof targetWindow==="object"&&targetWindow&&targetWindow.postMessage){targetWindow.postMessage({'type':'grayin'},'*');}};jQuery.extend(Boxy,{WRAPPER:""+""+""+""+"
",DEFAULTS:{title:null,closeable:true,draggable:true,clone:false,actuator:null,center:true,show:true,modal:false,fixed:true,closeText:"×",unloadOnHide:false,clickToFront:false,behaviours:Boxy.EF,afterDrop:Boxy.EF,preShow:Boxy.PS,afterShow:Boxy.EF,afterHide:Boxy.EF,afterAfterHide:Boxy.AAH,beforeUnload:Boxy.EF,hideFade:false,hideShrink:"vertical"},IE6:jQuery.browser.msie&&jQuery.browser.version<7,DEFAULT_X:50,DEFAULT_Y:50,MODAL_OPACITY:.7,zIndex:1337,dragConfigured:false,resizeConfigured:false,dragging:null,load:function(a,b){b=b||{};var c={url:a,type:"GET",dataType:"html",cache:false,success:function(a){a=jQuery(a);if(b.filter)a=jQuery(b.filter,a);new Boxy(a,b)}};jQuery.each(["type","cache"],function(){if(this in b){c[this]=b[this];delete b[this]}});jQuery.ajax(c)},loadImage:function(a,b){var c=new Image;c.onload=function(){new Boxy($('
').append(this),b)};c.src=a},get:function(a){var b=jQuery(a).parents(".boxy-wrapper");return b.length?jQuery.data(b[0],"boxy"):null},linkedTo:function(a){return jQuery.data(a,"active.boxy")},alert:function(a,b,c){return Boxy.ask(a,["OK"],b,c)},confirm:function(a,b,c){return Boxy.ask(a,["OK","Cancel"],function(a){if(a=="OK")b()},c)},ask:function(a,b,c,d){d=jQuery.extend({modal:true,closeable:false},d||{},{show:true,unloadOnHide:true});var e=jQuery("
").append(jQuery('
').html(a));var f=jQuery('
');f.html(jQuery.map(Boxy._values(b),function(a){return""}).join(" "));jQuery("input[type=button]",f).click(function(){var a=this;Boxy.get(this).hide(function(){if(c){jQuery.each(b,function(d,e){if(e==a.value){c(b instanceof Array?e:d);return false}})}})});e.append(f);new Boxy(e,d)},isModalVisible:function(){return jQuery(".boxy-modal-blackout").length>0},_u:function(){for(var a=0;a
').css(jQuery.extend(Boxy._cssForOverlay(),{zIndex:Boxy._nextZ(),opacity:Boxy.MODAL_OPACITY})).appendTo(document.body);this.toTop();if(this.options.closeable){jQuery(document.body).bind("keypress.boxy",function(b){var c=b.which||b.keyCode;if(c==27){a.hide();jQuery(document.body).unbind("keypress.boxy")}})}}this.getInner().stop().css({width:"",height:""});this.boxy.stop().css({opacity:1}).show();this.visible=true;this.boxy.find(".close:first").focus();this._fire("preShow");this._fire("afterShow");return this},hide:function(a){if(!this.visible)return;var b=this;if(this.options.modal){jQuery(document.body).unbind("keypress.boxy");this.modalBlackout.animate({opacity:0},function(){jQuery(this).remove()})}var c={boxy:{},inner:{}},d=0,e=function(){b.boxy.css({display:"none"});b.visible=false;b._fire("afterHide");b._fire("afterAfterHide");if(a)a(b);if(b.options.unloadOnHide)b.unload()};if(this.options.hideShrink){var f=this.getInner(),g=this.options.hideShrink,h=this.getPosition();d|=1;if(g===true||g=="vertical"){c.inner.height=0;c.boxy.top=h[1]+f.height()/2}if(g===true||g=="horizontal"){c.inner.width=0;c.boxy.left=h[0]+f.width()/2}}if(this.options.hideFade){d|=2;c.boxy.opacity=0}if(d){if(d&1)f.stop().animate(c.inner,300);this.boxy.stop().animate(c.boxy,300,e)}else{e()}return this},toggle:function(){this[this.visible?"hide":"show"]();return this},hideAndUnload:function(a){this.options.unloadOnHide=true;this.hide(a);return this},unload:function(){this._fire("beforeUnload");this.boxy.remove();if(this.options.actuator){jQuery.data(this.options.actuator,"active.boxy",false)}},toTop:function(){this.boxy.css({zIndex:Boxy._nextZ()});return this},getTitle:function(){return jQuery("> .title-bar h2",this.getInner()).html()},setTitle:function(a){jQuery("> .title-bar h2",this.getInner()).html(a);return this},_getBoundsForResize:function(a,b){var c=this.getContentSize();var d=[a-c[0],b-c[1]];var e=this.getPosition();return[Math.max(e[0]-d[0]/2,0),Math.max(e[1]-d[1]/2,0),a,b]},_setupTitleBar:function(){if(this.options.title){var a=this;var b=jQuery("
").html("

"+this.options.title+"

");if(this.options.closeable){b.append(jQuery("").html(this.options.closeText))}if(this.options.draggable){b[0].onselectstart=function(){return false};b[0].unselectable="on";b[0].style.MozUserSelect="none";if(!Boxy.dragConfigured){jQuery(document).mousemove(Boxy._handleDrag);Boxy.dragConfigured=true}b.mousedown(function(b){a.toTop();Boxy.dragging=[a,b.pageX-a.boxy[0].offsetLeft,b.pageY-a.boxy[0].offsetTop];jQuery(this).addClass("dragging")}).mouseup(function(){jQuery(this).removeClass("dragging");Boxy.dragging=null;a._fire("afterDrop")})}this.getInner().prepend(b);this._setupDefaultBehaviours(b)}},_setupDefaultBehaviours:function(a){var b=this;if(this.options.clickToFront){a.click(function(){b.toTop()})}jQuery(".close",a).click(function(){b.hide();return false}).mousedown(function(a){a.stopPropagation()})},_fire:function(a){this.options[a].call(this)}}