(function(a){var b=function(f,e){var d=this;this._dragging=false;this._content=f;this._options=e;this.dh=null;this.mh=null;this.dt=null;this.dc=null;this.bo=null;this.bc=null;this.selector=null;this.ajaxurl=null;this.options=null;this.defaults={boxid:null,boxclass:null,type:"dialog",title:"",width:0,height:0,timeout:0,draggable:true,modal:true,focus:null,position:"center",overlay:75,showTitle:true,showButton:true,showCancel:true,showOk:true,okBtnName:"OK",cancelBtnName:"CANCEL",contentType:"text",contentChange:false,clickClose:false,zIndex:999,animate:false,trigger:null,onclose:null,onopen:null,onok:null};this.types=new Array("dialog","error","warning","success","prompt","box","loader");this.titles={error:"ERROR",warning:"WARNING",success:"SUCCESSFULLY",prompt:"PLEASE CONFIRM",dialog:"INFORMATION",box:"",loader:""};this.initOptions=function(){if(typeof(d._options)=="undefined"){d._options={}}if(typeof(d._options.type)=="undefined"){d._options.type="dialog"}if(!a.inArray(d._options.type,d.types)){d._options.type=d.types[0]}if(typeof(d._options.boxclass)=="undefined"){d._options.boxclass=d._options.type+"box"}if(typeof(d._options.title)=="undefined"){d._options.title=d.titles[d._options.type]}if(f.substr(0,1)=="#"){d._options.contentType="selector";d.selector=f}d.options=a.extend({},d.defaults,d._options)};this.initBox=function(){var g="";if(d.options.type=="showbox"){g='<div class="showbox_dialog"><div class="dialog-header"><div class="dialog-tl"></div><div class="dialog-title"></div><div class="dialog-tr"><div class="dialog-close" title="Close"><a href="javascript:;" onfocus="this.blur()"></a></div></div></div><div class="dialog-con"><div class="dialog-con2"><div class="dialog-content"></div><div class="dialog-button"><input type="button" class="dialog-ok" value="OK" />&nbsp;<input type="button" class="dialog-cancel" value="CANCEL" /></div></div></div><div class="dialog-bot"><div class="dialog-bl"></div><div class="dialog-bc"></div><div class="dialog-br"></div></div></div>'}else{g="<div class='dialog-box'><div class='dialog-header'><div class='dialog-title'></div><div class='dialog-close'></div></div><div class='dialog-content'></div><div style='clear:both'></div><div class='dialog-button'><input type='button' class='dialog-ok' value='OK' /><input type='button' class='dialog-cancel' value='CANCEL' /></div></div>"}d.dh=a(g).appendTo("body").hide().css({position:"absolute",overflow:"hidden",zIndex:d.options.zIndex});d.dt=d.dh.find(".dialog-title");d.dc=d.dh.find(".dialog-content");d.bo=d.dh.find(".dialog-ok");d.bc=d.dh.find(".dialog-cancel");if(d.options.boxid){d.dh.attr("id",d.options.boxid)}if(d.options.boxclass){d.dh.addClass(d.options.boxclass)}if(d.options.height>0){d.dc.css("height",d.options.height)}if(d.options.width>0){d.dh.css("width",d.options.width)}a(".dialog-mask").bgiframe();d.dh.bgiframe()};this.initMask=function(){if(d.options.modal){d.mh=a("<div class='dialog-mask'></div>").appendTo("body").hide().css({opacity:d.options.overlay/100,filter:"alpha(opacity="+d.options.overlay+")",width:d.bwidth(),height:d.bheight(),zIndex:d.options.zIndex-1})}};this.initContent=function(h){d.dh.find(".dialog-ok").val(d.options.okBtnName);d.dh.find(".dialog-cancel").val(d.options.cancelBtnName);d.dh.find(".dialog-title").html(d.options.title);if(!d.options.showTitle){d.dh.find(".dialog-header").hide()}if(!d.options.showButton){d.dh.find(".dialog-button").hide()}if(!d.options.showCancel){d.dh.find(".dialog-cancel").hide()}if(!d.options.showOk){d.dh.find(".dialog-ok").hide()}if(d.options.contentType=="selector"){d.selector=d._content;d._content=a(d.selector).html();d.setContent(d._content);var g=a(d.selector).find(":checkbox");d.dh.find(".dialog-content").find(":checkbox").each(function(j){this.checked=g[j].checked});a(d.selector).empty();d.onopen();d.show();d.focus()}else{if(d.options.contentType=="ajax"){d.ajaxurl=d._content;d.setContent('<div class="dialog-loading"></div>');d.show();a.get(d.ajaxurl,function(i){d._content=i;d.setContent(d._content);d.onopen();d.focus()})}else{d.setContent(d._content);d.onopen();d.show();d.focus()}}};this.initEvent=function(){d.dh.find(".dialog-close, .dialog-cancel, .dialog-ok").unbind("click").click(function(){d.close()});if(typeof(d.options.onok)=="function"){d.dh.find(".dialog-ok").unbind("click").click(d.options.onok)}if(typeof(d.options.oncancel)=="function"){d.dh.find(".dialog-cancel").unbind("click").click(d.options.oncancel)}if(d.options.timeout>0){window.setTimeout(d.close,(d.options.timeout*1000))}this.draggable()};this.draggable=function(){if(d.options.draggable&&d.options.showTitle){d.dh.find(".dialog-header").mousedown(function(i){d._ox=d.dh.position().left;d._oy=d.dh.position().top;d._mx=i.clientX;d._my=i.clientY;d._dragging=true});if(d.mh){var g=d.mh}else{var g=a(document)}a(document).mousemove(function(i){if(d._dragging==true){d.dh.css({left:d._ox+i.clientX-d._mx,top:d._oy+i.clientY-d._my})}}).mouseup(function(){d._mx=null;d._my=null;d._dragging=false});var h=d.dh.find(".dialog-header").get(0);h.unselectable="on";h.onselectstart=function(){return false};if(h.style){h.style.MozUserSelect="none"}}};this.onopen=function(){if(typeof(d.options.onopen)=="function"){d.options.onopen()}};this.show=function(){if(d.options.position=="center"){d.setCenterPosition()}if(d.options.position=="element"){d.setElementPosition()}if(d.options.animate){d.dh.fadeIn("slow");if(d.mh){d.mh.fadeIn("normal")}}else{d.dh.show();if(d.mh){d.mh.show()}}};this.focus=function(){if(d.options.focus){d.dh.find(d.options.focus).focus()}else{d.dh.find(".dialog-cancel").focus()}};this.find=function(g){return d.dh.find(g)};this.setTitle=function(g){d.dh.find(".dialog-title").html(g)};this.getTitle=function(){return d.dh.find(".dialog-title").html()};this.setContent=function(g){d.dh.find(".dialog-content").html(g)};this.getContent=function(){return d.dh.find(".dialog-content").html()};this.hideButton=function(g){d.dh.find(".dialog-"+g).hide()};this.showButton=function(g){d.dh.find(".dialog-"+g).show()};this.setButtonTitle=function(h,g){d.dh.find(".dialog-"+h).val(g)};this.close=function(){if(d.animate){d.dh.fadeOut("slow",function(){d.dh.hide()});if(d.mh){d.mh.fadeOut("normal",function(){d.mh.hide()})}}else{d.dh.hide();if(d.mh){d.mh.hide()}}if(d.options.contentType=="selector"){if(d.options.contentChange){var g=d.find(":checkbox");a(d.selector).html(d.getContent());if(g.length>0){a(d.selector).find(":checkbox").each(function(h){this.checked=g[h].checked})}}else{a(d.selector).html(d._content)}}if(typeof(d.options.onclose)=="function"){d.options.onclose()}d.dh.remove();if(d.mh){d.mh.remove()}};this.bheight=function(){if(a.browser.msie&&a.browser.version<7){var h=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);var g=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);if(h<g){return a(window).height()}else{return h}}else{return a(document).height()}};this.bwidth=function(){if(a.browser.msie&&a.browser.version<7){var g=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);var h=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);if(g<h){return a(window).width()}else{return g}}else{return a(document).width()}};this.setCenterPosition=function(){var h=a(window),i=a(document),j=i.scrollTop(),g=i.scrollLeft(),k=j;j+=(h.height()-d.dh.height())/2/2;j=Math.max(j,k);g+=(h.width()-d.dh.width())/2;d.dh.css({top:j,left:g})};this.setElementPosition=function(){var h=a("#"+d.options.trigger);if(h.length==0){alert("OOPS");d.close();return false}var g=0;if(!a.browser.msie||a.browser.version>=7){g=a(window).width()-document.body.scrollWidth}var j=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft)+h.position().left;if(j+d.dh.width()>document.body.clientWidth){j=h.position().left+h.width()+g-d.dh.width()}var i=Math.max(document.documentElement.scrollTop,document.body.scrollTop)+h.position().top;if(i+d.dh.height()+h.height()>document.documentElement.clientHeight){i=i-d.dh.height()-5}else{i=i+h.height()+5}d.dh.css({top:i,left:j});return true};this.correctPNG=function(){if(a.browser.msie&&/6.0/.test(navigator.userAgent)){for(var n=0;n<document.images.length;n++){var k=document.images[n];var m=k.src.toUpperCase();if(m.substring(m.length-3,m.length)=="PNG"){var h=(k.id)?"id='"+k.id+"' ":"";var l=(k.className)?"class='"+k.className+"' ":"";var o=(k.title)?"title='"+k.title+"' ":"title='"+k.alt+"' ";var j="display:inline-block;"+k.style.cssText;if(k.align=="left"){j="float:left;"+j}if(k.align=="right"){j="float:right;"+j}if(k.parentElement.href){j="cursor:hand;"+j}var g="<span "+h+l+o+' style="width:'+k.width+"px; height:"+k.height+"px;"+j+";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+k.src+"', sizingMethod='scale');\"></span>";k.outerHTML=g;n=n-1}}}};this.initialize=function(){d.initOptions();d.initMask();d.initBox();d.initContent();d.initEvent();d.correctPNG();return d};this.initialize()};var c=function(){var d=this;this._onbox=false;this._opening=false;this.boxs=new Array();this.zIndex=999;this.push=function(e){this.boxs.push(e)};this.pop=function(){if(this.boxs.length>0){return this.boxs.pop()}else{return false}};this.open=this.ds=function(g,e){d._opening=true;if(typeof(e)=="undefined"){e={}}if(e.boxid){this.close(e.boxid)}e.zIndex=this.zIndex;this.zIndex+=10;var f=new b(g,e);f.dh.click(function(){d._onbox=true});this.push(f);return f};this.close=function(f){if(f){for(var e=0;e<this.boxs.length;e++){if(this.boxs[e].dh.attr("id")==f){this.boxs[e].close();this.boxs.splice(e,1)}}}else{this.pop().close()}};this.loader=function(e){return this.open(e,{boxid:"_5FA2DB591EB538B98B79FC6737ED4452_",type:"loader",height:68,showTitle:false,showButton:false})};this.loaderClose=function(){return this.close("_5FA2DB591EB538B98B79FC6737ED4452_")};this.length=function(){return this.boxs.length};this.getTopBox=function(){return this.boxs[this.boxs.length-1]};this.find=function(e){return this.getTopBox().dh.find(e)};this.setTitle=function(e){this.getTopBox().setTitle(e)};this.getTitle=function(){return this.getTopBox().getTitle()};this.setContent=function(e){this.getTopBox().setContent(e)};this.getContent=function(){return this.getTopBox().getContent()};this.hideButton=function(e){this.getTopBox().hideButton(e)};this.showButton=function(e){this.getTopBox().showButton(e)};this.setButtonTitle=function(f,e){this.getTopBox().setButtonTitle(f,e)};a(window).scroll(function(){if(d.length()>0){var e=d.getTopBox();if(e.options.position=="center"){d.getTopBox().setCenterPosition()}}});a(document).click(function(){if(d.length()>0){var e=d.getTopBox();if(!d._opening&&!d._onbox&&e.options.clickClose){e.close()}}d._opening=false;d._onbox=false})};a.extend({showbox:new c()})})(jQuery);
