(function(k,h,s){h.extend(k,{iframe:function(l,i,c,f,g){i||(i=450);c||(c=386);if(/(\d+)%/.test(i))i=parseInt(RegExp.$1)/100*cmstop.innerWidth();if(/(\d+)%/.test(c))c=parseInt(RegExp.$1)/100*cmstop.innerHeight();var b=h('<iframe frameborder="0" scrolling="auto" src="'+l+'" width="100%" height="100%" ></iframe>'),d=h("<div/>").html(b),a=h('<div style="background:#44DAF4;z-index:1;position:absolute;display:none;width:100%;height:100%"/>').css("opacity",0.4);d.dialog({width:i,height:c,modal:true,title:k.substr(l,
30),close:function(){b.data("bindclose")?b.trigger("close"):d.dialog("destroy").remove()}});a.insertBefore(b);l=function(){a.show();h(document).mouseup(e)};var e=function(){h(document).unbind("mouseup",e);a.hide()},m=d.prev().mousedown(l).children("span:first");d.nextAll(".ui-resizable-handle").mousedown(l);d.css("overflow","hidden");b.bind("load",function(){try{var o=this.contentDocument||this.contentWindow.document,p=this.contentWindow||this;if(!b.data("bindclose")){b.bind("close",function(){b.unbind().bind("load",
function(){d.dialog("destroy").remove()});p.location="about:blank"});b.data("bindclose",1)}p.getDialog=function(){return d};g&&(p.dialogCallback=g);if(o.title&&o.title.length)m.text(k.substr(o.title,50));else throw"no title";}catch(q){m.text(k.substr(this.src,50))}(f=k.func(f))&&f(b)});return d},ajax:function(l,i,c,f,g,b,d){c||(c=450);f||(f=386);if(/(\d+)%/.test(c))c=parseInt(RegExp.$1)/100*cmstop.innerWidth();if(/(\d+)%/.test(f))f=parseInt(RegExp.$1)/100*cmstop.innerHeight();var a=h("<div/>"),e=
{};(b=k.func(b))&&(e["\u786e\u5b9a"]=function(){b(a)&&a.dialog("close");return true})&&(d=k.func(d))&&(e["\u53d6\u6d88"]=function(){d(a)&&a.dialog("close");return false});g=k.func(g);a.dialog({autoOpen:false,width:c,height:f,modal:true,title:l,buttons:e,close:function(){a.dialog("destroy").remove()}}).load(i,function(){a.dialog("open");g&&g(a)}).bind("ajaxload",function(){g&&g(a)});return a},form:function(l,i,c,f,g,b,d,a){var e=null;return cmstop.ajax(l,i,c,f,function(m){e=h("form:eq(0)",m);if(e.length){var o=
h('<div class="masker"></div>'),p=m.parent();m.before(o);var q=m.nextAll("div.btn_area").children("button");(b=k.func(b))&&b(e,m);var r=function(){e.ajaxSubmit({dataType:"json",type:"post",success:function(j){var n=null;j.state===s&&(n=h('<div class="warning"><sub></sub>'+(h.isArray(j.info)?j.info.join("<br/>"):j.info)+"</div>"))||!j.state&&(n=h('<div class="error"><sub></sub>'+j.error+"</div>"))||j.info&&(n=h('<div class="success"><sub></sub>'+j.info+"</div>"));n&&(m.prepend(n),setTimeout(function(){n&&
n.hide()},2E3));(g=k.func(g))?g(j)?m.dialog("destroy").remove():(o.hide(),q.removeAttr("disabled")):j.state?m.dialog("destroy").remove():(o.hide(),q.removeAttr("disabled"));return false},beforeSubmit:function(j,n,t){(d=cmstop.func(d))&&d(e,j,t);q.attr("disabled","disabled");o.css({height:p.height(),width:p.width()}).show();return true},beforeSerialize:function(j,n){(a=cmstop.func(a))&&a(j,n)}})};if(e[0].getAttribute("name"))e.validate({submitHandler:r});else{h(e[0].elements).not(":button,:submit,:image,:reset,:hidden,[disabled],[readonly]").eq(0).focus();
e.submit(function(){r(e);return false})}}},function(){e&&e.submit();return false},function(){return true})},dialog:function(l,i,c,f,g,b){c||(c=450);f||(f=386);if(/(\d+)%/.test(c))c=parseInt(RegExp.$1)/100*cmstop.innerWidth();if(/(\d+)%/.test(f))f=parseInt(RegExp.$1)/100*cmstop.innerHeight();g=k.func(g)||function(){};b=k.func(b)||function(){};var d={"\u786e\u5b9a":function(){g(a)?a.dialog("destroy"):a.dialog("close");return true},"\u53d6\u6d88":function(){b(a)?a.dialog("destroy"):a.dialog("close");
return false}},a;i.jquery?a=i:(a=h("#"+i)).length||(a=h('<div id="'+i+'">'));if(a.hasClass("ui-dialog-content")){a.dialog("option","width",c);a.dialog("option","height",f);a.dialog("option","title",l);a.dialog("option","buttons",d);a.dialog("open");return a}a.dialog({width:c,height:f,modal:true,title:l,buttons:d});return a}})})(cmstop,jQuery);
