dp_common={modalCounter:0,waitForNewPage:function(a){jQuery("#grayLayer").css("opacity",0.1).fadeIn("fast",a);this.modalCounter+=1;return true},resumeThisPage:function(){this.modalCounter-=1;if(this.modalCounter<=0){jQuery("#grayLayer").css("opacity",0.1).fadeOut("fast");this.modalCounter=0}return true},bindEvent:function(c,d,f,b,a,e){if(e){d.unbind(c)}d.each(function(){jQuery(this)[c](function(g){if(b!=null){return b[f](this,g,a)}else{return f(this,g,a)}})})},bindEvents:function(b){for(var a in b){a=b[a];dp_common.bindEvent(a[0],a[1],a[2],a[3],a[4],a[5])}},textFilter:function(e,d,b){e.find(".matchesSearch").each(function(){jQuery(this).replaceWith(jQuery(this).text())});if(d!=""){if(b==null){b=" "}d=d.replace("\\","\\\\").replace("[","\\[").replace("(","\\(");var a=b+":not(:has(*))",c=new RegExp("("+d+")","ig");e.each(function(){parent=this;parent.style.display="none";jQuery(a,this).each(function(){var g=jQuery(this).text(),f=g.replace(c,'<span class="matchesSearch">$1</span>');if(f!=g){jQuery(this).html(f);parent.style.display=""}})})}else{e.css("display","")}},sortHtml:function(c,d,a){var b=function(g,f){var i=jQuery(d,g).text().toUpperCase(),h=jQuery(d,f).text().toUpperCase();if(a>0){return i>h}else{return i<=h}},e=c.children().get();c.children().remove();e.sort(b);jQuery.each(e,function(f,g){c.append(g)})},sortTable:function(a,e,f){var d=f.table,g=f.callback,c=jQuery(a),b=c.hasClass("ascending");dp_common.waitForNewPage(function(){jQuery(".sort",d).removeClass("ascending").removeClass("descending");var h=null,i=c.parent().children().index(a);if(b){h=-1;c.addClass("descending")}else{h=1;c.addClass("ascending")}dp_common.sortHtml(jQuery("tbody",d),"td:eq("+i+")",h);if(typeof(g)=="function"){g(d)}dp_common.resumeThisPage()})},__stripeRows:function(a){a.filter(":even").removeClass("odd").addClass("even");a.filter(":odd").removeClass("even").addClass("odd");a.removeClass("last").removeClass("last");a.filter(":first").addClass("first");a.filter(":last").addClass("last")},stripeTable:function(a,b){var c=jQuery("tbody tr:visible",a);dp_common.__stripeRows(c);return true},stripeList:function(a,b){var c=jQuery(a).children("li:visible");dp_common.__stripeRows(c);return true},validateInput:function(e,b,c){var k=e.getAttribute("wl-validate"),g=e.getAttribute("wl-required"),n=null,l=/^$|([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6})/i,h,f,m,d,a,j;switch(e.tagName.toLowerCase()){case"input":case"textarea":n=e.value;break;case"select":n=e.options[e.selectedIndex].value;break;default:alert(e.tagName)}if(g!=null&&n==""){c.invalid(e);return}switch(k){case"re":h=new RegExp(e.getAttribute("wl-re"));if(n.match(h)){c.valid(e)}else{c.invalid(e)}break;case"email":if(n.match(l)){c.valid(e)}else{c.invalid(e)}break;case"email-list":f=n.split(";");m=true;for(d in f){email=jQuery.trim(f[d]);if(m&&!email.match(l)){c.invalid(e);m=false}}if(m){c.valid(e)}break;case"ip":h=/^$|^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;m=true;if(n.match(h)){j=n.split(".");for(d in j){if(j[d]>255){m=false}}}else{m=false}if(m){c.valid(e)}else{c.invalid(e)}break;case"byte":h=/^$|^(\d{1,3})$/;m=true;if(n.match(h)){if(n>255){m=false}}else{m=false}if(m){c.valid(e)}else{c.invalid(e)}break;case"ns":h=/^$|^[a-z0-9\-\_]+\.([a-z0-9\-\_]+\.)*[a-z0-9\-\_]+\.[a-z]{2,4}(\.[a-z]{2})?$/i;if(n.match(h)){c.valid(e)}else{c.invalid(e)}break;case"aname":h=/^$|^[a-z0-9-\.\*]/;if(n.match(h)){c.valid(e)}else{c.invalid(e)}break;case"custom":a=e.getAttribute("wl-method");if(c[a](e)){c.valid(e)}else{c.invalid(e)}break;default:return}},delayedValidateInputTimer:-1,delayedValidateInput:function(a,c,b){if(dp_common.delayedValidateInputTimer!=-1){clearTimeout(dp_common.delayedValidateInputTimer);dp_common.delayedValidateInputTimer=-1}dp_common.delayedValidateInputTimer=setTimeout(function(){dp_common.validateInput(a,c,b)},3000)},bindValidation:function(a,d,c){this.bindEvent("blur",a,"validateInput",this,d);this.bindEvent("keyup",a,"delayedValidateInput",this,d);if(c!=null){var b=function(){jQuery(a).each(function(){dp_common.validateInput(this,null,d)})};this.bindEvent("click",c,b)}},doModal:function(b,c,d){var a=jQuery(d);this.waitForNewPage();a.css({display:"",height:"0px",width:"0px"}).animate({height:"600px",width:"800px"})},exitModal:function(b,c,d){var a=jQuery(d);a.animate({height:"0px",width:"0px"},"linear",function(){jQuery(this).css("display","none");dp_common.resumeThisPage()})},messageHandlers:[],registerMessageHandler:function(a){this.messageHandlers.push(a)},info:function(a){for(var b in this.messageHandlers){this.messageHandlers[b].handleMessage("info",a)}},warning:function(a){for(var b in this.messageHandlers){this.messageHandlers[b].handleMessage("warning",a)}},error:function(a){for(var b in this.messageHandlers){this.messageHandlers[b].handleMessage("error",a)}},debugLoggers:[],registerDebugLogger:function(a){this.debugLoggers.push(a)},debugLog:function(a){for(var b in this.debugLoggers){this.debugLoggers[b].debugLog(a)}},asyncLoad:function(url,params,container,object,callback){var cb=function(data){dp_common.resumeThisPage();var re=/\[H\](.+)\[\/H\]/,json=data.match(re),response=null;if(json!=null&&json[1]!=null){eval("var tmp= "+json[1]);response=tmp;if(response.dp_info!=null){dp_common.info(response.dp_info);response.dp_info=null}if(response.dp_warning!=null){dp_common.warning(response.dp_warning);response.dp_warning=null}if(response.dp_error!=null){dp_common.error(response.dp_error);response.dp_error=null}}if(container!=null){jQuery(container).html(data)}if(object!=null&&callback!=null){object[callback](response)}};this.waitForNewPage();jQuery.post(url,params,cb)}};
