(function($){
$.modal=function(_2,_3){
return $.modal.impl.init(_2,_3);
};
$.modal.close=function(){
$.modal.impl.close(true);
};
$.fn.modal=function(_4){
return $.modal.impl.init(this,_4);
};
$.modal.defaults={overlay:50,overlayId:"modalOverlay",overlayCss:{},containerId:"modalContainer",containerCss:{},close:true,closeTitle:"Close",closeClass:"modalClose",persist:false,onOpen:null,onShow:null,onClose:null};
$.modal.impl={opts:null,dialog:{},init:function(_5,_6){
if(this.dialog.data){
return false;
}
this.opts=$.extend({},$.modal.defaults,_6);
if(typeof _5=="object"){
_5=_5 instanceof jQuery?_5:$(_5);
if(_5.parent().parent().size()>0){
this.dialog.parentNode=_5.parent();
if(!this.opts.persist){
this.dialog.original=_5.clone(true);
}
}
}else{
if(typeof _5=="string"||typeof _5=="number"){
_5=$("<div>").html(_5);
}else{
if(console){
console.log("SimpleModal Error: Unsupported data type: "+typeof _5);
}
return false;
}
}
this.dialog.data=_5.addClass("modalData");
_5=null;
this.create();
this.open();
if($.isFunction(this.opts.onShow)){
this.opts.onShow.apply(this,[this.dialog]);
}
return this;
},create:function(){
this.dialog.overlay=$("<div>").attr("id",this.opts.overlayId).addClass("modalOverlay").css($.extend(this.opts.overlayCss,{opacity:this.opts.overlay/100,height:"100%",width:"100%",position:"fixed",left:0,top:0,zIndex:3000})).hide().appendTo("body");
this.dialog.container=$("<div>").attr("id",this.opts.containerId).addClass("modalContainer").css($.extend(this.opts.containerCss,{position:"fixed",zIndex:3100})).append(this.opts.close?"<a class=\"modalCloseImg "+this.opts.closeClass+"\" title=\""+this.opts.closeTitle+"\"></a>":"").hide().appendTo("body");
if($.browser.msie&&($.browser.version<7)){
this.fixIE();
}
this.dialog.container.append(this.dialog.data.hide());
},bindEvents:function(){
var _7=this;
$("."+this.opts.closeClass).click(function(e){
e.preventDefault();
_7.close();
});
},unbindEvents:function(){
$("."+this.opts.closeClass).unbind("click");
},fixIE:function(){
var _9=$(document.body).height()+"px";
var _a=$(document.body).width()+"px";
this.dialog.overlay.css({position:"absolute",height:_9,width:_a});
this.dialog.container.css({position:"absolute"});
this.dialog.iframe=$("<iframe src=\"javascript:false;\">").css($.extend(this.opts.iframeCss,{opacity:0,position:"absolute",height:_9,width:_a,zIndex:1000,width:"100%",top:0,left:0})).hide().appendTo("body");
},open:function(){
if(this.dialog.iframe){
this.dialog.iframe.show();
}
if($.isFunction(this.opts.onOpen)){
this.opts.onOpen.apply(this,[this.dialog]);
}else{
this.dialog.overlay.show();
this.dialog.container.show();
this.dialog.data.show();
}
this.bindEvents();
},close:function(_b){
if(!this.dialog.data){
return false;
}
if($.isFunction(this.opts.onClose)&&!_b){
this.opts.onClose.apply(this,[this.dialog]);
}else{
if(this.dialog.parentNode){
if(this.opts.persist){
this.dialog.data.hide().appendTo(this.dialog.parentNode);
}else{
this.dialog.data.remove();
this.dialog.original.appendTo(this.dialog.parentNode);
}
}else{
this.dialog.data.remove();
}
this.dialog.container.remove();
this.dialog.overlay.remove();
if(this.dialog.iframe){
this.dialog.iframe.remove();
}
this.dialog={};
}
this.unbindEvents();
}};
})(jQuery);
vmf.modal=function(){
return {show:function(id){
$("#"+id).modal();
},hide:function(){
$.modal.close();
}};
}();
vmf.loadCss("/files/include/module/modal.css");

