/* w2ui 1.x (c) http://w2ui.com, vitmalina@gmail.com */
var w2ui=w2ui||{},w2obj=w2obj||{},w2utils=function(){function t(e){var t=/^[-]?[0-9]+$/;return t.test(e)}function n(e){var t=new RegExp(w2utils.settings["float"]);return t.test(e)}function r(e){var t=new RegExp(w2utils.settings.currency);return t.test(e)}function i(e){var t=/^[a-fA-F0-9]+$/;return t.test(e)}function s(e){var t=/^[a-zA-Z0-9_-]+$/;return t.test(e)}function o(e){var t=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/;return t.test(e)}function u(e,t){if(!e)return!1;t||(t=w2utils.settings.date_format);var n=e.replace(/-/g,"/").replace(/\./g,"/").toLowerCase().split("/"),r=t.replace(/-/g,"/").replace(/\./g,"/").toLowerCase(),i="Invalid Date",s,o,u;return r=="mm/dd/yyyy"&&(s=n[0],o=n[1],u=n[2]),r=="dd/mm/yyyy"&&(s=n[1],o=n[0],u=n[2]),r=="yyyy/dd/mm"&&(s=n[2],o=n[1],u=n[0]),r=="yyyy/mm/dd"&&(s=n[1],o=n[2],u=n[0]),i=new Date(s+"/"+o+"/"+u),typeof s=="undefined"?!1:i=="Invalid Date"?!1:i.getMonth()+1!=s||i.getDate()!=o||i.getFullYear()!=u?!1:!0}function a(e){if(String(e)=="undefined")return!1;var t;e=e.toUpperCase(),e.indexOf("PM")>=0||e.indexOf("AM")>=0?t=12:t=23,e=$.trim(e.replace("AM","")),e=$.trim(e.replace("PM",""));var n=e.split(":");return n.length!=2?!1:n[0]==""||parseInt(n[0])<0||parseInt(n[0])>t||!this.isInt(n[0])?!1:n[1]==""||parseInt(n[1])<0||parseInt(n[1])>59||!this.isInt(n[1])?!1:!0}function f(e,t){var n=w2utils.settings.shortmonths,r=w2utils.settings.fullmonths;typeof t=="undefined"&&(t=this.settings.date_format);if(typeof e=="undefined"||e==""||e==null)return"";var i=new Date(e);w2utils.isInt(e)&&(i=new Date(Number(e)));var s=String(e).split("-");s.length==3&&(i=new Date(s[0],Number(s[1])-1,s[2]));var s=String(e).split("/");s.length==3&&(i=new Date(s[2],Number(s[0])-1,s[1]));if(i=="Invalid Date")return"";var o=i.getFullYear(),u=i.getMonth(),a=i.getDate(),f=t.toLowerCase().replace("yyyy",o).replace("mm",u+1).replace("dd",a).replace("mon",n[u]).replace("month",r[u]);return f}function l(e){var t="";if(w2utils.isFloat(e)||w2utils.isInt(e)||w2utils.isMoney(e))t=String(e).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,");return t}function c(e){var t=w2utils.settings.shortmonths;if(e==""||typeof e=="undefined"||e==null)return"";w2utils.isInt(e)&&(e=Number(e));var n=new Date(e);w2utils.isInt(e)&&(n=new Date(Number(e)));var r=String(e).split("-");r.length==3&&(n=new Date(r[0],Number(r[1])-1,r[2]));var r=String(e).split("/");r.length==3&&(n=new Date(r[2],Number(r[0])-1,r[1]));if(n=="Invalid Date")return"";var i=new Date,s=new Date;s.setTime(s.getTime()-864e5);var o=t[n.getMonth()]+" "+n.getDate()+", "+n.getFullYear(),u=t[i.getMonth()]+" "+i.getDate()+", "+i.getFullYear(),a=t[s.getMonth()]+" "+s.getDate()+", "+s.getFullYear(),f=n.getHours()-(n.getHours()>12?12:0)+":"+(n.getMinutes()<10?"0":"")+n.getMinutes()+" "+(n.getHours()>=12?"pm":"am"),l=n.getHours()-(n.getHours()>12?12:0)+":"+(n.getMinutes()<10?"0":"")+n.getMinutes()+":"+(n.getSeconds()<10?"0":"")+n.getSeconds()+" "+(n.getHours()>=12?"pm":"am"),c=o;return o==u&&(c=f),o==a&&(c=w2utils.lang("Yesterday")),'<span title="'+o+" "+l+'">'+c+"</span>"}function h(e){if(e==""||typeof e=="undefined"||e==null)return"";w2utils.isInt(e)&&(e=Number(e));var t=new Date(e);w2utils.isInt(e)&&(t=new Date(Number(e)));var n=String(e).split("-");n.length==3&&(t=new Date(n[0],Number(n[1])-1,n[2]));var n=String(e).split("/");n.length==3&&(t=new Date(n[2],Number(n[0])-1,n[1]));if(t=="Invalid Time")return"";var r=new Date,i=(r.getTime()-t.getTime())/1e3,s="",o="";return i<60?(s=Math.floor(i),o="sec",i<0&&(s=0,o="sec")):i<3600?(s=Math.floor(i/60),o="min"):i<86400?(s=Math.floor(i/60/60),o="hour"):i<2592e3?(s=Math.floor(i/24/60/60*10)/10,o="day"):i<31104e3?(s=Math.floor(i/30/24/60/60*10)/10,o="month"):i>=31104e3&&(s=Math.floor(i/12/30/24/60/60*10)/10,o="year"),s+" "+o+(s>1?"s":"")}function p(e){if(!w2utils.isFloat(e)||e=="")return"";e=parseFloat(e);if(e==0)return 0;var t=["Bt","KB","MB","GB","TB"],n=parseInt(Math.floor(Math.log(e)/Math.log(1024)));return(Math.floor(e/Math.pow(1024,n)*10)/10).toFixed(n==0?0:1)+" "+t[n]}function d(e){if(e==null)return e;switch(typeof e){case"number":break;case"string":e=$.trim(String(e).replace(/(<([^>]+)>)/ig,""));break;case"object":for(var t in e)e[t]=this.stripTags(e[t])}return e}function v(e){if(e==null)return e;switch(typeof e){case"number":break;case"string":e=String(e).replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;");break;case"object":for(var t in e)e[t]=this.encodeTags(e[t])}return e}function m(e){return typeof e=="undefined"||e==""||e==null?"":String(e).replace(/([;&,\.\+\*\~'`:"\!\^#$%@\[\]\(\)=<>\|\/? {}\\])/g,"\\$1")}function g(e){function c(e){var e=String(e).replace(/\r\n/g,"\n"),t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(r&63|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(r&63|128))}return t}var t="",n,r,i,s,o,u,a,f=0,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e=c(e);while(f<e.length)n=e.charCodeAt(f++),r=e.charCodeAt(f++),i=e.charCodeAt(f++),s=n>>2,o=(n&3)<<4|r>>4,u=(r&15)<<2|i>>6,a=i&63,isNaN(r)?u=a=64:isNaN(i)&&(a=64),t=t+l.charAt(s)+l.charAt(o)+l.charAt(u)+l.charAt(a);return t}function y(e){function c(e){var t="",n=0,r=0,i=0,s=0;while(n<e.length)r=e.charCodeAt(n),r<128?(t+=String.fromCharCode(r),n++):r>191&&r<224?(s=e.charCodeAt(n+1),t+=String.fromCharCode((r&31)<<6|s&63),n+=2):(s=e.charCodeAt(n+1),c3=e.charCodeAt(n+2),t+=String.fromCharCode((r&15)<<12|(s&63)<<6|c3&63),n+=3);return t}var t="",n,r,i,s,o,u,a,f=0,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length)s=l.indexOf(e.charAt(f++)),o=l.indexOf(e.charAt(f++)),u=l.indexOf(e.charAt(f++)),a=l.indexOf(e.charAt(f++)),n=s<<2|o>>4,r=(o&15)<<4|u>>2,i=(u&3)<<6|a,t+=String.fromCharCode(n),u!=64&&(t+=String.fromCharCode(r)),a!=64&&(t+=String.fromCharCode(i));return t=c(t),t}function b(e,t,n,r){function u(e,t,n){var r=!!window.webkitURL;return!r&&typeof n!="undefined"&&(t=n),";"+e+": "+t+"; -webkit-"+e+": "+t+"; -moz-"+e+": "+t+"; "+"-ms-"+e+": "+t+"; -o-"+e+": "+t+";"}var i=$(e).width(),s=$(e).height(),o=.5;if(!e||!t){console.log("ERROR: Cannot do transition when one of the divs is null");return}e.parentNode.style.cssText+=u("perspective","700px")+"; overflow: hidden;",e.style.cssText+="; position: absolute; z-index: 1019; "+u("backface-visibility","hidden"),t.style.cssText+="; position: absolute; z-index: 1020; "+u("backface-visibility","hidden");switch(n){case"slide-left":e.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),t.style.cssText+="overflow: hidden; "+u("transform","translate3d("+i+"px, 0, 0)","translate("+i+"px, 0)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+";"+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),e.style.cssText+=u("transition",o+"s")+";"+u("transform","translate3d(-"+i+"px, 0, 0)","translate(-"+i+"px, 0)")},1);break;case"slide-right":e.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),t.style.cssText+="overflow: hidden; "+u("transform","translate3d(-"+i+"px, 0, 0)","translate(-"+i+"px, 0)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","translate3d(0px, 0, 0)","translate(0px, 0)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","translate3d("+i+"px, 0, 0)","translate("+i+"px, 0)")},1);break;case"slide-down":e.style.cssText+="overflow: hidden; z-index: 1; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),t.style.cssText+="overflow: hidden; z-index: 0; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","translate3d(0, "+s+"px, 0)","translate(0, "+s+"px)")},1);break;case"slide-up":e.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),t.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, "+s+"px, 0)","translate(0, "+s+"px)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)")},1);break;case"flip-left":e.style.cssText+="overflow: hidden; "+u("-transform","rotateY(0deg)"),t.style.cssText+="overflow: hidden; "+u("transform","rotateY(-180deg)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateY(0deg)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateY(180deg)")},1);break;case"flip-right":e.style.cssText+="overflow: hidden; "+u("transform","rotateY(0deg)"),t.style.cssText+="overflow: hidden; "+u("transform","rotateY(180deg)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateY(0deg)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateY(-180deg)")},1);break;case"flip-down":e.style.cssText+="overflow: hidden; "+u("transform","rotateX(0deg)"),t.style.cssText+="overflow: hidden; "+u("transform","rotateX(180deg)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateX(0deg)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateX(-180deg)")},1);break;case"flip-up":e.style.cssText+="overflow: hidden; "+u("transform","rotateX(0deg)"),t.style.cssText+="overflow: hidden; "+u("transform","rotateX(-180deg)"),$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateX(0deg)"),e.style.cssText+=u("transition",o+"s")+"; "+u("transform","rotateX(180deg)")},1);break;case"pop-in":e.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),t.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)")+"; "+u("transform","scale(.8)")+"; opacity: 0;",$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; "+u("transform","scale(1)")+"; opacity: 1;",e.style.cssText+=u("transition",o+"s")+";"},1);break;case"pop-out":e.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)")+"; "+u("transform","scale(1)")+"; opacity: 1;",t.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)")+"; opacity: 0;",$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; opacity: 1;",e.style.cssText+=u("transition",o+"s")+"; "+u("transform","scale(1.7)")+"; opacity: 0;"},1);break;default:e.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)"),t.style.cssText+="overflow: hidden; "+u("transform","translate3d(0, 0, 0)","translate(0, 0)")+"; opacity: 0;",$(t).show(),window.setTimeout(function(){t.style.cssText+=u("transition",o+"s")+"; opacity: 1;",e.style.cssText+=u("transition",o+"s")},1)}setTimeout(function(){n=="slide-down"&&($(e).css("z-index","1019"),$(t).css("z-index","1020")),t&&$(t).css({opacity:"1","-webkit-transition":"","-moz-transition":"","-ms-transition":"","-o-transition":"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":"","-webkit-backface-visibility":"","-moz-backface-visibility":"","-ms-backface-visibility":"","-o-backface-visibility":""}),e&&($(e).css({opacity:"1","-webkit-transition":"","-moz-transition":"","-ms-transition":"","-o-transition":"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":"","-webkit-backface-visibility":"","-moz-backface-visibility":"","-ms-backface-visibility":"","-o-backface-visibility":""}),e.parentNode&&$(e.parentNode).css({"-webkit-perspective":"","-moz-perspective":"","-ms-perspective":"","-o-perspective":""})),typeof r=="function"&&r()},o*1e3)}function w(e,t){var n={left:parseInt($(e).css("border-left-width"))||0,right:parseInt($(e).css("border-right-width"))||0,top:parseInt($(e).css("border-top-width"))||0,bottom:parseInt($(e).css("border-bottom-width"))||0},r={left:parseInt($(e).css("margin-left"))||0,right:parseInt($(e).css("margin-right"))||0,top:parseInt($(e).css("margin-top"))||0,bottom:parseInt($(e).css("margin-bottom"))||0},i={left:parseInt($(e).css("padding-left"))||0,right:parseInt($(e).css("padding-right"))||0,top:parseInt($(e).css("padding-top"))||0,bottom:parseInt($(e).css("padding-bottom"))||0};switch(t){case"top":return n.top+r.top+i.top;case"bottom":return n.bottom+r.bottom+i.bottom;case"left":return n.left+r.left+i.left;case"right":return n.right+r.right+i.right;case"width":return n.left+n.right+r.left+r.right+i.left+i.right+parseInt($(e).width());case"height":return n.top+n.bottom+r.top+r.bottom+i.top+i.bottom+parseInt($(e).height());case"+width":return n.left+n.right+r.left+r.right+i.left+i.right;case"+height":return n.top+n.bottom+r.top+r.bottom+i.top+i.bottom}return 0}function E(e){var t=this.settings.phrases[e];return typeof t=="undefined"?e:t}function S(e,t){var n=w2utils.settings;typeof e=="string"&&(e={lang:e}),e=$.extend({path:"locale",lang:"en-us"},e),$.ajax({url:e.path+"/"+e.lang.toLowerCase()+".json",type:"GET",dataType:"JSON",cache:!1,success:function(e,n,r){w2utils.settings=$.extend(!0,w2utils.settings,e),typeof t=="function"&&t(e)},error:function(e,t,r){console.log("ERROR: Cannot load locale "+n.lang+" in "+n.path)}})}function x(){if(w2utils._scrollBarSize)return w2utils._scrollBarSize;var e='<div id="_scrollbar_width" style="position: absolute; top: -300px; width: 100px; height: 100px; overflow-y: scroll;">	<div style="height: 120px">1</div></div>';return $("body").append(e),w2utils._scrollBarSize=100-$("#_scrollbar_width > div").width(),$("#_scrollbar_width").remove(),w2utils._scrollBarSize}var e={settings:{locale:"en-us",date_format:"mm/dd/yyyy",date_display:"Mon dd, yyyy",time_format:"hh:mi pm",currency:"^[$€£¥]?[-]?[0-9]*[.]?[0-9]+$","float":"^[-]?[0-9]*[.]?[0-9]+$",shortmonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],fullmonths:["January","February","March","April","May","June","July","August","September","October","November","December"],shortdays:["M","T","W","T","F","S","S"],fulldays:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],RESTfull:!1,phrases:{}},isInt:t,isFloat:n,isMoney:r,isHex:i,isAlphaNumeric:s,isEmail:o,isDate:u,isTime:a,age:h,date:c,size:p,formatDate:f,format:l,stripTags:d,encodeTags:v,escapeId:m,base64encode:g,base64decode:y,transition:b,lang:E,getSize:w,scrollBarSize:x,locale:S};return e}();$.w2event={on:function(e,t){$.isPlainObject(e)||(e={type:e}),e=$.extend({type:null,execute:"before",target:null,onComplete:null},e);if(typeof e.type=="undefined"){console.log("ERROR: You must specify event type when calling .on() method of "+this.name);return}if(typeof t=="undefined"){console.log("ERROR: You must specify event handler function when calling .on() method of "+this.name);return}this.handlers.push({event:e,handler:t})},off:function(e,t){$.isPlainObject(e)||(e={type:e}),e=$.extend({},{type:null,execute:"before",target:null,onComleted:null},e);if(typeof e.type=="undefined"){console.log("ERROR: You must specify event type when calling .off() method of "+this.name);return}typeof t=="undefined"&&(t=null);var n=[];for(var r in this.handlers){var i=this.handlers[r];(i.event.type!=e.type&&e.type!="*"||i.event.target!=e.target&&e.target!=null||i.handler!=t&&t!=null)&&n.push(i)}this.handlers=n},trigger:function(e){var e=$.extend({type:null,phase:"before",target:null,stop:!1},e,{preventDefault:function(){this.stop=!0}});typeof e.target=="undefined"&&(e.target=null);for(var t=this.handlers.length-1;t>=0;t--){var n=this.handlers[t];if((n.event.type==e.type||n.event.type=="*")&&(n.event.target==e.target||n.event.target==null)&&(n.event.execute==e.phase||n.event.execute=="*"||n.event.phase=="*")){var r=n.handler.call(this,e.target,e);if($.isPlainObject(r)){$.extend(e,r);if(e.stop===!0)return e}}}if(e.phase=="before"&&typeof this["on"+e.type.substr(0,1).toUpperCase()+e.type.substr(1)]=="function"){var r=this["on"+e.type.substr(0,1).toUpperCase()+e.type.substr(1)].call(this,e.target,e);if($.isPlainObject(r)){$.extend(e,r);if(e.stop===!0)return e}}if(typeof e.object!="undefined"&&e.object!=null&&e.phase=="before"&&typeof e.object["on"+e.type.substr(0,1).toUpperCase()+e.type.substr(1)]=="function"){var r=e.object["on"+e.type.substr(0,1).toUpperCase()+e.type.substr(1)].call(this,e.target,e);if($.isPlainObject(r)){$.extend(e,r);if(e.stop===!0)return e}}return e.phase=="after"&&e.onComplete!=null&&e.onComplete.call(this,e),e}},w2utils.keyboard=function(e){function n(){$(document).on("keydown",r),$(document).on("mousedown",i)}function r(e){var n=e.target.tagName;if($.inArray(n,["INPUT","SELECT","TEXTAREA"])!=-1)return;if(!t)return;w2ui[t]&&typeof w2ui[t].keydown=="function"&&w2ui[t].keydown.call(w2ui[t],e)}function i(e){var n=e.target.tagName,r=$(e.target).parents(".w2ui-reset");r.length>0&&(t=r.attr("name"))}function s(){}function o(e){if(typeof e=="undefined")return t;t=e}var t=null;return e.register=s,e.active=o,n(),e}({}),function(){$.fn.w2render=function(e){$(this).length>0&&(typeof e=="string"&&w2ui[e]&&w2ui[e].render($(this)[0]),typeof e=="object"&&e.render($(this)[0]))},$.fn.w2destroy=function(e){!e&&this.length>0&&(e=this.attr("name")),typeof e=="string"&&w2ui[e]&&w2ui[e].destroy(),typeof e=="object"&&e.destroy()},$.fn.w2marker=function(e){return e==""||typeof e=="undefined"?$(this).each(function(e,t){t.innerHTML=t.innerHTML.replace(/\<span class=\"w2ui\-marker\"\>(.*)\<\/span\>/ig,"$1")}):$(this).each(function(t,n){typeof e=="string"&&(e=[e]),n.innerHTML=n.innerHTML.replace(/\<span class=\"w2ui\-marker\"\>(.*)\<\/span\>/ig,"$1");for(var r in e){var i=e[r];i=i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&").replace(/&/g,"&amp;").replace(/</g,"&gt;").replace(/>/g,"&lt;");var s=new RegExp(i+"(?!([^<]+)?>)","gi");n.innerHTML=n.innerHTML.replace(s,function(e){return'<span class="w2ui-marker">'+e+"</span>"})}})},$.fn.w2tag=function(e,t){$.isPlainObject(t)||(t={}),$.isPlainObject(t.css)||(t.css={}),typeof t["class"]=="undefined"&&(t["class"]="");if($(this).length==0){$(".global-tag").each(function(e,t){var n=$(t).data("options");typeof n=="undefined"&&(n={}),$($(t).data("taged-el")).removeClass(n["class"]),clearInterval($(t).data("timer")),$(t).remove()});return}return $(this).each(function(n,r){var i=r.id,s=w2utils.escapeId(r.id);if(e==""||e==null||typeof e=="undefined")$("#global-tag-"+s).css("opacity",0),setTimeout(function(){clearInterval($("#global-tag-"+s).data("timer")),$("#global-tag-"+s).remove()},300);else{clearInterval($("#global-tag-"+s).data("timer")),$("#global-tag-"+s).remove(),$("body").append('<div id="global-tag-'+i+'" class="global-tag" '+'	style="position: absolute; z-index: 1701; opacity: 0; -webkit-transition: opacity .3s; -moz-transition: opacity .3s; -ms-transition: opacity .3s; -o-transition: opacity .3s"></div>');var o=setInterval(function(){if($(r).length==0||$(r).offset().left==0&&$(r).offset().top==0){clearInterval($("#global-tag-"+s).data("timer")),a();return}$("#global-tag-"+s).data("position")!=$(r).offset().left+r.offsetWidth+"x"+$(r).offset().top&&$("#global-tag-"+s).css({"-webkit-transition":".2s","-moz-transition":".2s","-ms-transition":".2s","-o-transition":".2s",left:$(r).offset().left+r.offsetWidth+"px",top:$(r).offset().top+"px"}).data("position",$(r).offset().left+r.offsetWidth+"x"+$(r).offset().top)},100);setTimeout(function(){if(!$(r).offset())return;$("#global-tag-"+s).css({opacity:"1",left:$(r).offset().left+r.offsetWidth+"px",top:$(r).offset().top+"px"}).html('<div style="margin-top: -2px 0px 0px -2px; white-space: nowrap;"> <div class="bubble-tag">'+e+"</div> </div>").data("text",e).data("taged-el",r).data("options",t).data("position",$(r).offset().left+r.offsetWidth+"x"+$(r).offset().top).data("timer",o),$(r).off("keypress",a).on("keypress",a).off("change",a).on("change",a).css(t.css).addClass(t["class"]),typeof t.onShow=="function"&&t.onShow()},1);var u="";$(r).length>0&&(u=$(r)[0].style.cssText);function a(){if($("#global-tag-"+s).length<=0)return;clearInterval($("#global-tag-"+s).data("timer")),$("#global-tag-"+s).remove(),$(r).off("keypress",a).removeClass(t["class"]),$(r).length>0&&($(r)[0].style.cssText=u),typeof t.onHide=="function"&&t.onHide()}}})},$.fn.w2overlay=function(e,t){function o(){typeof t.onHide=="function"&&t.onHide(),$("#w2ui-overlay").remove(),$(document).off("click",o)}var n=!1;$.isPlainObject(t)||(t={}),$.isPlainObject(t.css)||(t.css={});if(this.length==0||e==""||typeof e=="undefined"){typeof t.onHide=="function"&&t.onHide(),$("#w2ui-overlay").remove(),$(document).off("click",o);return}$("#w2ui-overlay").length>0&&(n=!0,$(document).off("click",o),$("#w2ui-overlay").remove()),$("body").append('<div id="w2ui-overlay" class="w2ui-reset w2ui-overlay"><div></div></div>');var r=this,i=$("#w2ui-overlay div");i.css(t.css).html(e),typeof t["class"]!="undefined"&&i.addClass(t["class"]),typeof t.top=="undefined"&&(t.top=0),typeof t.left=="undefined"&&(t.left=0),typeof t.width=="undefined"&&(t.width=100),typeof t.height=="undefined"&&(t.height=0);var s=i.css("background-color"),i=$("#w2ui-overlay");typeof s!="undefined"&&s!="rgba(0, 0, 0, 0)"&&s!="transparent"&&i.css("background-color",s),i.css({display:"none",left:$(r).offset().left+t.left+"px",top:$(r).offset().top+w2utils.getSize($(r),"height")+3+t.top+"px","min-width":t.width?t.width:"auto","min-height":t.height?t.height:"auto"}).fadeIn("fast").data("position",$(r).offset().left+"x"+($(r).offset().top+r.offsetHeight)).on("click",function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}),setTimeout(function(){$(document).on("click",o),typeof t.onShow=="function"&&t.onShow()},1)}}(),function(){var w2grid=function(e){this.name=null,this.box=null,this.header="",this.url="",this.columns=[],this.columnGroups=[],this.records=[],this.summary=[],this.searches=[],this.searchData=[],this.sortData=[],this.postData={},this.toolbar={},this.show={header:!1,toolbar:!1,footer:!1,columnHeaders:!0,lineNumbers:!1,expandColumn:!1,selectColumn:!1,emptyRecords:!0,toolbarReload:!0,toolbarColumns:!0,toolbarSearch:!0,toolbarAdd:!1,toolbarDelete:!1,toolbarSave:!1},this.autoLoad=!0,this.fixedBody=!0,this.recordHeight=25,this.multiSearch=!0,this.multiSelect=!0,this.multiSort=!0,this.total=0,this.buffered=0,this.limit=100,this.offset=0,this.style="",this.msgDelete=w2utils.lang("Are you sure you want to delete selected records?"),this.msgNotJSON=w2utils.lang("Returned data is not in valid JSON format."),this.msgRefresh=w2utils.lang("Refreshing..."),this.onAdd=null,this.onRequest=null,this.onLoad=null,this.onDelete=null,this.onDeleted=null,this.onSave=null,this.onSaved=null,this.onSelect=null,this.onUnselect=null,this.onClick=null,this.onDblClick=null,this.onSort=null,this.onSearch=null,this.onChange=null,this.onExpand=null,this.onCollapse=null,this.onError=null,this.onKeyboard=null,this.onToolbar=null,this.onColumnOnOff=null,this.onRender=null,this.onRefresh=null,this.onReload=null,this.onResize=null,this.onDestroy=null,this.last={field:"all",caption:w2utils.lang("All Fields"),logic:"OR",search:"",searchIds:[],multi:!1,scrollTop:0,scrollLeft:0,selected:[],sortData:null,sortCount:0,xhr:null,range_start:null,range_end:null},this.isIOS=navigator.userAgent.toLowerCase().indexOf("iphone")!=-1||navigator.userAgent.toLowerCase().indexOf("ipod")!=-1||navigator.userAgent.toLowerCase().indexOf("ipad")!=-1?!0:!1,$.extend(!0,this,e,w2obj.grid)};$.fn.w2grid=function(e){if(typeof e=="object"||!e){if(!e||typeof e.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2grid().');return}if(typeof w2ui[e.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+e.name+").");return}if(!w2utils.isAlphaNumeric(e.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var t=e.columns,n=e.columnGroups,r=e.records,i=e.searches,s=e.searchData,o=e.sortData,u=e.postData,a=e.toolbar,f=new w2grid(e);$.extend(f,{postData:{},records:[],columns:[],searches:[],toolbar:{},sortData:[],searchData:[],handlers:[]}),f.onExpand!=null&&(f.show.expandColumn=!0),$.extend(!0,f.toolbar,a);for(var l in t)f.columns[l]=$.extend(!0,{},t[l]);for(var l in n)f.columnGroups[l]=$.extend(!0,{},n[l]);for(var l in i)f.searches[l]=$.extend(!0,{},i[l]);for(var l in s)f.searchData[l]=$.extend(!0,{},s[l]);for(var l in o)f.sortData[l]=$.extend(!0,{},o[l]);f.postData=$.extend(!0,{},u);for(var c in r){if(r[c].recid==null||typeof r[c].recid=="undefined"){console.log("ERROR: Cannot add records without recid. (obj: "+f.name+")");return}f.records[c]=$.extend(!0,{},r[c])}f.records.length>0&&(f.buffered=f.records.length);for(var h in f.columns){var p=f.columns[h];if(typeof p.searchable=="undefined"||f.getSearch(p.field)!=null)continue;var d=p.searchable,v="";p.searchable===!0&&(d="text",v='size="20"'),f.addSearch({field:p.field,caption:p.caption,type:d,attr:v})}return f.initToolbar(),$(this).length!=0&&f.render($(this)[0]),w2ui[f.name]=f,f}if(w2ui[$(this).attr("name")]){var m=w2ui[$(this).attr("name")];return m[e].apply(m,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+e+" does not exist on jQuery.w2grid")},w2grid.prototype={add:function(e){$.isArray(e)||(e=[e]);var t=0;for(var n in e){if(e[n].recid==null||typeof e[n].recid=="undefined"){console.log("ERROR: Cannot add record without recid. (obj: "+this.name+")");continue}this.records.push(e[n]),t++}return this.buffered=this.records.length,this.url==""&&(this.localSort(),this.localSearch()),this.refresh(),t},find:function(e,t){if(typeof e=="undefined"||e==null)e={};var n=[];for(var r=0;r<this.records.length;r++){var i=!0;for(var s in e){var o=this.records[r][s];String(s).indexOf(".")!=-1&&(o=this.parseObj(this.records[r],s)),e[s]!=o&&(i=!1)}i&&t!==!0&&n.push(this.records[r].recid),i&&t===!0&&n.push(this.records[r])}return n},set:function(e,t,n){typeof e=="object"&&(n=t,t=e,e=null);if(e==null){for(var r in this.records)$.extend(!0,this.records[r],t);return n!==!0&&this.refresh(),!0}var i=this.get(e,!0);if(i==null)return!1;$.extend(!0,this.records[i],t);if(n!==!0){var s=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(e));if(s.length!=0){var o=s.attr("line");if(this.searchData.length>0&&this.url=="")for(var u in this.last.searchIds)this.last.searchIds[u]==i&&(i=u);$(s).replaceWith(this.getRecordHTML(i,o))}}return!0},get:function(e,t){for(var n=0;n<this.records.length;n++)if(this.records[n].recid==e)return t===!0?n:this.records[n];return null},remove:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.records.length-1;n>=0;n--)this.records[n].recid==arguments[t]&&(this.records.splice(n,1),e++);return this.url==""&&(this.buffered=this.records.length,this.localSort(),this.localSearch()),this.refresh(),e},addColumn:function(e,t){arguments.length==1?(t=e,e=this.columns.length):(e=this.getColumn(e,!0),e===null&&(e=this.columns.length)),$.isArray(t)||(t=[t]);for(var n in t)this.columns.splice(e,0,t[n]),e++;this.initColumnOnOff(),this.refresh()},removeColumn:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.columns.length-1;n>=0;n--)this.columns[n].field==arguments[t]&&(this.columns.splice(n,1),e++);return this.initColumnOnOff(),this.refresh(),e},getColumn:function(e,t){for(var n=0;n<this.columns.length;n++)if(this.columns[n].field==e)return t===!0?n:this.columns[n];return null},showColumn:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.columns.length-1;n>=0;n--)this.columns[n].field==arguments[t]&&this.columns[n].hidden!==!1&&(this.columns[n].hidden=!1,e++);return this.refresh(),e},hideColumn:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.columns.length-1;n>=0;n--)this.columns[n].field==arguments[t]&&this.columns[n].hidden!==!0&&(this.columns[n].hidden=!0,e++);return this.refresh(),e},addSearch:function(e,t){arguments.length==1?(t=e,e=this.searches.length):(e=this.getSearch(e,!0),e===null&&(e=this.searches.length)),$.isArray(t)||(t=[t]);for(var n in t)this.searches.splice(e,0,t[n]),e++;this.searchClose()},removeSearch:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.searches.length-1;n>=0;n--)this.searches[n].field==arguments[t]&&(this.searches.splice(n,1),e++);return this.searchClose(),e},getSearch:function(e,t){for(var n=0;n<this.searches.length;n++)if(this.searches[n].field==e)return t===!0?n:this.searches[n];return null},showSearch:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.searches.length-1;n>=0;n--)this.searches[n].field==arguments[t]&&this.searches[n].hidden!==!1&&(this.searches[n].hidden=!1,e++);return this.searchClose(),e},hideSearch:function(){var e=0;for(var t=0;t<arguments.length;t++)for(var n=this.searches.length-1;n>=0;n--)this.searches[n].field==arguments[t]&&this.searches[n].hidden!==!0&&(this.searches[n].hidden=!0,e++);return this.searchClose(),e},getSearchData:function(e){for(var t in this.searchData)if(this.searchData[t].field==e)return this.searchData[t];return null},clear:function(){this.records=[],this.buffered=0,this.refresh()},localSort:function(e){if(this.url!=""){console.log("ERROR: grid.localSort can only be used on local data source, grid.url should be empty.");return}var t=(new Date).getTime(),n=this;return this.records.sort(function(e,t){var r=0;for(var i in n.sortData){var s=e[n.sortData[i].field],o=t[n.sortData[i].field];String(n.sortData[i].field).indexOf(".")!=-1&&(s=n.parseObj(e,n.sortData[i].field),o=n.parseObj(t,n.sortData[i].field)),typeof s=="string"&&(s=$.trim(s.toLowerCase())),typeof o=="string"&&(o=$.trim(o.toLowerCase())),s>o&&(r=n.sortData[i].direction=="asc"?1:-1),s<o&&(r=n.sortData[i].direction=="asc"?-1:1),typeof s!="object"&&typeof o=="object"&&(r=-1),typeof o!="object"&&typeof s=="object"&&(r=1);if(r!=0)break}return r}),t=(new Date).getTime()-t,e!==!0&&setTimeout(function(){$("#grid_"+n.name+"_footer").find(".w2ui-footer-left").html("Sorting took "+t/1e3+" sec")},10),t},localSearch:function(e){if(this.url!=""){console.log("ERROR: grid.localSearch can only be used on local data source, grid.url should be empty.");return}var t=(new Date).getTime(),n=this;this.total=this.records.length,this.last.searchIds=[];if(this.searchData.length>0&&this.url==""){this.total=0;for(var r in this.records){var i=this.records[r],s=0;for(var o in this.searchData){var u=this.searchData[o],a=this.getSearch(u.field);if(u==null)continue;var f=String(n.parseObj(i,a.field)).toLowerCase();if(typeof u.value!="undefined")if(!$.isArray(u.value))var l=String(u.value).toLowerCase();else var l=u.value[0],c=u.value[1];switch(u.operator){case"is":i[a.field]==u.value&&s++,(a.type=="text"||a.type=="list")&&f==l&&s++;if(a.type=="date"){var h=new Date(f),p=new Date(l);d0=Date.UTC(h.getFullYear(),h.getMonth(),h.getDate()),d1=Date.UTC(p.getFullYear(),p.getMonth(),p.getDate()),d0==d1&&s++}break;case"between":a.type=="int"&&parseInt(i[a.field])>=parseInt(l)&&parseInt(i[a.field])<=parseInt(c)&&s++,a.type=="float"&&parseFloat(i[a.field])>=parseFloat(l)&&parseFloat(i[a.field])<=parseFloat(c)&&s++;if(a.type=="date"){var h=new Date(f),p=new Date(l),d=new Date(c);d0=Date.UTC(h.getFullYear(),h.getMonth(),h.getDate()),d1=Date.UTC(p.getFullYear(),p.getMonth(),p.getDate()),d2=Date.UTC(d.getFullYear(),d.getMonth(),d.getDate()),d0>=d1&&d0<=d2&&s++}break;case"begins with":f.indexOf(l)==0&&s++;break;case"contains":f.indexOf(l)>=0&&s++;break;case"ends with":f.indexOf(l)==f.length-l.length&&s++}}(this.last.logic=="OR"&&s!=0||this.last.logic=="AND"&&s==this.searchData.length)&&this.last.searchIds.push(parseInt(r))}this.total=this.last.searchIds.length}return this.buffered=this.total,t=(new Date).getTime()-t,e!==!0&&setTimeout(function(){$("#grid_"+n.name+"_footer").find(".w2ui-footer-left").html("Search took "+t/1e3+" sec")},10),t},select:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(r==null||r.selected===!0)continue;var i=this.trigger({phase:"before",type:"select",target:this.name,recid:r.recid});if(i.stop===!0)continue;var s=this.get(r.recid,!0);r.selected=!0,$("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid)).addClass("w2ui-selected").data("selected","yes"),$("#grid_"+this.name+"_cell_"+s+"_select_check").prop("checked",!0),t++,this.trigger($.extend(i,{phase:"after"}))}$("#grid_"+this.name+"_check_all").prop
("checked",!0),$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length!=0&&$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length==$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]:checked").length?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1);var o="",u=this.getSelection();return u.length>0&&(o=String(u.length).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")+" selected",u.length==1&&(o="Record ID: "+u[0]+" ")),$("#grid_"+this.name+"_footer .w2ui-footer-left").html(o),t},unselect:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(r==null||r.selected!==!0)continue;var i=this.trigger({phase:"before",type:"unselect",target:this.name,recid:r.recid});if(i.stop===!0)continue;var s=this.get(r.recid,!0);r.selected=!1,$("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid)).removeClass("w2ui-selected").removeData("selected"),$("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid)).length!=0&&($("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid))[0].style.cssText="height: "+this.recordHeight+"px; "+$("#grid_"+this.name+"_rec_"+w2utils.escapeId(r.recid)).attr("custom_style")),$("#grid_"+this.name+"_cell_"+s+"_select_check").prop("checked",!1),t++,this.trigger($.extend(i,{phase:"after"}))}$("#grid_"+this.name+"_check_all").prop("checked",!0),$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length!=0&&$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length==$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]:checked").length?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1);var o="",u=this.getSelection();return u.length>0&&(o=String(u.length).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")+" selected",u.length==1&&(o="Record ID: "+u[0]+" ")),$("#"+this.name+"_grid_footer .w2ui-footer-left").html(o),t},selectAll:function(){if(this.multiSelect===!1)return;var e=this.trigger({phase:"before",type:"select",target:this.name,all:!0});if(e.stop===!0)return;if(this.searchData.length==0&&this.url=="")this.set({selected:!0});else{for(var t=0;t<this.last.searchIds.length;t++)this.records[this.last.searchIds[t]].selected=!0;this.refresh()}this.getSelection().length>0?this.toolbar.enable("delete"):this.toolbar.disable("delete"),this.trigger($.extend(e,{phase:"after"}))},selectNone:function(){var e=this.trigger({phase:"before",type:"unselect",target:this.name,all:!0});if(e.stop===!0)return;this.last.selected=[];for(var t in this.records){var n=this.records[t];n.selected===!0&&(n.selected=!1,$("#grid_"+this.name+"_rec_"+w2utils.escapeId(n.recid)).removeClass("w2ui-selected").removeData("selected"),$("#grid_"+this.name+"_cell_"+t+"_select_check").prop("checked",!1))}this.trigger($.extend(e,{phase:"after"}))},getSelection:function(){return this.find({selected:!0})},search:function(e,t){var n=this,r=[],i=this.last.multi,s=this.last.logic,o=this.last.field,u=this.last.search;if(arguments.length==0){for(var a in this.searches){var f=this.searches[a],l=$("#grid_"+this.name+"_operator_"+a).val(),c=$("#grid_"+this.name+"_field_"+a).val(),h=$("#grid_"+this.name+"_field2_"+a).val();if(c!=""&&c!=null||typeof h!="undefined"&&h!=""){var p={field:f.field,type:f.type,operator:l};l=="between"?$.extend(p,{value:[c,h]}):$.extend(p,{value:c}),r.push(p)}}r.length>0&&this.url==""&&(i=!0,s="AND")}if($.isArray(e)){var d="AND";typeof t=="string"&&(d=t.toUpperCase(),d!="OR"&&d!="AND"&&(d="AND")),u="",i=!0,s=d;for(var v in e){var m=e[v],f=this.getSearch(m.field);if(f==null){console.log('ERROR: Cannot find field "'+m.field+'" when submitting a search.');continue}var p=$.extend(!0,{},m);typeof p.type=="undefined"&&(p.type=f.type),typeof p.operator=="undefined"&&(p.operator="is",p.type=="text"&&(p.operator="contains")),r.push(p)}}if(typeof e=="string"&&typeof t=="string"){o=e,u=t,i=!1,s="OR";if(t!="")for(var a in this.searches){var f=this.searches[a];f.field==e&&(this.last.caption=f.caption);if(e!="all"&&f.field==e){var p={field:f.field,type:f.type,operator:f.type=="text"?"contains":"is",value:t};r.push(p)}if(e=="all"){if(f.type=="text"||f.type=="int"&&w2utils.isInt(t)||f.type=="float"&&w2utils.isFloat(t)||f.type=="money"&&w2utils.isMoney(t)||f.type=="hex"&&w2utils.isHex(t)||f.type=="date"&&w2utils.isDate(t)||f.type=="alphaNumeric"&&w2utils.isAlphaNumeric(t)){var p={field:f.field,type:f.type,operator:f.type=="text"?"contains":"is",value:t};r.push(p)}if(f.type=="int"&&String(t).indexOf("-")!=-1){var g=String(t).split("-"),p={field:f.field,type:f.type,operator:"between",value:[g[0],g[1]]};r.push(p)}}}}var y=this.trigger({phase:"before",type:"search",target:this.name,searchData:r,searchField:e?e:"multi",searchValue:t?t:"multi"});if(y.stop===!0)return;this.searchData=y.searchData,this.last.field=o,this.last.search=u,this.last.multi=i,this.last.logic=s,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selected=[],this.searchClose(),this.set({expanded:!1}),this.url!=""?(this.last.xhr_offset=0,this.reload()):(this.localSearch(),this.refresh()),this.trigger($.extend(y,{phase:"after"}))},searchOpen:function(){if(!this.box)return;if(this.searches.length==0)return;var e=this;$("#tb_"+this.name+"_toolbar_item_search-advanced").w2overlay(this.getSearchesHTML(),{left:-10,"class":"w2ui-grid-searches",onShow:function(){e.last.logic=="OR"&&(e.searchData=[]),e.initSearches(),$("#w2ui-overlay .w2ui-grid-searches").data("grid-name",e.name);var t=$("#w2ui-overlay .w2ui-grid-searches *[rel=search]");t.length>0&&t[0].focus()}})},searchClose:function(){if(!this.box)return;if(this.searches.length==0)return;this.toolbar&&this.toolbar.uncheck("search-advanced"),$("#w2ui-overlay .w2ui-grid-searches").length>0&&$().w2overlay()},searchShowFields:function(e){typeof e=="undefined"&&(e=$("#grid_"+this.name+"_search_all"));var t='<div class="w2ui-select-field"><table>';for(var n=-1;n<this.searches.length;n++){var r=this.searches[n];if(n==-1){if(!this.multiSearch)continue;r={type:"text",field:"all",caption:"All Fields"}}else if(this.searches[n].hidden===!0)continue;t+="<tr 	"+(this.isIOS?"onTouchStart":"onClick")+"=\"var obj = w2ui['"+this.name+"']; "+"		if ('"+r.type+"' == 'list' || '"+r.type+"' == 'enum') {"+"			obj.last.search = '';"+"			obj.last.item = '';"+"			$('#grid_"+this.name+"_search_all').val('')"+"		}"+"		if (obj.last.search != '') { "+"			obj.search('"+r.field+"', obj.last.search); "+"		} else { "+"			obj.last.field = '"+r.field+"'; "+"			obj.last.caption = '"+r.caption+"'; "+"		}"+"		$('#grid_"+this.name+"_search_all').attr('placeholder', '"+r.caption+"');"+'		$().w2overlay();">'+'<td><input type="checkbox" tabIndex="-1" '+(r.field==this.last.field?"checked":"disabled")+"></td>"+"<td>"+r.caption+"</td>"+"</tr>"}t+="</table></div>",$(e).w2overlay(t,{left:-15,top:7})},searchReset:function(){var e=this.trigger({phase:"before",type:"search",target:this.name,searchData:[]});if(e.stop===!0)return;this.searchData=[],this.last.search="",this.last.logic="OR",this.last.multi&&(this.multiSearch?(this.last.field="all",this.last.caption=w2utils.lang("All Fields")):(this.last.field=this.searches[0].field,this.last.caption=this.searches[0].caption)),this.last.multi=!1,this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selected=[],this.searchClose(),this.url!=""?(this.last.xhr_offset=0,this.reload()):(this.localSearch(),this.refresh()),this.trigger($.extend(e,{phase:"after"}))},skip:function(e){if(this.url!=""){this.offset=parseInt(e);if(this.offset<0||!w2utils.isInt(this.offset))this.offset=0;this.offset>this.total&&(this.offset=this.total-this.limit),this.records=[],this.buffered=0,this.last.xhr_offset=0,this.last.pull_more=!0,this.last.scrollTop=0,this.last.scrollLeft=0,$("#grid_"+this.name+"_records").prop("scrollTop",0),this.initColumnOnOff(),this.reload()}else console.log("ERROR: grid.skip() can only be called when you have remote data source.")},load:function(e,t){if(typeof e=="undefined"){console.log('ERROR: You need to provide url argument when calling .load() method of "'+this.name+'" object.');return}this.request("get-records",{},e,t)},reload:function(e){this.url!=""?this.request("get-records",{},null,e):(this.refresh(),typeof e=="function"&&e())},reset:function(e){this.offset=0,this.searchData=[],this.last.search="",this.last.searchIds=[],this.last.field="all",this.last.caption=w2utils.lang("All Fields"),this.last.logic="OR",this.last.scrollTop=0,this.last.scrollLeft=0,this.last.selected=[],this.last.range_start=null,this.last.range_end=null,this.last.xhr_offset=0,this.last.sortData!=null&&(this.sortData=this.last.sortData),this.set({selected:!1,expanded:!1},!0),e||this.refresh()},request:function(e,t,n,r){typeof t=="undefined"&&(t={});if(typeof n=="undefined"||n==""||n==null)n=this.url;if(n==""||n==null)return;var i={};w2utils.isInt(this.offset)||(this.offset=0),w2utils.isInt(this.last.xhr_offset)||(this.last.xhr_offset=0),i.cmd=e,i.name=this.name,i.limit=this.limit,i.offset=parseInt(this.offset)+this.last.xhr_offset,i.selected=this.getSelection(),i.search=this.searchData,i["search-logic"]=this.last.logic,i.sort=this.sortData.length!=0?this.sortData:"",$.extend(i,this.postData),$.extend(i,t);if(e=="get-records"){var s=this.trigger({phase:"before",type:"request",target:this.name,url:n,postData:i});if(s.stop===!0)return typeof r=="function"&&r(),!1}else var s={url:this.url,postData:this.postData};var o=this;this.lock(this.msgRefresh,!0);if(this.last.xhr)try{this.last.xhr.abort()}catch(u){}var a="GET";i.cmd=="save-records"&&(a="PUT"),i.cmd=="delete-records"&&(a="DELETE"),w2utils.settings.RESTfull||(a="POST"),this.last.xhr_cmd=i.cmd,this.last.xhr_start=(new Date).getTime(),this.last.xhr=$.ajax({type:a,url:s.url,data:String($.param(s.postData,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]"),dataType:"text",complete:function(t,n){o.requestComplete(n,e,r)}}),e=="get-records"&&this.trigger($.extend(s,{phase:"after"}))},requestComplete:function(status,cmd,callBack){var obj=this;this.unlock(),setTimeout(function(){$("#grid_"+obj.name+"_footer").find(".w2ui-footer-left").html("Server Response "+((new Date).getTime()-obj.last.xhr_start)/1e3+" sec")},10),this.last.pull_more=!1,this.last.pull_refresh=!0;var event_name="load";this.last.xhr_cmd=="save-records"&&(event_name="saved"),this.last.xhr_cmd=="delete-records"&&(event_name="deleted");var eventData=this.trigger({phase:"before",target:this.name,type:event_name,xhr:this.last.xhr,status:status});if(eventData.stop===!0)return typeof callBack=="function"&&callBack(),!1;var responseText=this.last.xhr.responseText;if(status!="error"){if(typeof responseText!="undefined"&&responseText!=""){var data;if(typeof responseText=="object")data=responseText;else try{eval("data = "+responseText)}catch(e){}typeof data=="undefined"&&(data={status:"error",message:this.msgNotJSON,responseText:responseText});if(data["status"]=="error")obj.error(data.message);else{if(cmd=="get-records")if(this.last.xhr_offset==0)this.records=[],$.extend(!0,this,data),this.buffered=this.records.length;else{var records=data.records;delete data.records,$.extend(!0,this,data);for(var r in records)this.records.push(records[r]);this.buffered=this.records.length}if(cmd=="delete-records"){this.reload();return}}}}else obj.error("AJAX Error. See console for more details.");this.url==""&&(this.localSort(),this.localSearch()),this.total=parseInt(this.total),this.trigger($.extend(eventData,{phase:"after"})),this.last.xhr_offset==0?this.refresh():this.doScroll(),typeof callBack=="function"&&callBack()},error:function(e){var t=this,n=this.trigger({target:this.name,type:"error",message:e,xhr:this.last.xhr});if(n.stop===!0)return typeof callBack=="function"&&callBack(),!1;setTimeout(function(){$("#w2ui-popup").length>0?$().w2popup("message",{width:370,height:140,html:'<div class="w2ui-grid-error-msg" style="font-size: 11px;">ERROR: '+e+"</div>"+'<div style="position: absolute; bottom: 7px; left: 0px; right: 0px; text-align: center;">'+'	<input type="button" value="Ok" onclick="$().w2popup(\'message\');" class="w2ui-grid-popup-btn">'+"</div>"}):$().w2popup("open",{width:420,height:200,showMax:!1,title:"Error",body:'<div class="w2ui-grid-error-msg">'+e+"</div>",buttons:'<input type="button" value="Ok" onclick="$().w2popup(\'close\');" class="w2ui-grid-popup-btn">'})},1),this.trigger($.extend(n,{phase:"after"}))},getChanged:function(){var e=[],t=this.find({changed:!0},!0);for(var n in t)e.push($.extend(!0,{recid:t[n].recid},t[n].changes));return e},doAdd:function(){var e=this.trigger({phase:"before",target:this.name,type:"add",recid:null});if(e.stop===!0)return!1;this.trigger($.extend(e,{phase:"after"}))},doSave:function(){var obj=this,changed=this.getChanged(),eventData=this.trigger({phase:"before",target:this.name,type:"save",changed:changed});if(eventData.stop===!0)return!1;if(this.url!="")this.request("save-records",{changed:eventData.changed},null,function(){obj.trigger($.extend(eventData,{phase:"after"}))});else{for(var c in changed){var record=this.get(changed[c].recid);for(var s in changed[c]){if(s=="recid")continue;try{eval("record."+s+" = changed[c][s]")}catch(e){}delete record.changed,delete record.changes}}$(this.box).find(".w2ui-editable input").removeClass("changed"),this.selectNone(),this.trigger($.extend(eventData,{phase:"after"}))}},doEdit:function(type,el,event){var recid=$(el).attr("recid"),field=$(el).attr("field"),record=this.get(recid);record.selected||(this.selectNone(),this.select(recid));switch(type){case"click":event.stopPropagation?event.stopPropagation():event.cancelBubble=!0,event.preventDefault&&event.preventDefault();break;case"focus":$(el).addClass("active");break;case"blur":$(el).removeClass("active");var original=record[field];try{original=eval("record."+field)}catch(e){}typeof original=="undefined"&&(original="");if($(el).val()!=original){var eventData=this.trigger({phase:"before",type:"change",target:el.id,recid:recid,field:field,original:original});if(eventData.stop===!0)return!1;record.changed=!0,record.changes=record.changes||{},record.changes[field]=$(el).val(),$(el).addClass("changed"),this.trigger($.extend(eventData,{phase:"after"}))}else record.changes&&delete record.changes[field],$.isEmptyObject(record.changes)&&delete record.changed,$(el).removeClass("changed");break;case"keyup":if($(el).data("stop")===!0){$(el).data("stop",!1);break}if(event.keyCode==40||event.keyCode==13){var newEl=$("#grid_"+this.name+"_edit_"+(parseInt($(el).attr("line"))+1)+"_"+$(el).attr("column"));newEl.length>0&&(newEl[0].select(),newEl[0].focus())}if(event.keyCode==38){var newEl=$("#grid_"+this.name+"_edit_"+(parseInt($(el).attr("line"))-1)+"_"+$(el).attr("column"));newEl.length>0&&(newEl[0].select(),newEl[0].focus())}}},doDelete:function(e){var t=this.trigger({phase:"before",target:this.name,type:"delete"});if(t.stop===!0)return!1;var n=this.getSelection();if(n.length==0)return;if(this.msgDelete!=""&&!e){$().w2popup({width:400,height:180,showMax:!1,title:w2utils.lang("Delete Confirmation"),body:'<div class="w2ui-grid-delete-msg">'+this.msgDelete+"</div>",buttons:'<input type="button" value="'+w2utils.lang("No")+'" onclick="$().w2popup(\'close\');" class="w2ui-grid-popup-btn">'+'<input type="button" value="'+w2utils.lang("Yes")+'" onclick="w2ui[\''+this.name+"'].doDelete(true); $().w2popup('close');\" class=\"w2ui-grid-popup-btn\">"});return}this.url!=""?this.request("delete-records"):this.remove.apply(this,n),this.trigger($.extend(t,{phase:"after"}))},doClick:function(e,t){var n=(new Date).getTime();w2utils.isInt(e)&&(e=parseInt(e)),typeof t=="undefined"&&(t={});var r=this.trigger({phase:"before",target:this.name,type:"click",recid:e,event:t});if(r.stop===!0)return!1;var i=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(e)).parents("tr");if(i.length>0&&String(i.attr("id")).indexOf("expanded_row")!=-1){var s=i.parents(".w2ui-grid").attr("name");w2ui[s].selectNone(),i.parents(".w2ui-grid").find(".w2ui-expanded-row .w2ui-grid").each(function(e,t){var n=$(t).attr("name");w2ui[n]&&w2ui[n].selectNone()})}$(this.box).find(".w2ui-expanded-row .w2ui-grid").each(function(e,t){var n=$(t).attr("name");w2ui[n]&&w2ui[n].selectNone()});var o=this,u=this.getSelection();$("#grid_"+this.name+"_check_all").prop("checked",!1);var a=this.get(e);if(t.shiftKey&&u.length>0){var f=this.get(u[0],!0),l=this.get(e,!0),c=[];if(f<=l)for(var h=f+1;h<=l;h++){if(this.searchData.length>0&&this.url==""&&$.inArray(h,this.last.searchIds)==-1)continue;c.push(this.records[h].recid),u.push(this.records[h].recid)}else for(var h=f-1;h>=l;h--){if(this.searchData.length>0&&this.url==""&&$.inArray(h,this.last.searchIds)==-1)continue;c.push(this.records[h].recid),u.push(this.records[h].recid)}this.select.apply(this,c)}else if((!t.ctrlKey&&!t.shiftKey&&!t.metaKey||!this.multiSelect)&&!this.showSelectColumn){var p=a.selected;u.length>300?this.selectNone():this.unselect.apply(this,u),p===!0?(this.unselect(e),u=[]):(this.select(e),u=[e])}else a.selected===!0?(this.unselect(a.recid),u.splice($.inArray(a.recid,u),1)):(this.select(a.recid),u.push(a.recid)),setTimeout(function(){window.getSelection&&window.getSelection().removeAllRanges()},10);u.length>0?o.toolbar.enable("delete"):o.toolbar.disable("delete");var d="";u.length>0&&(d=String(u.length).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")+" selected",u.length==1&&(d="Record ID: "+u[0]+" ")),$("#"+o.name+"_grid_footer .w2ui-footer-left").html(d),o.last.selected=u,o.initResize(),this.trigger($.extend(r,{phase:"after"}))},keydown:function(e){var t=this,n=t.trigger({phase:"before",type:"keyboard",target:t.name,event:e});if(n.stop===!0)return!1;var r=t.getSelection();if(r.length==0)return;var i=$("#grid_"+t.name+"_records"),s=r[0],o=t.get(s,!0),u=t.get(s),a=$("#grid_"+t.name+"_rec_"+w2utils.escapeId(t.records[o].recid)),f=!1;switch(e.keyCode){case 32:f=!0;break;case 8:t.doDelete(),f=!0;break;case 27:t.selectNone(),f=!0;break;case 65:if(!e.metaKey&&!e.ctrlKey)break;t.selectAll(),f=!0;break;case 70:if(!e.metaKey&&!e.ctrlKey)break;$("#grid_"+t.name+"_search_all").focus(),f=!0;break;case 13:if(a.length<=0||t.show.expandColumn!==!0)break;t.toggle(r[0],e),f=!0;break;case 37:var l=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(t.records[o].recid)).parents("tr");if(l.length>0&&String(l.attr("id")).indexOf("expanded_row")!=-1){var s=l.prev().attr("recid"),c=l.parents(".w2ui-grid").attr("name");t.selectNone(),w2utils.keyboard.active(c),w2ui[c].set(s,{expanded:!1}),w2ui[c].collapse(s),w2ui[c].doClick(s),f=!0;break}if(a.length<=0||u.expanded!==!0)break;t.set(r[0],{expanded:!1},!0),t.collapse(r[0],e),f=!0;break;case 39:if(a.length<=0||u.expanded===!0||t.show.expandColumn!==!0)break;t.expand(r[0],e),f=!0;break;case 38:if(a.length<=0)break;if(o>0&&t.last.searchIds.length==0||t.last.searchIds.length>0&&o>t.last.searchIds[0]){o--;if(t.last.searchIds.length>0)for(;;){if($.inArray(o,t.last.searchIds)!=-1||o<0)break;o--}if(t.records[o].expanded){var h=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(t.records[o].recid)+"_expanded_row").find(".w2ui-grid");if(h.length>0&&w2ui[h.attr("name")]){t.selectNone();var c=h.attr("name"),p=w2ui[c].records;w2utils.keyboard.active(c),w2ui[c].doClick(p[p.length-1].recid),f=!0;break}}t.selectNone(),t.doClick(t.records[o].recid,e),t.scrollIntoView(o),e.preventDefault&&e.preventDefault()}else{var l=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(t.records[o].recid)).parents("tr");if(l.length>0&&String(l.attr("id")).indexOf("expanded_row")!=-1){var s=l.prev().attr("recid"),c=l.parents(".w2ui-grid").attr("name");t.selectNone(),w2utils.keyboard.active(c),w2ui[c].doClick(s),f=!0;break}}break;case 40:if(a.length<=0)break;if(t.records[o].expanded){var h=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(t.records[o].recid)+"_expanded_row").find(".w2ui-grid");if(h.length>0&&w2ui[h.attr("name")]){t.selectNone();var c=h.attr("name"),p=w2ui[c].records;w2utils.keyboard.active(c),w2ui[c].doClick(p[0].recid),f=!0;break}}if(o+1<t.records.length&&t.last.searchIds.length==0||t.last.searchIds.length>0&&o<t.last.searchIds[t.last.searchIds.length-1]){o++;if(t.last.searchIds.length>0)for(;;){if($.inArray(o,t.last.searchIds)!=-1||o>t.records.length)break;o++}t.selectNone(),t.doClick(t.records[o].recid,e),t.scrollIntoView(o),f=!0}else{var l=$("#grid_"+this.name+"_rec_"+w2utils.escapeId(t.records[o].recid)).parents("tr");if(l.length>0&&String(l.attr("id")).indexOf("expanded_row")!=-1){var s=l.next().attr("recid"),c=l.parents(".w2ui-grid").attr("name");t.selectNone(),w2utils.keyboard.active(c),w2ui[c].doClick(s),f=!0;break}}}f&&e.preventDefault&&e.preventDefault(),t.trigger($.extend(n,{phase:"after"}))},scrollIntoView:function(e){if(typeof e=="undefined"){var t=this.getSelection();if(t.length==0)return;e=this.get(t[0],!0)}var n=$("#grid_"+this.name+"_records");if(n.length==0)return;var r=Math.floor(n[0].scrollTop/this.recordHeight),i=r+Math.floor(n.height()/this.recordHeight);e==r&&n.animate({scrollTop:n.scrollTop()-n.height()/1.3}),e==i&&n.animate({scrollTop:n.scrollTop()+n.height()/1.3}),(e<r||e>i)&&n.animate({scrollTop:(e-1)*this.recordHeight})},doDblClick:function(e,t){window.getSelection&&window.getSelection().removeAllRanges();var n=this.trigger({phase:"before",target:this.name,type:"dblClick",recid:e,event:t});if(n.stop===!0)return!1;var r=this.get(e);clearTimeout(this._click_timer),this.selectNone(),this.select(e),this.last.selected=this.getSelection(),this.trigger($.extend(n,{phase:"after"}))},toggle:function(e){var t=this.get(e);return t.expanded===!0?this.collapse(e):this.expand(e)},expand:function(e){function u(){var t=$("#grid_"+n.name+"_rec_"+r+"_expanded"),i=$("#grid_"+n.name+"_rec_"+r+"_expanded_row .w2ui-expanded1 > div");if(t.height()<5)return;t.css("opacity",1),i.show().css("opacity",1),$("#grid_"+n.name+"_cell_"+n.get(e,!0)+"_expand div").html("-")}var t=this.get(e),n=this,r=w2utils.escapeId(e);if($("#grid_"+this.name+"_rec_"+r+"_expanded_row").length>0)return!1;var i=1+(this.show.selectColumn?1:0),s="";$("#grid_"+this.name+"_rec_"+r).after('<tr id="grid_'+this.name+"_rec_"+r+'_expanded_row" class="w2ui-expanded-row '+s+'">'+(this.show.lineNumbers?'<td class="w2ui-col-number"></td>':"")+'	<td class="w2ui-grid-data w2ui-expanded1" colspan="'+i+'"><div style="display: none"></div></td>'+'	<td colspan="100" class="w2ui-expanded2">'+'		<div id="grid_'+this.name+"_rec_"+r+'_expanded" style="opacity: 0;"></div>'+"	</td>"+"</tr>");var o=this.trigger({phase:"before",type:"expand",target:this.name,recid:e,box_id:"grid_"+this.name+"_rec_"+r+"_expanded",ready:u});return o.stop===!0?($("#grid_"+this.name+"_rec_"+r+"_expanded_row").remove(),!1):($("#grid_"+this.name+"_rec_"+r).attr("expanded","yes").addClass("w2ui-expanded"),$("#grid_"+this.name+"_rec_"+r+"_expanded_row").show(),$("#grid_"+this.name+"_cell_"+this.get(e,!0)+"_expand div").html('<div class="w2ui-spinner" style="width: 16px; margin: -2px 2px;"></div>'),t.expanded=!0,setTimeout(u,300),this.trigger($.extend(o,{phase:"after"})),this.resizeRecords(),!0)},collapse:function(e){var t=this.get(e),n=this,r=w2utils.escapeId(e);if($("#grid_"+this.name+"_rec_"+r+"_expanded_row").length==0)return!1;var i=this.trigger({phase:"before",type:"collapse",target:this.name,recid:e,box_id:"grid_"+this.name+"_rec_"+r+"_expanded"});return i.stop===!0?!1:($("#grid_"+this.name+"_rec_"+r).removeAttr("expanded").removeClass("w2ui-expanded"),$("#grid_"+this.name+"_rec_"+r+"_expanded").css("opacity",0),$("#grid_"+this.name+"_cell_"+this.get(e,!0)+"_expand div").html("+"),setTimeout(function(){$("#grid_"+n.name+"_rec_"+r+"_expanded").height("0px"),setTimeout(function(){$("#grid_"+n.name+"_rec_"+r+"_expanded_row").remove(),delete t.expanded,n.trigger($.extend(i,{phase:"after"})),n.resizeRecords()},300)},200),!0)},doSort:function(e,t,n){var r=this.trigger({phase:"before",type:"sort",target:this.name,field:e,direction:t,event:n});if(r.stop===!0)return!1;if(typeof e=="undefined"){this.trigger($.extend(r,{phase:"after"}));return}var i=this.sortData.length;for(var s in this.sortData)if(this.sortData[s].field==e){i=s;break}if(typeof t=="undefined"||t==null)if(typeof this.sortData[i]=="undefined")t="asc";else switch(String(this.sortData[i].direction)){case"asc":t="desc";break;case"desc":t="asc";break;default:t="asc"}this.multiSort===!1&&(this.sortData=[],i=0),!n.ctrlKey&&!n.metaKey&&(this.sortData=[],i=0),typeof this.sortData[i]=="undefined"&&(this.sortData[i]={}),this.sortData[i].field=e,this.sortData[i].direction=t,this.url==""?(this.localSort(),this.searchData.length>0&&this.localSearch(!0),this.trigger($.extend(r,{phase:"after"})),this.refresh()):(this.trigger($.extend(r,{phase:"after"})),this.last.xhr_offset=0,this.reload())},resize:function(){var e=this,t=(new Date).getTime();window.getSelection&&window.getSelection().removeAllRanges();if(!this.box||$(this.box).attr("name")!=this.name)return;$(this.box).find("> div").css("width",$(this.box).width()).css("height",$(this.box).height());var n=this.trigger({phase:"before",type:"resize",target:this.name});return n.stop===!0?!1:(e.resizeBoxes(),e.resizeRecords(),$("#grid_"+e.name+"_records .w2ui-editable input").each(function(t,n){var r=e.columns[$(n).attr("column")];r&&r.editable&&$(n).w2field(r.editable)}),this.trigger($.extend(n,{phase:"after"})),(new Date).getTime()-t)},refresh:function(){var e=this,t=(new Date).getTime();this.total<0&&(this.total=this.records.length),this.buffered<=0&&this.url==""&&(this.buffered=this.total),window.getSelection&&window.getSelection().removeAllRanges();if(!this.box)return;var n=this.trigger({phase:"before",target:this.name,type:"refresh"});if(n.stop===!0)return!1;this.show.header?$("#grid_"+this.name+"_header").html(this.header+"&nbsp;").show():$("#grid_"+this.name+"_header").hide(),this.show.toolbar?this.toolbar&&this.toolbar.get("column-on-off")&&this.toolbar.get("column-on-off").checked||($("#grid_"+this.name+"_toolbar").show(),typeof this.toolbar=="object"&&(this.toolbar.refresh(),$("#grid_"+this.name+"_search_all").val(this.last.search))):$("#grid_"+this.name+"_toolbar").hide(),this.searchClose(),this.searches.length==0&&(this.last.field="No Search Fields"),!this.multiSearch&&this.last.field=="all"&&(this.last.field=this.searches[0].field,this.last.caption=this.searches[0].caption);for(var r in this.searches)this.searches[r].field==this.last.field&&(this.last.caption=this.searches[r].caption);this.last.multi?$("#grid_"+this.name+"_search_all").attr("placeholder",w2utils.lang("Multi Fields")):$("#grid_"+this.name+"_search_all").attr("placeholder",this.last.caption),this._focus_when_refreshed===!0&&setTimeout(function(){var t=$("#grid_"+e.name+"_search_all");t.length>0&&t[0].focus(),setTimeout(function(){t.length>0&&t[0].focus(),delete e._focus_when_refreshed},500)},100);var i="";i+='<div id="grid_'+this.name+'_records" class="w2ui-grid-records"'+"	onscroll=\"var obj = w2ui['"+this.name+"']; "+"		obj.last.scrollTop = this.scrollTop; "+"		obj.last.scrollLeft = this.scrollLeft; "+"		$('#grid_"+this.name+"_columns')[0].scrollLeft = this.scrollLeft;"+"		$('#grid_"+this.name+"_summary')[0].scrollLeft = this.scrollLeft;"+'		obj.doScroll(event);">'+this.getRecordsHTML()+"</div>"+'<div id="grid_'+this.name+'_columns" class="w2ui-grid-columns">'+"	<table>"+this.getColumnsHTML()+"</table>"+"</div>",$("#grid_"+this.name+"_body").html(i);var s=this.find({summary:!0},!0);if(s.length>0){for(var o in s)this.summary.push(s[o]);this.remove.apply(this,this.find({summary:!0}))}this.summary.length>0?$("#grid_"+this.name+"_summary").html(this.getSummaryHTML()).show():$("#grid_"+this.name+"_summary").hide(),this.show.footer?$("#grid_"+this.name+"_footer").html(this.getFooterHTML()).show():$("#grid_"+this.name+"_footer").hide();if(this.last.selected.length>0)for(var r in this.last.selected)this.get(this.last.selected[r])!=null&&this.select(this.get(this.last.selected[r]).recid);this.searchData.length>0?$("#grid_"+this.name+"_searchClear").show():$("#grid_"+this.name+"_searchClear").hide(),$("#grid_"+this.name+"_check_all").prop("checked",!0),$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length!=0&&$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]").length==$("#grid_"+this.name+"_records").find(".grid_select_check[type=checkbox]:checked").length?$("#grid_"+this.name+"_check_all").prop("checked",!0):$("#grid_"+this.name+"_check_all").prop("checked",!1);var u="",a=this.getSelection();a.length>0&&(u=String(a.length).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")+" selected",a.length==1&&(u="Record ID: "+a[0]+" ")),$("#"+this.name+"_grid_footer .w2ui-footer-left").html(u);var f=e.find({expanded:!0});for(var l in f){var c=this.trigger({phase:"before",type:"expand",target:this.name,recid:f[l],box_id:"grid_"+this.name+"_rec_"+w2utils.escapeId(f[l])+"_expanded"});if(c.stop===!0)return!1;this.trigger($.extend(c,{phase:"after"}))}return setTimeout(function(){var t=$.trim($("#grid_"+e.name+"_search_all").val());t!=""&&$(e.box).find(".w2ui-grid-data > div").w2marker(t)},50),this.trigger($.extend(n,{phase:"after"})),e.resize(),setTimeout(function(){e.resize(),e.doScroll()},1),(new Date).getTime()-t},render:function(e){var t=this,n=(new Date).getTime();window.getSelection&&window.getSelection().removeAllRanges(),typeof e!="undefined"&&e!=null&&($(this.box).find("#grid_"+this.name+"_body").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-grid").html(""),this.box=e);if(!this.box)return;this.last.sortData==null&&(this.last.sortData=this.sortData);var r=this.trigger({phase:"before",target:this.name,type:"render",box:e});return r.stop===!0?!1:($(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-grid").html('<div>	<div id="grid_'+this.name+'_header" class="w2ui-grid-header"></div>'+'	<div id="grid_'+this.name+'_toolbar" class="w2ui-grid-toolbar"></div>'+'	<div id="grid_'+this.name+'_body" class="w2ui-grid-body"></div>'+'	<div id="grid_'+this.name+'_summary" class="w2ui-grid-body w2ui-grid-summary"></div>'+'	<div id="grid_'+this.name+'_footer" class="w2ui-grid-footer"></div>'+"</div>"),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),this.initToolbar(),this.toolbar!=null&&this.toolbar.render($("#grid_"+this.name+"_toolbar")[0]),$("#grid_"+this.name+"_footer").html(this.getFooterHTML()),this.reload(),this.trigger($.extend(r,{phase:"after"})),$(".w2ui-layout").length==0&&(this.tmp_resize=function(e){w2ui[t.name].resize()},$(window).off("resize",this.tmp_resize).on("resize",this.tmp_resize)),(new Date).getTime()-n)},destroy:function(){var e=this.trigger({phase:"before",target:this.name,type:"destroy"});if(e.stop===!0)return!1;$(window).off("resize",this.tmp_resize),typeof this.toolbar=="object"&&this.toolbar.destroy&&this.toolbar.destroy(),$(this.box).find("#grid_"+this.name+"_body").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-grid").html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"}))},initColumnOnOff:function(){if(!this.show.toolbarColumns)return;var e=this,t='<div class="w2ui-col-on-off"><table>';for(var n in this.columns){var r=this.columns[n];t+='<tr><td>	<input id="grid_'+this.name+"_column_"+n+'_check" type="checkbox" tabIndex="-1" '+(r.hidden?"":"checked")+"		onclick=\"w2ui['"+e.name+"'].columnOnOff(this, event, '"+r.field+"');\">"+"</td>"+"<td>"+'	<label for="grid_'+this.name+"_column_"+n+'_check">'+(this.columns[n].caption==""?"- column "+(n+1)+" -":this.columns[n].caption)+"</label>"+"</td>"+"</tr>"}t+='<tr><td colspan="2"><div style="border-top: 1px solid #ddd;"></div></td></tr>',this.url!=""&&(t+='<tr><td colspan="2" style="padding: 0px">	<div style="cursor: pointer; padding: 2px 8px; cursor: default">		Skip <input type="text" style="width: 45px" value="'+this.offset+'" '+"				onchange=\"w2ui['"+e.name+"'].columnOnOff(this, event, 'skip', this.value);\"> Records"+"	</div>"+"</td></tr>"),t+='<tr><td colspan="2" onclick="w2ui[\''+e.name+"'].columnOnOff(this, event, 'line-numbers');\">"+'	<div style="cursor: pointer; padding: 4px 8px; cursor: default">Toggle Line Numbers</div>'+"</td></tr>"+'<tr><td colspan="2" onclick="w2ui[\''+e.name+"'].columnOnOff(this, event, 'resize');\">"+'	<div style="cursor: pointer; padding: 4px 8px; cursor: default">Reset Column Size</div>'+"</td></tr>",t+="</table></div>",this.toolbar.get("column-on-off").html=t},columnOnOff:function(e,t,n,r){var i=this.trigger({phase:"before",target:this.name,type:"columnOnOff",checkbox:e,field:n,event:t});if(i.stop===!0)return!1;var s=this;for(var o in this.records)this.records[o].expanded===!0&&(this.records[o].expanded=!1);var u=!0;if(n=="line-numbers")this.show.lineNumbers=!this.show.lineNumbers,this.refresh();else if(n=="skip")w2utils.isInt(r)||(r=0),s.skip
(r);else if(n=="resize"){for(var a in this.columns)typeof this.columns[a].sizeOriginal!="undefined"&&(this.columns[a].size=this.columns[a].sizeOriginal);this.initResize(),this.resize()}else{var f=this.getColumn(n);f.hidden?($(e).prop("checked",!0),this.showColumn(f.field)):($(e).prop("checked",!1),this.hideColumn(f.field)),u=!1}this.initColumnOnOff(),u&&setTimeout(function(){$().w2overlay(),s.toolbar.uncheck("column-on-off")},100),this.trigger($.extend(i,{phase:"after"}))},initToolbar:function(){if(typeof this.toolbar["render"]=="undefined"){var e=this.toolbar.items;this.toolbar.items=[],this.toolbar=$().w2toolbar($.extend(!0,{},this.toolbar,{name:this.name+"_toolbar",owner:this})),this.show.toolbarReload&&this.toolbar.items.push({type:"button",id:"reload",img:"icon-reload",hint:w2utils.lang("Reload data in the list")}),this.show.toolbarColumns&&(this.toolbar.items.push({type:"drop",id:"column-on-off",img:"icon-columns",hint:w2utils.lang("Show/hide columns"),arrow:!1,html:""}),this.initColumnOnOff()),(this.show.toolbarReload||this.show.toolbarColumn)&&this.toolbar.items.push({type:"break",id:"break0"});if(this.show.toolbarSearch){var t='<table cellpadding="0" cellspacing="0"><tr>	<td>		<div class="w2ui-icon icon-search-down w2ui-search-down" title="'+w2utils.lang("Select Search Field")+'" '+(this.isIOS?"onTouchStart":"onClick")+"=\"var obj = w2ui['"+this.name+"']; obj.searchShowFields(this);\"></div>"+"	</td>"+"	<td>"+'		<input id="grid_'+this.name+'_search_all" class="w2ui-search-all" '+'			placeholder="'+this.last.caption+'" value="'+this.last.search+'"'+'			onkeyup="if (event.keyCode == 13) { '+"				w2ui['"+this.name+"']._focus_when_refreshed = true; "+"				w2ui['"+this.name+"'].search(w2ui['"+this.name+"'].last.field, this.value); "+'			}">'+"	</td>"+"	<td>"+'		<div title="Clear Search" class="w2ui-search-clear" id="grid_'+this.name+'_searchClear"  '+"			 onclick=\"var obj = w2ui['"+this.name+"']; obj.searchReset();\" "+"		>&nbsp;&nbsp;</div>"+"	</td>"+"</tr></table>";this.toolbar.items.push({type:"html",id:"search",html:t}),this.multiSearch&&this.searches.length>0&&this.toolbar.items.push({type:"check",id:"search-advanced",caption:w2utils.lang("Search..."),hint:w2utils.lang("Open Search Fields")})}(this.show.toolbarAdd||this.show.toolbarDelete||this.show.toolbarSave)&&this.toolbar.items.push({type:"break",id:"break1"}),this.show.toolbarAdd&&this.toolbar.items.push({type:"button",id:"add",caption:w2utils.lang("Add New"),hint:w2utils.lang("Add new record"),img:"icon-add"}),this.show.toolbarDelete&&this.toolbar.items.push({type:"button",id:"delete",caption:w2utils.lang("Delete"),hint:w2utils.lang("Delete selected records"),img:"icon-delete",disabled:!0}),this.show.toolbarSave&&((this.show.toolbarAdd||this.show.toolbarDelete)&&this.toolbar.items.push({type:"break",id:"break2"}),this.toolbar.items.push({type:"button",id:"save",caption:w2utils.lang("Save"),hint:w2utils.lang("Save changed records"),img:"icon-save"}));for(var n in e)this.toolbar.items.push(e[n]);var r=this;this.toolbar.on("click",function(e,t){var n=r.trigger({phase:"before",type:"toolbar",target:e,data:t});if(n.stop===!0)return!1;switch(e){case"reload":var i=r.trigger({phase:"before",type:"reload",target:r.name});if(i.stop===!0)return!1;r.reset(!0),r.reload(),r.trigger($.extend(i,{phase:"after"}));break;case"column-on-off":for(var s in r.columns)r.columns[s].hidden?$("#grid_"+r.name+"_column_"+s+"_check").prop("checked",!1):$("#grid_"+r.name+"_column_"+s+"_check").prop("checked",!0);r.initResize(),r.resize();break;case"search-advanced":var o=this,u=this.get(e);if(u.checked)r.searchClose(),setTimeout(function(){o.uncheck(e)},1);else{r.searchOpen(),t.event.stopPropagation();function a(){o.uncheck(e),$(document).off("click","body",a)}$(document).on("click","body",a)}break;case"add":r.doAdd();break;case"delete":r.doDelete();break;case"save":r.doSave()}r.trigger($.extend(n,{phase:"after"}))})}return},initSearches:function(){var e=this;for(var t in this.searches){var n=this.searches[t],r=this.getSearchData(n.field);switch(String(n.type).toLowerCase()){case"alphaNumeric":case"text":$("#grid_"+this.name+"_operator_"+t).val("begins with");break;case"int":case"float":case"hex":case"money":case"date":$("#grid_"+this.name+"_field_"+t).w2field(n.type),$("#grid_"+this.name+"_field2_"+t).w2field(n.type);break;case"list":var i='<option value="">--</option>';for(var s in n.items)if($.isPlainObject(n.items[s])){var o=n.items[s].id,u=n.items[s].text;typeof o=="undefined"&&typeof n.items[s].value!="undefined"&&(o=n.items[s].value),typeof u=="undefined"&&typeof n.items[s].caption!="undefined"&&(u=n.items[s].caption),o==null&&(o=""),i+='<option value="'+o+'">'+u+"</option>"}else i+='<option value="'+n.items[s]+'">'+n.items[s]+"</option>";$("#grid_"+this.name+"_field_"+t).html(i)}r!=null&&($("#grid_"+this.name+"_operator_"+t).val(r.operator).trigger("change"),$.isArray(r.value)?($("#grid_"+this.name+"_field_"+t).val(r.value[0]).trigger("change"),$("#grid_"+this.name+"_field2_"+t).val(r.value[1]).trigger("change")):typeof r.value!="udefined"&&$("#grid_"+this.name+"_field_"+t).val(r.value).trigger("change"))}$("#w2ui-overlay .w2ui-grid-searches *[rel=search]").on("keypress",function(t){t.keyCode==13&&e.search()})},initResize:function(){var e=this;$(this.box).find(".w2ui-resizer").off("click").on("click",function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,e.preventDefault&&e.preventDefault()}).off("mousedown").on("mousedown",function(t){t||(t=window.event),window.addEventListener||window.document.attachEvent("onselectstart",function(){return!1}),e.resizing=!0,e.tmp_x=t.screenX,e.tmp_y=t.screenY,e.tmp_col=$(this).attr("name"),t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,t.preventDefault&&t.preventDefault();for(var n in e.columns)typeof e.columns[n].sizeOriginal=="undefined"&&(e.columns[n].sizeOriginal=e.columns[n].size),e.columns[n].size=e.columns[n].sizeCalculated;var r=function(t){if(e.resizing!=1)return;t||(t=window.event),e.tmp_div_x=t.screenX-e.tmp_x,e.tmp_div_y=t.screenY-e.tmp_y,e.columns[e.tmp_col].size=parseInt(e.columns[e.tmp_col].size)+e.tmp_div_x+"px",e.resizeRecords(),e.tmp_x=t.screenX,e.tmp_y=t.screenY},i=function(t){delete e.resizing,$(document).off("mousemove","body"),$(document).off("mouseup","body"),e.resizeRecords()};$(document).on("mousemove","body",r),$(document).on("mouseup","body",i)}).each(function(e,t){var n=$(t).parent();$(t).css({height:"25px","margin-left":n.width()-3+"px"})})},resizeBoxes:function(){var e=$(this.box).find("> div"),t=$("#grid_"+this.name+"_header"),n=$("#grid_"+this.name+"_toolbar"),r=$("#grid_"+this.name+"_summary"),i=$("#grid_"+this.name+"_footer"),s=$("#grid_"+this.name+"_body"),o=$("#grid_"+this.name+"_columns"),u=$("#grid_"+this.name+"_records");this.show.header&&t.css({top:"0px",left:"0px",right:"0px"}),this.show.toolbar&&n.css({top:0+(this.show.header?w2utils.getSize(t,"height"):0)+"px",left:"0px",right:"0px"}),this.show.footer&&i.css({bottom:"0px",left:"0px",right:"0px"}),this.summary.length>0&&r.css({bottom:0+(this.show.footer?w2utils.getSize(i,"height"):0)+"px",left:"0px",right:"0px"}),s.css({top:0+(this.show.header?w2utils.getSize(t,"height"):0)+(this.show.toolbar?w2utils.getSize(n,"height"):0)+"px",bottom:0+(this.show.footer?w2utils.getSize(i,"height"):0)+(this.summary.length>0?w2utils.getSize(r,"height"):0)+"px",left:"0px",right:"0px"})},resizeRecords:function(){var e=this;$(this.box).find(".w2ui-empty-record").remove();var t=$(this.box),n=$(this.box).find("> div"),r=$("#grid_"+this.name+"_header"),i=$("#grid_"+this.name+"_toolbar"),s=$("#grid_"+this.name+"_summary"),o=$("#grid_"+this.name+"_footer"),u=$("#grid_"+this.name+"_body"),a=$("#grid_"+this.name+"_columns"),f=$("#grid_"+this.name+"_records");if(!this.fixedBody)setTimeout(function(){var f=w2utils.getSize(a,"height")+w2utils.getSize($("#grid_"+e.name+"_records table"),"height");e.height=f+w2utils.getSize(n,"+height")+(e.show.header?w2utils.getSize(r,"height"):0)+(e.show.toolbar?w2utils.getSize(i,"height"):0)+(s.css("display")!="none"?w2utils.getSize(s,"height"):0)+(e.show.footer?w2utils.getSize(o,"height"):0),n.css("height",e.height),u.css("height",f),t.css("height",w2utils.getSize(n,"height")+w2utils.getSize(t,"+height"))},1);else{var l=n.height()-(this.show.header?w2utils.getSize(r,"height"):0)-(this.show.toolbar?w2utils.getSize(i,"height"):0)-(s.css("display")!="none"?w2utils.getSize(s,"height"):0)-(this.show.footer?w2utils.getSize(o,"height"):0);u.css("height",l)}var c=!1,h=!1;u.height()-a.height()<$(f).find(">table").height()&&(h=!0),u.width()<$(f).find(">table").width()&&(c=!0),this.fixedBody||(h=!1,c=!1),c||h?(a.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show(),f.css({top:(this.columnGroups.length>0&&this.show.columns?1:0)+w2utils.getSize(a,"height")+"px","-webkit-overflow-scrolling":"touch","overflow-x":c?"auto":"hidden","overflow-y":h?"auto":"hidden"})):(a.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").hide(),f.css({top:(this.columnGroups.length>0&&this.show.columns?1:0)+w2utils.getSize(a,"height")+"px",overflow:"hidden"}),f.length>0&&(this.last.scrollTop=0,this.last.scrollLeft=0));if(this.show.emptyRecords&&!h){var p=Math.floor(f.height()/this.recordHeight)+1;if(this.fixedBody)for(var d=this.buffered;d<=p;d++){var v="";v+='<tr class="'+(d%2?"w2ui-even":"w2ui-odd")+' w2ui-empty-record" style="height: '+this.recordHeight+'">',this.show.lineNumbers&&(v+='<td class="w2ui-col-number"></td>'),this.show.selectColumn&&(v+='<td class="w2ui-grid-data w2ui-col-select"></td>'),this.show.expandColumn&&(v+='<td class="w2ui-grid-data w2ui-col-expand"></td>');var m=0;while(this.columns.length>0){var g=this.columns[m];if(g.hidden){m++;if(typeof this.columns[m]=="undefined")break;continue}v+='<td class="w2ui-grid-data" '+(typeof g.attr!="undefined"?g.attr:"")+' col="'+m+'"></td>',m++;if(typeof this.columns[m]=="undefined")break}v+='<td class="w2ui-grid-data-last"></td>',v+="</tr>",$("#grid_"+this.name+"_records > table").append(v)}}if(u.length>0){var y=parseInt(u.width())-(h?w2utils.scrollBarSize():0)-(this.show.lineNumbers?34:0)-(this.show.selectColumn?26:0)-(this.show.expandColumn?26:0),b=y,w=0,E=!1;for(var S=0;S<this.columns.length;S++){var g=this.columns[S];typeof g.gridMinWidth!="undefined"&&(g.gridMinWidth>b&&g.hidden!==!0&&(g.hidden=!0,E=!0),g.gridMinWidth<b&&g.hidden===!0&&(g.hidden=!1,E=!0))}if(E===!0){this.refresh();return}for(var S=0;S<this.columns.length;S++){var g=this.columns[S];if(g.hidden)continue;String(g.size).substr(String(g.size).length-2).toLowerCase()=="px"?(y-=parseFloat(g.size),this.columns[S].sizeCalculated=g.size,this.columns[S].sizeType="px"):(w+=parseFloat(g.size),this.columns[S].sizeType="%",delete g.sizeCorrected)}if(w!=100&&w>0)for(var S=0;S<this.columns.length;S++){var g=this.columns[S];if(g.hidden)continue;g.sizeType=="%"&&(g.sizeCorrected=Math.round(parseFloat(g.size)*100*100/w)/100+"%")}for(var S=0;S<this.columns.length;S++){var g=this.columns[S];if(g.hidden)continue;g.sizeType=="%"&&(typeof this.columns[S].sizeCorrected!="undefined"?this.columns[S].sizeCalculated=Math.floor(y*parseFloat(g.sizeCorrected)/100)-1+"px":this.columns[S].sizeCalculated=Math.floor(y*parseFloat(g.size)/100)-1+"px")}}var x=0;for(var S=0;S<this.columns.length;S++){var g=this.columns[S];if(g.hidden)continue;typeof g.min=="undefined"&&(g.min=20),parseInt(g.sizeCalculated)<parseInt(g.min)&&(g.sizeCalculated=g.min+"px"),parseInt(g.sizeCalculated)>parseInt(g.max)&&(g.sizeCalculated=g.max+"px"),x+=parseInt(g.sizeCalculated)}var T=parseInt(b)-parseInt(x);if(T>0&&w>0){var S=0;for(;;){var g=this.columns[S];if(typeof g=="undefined"){S=0;continue}if(g.hidden||g.sizeType=="px"){S++;continue}g.sizeCalculated=parseInt(g.sizeCalculated)+1+"px",T--;if(T==0)break;S++}}else T>0&&a.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show();a.find("> table > tbody > tr:nth-child(1) td").each(function(t,n){var r=$(n).attr("col");typeof r!="undefined"&&e.columns[r]&&$(n).css("width",e.columns[r].sizeCalculated),$(n).hasClass("w2ui-head-last")&&$(n).css("width",w2utils.scrollBarSize()+(T>0&&w==0?T:0)+"px")}),a.find("> table > tbody > tr").length==3&&a.find("> table > tbody > tr:nth-child(1) td").html("").css({height:"0px",border:"0px",padding:"0px",margin:"0px"}),f.find("> table > tbody > tr:nth-child(1) td").each(function(t,n){var r=$(n).attr("col");typeof r!="undefined"&&e.columns[r]&&$(n).css("width",e.columns[r].sizeCalculated),$(n).hasClass("w2ui-grid-data-last")&&$(n).css("width",(T>0&&w==0?T:0)+"px")}),s.find("> table > tbody > tr:nth-child(1) td").each(function(t,n){var r=$(n).attr("col");typeof r!="undefined"&&e.columns[r]&&$(n).css("width",e.columns[r].sizeCalculated),$(n).hasClass("w2ui-grid-data-last")&&$(n).css("width",w2utils.scrollBarSize()+(T>0&&w==0?T:0)+"px")}),this.initResize(),this.last.scrollTop!=""&&f.length>0&&(a.prop("scrollLeft",this.last.scrollLeft),f.prop("scrollTop",this.last.scrollTop),f.prop("scrollLeft",this.last.scrollLeft))},getSearchesHTML:function(){var e='<table cellspacing="0">',t=!1;for(var n=0;n<this.searches.length;n++){var r=this.searches[n];if(r.hidden)continue;var i="";t==0&&(i='<input type="button" value="X" onclick="obj = w2ui[\''+this.name+"']; if (obj) { obj.searchClose(); }\">",t=!0),typeof r.inTag=="undefined"&&(r.inTag=""),typeof r.outTag=="undefined"&&(r.outTag=""),typeof r.type=="undefined"&&(r.type="text");if(r.type=="text")var s='<select id="grid_'+this.name+"_operator_"+n+'">'+'	<option value="is">'+w2utils.lang("is")+"</option>"+'	<option value="begins with">'+w2utils.lang("begins with")+"</option>"+'	<option value="contains">'+w2utils.lang("contains")+"</option>"+'	<option value="ends with">'+w2utils.lang("ends with")+"</option>"+"</select>";if(r.type=="int"||r.type=="float"||r.type=="date")var s='<select id="grid_'+this.name+"_operator_"+n+'" onchange="var el = $(\'#grid_'+this.name+"_range_"+n+"'); "+"					if ($(this).val() == 'is') el.hide(); else el.show();\">"+'	<option value="is">'+w2utils.lang("is")+"</option>"+'	<option value="between">'+w2utils.lang("between")+"</option>"+"</select>";if(r.type=="list")var s='is <input type="hidden" value="is" id="grid_'+this.name+"_operator_"+n+'">';e+='<tr>	<td class="close-btn">'+i+"</td>"+'	<td class="caption">'+r.caption+"</td>"+'	<td class="operator">'+s+"</td>"+'	<td class="value">';switch(r.type){case"alphaNumeric":case"text":e+='<input rel="search" type="text" size="40" id="grid_'+this.name+"_field_"+n+'" name="'+r.field+'" '+r.inTag+">";break;case"int":case"float":case"hex":case"money":case"date":e+='<input rel="search" type="text" size="12" id="grid_'+this.name+"_field_"+n+'" name="'+r.field+'" '+r.inTag+">"+'<span id="grid_'+this.name+"_range_"+n+'" style="display: none">'+'&nbsp;-&nbsp;&nbsp;<input rel="search" type="text" size="12" id="grid_'+this.name+"_field2_"+n+'" name="'+r.field+'" '+r.inTag+">"+"</span>";break;case"list":e+='<select rel="search" id="grid_'+this.name+"_field_"+n+'" name="'+r.field+'" '+r.inTag+"></select>"}e+=r.outTag+"	</td>"+"</tr>"}return e+='<tr>	<td colspan="4" class="actions">		<div>		<input type="button" onclick="obj = w2ui[\''+this.name+'\']; if (obj) { obj.searchReset(); }" value="'+w2utils.lang("Reset")+'">'+'		<input type="button" onclick="obj = w2ui[\''+this.name+'\']; if (obj) { obj.search(); }" value="'+w2utils.lang("Search")+'">'+"		</div>"+"	</td>"+"</tr></table>",e},getColumnsHTML:function(){function n(){var t="<tr>";e.columnGroups[e.columnGroups.length-1].caption!=""&&e.columnGroups.push({caption:""}),e.show.lineNumbers&&(t+='<td class="w2ui-head w2ui-col-number">	<div>&nbsp;</div></td>'),e.show.selectColumn&&(t+='<td class="w2ui-head w2ui-col-select">	<div>&nbsp;</div></td>'),e.show.expandColumn&&(t+='<td class="w2ui-head w2ui-col-expand">	<div>&nbsp;</div></td>');var n=0;for(var r=0;r<e.columnGroups.length;r++){var i=e.columnGroups[r],s=e.columns[n];if(typeof i.span=="undefined"||i.span!=parseInt(i.span))i.span=1;typeof i.colspan!="undefined"&&(i.span=i.colspan);if(i.master===!0){var o="";for(var u in e.sortData)e.sortData[u].field==s.field&&(e.sortData[u].direction=="asc"&&(o="w2ui-sort-down"),e.sortData[u].direction=="desc"&&(o="w2ui-sort-up"));var a="";s.resizable==1&&(a='<div class="w2ui-resizer" name="'+n+'"></div>'),t+='<td class="w2ui-head '+o+'" col="'+n+'" rowspan="2" colspan="'+(i.span+(r==e.columnGroups.length-1?1:0))+'" '+(s.sortable?"onclick=\"w2ui['"+e.name+"'].doSort('"+s.field+"', null, event);\"":"")+">"+a+'	<div class="w2ui-col-group '+o+'">'+(s.caption==""?"&nbsp;":s.caption)+"	</div>"+"</td>"}else t+='<td class="w2ui-head" col="'+n+'" '+'		colspan="'+(i.span+(r==e.columnGroups.length-1?1:0))+'">'+'	<div class="w2ui-col-group">'+(i.caption==""?"&nbsp;":i.caption)+"	</div>"+"</td>";n+=i.span}return t+="</tr>",t}function r(t){var n="<tr>";e.show.lineNumbers&&(n+='<td class="w2ui-head w2ui-col-number">	<div>#</div></td>'),e.show.selectColumn&&(n+='<td class="w2ui-head w2ui-col-select" 		onclick="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">	<div>		<input type="checkbox" id="grid_'+e.name+'_check_all" tabIndex="-1"'+'			style="'+(e.multiSelect==0?"display: none;":"")+'"'+"			onclick=\"if (this.checked) w2ui['"+e.name+"'].selectAll(); "+"					 else w2ui['"+e.name+"'].selectNone(); "+'					 if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">'+"	</div>"+"</td>"),e.show.expandColumn&&(n+='<td class="w2ui-head w2ui-col-expand">	<div>&nbsp;</div></td>');var r=0,i=0;for(var s=0;s<e.columns.length;s++){var o=e.columns[s],u={};s==i&&(i+=typeof e.columnGroups[r]!="undefined"?parseInt(e.columnGroups[r].span):0,r++);if(typeof e.columnGroups[r-1]!="undefined")var u=e.columnGroups[r-1];if(o.hidden)continue;var a="";for(var f in e.sortData)e.sortData[f].field==o.field&&(e.sortData[f].direction=="asc"&&(a="w2ui-sort-down"),e.sortData[f].direction=="desc"&&(a="w2ui-sort-up"));if(u.master!==!0||t){var l="";o.resizable==1&&(l='<div class="w2ui-resizer" name="'+s+'"></div>'),n+='<td col="'+s+'" class="w2ui-head '+a+'" '+(o.sortable?"onclick=\"w2ui['"+e.name+"'].doSort('"+o.field+"', null, event);\"":"")+">"+l+'	<div class="'+a+'">'+(o.caption==""?"&nbsp;":o.caption)+"	</div>"+"</td>"}}return n+='<td class="w2ui-head w2ui-head-last"><div>&nbsp;</div></td>',n+="</tr>",n}var e=this,t="";return this.show.columnHeaders&&(this.columnGroups.length>0?t=r(!0)+n()+r(!1):t=r(!0)),t},getRecordsHTML:function(){this.buffered>300?this.show_extra=30:this.show_extra=300;var e=$("#grid_"+this.name+"_records"),t=Math.floor(e.height()/this.recordHeight)+this.show_extra+1;this.fixedBody||(t=this.buffered);var n="<table>"+this.getRecordHTML(-1,0);n+='<tr id="grid_'+this.name+'_rec_top" line="top" style="height: '+0+'px">'+'	<td colspan="200"></td>'+"</tr>";for(var r=0;r<t;r++)n+=this.getRecordHTML(r,r+1);return n+='<tr id="grid_'+this.name+'_rec_bottom" line="bottom" style="height: '+(this.buffered-t)*this.recordHeight+'px">'+'	<td colspan="200"></td>'+"</tr>"+'<tr id="grid_'+this.name+'_rec_more" style="display: none">'+'	<td colspan="200" class="w2ui-load-more"></td>'+"</tr>"+"</table>",this.last.range_start=0,this.last.range_end=t,n},getSummaryHTML:function(){if(this.summary.length==0)return;var e="<table>";for(var t=0;t<this.summary.length;t++)e+=this.getRecordHTML(t,t+1,!0);return e+="</table>",e},doScroll:function(e){function w(){clearTimeout(n.last.marker_timer),n.last.marker_timer=setTimeout(function(){var e=[];for(var t in n.searchData){var r=n.searchData[t];$.inArray(r.value,e)==-1&&e.push(r.value)}e.length>0&&$(n.box).find(".w2ui-grid-data > div").w2marker(e)},50)}var t=(new Date).getTime(),n=this,r=$("#grid_"+this.name+"_records");if(r.length==0)return;this.buffered>300?this.show_extra=30:this.show_extra=300;if(r.height()<this.buffered*this.recordHeight&&r.css("overflow-y")=="hidden"){this.refresh();return}var i=Math.floor(r[0].scrollTop/this.recordHeight+1),s=Math.floor(r[0].scrollTop/this.recordHeight+1)+Math.floor(r.height()/this.recordHeight);i>this.buffered&&(i=this.buffered),s>this.buffered&&(s=this.buffered),$("#grid_"+this.name+"_footer .w2ui-footer-right").html(w2utils.format(this.offset+i)+"-"+w2utils.format(this.offset+s+1)+" of "+w2utils.format(this.total)+(this.url!=""?" (buffered "+w2utils.format(this.buffered)+(this.offset>0?", skip "+w2utils.format(this.offset):"")+")":""));if(!this.fixedBody||this.total<=300)return;var o=Math.floor(r[0].scrollTop/this.recordHeight)-this.show_extra,u=o+Math.floor(r.height()/this.recordHeight)+this.show_extra*2+1;o<1&&(o=1),u>this.total&&(u=this.total);var a=r.find("#grid_"+this.name+"_rec_top"),f=r.find("#grid_"+this.name+"_rec_bottom");String(a.next().prop("id")).indexOf("_expanded_row")!=-1&&a.next().remove(),String(f.prev().prop("id")).indexOf("_expanded_row")!=-1&&f.prev().remove();var l=parseInt(a.next().attr("line")),c=parseInt(f.prev().attr("line"));if(l<o||l==1||this.last.pull_refresh){if(u<=c+this.show_extra&&u!=this.total&&!this.last.pull_refresh)return;this.last.pull_refresh=!1;for(;;){var h=r.find("#grid_"+this.name+"_rec_top").next();if(h.attr("line")=="bottom")break;if(!(parseInt(h.attr("line"))<o))break;h.remove()}var h=r.find("#grid_"+this.name+"_rec_bottom").prev(),p=h.attr("line");p=="top"&&(p=o);for(var d=parseInt(p)+1;d<=u;d++){if(!this.records[d-1])continue;this.records[d-1].expanded===!0&&(this.records[d-1].expanded=!1),f.before(this.getRecordHTML(d-1,d))}w()}else{if(o>=l-this.show_extra&&o>1)return;for(;;){var h=r.find("#grid_"+this.name+"_rec_bottom").prev();if(h.attr("line")=="top")break;if(!(parseInt(h.attr("line"))>u))break;h.remove()}var h=r.find("#grid_"+this.name+"_rec_top").next(),p=h.attr("line");p=="bottom"&&(p=u);for(var d=parseInt(p)-1;d>=o;d--){if(!this.records[d-1])continue;this.records[d-1].expanded===!0&&(this.records[d-1].expanded=!1),a.after(this.getRecordHTML(d-1,d))}w()}var v=(o-1)*n.recordHeight,m=(this.buffered-u)*n.recordHeight;m<0&&(m=0),a.css("height",v+"px"),f.css("height",m+"px"),n.last.range_start=o,n.last.range_end=u;var g=Math.floor(r[0].scrollTop/this.recordHeight),y=g+Math.floor(r.height()/this.recordHeight);if(y+20>this.buffered&&this.last.pull_more!==!0&&this.buffered<this.total-this.offset)if(this.autoLoad===!0)this.last.pull_more=!0,this.last.xhr_offset+=this.limit,this.request("get-records");else{var b=$("#grid_"+this.name+"_rec_more");b.css("display")=="none"&&b.show().on("click",function(){$(this).find("td").html('<div><div style="width: 20px; height: 20px;" class="w2ui-spinner"></div></div>'),n.last.pull_more=!0,n.last.xhr_offset+=n.limit,n.request("get-records")}),b.find("td").text().indexOf("Load")==-1&&b.find("td").html("<div>Load "+n.limit+" More...</div>")}this.buffered>=this.total-this.offset&&$("#grid_"+this.name+"_rec_more").hide();return},getRecordHTML:function(e,t,n){var r="";if(e==-1){r+='<tr line="0">',this.show.lineNumbers&&(r+='<td class="w2ui-col-number" style="height: 0px;"></td>'),this.show.selectColumn&&(r+='<td class="w2ui-col-select" style="height: 0px;"></td>'),this.show.expandColumn&&(r+='<td class="w2ui-col-expand" style="height: 0px;"></td>');for(var i in this.columns){if(this.columns[i].hidden)continue;r+='<td class="w2ui-grid-data" col="'+i+'" style="height: 0px;"></td>'}return r+='<td class="w2ui-grid-data-last" style="height: 0px;"></td>',r+="</tr>",r}if(n!==!0)if(this.searchData.length>0&&this.url==""){if(e>=this.last.searchIds.length)return"";e=this.last.searchIds[e],record=this.records[e]}else{if(e>=this.records.length)return"";record=this.records[e]}else{if(e>=this.summary.length)return"";record=this.summary[e]}if(!record)return"";var s=w2utils.escapeId(record.recid);record.selected?r+='<tr id="grid_'+this.name+"_rec_"+record.recid+'" recid="'+record.recid+'" line="'+t+'" '+' class="w2ui-selected '+(t%2==0?"w2ui-even":"w2ui-odd")+(record.expanded===!0?" w2ui-expanded":"")+'" '+(n!==!0?this.isIOS?"	onclick  = \"w2ui['"+this.name+"'].doDblClick('"+record.recid+"', event);\" ":"	onclick	 = \"w2ui['"+this.name+"'].doClick('"+record.recid+"', event);\""+"	ondblclick  = \"w2ui['"+this.name+"'].doDblClick('"+record.recid+"', event);\" ":"")+' style="height: '+this.recordHeight+'px" '+(record.style?'custom_style="'+record.style+'"':"")+">":r+='<tr id="grid_'+this.name+"_rec_"+record.recid+'" recid="'+record.recid+'" line="'+t+'" '+'	class="'+(t%2==0?"w2ui-even":"w2ui-odd")+(record.expanded===!0?" w2ui-expanded":"")+'" '+(n!==!0?this.isIOS?"	onclick = \"w2ui['"+this.name+"'].doDblClick('"+record.recid+"', event);\" ":"	onclick =\"w2ui['"+this.name+"'].doClick('"+record.recid+"', event);\""+"	ondblclick = \"w2ui['"+this.name+"'].doDblClick('"+record.recid+"', event);\" ":"")+' style="height: '+this.recordHeight+"px; "+(record.style?record.style+'" custom_style="'+record.style:"")+'" '+">",this.show.lineNumbers&&(r+='<td id="grid_'+this.name+"_cell_"+e+'_number" valign="top" class="w2ui-col-number">'+(n!==!0?"<div>"+t+"</div>":"")+"</td>"),this.show.selectColumn&&(r+='<td id="grid_'+this.name+"_cell_"+e+'_select" valign="top" class="w2ui-grid-data w2ui-col-select" '+'		onclick="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">'+(n!==!0?'	<div>		<input id="grid_'+this.name+"_cell_"+e+'_select_check" class="grid_select_check" type="checkbox" tabIndex="-1"'+"			"+(record.selected?'checked="checked"':"")+"			onclick=\"var obj = w2ui['"+this.name+"']; if (!obj.multiSelect) { obj.selectNone(); }"+"				if (this.checked) obj.select('"+record.recid+"'); else obj.unselect('"+record.recid+"'); "+'				if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">'+"	</div>":"")+"</td>");if(this.show.expandColumn){var o="";record.expanded===!0?o="-":o="+",record.expanded=="none"&&(o=""),record.expanded=="spinner"&&(o='<div class="w2ui-spinner" style="width: 16px; margin: -2px 2px;"></div>'),r+='<td id="grid_'+this.name+"_cell_"+e+'_expand" valign="top" class="w2ui-grid-data w2ui-col-expand">'+(n!==!0?'	<div ondblclick="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;" 			onclick="w2ui[\''+this.name+"'].toggle('"+record.recid+"', event); "+'				if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">'+"		"+o+" </div>":"")+"</td>"}var u=0;for(;;){var a=this.columns[u];if(a.hidden){u++;if(typeof this.columns[u]=="undefined")break;continue}var f=this.parseObj(record,a.field);typeof a.render!="undefined"&&(typeof a.render=="function"&&(f=a.render.call(this,this.records[e],e,u)),typeof a.render=="object"&&(f=a.render[f]));if(f==null||typeof f=="undefined")f="";var l=String(f).replace(/"/g,"''");typeof a.title!="undefined"&&(typeof a.title=="function"&&(l=a.title.call(this,this.records[e],e,u)),typeof a.title=="string"&&(l=a.title));var c='<div title="'+l+'">'+f+"</div>";if($.isPlainObject(a.editable)){var h=a.editable;h.type=="enum"&&console.log("ERROR: Grid's inline editing does not support enum field type."),(h.type=="list"||h.type=="select")&&console.log("ERROR: Grid's inline editing does not support list/select field type."),typeof h.inTag=="undefined"&&(h.inTag=""),typeof h.outTag=="undefined"&&(h.outTag=""),typeof h.style=="undefined"&&(h.style=""),typeof h.items=="undefined"&&(h.items=[]);if((typeof record["editable"]=="undefined"||record.editable===!0)&&h.type!="enum"&&h.type!="list"&&h.type!="select"){var p="";if(record.changed&&typeof record.changes[a.field]!="undefined"){f=record.changes[a.field];var p=f}c='<div class="w2ui-editable"><input id="grid_'+this.name+"_edit_"+e+"_"+u+'" value="'+w2utils.stripTags(f)+'" type="text"  '+'	style="'+h.style+'" '+(record.changed&&p!=""?'class="changed"':"")+'	field="'+a.field+'" recid="'+record.recid+'" line="'+e+'" column="'+u+'" '+"	onclick = \"w2ui['"+this.name+"'].doEdit('click', this, event);\" "+"	onkeyup = \"w2ui['"+this.name+"'].doEdit('keyup', this, event);\" "+"	onfocus = \"w2ui['"+this.name+"'].doEdit('focus', this, event);\" "+"	onblur  = \"w2ui['"+this.name+"'].doEdit('blur', this, event);\" "+'	ondblclick = "if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; '+'				  this.select();" '+h.inTag+" >"+h.outTag+"</div>"}}r+='<td class="w2ui-grid-data" col="'+u+'" '+'	style="'+(typeof a.style!="undefined"?a.style:"")+'" '+(typeof a.attr!="undefined"?a.attr:"")+">"+c+"</td>",u++;if(typeof this.columns[u]=="undefined")break}r+='<td class="w2ui-grid-data-last"></td>',r+="</tr>";if(record.expanded===!0){var d=1+(this.show.selectColumn?1:0);r+='<tr id="grid_'+this.name+"_rec_"+record.recid+'_expanded_row">'+(this.show.lineNumbers?'<td class="w2ui-col-number"></td>':"")+'	<td class="w2ui-grid-data w2ui-expanded1" colspan="'+d+'"><div></div></td>'+'	<td colspan="100" class="w2ui-expanded2">'+'		<div id="grid_'+this.name+"_rec_"+record.recid+'_expanded">&nbsp;</div>'+"	</td>"+"</tr>"}return r},getFooterHTML:function(){return'<div>	<div class="w2ui-footer-left"></div>	<div class="w2ui-footer-right">'+this.buffered+"</div>"+'	<div class="w2ui-footer-center"></div>'+"</div>"},lock:function(e,t){var n=this;typeof e=="undefined"||e==""?setTimeout(function(){$("#grid_"+n.name+"_lock").remove(),$("#grid_"+n.name+"_status").remove()},25):($("#grid_"+n.name+"_lock").remove(),$("#grid_"+n.name+"_status").remove(),$(this.box).find("> div :first-child").before('<div id="grid_'+this.name+'_lock" class="w2ui-grid-lock"></div>'+'<div id="grid_'+this.name+'_status" class="w2ui-grid-status"></div>'),setTimeout(function(){var r=$("#grid_"+n.name+"_lock"),i=$("#grid_"+n.name+"_status");i.data("old_opacity",i.css("opacity")).css("opacity","0").show(),r.data("old_opacity",r.css("opacity")).css("opacity","0").show(),setTimeout(function(){var s=($(n.box).width()-w2utils.getSize(i,"width"))/2,o=($(n.box).height()*.9-w2utils.getSize(i,"height"))/2;r.css({opacity:r.data("old_opacity"),left:"0px",top:"0px",width:"100%",height:"100%"}),t===!0&&(e='<div style="display: inline-block; width: 24px; height: 24px; margin: -3px 8px -7px -10px;" class="w2ui-spinner"></div>'+e),i.html(e).css({opacity:i.data("old_opacity"),left:s+"px",top:o+"px"})},10)},10))},unlock:function(){this.lock()},parseObj:function(e,t){var n="";try{n=e;var r=String(t).split(".");for(var i in r)n=n[r[i]]}catch(s){n=""}return n}},$.extend(w2grid.prototype,$.w2event),w2obj.grid=w2grid}(),function(){var e=function(e){this.box=null,this.name=null,this.panels=[],this.padding=0,this.resizer=4,this.style="",this.css="",this.onShow=null,this.onHide=null,this.onResizing=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,$.extend(!0,this,e,w2obj.layout)};$.fn.w2layout=function(t){if(typeof t=="object"||!t){if(!t||typeof t.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2layout().');return}if(typeof w2ui[t.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+t.name+").");return}if(!w2utils.isAlphaNumeric(t.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=t.panels,r=new e(t);$.extend(r,{handlers:[],panels:[]});for(var i in n)r.panels[i]=$.extend(!0,{},e.prototype.panel,n[i]),($.isPlainObject(r.panels[i].tabs)||$.isArray(r.panels[i].tabs))&&r.initTabs(n[i].type),($.isPlainObject(r.panels[i].toolbar)||$.isArray(r.panels[i].toolbar))&&r.initToolbar(n[i].type);for(var i in{top:"",left:"",main:"",preview:"",right:"",bottom:""}){if(r.get(i)!=null)continue;r.panels[i]=$.extend(!0,{},e.prototype.panel,{type:i,hidden:!0,size:50})}return $(this).length>0&&r.render($(this)[0]),w2ui[r.name]=r,r}if(w2ui[$(this).attr("name")]){var s=w2ui[$(this).attr("name")];return s[t].apply(s,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+t+" does not exist on jQuery.w2layout")},e.prototype={panel:{type:null,size:100,minSize:20,hidden:!1,resizable:!1,overflow:"auto",style:"",content:"",tabs:null,toolbar:null,width:null,height:null,onRefresh:null,onShow:null,onHide:null},content:function(e,t,n){var r=this,i=this.get(e);if(i==null)return!1;if($("#layout_"+this.name+"_panel2_"+i.type).length>0)return!1;$("#layout_"+this.name+"_panel_"+i.type).scrollTop(0);if(t==null||typeof t=="undefined")return i.content;if(t instanceof jQuery)return console.log("ERROR: You can not pass jQuery object to w2layout.content() method"),!1;if(i.content=="")i.content=t,i.hidden||this.refresh(e);else{i.content=t;if(!i.hidden)if(n!=null&&n!=""&&typeof n!="undefined"){var s="layout_"+this.name+"_panel_"+i.type,o=$("#"+s+" > .w2ui-panel-content");o.after('<div class="w2ui-panel-content new-panel" style="'+o
[0].style.cssText+'"></div>');var u=$("#"+s+" > .w2ui-panel-content.new-panel");typeof t=="object"?(t.box=u[0],t.render()):u.html(t),w2utils.transition(o[0],u[0],n,function(){o.remove(),u.removeClass("new-panel"),window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){r.resize()},100)})}else i.hidden||this.refresh(e)}return window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){r.resize()},100),!0},html:function(e,t,n){this.content(e,t,n)},load:function(e,t,n,r){var i=this;return this.get(e)==null?!1:($.get(t,function(t,s,o){i.content(e,o.responseText,n),r&&r(),window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){i.resize()},100)}),!0)},show:function(e,t){var n=this,r=this.trigger({phase:"before",type:"show",target:e,panel:this.get(e),immediate:t});if(r.stop===!0)return!1;var i=n.get(e);return i==null?!1:(i.hidden=!1,t===!0?($("#layout_"+n.name+"_panel_"+e).css({opacity:"1"}),i.resizabled&&$("#layout_"+n.name+"_resizer_"+e).show(),n.trigger($.extend(r,{phase:"after"})),n.resize()):(i.resizabled&&$("#layout_"+n.name+"_resizer_"+e).show(),$("#layout_"+n.name+"_panel_"+e).css({opacity:"0"}),$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":".2s","-moz-transition":".2s","-ms-transition":".2s","-o-transition":".2s"}),setTimeout(function(){n.resize()},1),setTimeout(function(){$("#layout_"+n.name+"_panel_"+e).css({opacity:"1"})},250),setTimeout(function(){$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":"0s","-moz-transition":"0s","-ms-transition":"0s","-o-transition":"0s"}),n.trigger($.extend(r,{phase:"after"})),n.resize()},500)),!0)},hide:function(e,t){var n=this,r=this.trigger({phase:"before",type:"hide",target:e,panel:this.get(e),immediate:t});if(r.stop===!0)return!1;var i=n.get(e);return i==null?!1:(i.hidden=!0,t===!0?($("#layout_"+n.name+"_panel_"+e).css({opacity:"0"}),$("#layout_"+n.name+"_resizer_"+e).hide(),n.trigger($.extend(r,{phase:"after"})),n.resize()):($("#layout_"+n.name+"_resizer_"+e).hide(),$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":".2s","-moz-transition":".2s","-ms-transition":".2s","-o-transition":".2s"}),$("#layout_"+n.name+"_panel_"+e).css({opacity:"0"}),setTimeout(function(){n.resize()},1),setTimeout(function(){$(n.box).find(" > div .w2ui-panel").css({"-webkit-transition":"0s","-moz-transition":"0s","-ms-transition":"0s","-o-transition":"0s"}),n.trigger($.extend(r,{phase:"after"})),n.resize()},500)),!0)},toggle:function(e,t){var n=this.get(e);return n==null?!1:n.hidden?this.show(e,t):this.hide(e,t)},set:function(e,t){var n=this.get(e,!0);return n==null?!1:($.extend(this.panels[n],t),this.refresh(e),this.resize(),!0)},get:function(e,t){var n=null;for(var r in this.panels)if(this.panels[r].type==e)return t===!0?r:this.panels[r];return null},el:function(e){var t=$("#layout_"+this.name+"_panel_"+e+" .w2ui-panel-content");return t.length!=1?null:t[0]},initToolbar:function(e,t){var n=this.get(e);return n!=null&&typeof t=="undefined"&&(t=n.toolbar),n==null||t==null?!1:($.isArray(t)&&(t={items:t}),$().w2destroy(this.name+"_"+e+"_toolbar"),n.toolbar=$().w2toolbar($.extend({},t,{owner:this,name:this.name+"_"+e+"_toolbar"})),!0)},initTabs:function(e,t){var n=this.get(e);n!=null&&typeof t=="undefined"&&(t=n.tabs);if(n==null||t==null)return!1;var r={};if($.isArray(t)){$.extend(!0,r,{tabs:[]});for(var i in t){var s=t[i];typeof s=="object"?r.tabs.push(s):r.tabs.push({id:s,caption:s})}r.active=r.tabs[0].id}else $.extend(!0,r,t);return $().w2destroy(this.name+"_"+e+"_tabs"),n.tabs=$().w2tabs($.extend({},r,{owner:this,name:this.name+"_"+e+"_tabs"})),!0},render:function(e){window.getSelection&&window.getSelection().removeAllRanges();var t=(new Date).getTime(),n=this.trigger({phase:"before",type:"render",target:this.name,box:e});if(n.stop===!0)return!1;typeof e!="undefined"&&e!=null&&($(this.box).find("#layout_"+this.name+"_panel_main").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-layout").html(""),this.box=e);if(!this.box)return!1;$(this.box).attr("name",this.name).addClass("w2ui-layout").html("<div></div>"),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style);var r=["top","left","main","preview","right","bottom"];for(var i in r){var s=this.get(r[i]),o='<div id="layout_'+this.name+"_panel_"+r[i]+'" class="w2ui-panel">'+'	<div class="w2ui-panel-tabs"></div>'+'	<div class="w2ui-panel-toolbar"></div>'+'	<div class="w2ui-panel-content"></div>'+"</div>"+'<div id="layout_'+this.name+"_resizer_"+r[i]+'" class="w2ui-resizer"></div>';$(this.box).find(" > div").append(o),s.tabs!=null&&$(this.box).find("#layout_"+this.name+"_panel_"+r[i]+" .w2ui-panel-tabs").w2render(s.tabs),s.toolbar!=null&&$(this.box).find("#layout_"+this.name+"_panel_"+r[i]+" .w2ui-panel-toolbar").w2render(s.toolbar)}return $(this.box).find(" > div").append('<style id="layout_'+this.name+'_panel_css" style="position: absolute; top: 10000px;">'+this.css+"</style>"),this.trigger($.extend(n,{phase:"after"})),this.refresh(),this.initEvents(),(new Date).getTime()-t},refresh:function(e){window.getSelection&&window.getSelection().removeAllRanges(),typeof e=="undefined"&&(e=null);var t=(new Date).getTime(),n=this.trigger({phase:"before",type:"refresh",target:typeof e!="undefined"?e:this.name,panel:this.get(e)});if(n.stop===!0)return;if(e!=null&&typeof e!="undefined"){var r=this.get(e);if(r==null)return;var i=$("#layout_"+this.name+"_panel_"+e).css({display:r.hidden?"none":"block"});i=i.find(".w2ui-panel-content"),i.length>0&&(i.css("overflow",r.overflow)[0].style.cssText+=";"+r.style),typeof r.content=="object"&&r.content.render?r.content.render($("#layout_"+this.name+"_panel_"+r.type+" > .w2ui-panel-content")[0]):$("#layout_"+this.name+"_panel_"+r.type+" > .w2ui-panel-content").html(r.content);var s=$(this.box).find("#layout_"+this.name+"_panel_"+r.type+" .w2ui-panel-tabs");r.tabs!=null?s.find("[name="+r.tabs.name+"]").length==0?s.w2render(r.tabs):r.tabs.refresh():s.html("").removeClass("w2ui-tabs").hide();var s=$(this.box).find("#layout_"+this.name+"_panel_"+r.type+" .w2ui-panel-toolbar");r.toolbar!=null?s.find("[name="+r.toolbar.name+"]").length==0?s.w2render(r.toolbar):r.toolbar.refresh():s.html("").removeClass("w2ui-toolbar").hide()}else{if($("#layout_"+this.name+"_panel_main").length<=0){this.render();return}this.resize();for(var r in this.panels)this.refresh(this.panels[r].type)}return this.trigger($.extend(n,{phase:"after"})),(new Date).getTime()-t},resize:function(){window.getSelection&&window.getSelection().removeAllRanges();if(!this.box)return!1;var e=(new Date).getTime(),t=this.trigger({phase:"before",type:"resize",target:this.name,panel:this.tmp_resizing});if(t.stop===!0)return!1;this.padding<0&&(this.padding=0);var n=parseInt($(this.box).width()),r=parseInt($(this.box).height());$(this.box).find(" > div").css({width:n+"px",height:r+"px"});var i=this,s=this.get("main"),o=this.get("preview"),u=this.get("left"),a=this.get("right"),f=this.get("top"),l=this.get("bottom"),c=!0,h=o!=null&&o.hidden!=1?!0:!1,p=u!=null&&u.hidden!=1?!0:!1,d=a!=null&&a.hidden!=1?!0:!1,v=f!=null&&f.hidden!=1?!0:!1,m=l!=null&&l.hidden!=1?!0:!1;for(var g in{top:"",left:"",right:"",bottom:"",preview:""}){var y=this.get(g),b=String(y.size);if(y&&b.substr(b.length-1)=="%"){var w=r;y.type=="preview"&&(w=w-(f&&!f.hidden?f.sizeCalculated:0)-(l&&!l.hidden?l.sizeCalculated:0)),y.sizeCalculated=(y.type=="left"||y.type=="right"?n:w)*parseInt(y.size)/100}else y.sizeCalculated=parseInt(y.size);y.sizeCalculated<parseInt(y.minSize)&&(y.sizeCalculated=parseInt(y.minSize))}if(f!=null&&f.hidden!=1){var E=0,S=0,x=n,T=f.sizeCalculated;$("#layout_"+this.name+"_panel_top").css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px"}).show(),f.width=x,f.height=T,f.resizable&&(S=f.sizeCalculated-(this.padding==0?this.resizer:0),T=this.resizer>this.padding?this.resizer:this.padding,$("#layout_"+this.name+"_resizer_top").show().css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px",cursor:"ns-resize"}).bind("mousedown",function(e){return w2ui[i.name].startResize("top",e),!1}))}else $("#layout_"+this.name+"_panel_top").hide();if(u!=null&&u.hidden!=1){var E=0,S=0+(v?f.sizeCalculated+this.padding:0),x=u.sizeCalculated,T=r-(v?f.sizeCalculated+this.padding:0)-(m?l.sizeCalculated+this.padding:0),N=$("#layout_"+this.name+"_panel_left");window.navigator.userAgent.indexOf("MSIE")>0&&N.length>0&&N[0].clientHeight<N[0].scrollHeight&&(x+=17),$("#layout_"+this.name+"_panel_left").css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px"}).show(),u.width=x,u.height=T,u.resizable&&(E=u.sizeCalculated-(this.padding==0?this.resizer:0),x=this.resizer>this.padding?this.resizer:this.padding,$("#layout_"+this.name+"_resizer_left").show().css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px",cursor:"ew-resize"}).bind("mousedown",function(e){return w2ui[i.name].startResize("left",e),!1}))}else $("#layout_"+this.name+"_panel_left").hide(),$("#layout_"+this.name+"_resizer_left").hide();if(a!=null&&a.hidden!=1){var E=n-a.sizeCalculated,S=0+(v?f.sizeCalculated+this.padding:0),x=a.sizeCalculated,T=r-(v?f.sizeCalculated+this.padding:0)-(m?l.sizeCalculated+this.padding:0);$("#layout_"+this.name+"_panel_right").css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px"}).show(),a.width=x,a.height=T,a.resizable&&(E-=this.padding,x=this.resizer>this.padding?this.resizer:this.padding,$("#layout_"+this.name+"_resizer_right").show().css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px",cursor:"ew-resize"}).bind("mousedown",function(e){return w2ui[i.name].startResize("right",e),!1}))}else $("#layout_"+this.name+"_panel_right").hide();if(l!=null&&l.hidden!=1){var E=0,S=r-l.sizeCalculated,x=n,T=l.sizeCalculated;$("#layout_"+this.name+"_panel_bottom").css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px"}).show(),l.width=x,l.height=T,l.resizable&&(S-=this.padding==0?0:this.padding,T=this.resizer>this.padding?this.resizer:this.padding,$("#layout_"+this.name+"_resizer_bottom").show().css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px",cursor:"ns-resize"}).bind("mousedown",function(e){return w2ui[i.name].startResize("bottom",e),!1}))}else $("#layout_"+this.name+"_panel_bottom").hide();var E=0+(p?u.sizeCalculated+this.padding:0),S=0+(v?f.sizeCalculated+this.padding:0),x=n-(p?u.sizeCalculated+this.padding:0)-(d?a.sizeCalculated+this.padding:0),T=r-(v?f.sizeCalculated+this.padding:0)-(m?l.sizeCalculated+this.padding:0)-(h?o.sizeCalculated+this.padding:0),N=$("#layout_"+this.name+"_panel_main");window.navigator.userAgent.indexOf("MSIE")>0&&N.length>0&&N[0].clientHeight<N[0].scrollHeight&&(x+=17),$("#layout_"+this.name+"_panel_main").css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px"}),s.width=x,s.height=T;if(o!=null&&o.hidden!=1){var E=0+(p?u.sizeCalculated+this.padding:0),S=r-(m?l.sizeCalculated+this.padding:0)-o.sizeCalculated,x=n-(p?u.sizeCalculated+this.padding:0)-(d?a.sizeCalculated+this.padding:0),T=o.sizeCalculated,N=$("#layout_"+this.name+"_panel_preview");window.navigator.userAgent.indexOf("MSIE")>0&&N.length>0&&N[0].clientHeight<N[0].scrollHeight&&(x+=17),$("#layout_"+this.name+"_panel_preview").css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px"}).show(),o.width=x,o.height=T,o.resizable&&(S-=this.padding==0?0:this.padding,T=this.resizer>this.padding?this.resizer:this.padding,$("#layout_"+this.name+"_resizer_preview").show().css({display:"block",left:E+"px",top:S+"px",width:x+"px",height:T+"px",cursor:"ns-resize"}).bind("mousedown",function(e){return w2ui[i.name].startResize("preview",e),!1}))}else $("#layout_"+this.name+"_panel_preview").hide();for(var g in{top:"",left:"",main:"",preview:"",right:"",bottom:""}){var C=this.get(g),y="#layout_"+this.name+"_panel_"+g+" > .w2ui-panel-",r=0;C.tabs!=null&&(w2ui[this.name+"_"+g+"_tabs"]&&w2ui[this.name+"_"+g+"_tabs"].resize(),r+=w2utils.getSize($(y+"tabs").css({display:"block"}),"height")),C.toolbar!=null&&(w2ui[this.name+"_"+g+"_toolbar"]&&w2ui[this.name+"_"+g+"_toolbar"].resize(),r+=w2utils.getSize($(y+"toolbar").css({top:r+"px",display:"block"}),"height")),$(y+"content").css({display:"block"}).css({top:r+"px"})}var i=this;return clearTimeout(this._resize_timer),this._resize_timer=setTimeout(function(){for(var e in w2ui)typeof w2ui[e].resize=="function"&&typeof w2ui[e].panels=="undefined"&&w2ui[e].resize()},100),this.trigger($.extend(t,{phase:"after"})),(new Date).getTime()-e},destroy:function(){var e=this.trigger({phase:"before",type:"destroy",target:this.name});return e.stop===!0?!1:typeof w2ui[this.name]=="undefined"?!1:($(this.box).find("#layout_"+this.name+"_panel_main").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-layout").html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"})),$(window).off("resize",this.events.resize),$(document).off("mousemove",this.events.mousemove),$(document).off("mouseup",this.events.mouseup),!0)},initEvents:function(){var e=this;this.events={resize:function(t){w2ui[e.name].resize()},mousemove:function(t){w2ui[e.name].doResize(t)},mouseup:function(t){w2ui[e.name].stopResize(t)}},$(window).on("resize",this.events.resize),$(document).on("mousemove",this.events.mousemove),$(document).on("mouseup",this.events.mouseup)},startResize:function(e,t){if(!this.box)return;t||(t=window.event),window.addEventListener||window.document.attachEvent("onselectstart",function(){return!1}),this.tmp_resizing=e,this.tmp_x=t.screenX,this.tmp_y=t.screenY,this.tmp_div_x=0,this.tmp_div_y=0;if(e=="left"||e=="right")this.tmp_value=parseInt($("#layout_"+this.name+"_resizer_"+e)[0].style.left);if(e=="top"||e=="preview"||e=="bottom")this.tmp_value=parseInt($("#layout_"+this.name+"_resizer_"+e)[0].style.top)},doResize:function(e){if(!this.box)return;e||(e=window.event);if(typeof this.tmp_resizing=="undefined")return;var t=this.get(this.tmp_resizing),n=this.trigger({phase:"before",type:"resizing",target:this.tmp_resizing,object:t,event:e});if(n.stop===!0)return!1;var r=$("#layout_"+this.name+"_resizer_"+this.tmp_resizing);r.hasClass("active")||r.addClass("active"),this.tmp_div_x=e.screenX-this.tmp_x,this.tmp_div_y=e.screenY-this.tmp_y,this.tmp_resizing=="left"&&this.get("left").minSize-this.tmp_div_x>this.get("left").width&&(this.tmp_div_x=this.get("left").minSize-this.get("left").width),this.tmp_resizing=="left"&&this.get("main").minSize+this.tmp_div_x>this.get("main").width&&(this.tmp_div_x=this.get("main").width-this.get("main").minSize),this.tmp_resizing=="right"&&this.get("right").minSize+this.tmp_div_x>this.get("right").width&&(this.tmp_div_x=this.get("right").width-this.get("right").minSize),this.tmp_resizing=="right"&&this.get("main").minSize-this.tmp_div_x>this.get("main").width&&(this.tmp_div_x=this.get("main").minSize-this.get("main").width),this.tmp_resizing=="top"&&this.get("top").minSize-this.tmp_div_y>this.get("top").height&&(this.tmp_div_y=this.get("top").minSize-this.get("top").height),this.tmp_resizing=="top"&&this.get("main").minSize+this.tmp_div_y>this.get("main").height&&(this.tmp_div_y=this.get("main").height-this.get("main").minSize),this.tmp_resizing=="bottom"&&this.get("bottom").minSize+this.tmp_div_y>this.get("bottom").height&&(this.tmp_div_y=this.get("bottom").height-this.get("bottom").minSize),this.tmp_resizing=="bottom"&&this.get("main").minSize-this.tmp_div_y>this.get("main").height&&(this.tmp_div_y=this.get("main").minSize-this.get("main").height),this.tmp_resizing=="preview"&&this.get("preview").minSize+this.tmp_div_y>this.get("preview").height&&(this.tmp_div_y=this.get("preview").height-this.get("preview").minSize),this.tmp_resizing=="preview"&&this.get("main").minSize-this.tmp_div_y>this.get("main").height&&(this.tmp_div_y=this.get("main").minSize-this.get("main").height);switch(this.tmp_resizing){case"top":case"preview":case"bottom":this.tmp_div_x=0,r.length>0&&(r[0].style.top=this.tmp_value+this.tmp_div_y+"px");break;case"left":case"right":this.tmp_div_y=0,r.length>0&&(r[0].style.left=this.tmp_value+this.tmp_div_x+"px")}this.trigger($.extend(n,{phase:"after"}))},stopResize:function(e){if(!this.box)return;e||(e=window.event),window.addEventListener||window.document.attachEvent("onselectstart",function(){return!1});if(typeof this.tmp_resizing=="undefined")return;var t=this.get("top"),n=this.get("bottom"),r=this.get(this.tmp_resizing),i=parseInt($(this.box).height()),s=parseInt($(this.box).width()),o=String(r.size);switch(this.tmp_resizing){case"top":var u=parseInt(r.sizeCalculated)+this.tmp_div_y,a=0;break;case"bottom":var a=0;case"preview":var a=(t&&!t.hidden?t.sizeCalculated:0)+(n&&!n.hidden?n.sizeCalculated:0),u=parseInt(r.sizeCalculated)-this.tmp_div_y;break;case"left":var u=parseInt(r.sizeCalculated)+this.tmp_div_x,a=0;break;case"right":var u=parseInt(r.sizeCalculated)-this.tmp_div_x,a=0}o.substr(o.length-1)=="%"?r.size=Math.floor(u*100/(r.type=="left"||r.type=="right"?s:i-a)*100)/100+"%":r.size=u,this.resize(),$("#layout_"+this.name+"_resizer_"+this.tmp_resizing).removeClass("active"),delete this.tmp_resizing}},$.extend(e.prototype,$.w2event),w2obj.layout=e}(),function(){$.fn.w2popup=function(e,t){typeof e=="undefined"&&(t={},e="open"),$.isPlainObject(e)&&(t=e,e="open"),typeof t=="undefined"&&(t={});var n={};return $(this).length>0&&($(this).find("div[rel=title]").length>0&&(n.title=$(this).find("div[rel=title]").html()),$(this).find("div[rel=body]").length>0&&(n.body=$(this).find("div[rel=body]").html(),n.style=$(this).find("div[rel=body]")[0].style.cssText),$(this).find("div[rel=buttons]").length>0&&(n.buttons=$(this).find("div[rel=buttons]").html()),parseInt($(this).css("width"))!=0&&(n.width=parseInt($(this).css("width"))),parseInt($(this).css("height"))!=0&&(n.height=parseInt($(this).css("height")))),window.w2popup[e]($.extend({},n,t))},window.w2popup={defaults:{title:"",body:"",buttons:"",style:"",color:"#000",opacity:.4,speed:.3,modal:!1,maximized:!1,keyboard:!0,width:500,height:300,showClose:!0,showMax:!1,transition:null,onUnlock:null,onOpen:null,onChange:null,onBeforeClose:null,onClose:null,onMax:null,onMin:null},open:function(e){var t=$("#w2ui-popup").data("options"),e=$.extend({},this.defaults,{body:"",renderTime:0,onOpen:null,onChange:null,onBeforeClose:null,onClose:null},t,e);if(window.innerHeight==undefined){var n=document.documentElement.offsetWidth,r=document.documentElement.offsetHeight;w2utils.engine=="IE7"&&(n+=21,r+=4)}else var n=window.innerWidth,r=window.innerHeight;parseInt(n)-10<parseInt(e.width)&&(e.width=parseInt(n)-10),parseInt(r)-10<parseInt(e.height)&&(e.height=parseInt(r)-10);var i=(parseInt(r)-parseInt(e.height))/2*.6,s=(parseInt(n)-parseInt(e.width))/2;if($("#w2ui-popup").length==0){window.w2popup.lock($.extend({},e,{onMouseDown:e.modal?function(){$("#w2ui-lock").css({"-webkit-transition":".1s","-moz-transition":".1s","-ms-transition":".1s","-o-transition":".1s",opacity:"0.6"}),window.getSelection&&window.getSelection().removeAllRanges()}:null,onMouseUp:e.modal?function(){setTimeout(function(){$("#w2ui-lock").css({"-webkit-transition":".1s","-moz-transition":".1s","-ms-transition":".1s","-o-transition":".1s",opacity:e.opacity})},100),window.getSelection&&window.getSelection().removeAllRanges()}:function(){$().w2popup("close")},onClick:function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}}));var o='<div id="w2ui-popup" class="w2ui-popup" style="width: '+parseInt(e.width)+"px; height: "+parseInt(e.height)+"px; opacity: 0; "+"-webkit-transform: scale(0.8); -moz-transform: scale(0.8); -ms-transform: scale(0.8); -o-transform: scale(0.8); "+"left: "+s+"px; top: "+i+'px;">';e.title!=""&&(o+='<div class="w2ui-msg-title">'+(e.showClose?'<div class="w2ui-msg-button w2ui-msg-close" onclick="$().w2popup(\'close\'); if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">Close</div>':"")+(e.showMax?'<div class="w2ui-msg-button w2ui-msg-max" onclick="$().w2popup(\'toggle\')">Max</div>':"")+e.title+"</div>"),o+='<div class="w2ui-box1" style="'+(e.title==""?"top: 0px !important;":"")+(e.buttons==""?"bottom: 0px !important;":"")+'">',o+='<div class="w2ui-msg-body'+(!e.title!=""?" w2ui-msg-no-title":"")+(!e.buttons!=""?" w2ui-msg-no-buttons":"")+'" style="'+e.style+'">'+e.body+"</div>",o+="</div>",o+='<div class="w2ui-box2" style="'+(e.title==""?"top: 0px !important;":"")+(e.buttons==""?"bottom: 0px !important;":"")+'">',o+='<div class="w2ui-msg-body'+(!e.title!=""?" w2ui-msg-no-title":"")+(!e.buttons!=""?" w2ui-msg-no-buttons":"")+'" style="'+e.style+'"></div>',o+="</div>",e.buttons!=""&&(o+='<div class="w2ui-msg-buttons">'+e.buttons+"</div>"),o+="</div>",$("body").append(o),setTimeout(function(){$("#w2ui-popup .w2ui-box2").hide(),$("#w2ui-popup").css({"-webkit-transition":e.speed+"s opacity, "+e.speed+"s -webkit-transform","-webkit-transform":"scale(1)","-moz-transition":e.speed+"s opacity, "+e.speed+"s -moz-transform","-moz-transform":"scale(1)","-ms-transition":e.speed+"s opacity, "+e.speed+"s -ms-transform","-ms-transform":"scale(1)","-o-transition":e.speed+"s opacity, "+e.speed+"s -o-transform","-o-transform":"scale(1)",opacity:"1"})},1),setTimeout(function(){$("#w2ui-popup").css({"-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":""}),typeof e.onOpen=="function"&&setTimeout(function(){e.onOpen()},1)},e.speed*1e3)}else{if(typeof t=="undefined"||t["width"]!=e["width"]||t["height"]!=e["height"])$("#w2ui-panel").remove(),window.w2popup.resize(e.width,e.height);var u=$("#w2ui-popup .w2ui-box2 > .w2ui-msg-body").html(e.body);u.length>0&&(u[0].style.cssText=e.style),$("#w2ui-popup .w2ui-msg-buttons").html(e.buttons),$("#w2ui-popup .w2ui-msg-title").html((e.showClose?'<div class="w2ui-msg-button w2ui-msg-close" onclick="$().w2popup(\'close\')">Close</div>':"")+(e.showMax?'<div class="w2ui-msg-button w2ui-msg-max" onclick="$().w2popup(\'max\')">Max</div>':"")+e.title);var a=$("#w2ui-popup .w2ui-box1")[0],f=$("#w2ui-popup .w2ui-box2")[0];w2utils.transition(a,f,e.transition),f.className="w2ui-box1",a.className="w2ui-box2",$(f).addClass("w2ui-current-box"),$("#w2ui-popup").data("prev-size",null),setTimeout(function(){typeof e.onChange=="function"&&e.onChange()},1)}return $("#w2ui-popup").data("options",e),e.keyboard&&$(document).on("keydown",this.doKeydown),this.initMove(),this},doKeydown:function(e){var t=$("#w2ui-popup").data("options");if(!t.keyboard)return;switch(e.keyCode){case 27:if(t.modal===!0){$("#w2ui-lock").css({opacity:"0.6"}),setTimeout(function(){$("#w2ui-lock").css({opacity:t.opacity})},400);return}$().w2popup("close")}},close:function(e){var e=$.extend({},$("#w2ui-popup").data("options"),e);if(typeof e.onBeforeClose=="function"&&e.onBeforeClose()===!1)return;$("#w2ui-popup, #w2ui-panel").css({"-webkit-transition":e.speed+"s opacity, "+e.speed+"s -webkit-transform","-webkit-transform":"scale(0.9)","-moz-transition":e.speed+"s opacity, "+e.speed+"s -moz-transform","-moz-transform":"scale(0.9)","-ms-transition":e.speed+"s opacity, "+e.speed+"s -ms-transform","-ms-transform":"scale(0.9)","-o-transition":e.speed+"s opacity, "+e.speed+"s -o-transform","-o-transform":"scale(0.9)",opacity:"0"}),window.w2popup.unlock({opacity:0,onFinish:e.onFinish?e.onFinish:null}),setTimeout(function(){$("#w2ui-popup").remove(),$("#w2ui-panel").remove()},e.speed*1e3),typeof e.onClose=="function"&&e.onClose(),e.keyboard&&$(document).off("keydown",this.doKeydown)},toggle:function(){var e=$("#w2ui-popup").data("options");e.maximized===!0?$().w2popup("min"):$().w2popup("max")},max:function(){var e=$("#w2ui-popup").data("options");if(e.maximized===!0)return;window.w2popup.resize(1e4,1e4,function(){typeof e.onMax=="function"&&e.onMax()}),e.maximized=!0,e.prevSize=$("#w2ui-popup").css("width")+":"+$("#w2ui-popup").css("height"),$("#w2ui-popup").data("options",e)},min:function(){var e=$("#w2ui-popup").data("options");if(e.maximized!==!0)return;var t=e.prevSize.split(":");window.w2popup.resize(t[0],t[1],function(){typeof e.onMin=="function"&&e.onMin()}),e.maximized=!1,e.prevSize=null,$("#w2ui-popup").data("options",e)},get:function(){return $("#w2ui-popup").data("options")},set:function(e){$().w2popup("open",e)},clear:function(){$("#w2ui-popup .w2ui-msg-title").html(""),$("#w2ui-popup .w2ui-msg-body").html(""),$("#w2ui-popup .w2ui-msg-buttons").html("")},reset:function(){window.w2popup.open(window.w2popup.defaults)},load:function(e){function s(t,n){$("body").append('<div id="w2ui-tmp" style="display: none">'+t+"</div>"),typeof n!="undefined"&&$("#w2ui-tmp #"+n).length>0?$("#w2ui-tmp #"+n).w2popup(e):$("#w2ui-tmp > div").w2popup(e);if($("#w2ui-tmp > style").length>0){var r=$("<div>").append($("#w2ui-tmp > style").clone()).html();$("#w2ui-popup #div-style").length==0&&$("#w2ui-ppopup").append('<div id="div-style" style="position: absolute; left: -100; width: 1px"></div>'),$("#w2ui-popup #div-style").html(r)}$("#w2ui-tmp").remove()}if(String(e.url)=="undefined"){console.log("ERROR: The url parameter is empty.");return}var t=String(e.url).split("#"),n=t[0],r=t[1];String(e)=="undefined"&&(e={});var i=$("#w2ui-popup").data(n);typeof i!="undefined"&&i!=null?s(i,r):$.get(n,function(e,t,i){s(i.responseText,r),$("#w2ui-popup").data(n,i.responseText)})},message:function(e){$().w2tag(),parseInt(e.width)<10&&(e.width=10),parseInt(e.height)<10&&(e.height=10),typeof e.hideOnClick=="undefined"&&(e.hideOnClick=!0);var t=$("#w2ui-popup .w2ui-msg-title");if($("#w2ui-popup .w2ui-popup-message").length==0){var n=parseInt($("#w2ui-popup").width());$("#w2ui-popup .w2ui-box1").before('<div class="w2ui-popup-message" style="display: none; '+(t.length==0?"top: 0px;":"top: "+w2utils.getSize(t,"height")+"px;")+(typeof e.width!="undefined"?"width: "+e.width+"px; left: "+(n-e.width)/2+"px;":"left: 10px; right: 10px;")+(typeof e.height!="undefined"?"height: "+e.height+"px;":"bottom: 6px;")+'-webkit-transition: .3s; -moz-transition: .3s; -ms-transition: .3s; -o-transition: .3s;"'+(e.hideOnClick===!0?"onclick=\"$().w2popup('message');\"":"")+">"+"</div>")}else typeof e.width=="undefined"&&(e.width=w2utils.getSize($("#w2ui-popup .w2ui-popup-message"),"width")),typeof e.height=="undefined"&&(e.height=w2utils.getSize($("#w2ui-popup .w2ui-popup-message"),"height"));var r=$("#w2ui-popup .w2ui-popup-message").css("display");$("#w2ui-popup .w2ui-popup-message").css({"-webkit-transform":r=="none"?"translateY(-"+e.height+"px)":"translateY(0px)","-moz-transform":r=="none"?"translateY(-"+e.height+"px)":"translateY(0px)","-ms-transform":r=="none"?"translateY(-"+e.height+"px)":"translateY(0px)","-o-transform":r=="none"?"translateY(-"+e.height+"px)":"translateY(0px)"}),r=="none"?($("#w2ui-popup .w2ui-popup-message").show().html(e.html),$("#w2ui-popup .w2ui-msg-buttons").fadeOut("slow"),typeof e.onOpen=="function"&&e.onOpen()):$("#w2ui-popup .w2ui-msg-buttons").fadeIn("slow"),setTimeout(function(){$("#w2ui-popup .w2ui-popup-message").css({"-webkit-transform":r=="none"?"translateY(0px)":"translateY(-"+e.height+"px)","-moz-transform":r=="none"?"translateY(0px)":"translateY(-"+e.height+"px)","-ms-transform":r=="none"?"translateY(0px)":"translateY(-"+e.height+"px)","-o-transform":r=="none"?"translateY(0px)":"translateY(-"+e.height+"px)"})},1),setTimeout(function(){r!="none"&&($("#w2ui-popup .w2ui-popup-message").remove(),typeof e.onClose=="function"&&e.onClose())},300)},lock:function(e){if($("#w2ui-lock").length>0)return!1;var e=$.extend({},{onUnlock:null,onMouseDown:null,onMouseUp:null},e);return $("body").append('<div id="w2ui-lock" 	onmousewheel="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; if (event.preventDefault) event.preventDefault(); else return false;"	style="position: '+(w2utils.engine=="IE5"?"absolute":"fixed")+"; z-Index: 1199; left: 0px; top: 0px; "+"		   padding: 0px; margin: 0px; background-color: "+e.color+'; width: 100%; height: 100%; opacity: 0;"></div>'),setTimeout(function(){$("#w2ui-lock").css({"-webkit-transition":e.speed+"s opacity","-moz-transition":e.speed+"s opacity","-ms-transition":e.speed+"s opacity","-o-transition":e.speed+"s opacity",opacity:e.opacity}),$("body, body *").css({})},1),typeof e.onMouseDown=="function"&&$("#w2ui-lock").bind("mousedown",e.onMouseDown),typeof e.onMouseUp=="function"&&$("#w2ui-lock").bind("mouseup",e.onMouseUp),!0},unlock:function(e){if($("#w2ui-lock").length==0)return!1;var e=$.extend({},$("#w2ui-popup").data("options"),e);return $("#w2ui-lock").css({"-webkit-transition":e.speed+"s opacity","-moz-transition":e.speed+"s opacity","-ms-transition":e.speed+"s opacity","-o-transition":e.speed+"s opacity",opacity:e.opacity}),$("body, body *").css({}),setTimeout(function(){$("#w2ui-lock").remove(),typeof e.onUnlock=="function"&&e.onUnlock()},e.speed*1e3),!0},initMove:function(){var e=this;$("#w2ui-popup .w2ui-msg-title").on("mousedown",function(){e.startMove.apply(e,arguments)}).on("mousemove",function(){e.doMove.apply(e,arguments)}).on("mouseup",function(){e.stopMove.apply(e,arguments)}),$("#w2ui-popup .w2ui-msg-body").on("mousemove",function(){e.doMove.apply(e,arguments)}).on("mouseup",function(){e.stopMove.apply(e,arguments)}),$("#w2ui-lock").on("mousemove",function(){e.doMove.apply(e,arguments)}).on("mouseup",function(){e.stopMove.apply(e,arguments)})},resize:function(e,t,n){var r=$("#w2ui-popup").data("options");parseInt($(window).width())-10<parseInt(e)&&(e=parseInt($(window).width())-10),parseInt($(window).height())-10<parseInt(t)&&(t=parseInt($(window).height())-10);var i=(parseInt($(window).height())-parseInt(t))/2*.8,s=(parseInt($(window).width())-parseInt(e))/2;$("#w2ui-popup").css({"-webkit-transition":r.speed+"s width, "+r.speed+"s height, "+r.speed+"s left, "+r.speed+"s top","-moz-transition":r.speed+"s width, "+r.speed+"s height, "+r.speed+"s left, "+r.speed+"s top","-ms-transition":r.speed+"s width, "+r.speed+"s height, "+r.speed+"s left, "+r.speed+"s top","-o-transition":r.speed+"s width, "+r.speed+"s height, "+r.speed+"s left, "+r.speed+"s top",top:i,left:s,width:e,height:t}),typeof n=="function"&&setTimeout(function(){n()},r.speed*1e3)},startMove:function(e){e||(e=window.event),window.addEventListener||window.document.attachEvent("onselectstart",function(){return!1}),this.resizing=!0,this.tmp_x=e.screenX,this.tmp_y=e.screenY,e.stopPropagation?e.stopPropagation():e.cancelBubble=!0;if(!e.preventDefault)return!1;e.preventDefault()},doMove:function(e){if(this.resizing!=1)return;e||(e=window.event),this.tmp_div_x=e.screenX-this.tmp_x,this.tmp_div_y=e.screenY-this.tmp_y,$("#w2ui-popup").css({"-webkit-transition":"none","-webkit-transform":"translate3d("+this.tmp_div_x+"px, "+this.tmp_div_y+"px, 0px)","-moz-transition":"none","-moz-transform":"translate("+this.tmp_div_x+"px, "+this.tmp_div_y+"px)","-ms-transition":"none","-ms-transform":"translate("+this.tmp_div_x+"px, "+this.tmp_div_y+"px)","-o-transition":"none","-o-transform":"translate("+this.tmp_div_x+"px, "+this.tmp_div_y+"px)"}),$("#w2ui-panel").css({"-webkit-transition":"none","-webkit-transform":"translate3d("+this.tmp_div_x+"px, "+this.tmp_div_y+"px, 0px)","-moz-transition":"none","-moz-transform":"translate("+this.tmp_div_x+"px, "+this.tmp_div_y+"px)","-ms-transition":"none","-ms-transform":"translate("+this.tmp_div_x+"px, "+this.tmp_div_y+"px","-o-transition":"none","-o-transform":"translate("+this.tmp_div_x+"px, "+this.tmp_div_y+"px)"})},stopMove:function(e){if(this.resizing!=1)return;e||(e=window.event),this.tmp_div_x=e.screenX-this.tmp_x,this.tmp_div_y=e.screenY-this.tmp_y,$("#w2ui-popup").css({"-webkit-transition":"none","-webkit-transform":"translate3d(0px, 0px, 0px)","-moz-transition":"none","-moz-transform":"translate(0px, 0px)","-ms-transition":"none","-ms-transform":"translate(0px, 0px)","-o-transition":"none","-o-transform":"translate(0px, 0px)",left:parseInt($("#w2ui-popup").css("left"))+parseInt(this.tmp_div_x)+"px",top:parseInt($("#w2ui-popup").css("top"))+parseInt(this.tmp_div_y)+"px"}),$("#w2ui-panel").css({"-webkit-transition":"none","-webkit-transform":"translate3d(0px, 0px, 0px)","-moz-transition":"none","-moz-transform":"translate(0px, 0px)","-ms-transition":"none","-ms-transform":"translate(0px, 0px)","-o-transition":"none","-o-transform":"translate(0px, 0px)",left:parseInt($("#w2ui-panel").css("left"))+parseInt(this.tmp_div_x)+"px",top:parseInt($("#w2ui-panel").css("top"))+parseInt(this.tmp_div_y)+"px"}),delete this.resizing}},window.w2alert=function(e,t){typeof t=="undefined"&&(t=w2utils.lang("Notification")),$().w2popup({width:450,height:200,title:t,body:'<div class="w2ui-alert-body">'+e+"</div>",buttons:'<input type="button" value="'+w2utils.lang("Ok")+'" class="w2ui-alert-button" onclick="$().w2popup(\'close\');">'})},window.w2confirm=function(e,t,n){if(typeof n=="undefined"||typeof t=="function"
)n=t,t=w2utils.lang("Confirmation");typeof t=="undefined"&&(t=w2utils.lang("Confirmation")),$().w2popup({width:450,height:200,title:t,modal:!0,showClose:!1,body:'<div class="w2ui-confirm-body">'+e+"</div>",buttons:'<input id="buttonNo" type="button" value="'+w2utils.lang("No")+'" class="w2ui-confirm-button">&nbsp;'+'<input id="buttonYes" type="button" value="'+w2utils.lang("Yes")+'" class="w2ui-confirm-button">'}),$("#w2ui-popup #buttonNo").on("click",function(){$().w2popup("close"),typeof n=="function"&&n("No")}),$("#w2ui-popup #buttonYes").on("click",function(){$().w2popup("close"),typeof n=="function"&&n("Yes")})}}(),function(){var e=function(e){this.box=null,this.name=null,this.active=null,this.tabs=[],this.right="",this.style="",this.onClick=null,this.onClose=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,$.extend(!0,this,e,w2obj.tabs)};$.fn.w2tabs=function(t){if(typeof t=="object"||!t){if(!t||typeof t.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2tabs().');return}if(typeof w2ui[t.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+t.name+").");return}if(!w2utils.isAlphaNumeric(t.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=t.tabs,r=new e(t);$.extend(r,{tabs:[],handlers:[]});for(var i in n)r.tabs[i]=$.extend({},e.prototype.tab,n[i]);return $(this).length!=0&&r.render($(this)[0]),w2ui[r.name]=r,r}if(w2ui[$(this).attr("name")]){var s=w2ui[$(this).attr("name")];return s[t].apply(s,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+t+" does not exist on jQuery.w2tabs")},e.prototype={tab:{id:null,text:"",hidden:!1,disabled:!1,closable:!1,hint:"",onClick:null,onRefresh:null,onClose:null},add:function(e){return this.insert(null,e)},insert:function(e,t){$.isArray(t)||(t=[t]);for(var n in t){if(String(t[n].id)=="undefined"){console.log('ERROR: The parameter "id" is required but not supplied. (obj: '+this.name+")");return}var r=!0;for(var i in this.tabs)if(this.tabs[i].id==t[n].id){r=!1;break}if(!r){console.log('ERROR: The parameter "id='+t[n].id+'" is not unique within the current tabs. (obj: '+this.name+")");return}if(!w2utils.isAlphaNumeric(t[n].id)){console.log('ERROR: The parameter "id='+t[n].id+'" must be alpha-numeric + "-_". (obj: '+this.name+")");return}var t=$.extend({},t,t[n]);if(e==null||typeof e=="undefined")this.tabs.push(t);else{var s=this.get(e,!0);this.tabs=this.tabs.slice(0,s).concat([t],this.tabs.slice(s))}this.refresh(t[n].id)}},remove:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)return!1;t++,this.tabs.splice(this.get(r.id,!0),1),$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(r.id)).remove()}return t},select:function(e){return this.get(e)==null||this.active==e?!1:(this.active=e,this.refresh(),!0)},set:function(e,t){var n=this.get(e,!0);return n==null?!1:($.extend(this.tabs[n],t),this.refresh(e),!0)},get:function(e,t){for(var n in this.tabs)if(this.tabs[n].id==e)return t===!0?n:this.tabs[n];return null},show:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(!n||n.hidden===!1)continue;n.hidden=!1,this.refresh(n.id),e++}return e},hide:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(!n||n.hidden===!0)continue;n.hidden=!0,this.refresh(n.id),e++}return e},enable:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r||r.disabled===!1)continue;r.disabled=!1,this.refresh(r.id),t++}return t},disable:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r||r.disabled===!0)continue;r.disabled=!0,this.refresh(r.id),t++}return t},refresh:function(e){window.getSelection&&window.getSelection().removeAllRanges();if(String(e)=="undefined")for(var t in this.tabs)this.refresh(this.tabs[t].id);var n=this.trigger({phase:"before",type:"refresh",target:typeof e!="undefined"?e:this.name,tab:this.get(e)});if(n.stop===!0)return!1;var r=this.get(e);if(r==null)return;typeof r.caption!="undefined"&&(r.text=r.caption);var i=$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(r.id)),s=(r.closable?'<div class="w2ui-tab-close" onclick="w2ui[\''+this.name+"'].doClose('"+r.id+"', event);\"></div>":"")+'	<div class="w2ui-tab'+(this.active==r.id?" active":"")+(r.closable?" closable":"")+'" '+'		title="'+(typeof r.hint!="undefined"?r.hint:"")+'"'+"		onclick=\"w2ui['"+this.name+"'].doClick('"+r.id+"', event);\">"+r.text+"</div>";if(i.length==0){var o="";r.hidden&&(o+="display: none;"),r.disabled&&(o+="opacity: 0.2; -moz-opacity: 0.2; -webkit-opacity: 0.2; -o-opacity: 0.2; filter:alpha(opacity=20);"),html='<td id="tabs_'+this.name+"_tab_"+r.id+'" style="'+o+'" valign="middle">'+s+"</td>",this.get(e,true)!=this.tabs.length-1&&$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(e,!0))+1].id)).length>0?$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(e,!0))+1].id)).before(html):$(this.box).find("#tabs_"+this.name+"_right").before(html)}else i.html(s),r.hidden?i.css("display","none"):i.css("display",""),r.disabled?i.css({opacity:"0.2","-moz-opacity":"0.2","-webkit-opacity":"0.2","-o-opacity":"0.2",filter:"alpha(opacity=20)"}):i.css({opacity:"1","-moz-opacity":"1","-webkit-opacity":"1","-o-opacity":"1",filter:"alpha(opacity=100)"});this.trigger($.extend(n,{phase:"after"}))},render:function(e){var t=this.trigger({phase:"before",type:"render",target:this.name,box:e});if(t.stop===!0)return!1;window.getSelection&&window.getSelection().removeAllRanges(),String(e)!="undefined"&&e!=null&&($(this.box).find("> table #tabs_"+this.name+"_right").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-tabs").html(""),this.box=e);if(!this.box)return;var n='<table cellspacing="0" cellpadding="1" width="100%">	<tr><td width="100%" id="tabs_'+this.name+'_right" align="right">'+this.right+"</td></tr>"+"</table>";$(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-tabs").html(n),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),this.trigger($.extend(t,{phase:"after"})),this.refresh()},resize:function(){window.getSelection&&window.getSelection().removeAllRanges();var e=this.trigger({phase:"before",type:"resize",target:this.name});if(e.stop===!0)return!1;this.trigger($.extend(e,{phase:"after"}))},destroy:function(){var e=this.trigger({phase:"before",type:"destroy",target:this.name});if(e.stop===!0)return!1;$(this.box).find("> table #tabs_"+this.name+"_right").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-tabs").html(""),delete w2ui[this.name],this.trigger($.extend({phase:"after"}))},doClick:function(e,t){var n=this.get(e);if(n==null||n.disabled)return!1;var r=this.trigger({phase:"before",type:"click",target:e,tab:this.get(e),event:t});if(r.stop===!0)return!1;$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.active)+" .w2ui-tab").removeClass("active"),this.active=n.id,this.trigger($.extend(r,{phase:"after"})),this.refresh(e)},doClose:function(e,t){var n=this.get(e);if(n==null||n.disabled)return!1;var r=this.trigger({phase:"before",type:"close",target:e,tab:this.get(e),event:t});if(r.stop===!0)return!1;var i=this;$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(n.id)).css({"-webkit-transition":".2s","-moz-transition":"2s","-ms-transition":".2s","-o-transition":".2s",opacity:"0"}),setTimeout(function(){var e=$(i.box).find("#tabs_"+i.name+"_tab_"+w2utils.escapeId(n.id)).width();$(i.box).find("#tabs_"+i.name+"_tab_"+w2utils.escapeId(n.id)).html('<div style="width: '+e+'px; -webkit-transition: .2s; -moz-transition: .2s; -ms-transition: .2s; -o-transition: .2s"></div>'),setTimeout(function(){$(i.box).find("#tabs_"+i.name+"_tab_"+w2utils.escapeId(n.id)).find(":first-child").css({width:"0px"})},50)},200),setTimeout(function(){i.remove(e)},450),this.trigger($.extend(r,{phase:"after"})),this.refresh()},doInsert:function(e,t){if(this.get(e)==null)return;if(!$.isPlainObject(t))return;var n=!0;for(var r in this.tabs)if(this.tabs[r].id==t.id){n=!1;break}if(!n){console.log('ERROR: The parameter "id='+t.id+'" is not unique within the current tabs. (obj: '+this.name+")");return}var i=$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(t.id));if(i.length!=0)return;typeof t.caption!="undefined"&&(t.text=t.caption);var s='<div id="_tmp_tabs" class="w2ui-reset w2ui-tabs" style="position: absolute; top: -1000px;"><table cellspacing="0" cellpadding="1" width="100%"><tr><td id="_tmp_simple_tab" style="" valign="middle">'+(t.closable?'<div class="w2ui-tab-close"></div>':"")+'	<div class="w2ui-tab '+(this.active==t.id?"active":"")+'">'+t.text+"</div>"+"</td></tr></table>"+"</div>";$("body").append(s),tabHTML='<div style="width: 1px; -webkit-transition: 0.2s; -moz-transition: 0.2s; -ms-transition: 0.2s; -o-transition: 0.2s;">&nbsp;</div>';var o="";t.hidden&&(o+="display: none;"),t.disabled&&(o+="opacity: 0.2; -moz-opacity: 0.2; -webkit-opacity: 0.2; -o-opacity: 0.2; filter:alpha(opacity=20);"),html='<td id="tabs_'+this.name+"_tab_"+t.id+'" style="'+o+'" valign="middle">'+tabHTML+"</td>",this.get(e,true)!=this.tabs.length&&$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(e,!0))].id)).length>0?$(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(this.tabs[parseInt(this.get(e,!0))].id)).before(html):$(this.box).find("#tabs_"+this.name+"_right").before(html);var u=this;setTimeout(function(){var e=$("#_tmp_simple_tab").width();$("#_tmp_tabs").remove(),$("#tabs_"+u.name+"_tab_"+w2utils.escapeId(t.id)+" > div").css("width",e+"px")},1),setTimeout(function(){u.insert(e,t)},200)}},$.extend(e.prototype,$.w2event),w2obj.tabs=e}(),function(){var e=function(e){this.box=null,this.name=null,this.items=[],this.right="",this.onClick=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,$.extend(!0,this,e,w2obj.toolbar)};$.fn.w2toolbar=function(t){if(typeof t=="object"||!t){if(!t||typeof t.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2toolbar().');return}if(typeof w2ui[t.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+t.name+").");return}if(!w2utils.isAlphaNumeric(t.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=t.items,r=new e(t);$.extend(r,{items:[],handlers:[]});for(var i in n)r.items[i]=$.extend({},e.prototype.item,n[i]);return $(this).length!=0&&r.render($(this)[0]),w2ui[r.name]=r,r}if(w2ui[$(this).attr("name")]){var s=w2ui[$(this).attr("name")];return s[t].apply(s,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+t+" does not exist on jQuery.w2toolbar")},e.prototype={item:{id:null,type:"button",text:"",html:"",img:null,icon:null,hidden:!1,disabled:!1,checked:!1,arrow:!0,hint:"",group:null,items:null,onClick:null},add:function(e){this.insert(null,e)},insert:function(t,n){$.isArray(n)||(n=[n]);for(var r in n){if(typeof n[r].type=="undefined"){console.log('ERROR: The parameter "type" is required but not supplied in w2toolbar.add() method.');return}if($.inArray(String(n[r].type),["button","check","radio","drop","menu","break","html","spacer"])==-1){console.log('ERROR: The parameter "type" should be one of the following [button, check, radio, drop, menu, break, html, spacer] in w2toolbar.add() method.');return}if(typeof n[r].id=="undefined"){console.log('ERROR: The parameter "id" is required but not supplied in w2toolbar.add() method.');return}var i=!0;for(var s=0;s<this.items.length;s++)if(this.items[s].id==n[r].id){i=!1;return}if(!i){console.log('ERROR: The parameter "id" is not unique within the current toolbar.');return}if(!w2utils.isAlphaNumeric(n[r].id)){console.log('ERROR: The parameter "id" must be alpha-numeric + "-_".');return}var o=$.extend({},e.prototype.item,n[r]);if(t==null||typeof t=="undefined")this.items.push(o);else{var u=this.get(t,!0);this.items=this.items.slice(0,u).concat([o],this.items.slice(u))}this.refresh(o.id)}},remove:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,$(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(r.id)).remove();var i=this.get(r.id,!0);i&&this.items.splice(i,1)}return t},set:function(e,t){var n=this.get(e,!0);return n==null?!1:($.extend(this.items[n],t),this.refresh(e),!0)},get:function(e,t){for(var n=0;n<this.items.length;n++)if(this.items[n].id==e)return t===!0?n:this.items[n];return null},show:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,r.hidden=!1,this.refresh(r.id)}return t},hide:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,r.hidden=!0,this.refresh(r.id)}return t},enable:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,r.disabled=!1,this.refresh(r.id)}return t},disable:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,r.disabled=!0,this.refresh(r.id)}return t},check:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,r.checked=!0,this.refresh(r.id)}return t},uncheck:function(e){var t=0;for(var n=0;n<arguments.length;n++){var r=this.get(arguments[n]);if(!r)continue;t++,r.checked=!1,this.refresh(r.id)}return t},render:function(e){var t=this.trigger({phase:"before",type:"render",target:this.name,box:e});if(t.stop===!0)return!1;typeof e!="undefined"&&e!=null&&($(this.box).find("> table #tb_"+this.name+"_right").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-toolbar").html(""),this.box=e);if(!this.box)return;var n='<table cellspacing="0" cellpadding="0" width="100%"><tr>';for(var r=0;r<this.items.length;r++){var i=this.items[r];if(i==null)continue;i.type=="spacer"?n+='<td width="100%" id="tb_'+this.name+"_item_"+i.id+'" align="right"></td>':n+='<td id="tb_'+this.name+"_item_"+i.id+'" style="'+(i.hidden?"display: none":"")+'" '+'	class="'+(i.disabled?"disabled":"")+'" valign="middle">'+this.getItemHTML(i)+"</td>"}n+='<td width="100%" id="tb_'+this.name+'_right" align="right">'+this.right+"</td>",n+="</tr></table>",$(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-toolbar").html(n),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),this.trigger($.extend({phase:"after"}))},refresh:function(e){window.getSelection&&window.getSelection().removeAllRanges();var t=this.trigger({phase:"before",type:"refresh",target:typeof e!="undefined"?e:this.name,item:this.get(e)});if(t.stop===!0)return!1;if(typeof e=="undefined")for(var n=0;n<this.items.length;n++){if(typeof this.items[n].id=="undefined"){console.log("ERROR: Cannot refresh toolbar element with no id.");continue}this.refresh(this.items[n].id)}var r=this.get(e);if(r==null)return;var i=$(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(r.id)),s=this.getItemHTML(r);i.length==0?(s='<td id="tb_'+this.name+"_item_"+r.id+'" style="'+(r.hidden?"display: none":"")+'" '+'	class="'+(r.disabled?"disabled":"")+'" valign="middle">'+s+"</td>",this.get(e,true)==this.items.length-1?$(this.box).find("#tb_"+this.name+"_right").before(s):$(this.box).find("#tb_"+this.name+"_item_"+w2utils.escapeId(this.items[parseInt(this.get(e,!0))+1].id)).before(s)):(i.html(s),r.hidden?i.css("display","none"):i.css("display",""),r.disabled?i.addClass("disabled"):i.removeClass("disabled")),this.trigger($.extend({phase:"after"}))},resize:function(){window.getSelection&&window.getSelection().removeAllRanges();var e=this.trigger({phase:"before",type:"resize",target:this.name});if(e.stop===!0)return!1;this.trigger($.extend({phase:"after"}))},destroy:function(){var e=this.trigger({phase:"before",type:"destroy",target:this.name});if(e.stop===!0)return!1;$(this.box).find("> table #tb_"+this.name+"_right").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-toolbar").html(""),$(this.box).html(""),delete w2ui[this.name],this.trigger($.extend({phase:"after"}))},getMenuHTML:function(e){var t='<table cellspacing="0" cellpadding="0" class="w2ui-toolbar-drop">';for(var n=0;n<e.items.length;n++){var r=e.items[n];if(typeof r=="string"){var i=r.split("|");r={id:i[0],text:i[0],img:null,icon:null},i[1]&&(r.text=i[1]),i[2]&&(r.img=i[2]),i[3]&&(r.icon=i[3])}else typeof r.text!="undefined"&&typeof r.id=="undefined"&&(r.id=r.text),typeof r.text=="undefined"&&typeof r.id!="undefined"&&(r.text=r.id),typeof r.caption!="undefined"&&(r.text=r.caption),typeof r.img=="undefined"&&(r.img=null),typeof r.icon=="undefined"&&(r.icon=null);var s="<td>&nbsp;</td>";r.img&&(s='<td><div class="w2ui-tb-image w2ui-icon '+r.img+'"></div></td>'),r.icon&&(s='<td align="center"><div class="w2ui-tb-image"><span class="'+r.icon+'"></span></div></td>'),t+="<tr onmouseover=\"$(this).addClass('w2ui-selected');\" onmouseout=\"$(this).removeClass('w2ui-selected');\" 		onclick=\"$(document).click(); w2ui['"+this.name+"'].doMenuClick('"+e.id+"', event, '"+n+"');\">"+s+"	<td>"+r.text+"</td>"+"</tr>"}return t+="</table>",t},getItemHTML:function(e){var t="";typeof e.caption!="undefined"&&(e.text=e.caption),typeof e.hint=="undefined"&&(e.hint=""),typeof e.text=="undefined"&&(e.text="");switch(e.type){case"menu":e.html=this.getMenuHTML(e);case"button":case"check":case"radio":case"drop":var n="<td>&nbsp;</td>";e.img&&(n='<td><div class="w2ui-tb-image w2ui-icon '+e.img+'"></div></td>'),e.icon&&(n='<td><div class="w2ui-tb-image"><span class="'+e.icon+'"></span></div></td>'),t+='<table cellpadding="0" cellspacing="0" title="'+e.hint+'" class="w2ui-button '+(e.checked?"checked":"")+'" '+"       onclick     = \"var el=w2ui['"+this.name+"']; if (el) el.doClick('"+e.id+"', event);\" "+'       onmouseover = "'+(e.disabled?"":"$(this).addClass('over');")+'"'+'       onmouseout  = "'+(e.disabled?"":"$(this).removeClass('over');")+'"'+'       onmousedown = "'+(e.disabled?"":"$(this).addClass('down');")+'"'+'       onmouseup   = "'+(e.disabled?"":"$(this).removeClass('down');")+'"'+">"+"<tr><td>"+'  <table cellpadding="1" cellspacing="0">'+"  <tr>"+n+(e.text!=""?'<td class="w2ui-tb-caption" nowrap>'+e.text+"</td>":"")+(e.type!="drop"&&e.type!="menu"||e.arrow===!1?"":'<td class="w2ui-tb-down" nowrap>&nbsp;&nbsp;&nbsp;</td>')+"  </tr></table>"+"</td></tr></table>";break;case"break":t+='<table cellpadding="0" cellspacing="0"><tr>    <td><div class="w2ui-break">&nbsp;</div></td></tr></table>';break;case"html":t+='<table cellpadding="0" cellspacing="0"><tr>    <td nowrap>'+e.html+"</td>"+"</tr></table>"}var r="";return typeof e.onRender=="function"&&(r=e.onRender.call(this,e.id,t)),typeof this.onRender=="function"&&(r=this.onRender(e.id,t)),r!=""&&typeof r!="undefined"&&(t=r),t},doMenuClick:function(e,t,n){window.getSelection&&window.getSelection().removeAllRanges();var r=this,i=this.get(e);if(i&&!i.disabled){var s=this.trigger({phase:"before",type:"click",target:typeof e!="undefined"?e:this.name,item:this.get(e),subItem:typeof n!="undefined"&&this.get(e)?this.get(e).items[n]:null,event:t});if(s.stop===!0)return!1;this.trigger($.extend({phase:"after"}))}},doClick:function(e,t){window.getSelection&&window.getSelection().removeAllRanges();var n=this,r=this.get(e);if(r&&!r.disabled){var i=this.trigger({phase:"before",type:"click",target:typeof e!="undefined"?e:this.name,item:this.get(e),event:t});if(i.stop===!0)return!1;$("#tb_"+this.name+"_item_"+w2utils.escapeId(r.id)+" table.w2ui-button").removeClass("down");if(r.type=="radio"){for(var s=0;s<this.items.length;s++){var o=this.items[s];if(o==null||o.id==r.id||o.type!="radio")continue;o.group==r.group&&o.checked&&(o.checked=!1,this.refresh(o.id))}r.checked=!0,$("#tb_"+this.name+"_item_"+w2utils.escapeId(r.id)+" table.w2ui-button").addClass("checked")}if(r.type=="drop"||r.type=="menu")r.checked?r.checked=!1:setTimeout(function(){function t(){r.checked=!1,r.checked?$("#tb_"+n.name+"_item_"+w2utils.escapeId(r.id)+" table.w2ui-button").addClass("checked"):$("#tb_"+n.name+"_item_"+w2utils.escapeId(r.id)+" table.w2ui-button").removeClass("checked"),n.refresh(r.id),$(document).off("click",t)}var e=$("#tb_"+n.name+"_item_"+w2utils.escapeId(r.id)).width();$.isPlainObject(r.overlay)||(r.overlay={}),$("#tb_"+n.name+"_item_"+w2utils.escapeId(r.id)).w2overlay(r.html,$.extend({left:(e-50)/2,top:3},r.overlay)),$(document).on("click",t)},1);if(r.type=="check"||r.type=="drop"||r.type=="menu")r.checked=!r.checked,r.checked?$("#tb_"+this.name+"_item_"+w2utils.escapeId(r.id)+" table.w2ui-button").addClass("checked"):$("#tb_"+this.name+"_item_"+w2utils.escapeId(r.id)+" table.w2ui-button").removeClass("checked");this.trigger($.extend({phase:"after"}))}}},$.extend(e.prototype,$.w2event),w2obj.toolbar=e}(),function(){var e=function(e){this.name=null,this.box=null,this.sidebar=null,this.parent=null,this.nodes=[],this.selected=null,this.img=null,this.icon=null,this.style="",this.topHTML="",this.bottomHTML="",this.onClick=null,this.onDblClick=null,this.onContextMenu=null,this.onExpand=null,this.onCollapse=null,this.onKeyboard=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,$.extend(!0,this,e,w2obj.sidebar)};$.fn.w2sidebar=function(t){if(typeof t=="object"||!t){if(!t||typeof t.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2sidebar().');return}if(typeof w2ui[t.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+t.name+").");return}if(!w2utils.isAlphaNumeric(t.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=t.nodes,r=new e(t);return $.extend(r,{handlers:[],nodes:[]}),typeof n!="undefined"&&r.add(r,n),$(this).length!=0&&r.render($(this)[0]),r.sidebar=r,w2ui[r.name]=r,r}if(w2ui[$(this).attr("name")]){var i=w2ui[$(this).attr("name")];return i[t].apply(i,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+t+" does not exist on jQuery.w2sidebar")},e.prototype={node:{id:null,text:"",count:"",img:null,icon:null,nodes:[],style:"",selected:!1,expanded:!1,hidden:!1,disabled:!1,group:!1,plus:!1,onClick:null,onDblClick:null,onContextMenu:null,onExpand:null,onCollapse:null,parent:null,sidebar:null},add:function(e,t){return arguments.length==1&&(t=arguments[0],e=this),typeof e=="string"&&(e=this.get(e)),this.insert(e,null,t)},insert:function(t,n,r){if(arguments.length==2){r=arguments[1],n=arguments[0];var i=this.get(n);if(i==null){var s=r[o].caption!="undefined"?r[o].caption:r[o].text;return console.log('ERROR: Cannot insert node "'+s+'" because cannot find node "'+n+'" to insert before.'),null}t=this.get(n).parent}typeof t=="string"&&(t=this.get(t)),$.isArray(r)||(r=[r]);for(var o in r){if(typeof r[o].id=="undefined"){var s=r[o].caption!="undefined"?r[o].caption:r[o].text;console.log('ERROR: Cannot insert node "'+s+'" because it has no id.');continue}if(this.get(this,r[o].id)!=null){var s=r[o].caption!="undefined"?r[o].caption:r[o].text;console.log("ERROR: Cannot insert node with id="+r[o].id+" (text: "+s+") because another node with the same id already exists.");continue}var u=$.extend({},e.prototype.node,r[o]);u.sidebar=this,u.parent=t;var a=u.nodes;u.nodes=[];if(n==null)t.nodes.push(u);else{var i=this.get(t,n,!0);if(i==null){var s=r[o].caption!="undefined"?r[o].caption:r[o].text;return console.log('ERROR: Cannot insert node "'+s+'" because cannot find node "'+n+'" to insert before.'),null}t.nodes.splice(i,0,u)}typeof a!="undefined"&&a.length>0&&this.insert(u,null,a)}return this.refresh(t.id),u},remove:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(n==null)continue;var r=this.get(n.parent,arguments[t],!0);if(r==null)continue;n.parent.nodes.splice(r,1),e++}return e>0&&arguments.length==1?this.refresh(n.parent.id):this.refresh(),e},set:function(e,t,n){arguments.length==2&&(n=t,t=e,e=this),this._tmp=null,typeof e=="string"&&(e=this.get(e));if(e.nodes==null)return null;for(var r=0;r<e.nodes.length;r++){if(e.nodes[r].id==t){var i=n.nodes;return $.extend(e.nodes[r],n,{nodes:[]}),typeof i!="undefined"&&this.add(e.nodes[r],i),this.refresh(t),!0}this._tmp=this.set(e.nodes[r],t,n);if(this._tmp)return!0}return!1},get:function(e,t,n){if(arguments.length==1||arguments.length==2&&t===!0)n=t,t=e,e=this;this._tmp=null,typeof e=="string"&&(e=this.get(e));if(e.nodes==null)return null;for(var r=0;r<e.nodes.length;r++){if(e.nodes[r].id==t)return n===!0?r:e.nodes[r];this._tmp=this.get(e.nodes[r],t,n);if(this._tmp||this._tmp===0)return this._tmp}return this._tmp},hide:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(n==null)continue;n.hidden=!0,e++}return arguments.length==1?this.refresh(arguments[0]):this.refresh(),e},show:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(n==null)continue;n.hidden=!1,e++}return arguments.length==1?this.refresh(arguments[0]):this.refresh(),e},disable:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(n==null)continue;n.disabled=!0,n.selected&&this.unselect(n.id),e++}return arguments.length==1?this.refresh(arguments[0]):this.refresh(),e},enable:function(){var e=0;for(var t=0;t<arguments.length;t++){var n=this.get(arguments[t]);if(n==null)continue;n.disabled=!1,e++}return arguments.length==1?this.refresh(arguments[0]):this.refresh(),e},select:function(e){if(this.selected==e)return!1;this.unselect(this.selected);var t=this.get(e);if(!t)return!1;$(this.box).find("#node_"+w2utils.escapeId(e)).addClass("w2ui-selected").find(".w2ui-icon").addClass("w2ui-icon-selected"),t.selected=!0,this.selected=e},unselect:function(e){var t=this.get(e);return t?(t.selected=!1,$(this.box).find("#node_"+w2utils.escapeId(e)).removeClass("w2ui-selected").find(".w2ui-icon").removeClass("w2ui-icon-selected"),this.selected==e&&(this.selected=null),!0):!1},toggle:function(e){var t=this.get(e);if(t==null)return;if(t.plus){this.set(e,{plus:!1}),this.expand(e),this.refresh(e);return}if(t.nodes.length==0)return;this.get(e).expanded?this.collapse(e):this.expand(e)},expand:function(e){var t=this.trigger({phase:"before",type:"expand",target:e});if(t.stop===!0)return!1;var n=this.get(e);$(this.box).find("#node_"+w2utils.escapeId(e)+"_sub").slideDown("fast"),$(this.box).find("#node_"+w2utils.escapeId(e)+" .w2ui-node-dots:first-child").html('<div class="w2ui-expand">-</div>'),n.expanded=!0,this.trigger($.extend(t,{phase:"after"})),this.resize()},collapse:function(e){var t=this.trigger({phase:"before",type:"collapse",target:e});if(t.stop===!0)return!1;$(this.box).find("#node_"+w2utils.escapeId(e)+"_sub").slideUp("fast"),$(this.box).find("#node_"+w2utils.escapeId(e)+" .w2ui-node-dots:first-child").html('<div class="w2ui-expand">+</div>'),this.get(e).expanded=!1,this.trigger($.extend(t,{phase:"after"})),this.resize()},collapseAll:function(e){typeof e=="undefined"&&(e=this),typeof e=="string"&&(e=this.get(e));if(e.nodes==null)return null;for(var t=0;t<e.nodes.length;t++)e.nodes[t].expanded===!0&&(e.nodes[t].expanded=!1),e.nodes[t].nodes&&e.nodes[t].nodes.length>0&&this.collapseAll(e.nodes[t]);this.refresh(e.id)},expandAll:function(e){typeof e=="undefined"&&(e=this),typeof e=="string"&&(e=this.get(e));if(e.nodes==null)return null;for(var t=0;t<e.nodes.length;t++)e.nodes[t].expanded===!1&&(e.nodes[t].expanded=!0),e.nodes[t].nodes&&e.nodes[t].nodes.length>0&&this.collapseAll(e.nodes[t]);this.refresh(e.id)},expandParents:function(e){var t=this.get(e);if(t==null)return;t.parent&&(t.parent.expanded=!0,this.expandParents(t.parent.id)),this.refresh(e)},doClick:function(e,t){var n=this.get(e),r=this;if(n.disabled)return;var i=this.trigger({phase:"before",type:"click",target:e,event:t});if(i.stop===!0)return!1;!n.group&&!n.disabled&&($(this.box).find(".w2ui-node").each(function(e,t){var n=String(t.id).replace("node_",""),i=r.get(n);i&&i.selected&&(i.selected=!1,$(t).removeClass("w2ui-selected").find(".w2ui-icon").removeClass("w2ui-icon-selected"))}),$(this.box).find("#node_"+w2utils.escapeId(e)).addClass("w2ui-selected").find(".w2ui-icon").addClass("w2ui-icon-selected"),n.selected=!0,this.selected=e),this.trigger($.extend(i,{phase:"after"}))},keydown:function(e){var t=this,n=t.get(t.selected);if(!n)return;var r=t.trigger({phase:"before",type:"keyboard",target:t.name,event:e});if(r.stop===!0)return!1;var i=t.get(t.selected,!0);e.keyCode==13&&t.toggle(t.selected);if(e.keyCode==38){if(i>0){var s=n.parent.nodes[i-1];if(s.disabled){e.preventDefault&&e.preventDefault();return}t.doClick(s.id,e)}e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}if(e.keyCode==40){if(i<n.parent.nodes.length-1){var s=n.parent.nodes[i+1];if(s.disabled){e.preventDefault&&e.preventDefault();return}t.doClick(s.id,e)}e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation()}t.trigger($.extend(r,{phase:"after"}))},doDblClick:function(e,t){window.getSelection&&window.getSelection().removeAllRanges();var n=this.trigger({phase:"before",type:"dblClick",target:e,event:t});if(n.stop===!0)return!1;var r=this.get(e);r.nodes.length>0&&this.toggle(e),this.trigger($.extend(n,{phase:"after"}))},doContextMenu:function(e,t){var n=this.trigger({phase:"before",type:"contextMenu",target:e,event:t});if(n.stop===!0)return!1;this.trigger($.extend(n,{phase:"after"}))},render:function(e){var t=this.trigger({phase:"before",type:"render",target:this.name,box:e});if(t.stop===!0)return!1;typeof e!="undefined"&&e!=null&&($(this.box).find("> div > div.w2ui-sidebar-div").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-sidebar").html(""),this.box=e);if(!this.box)return;$(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-sidebar").html('<div><div class="w2ui-sidebar-top"></div><div class="w2ui-sidebar-div"></div><div class="w2ui-sidebar-bottom"></div></div>'),$(this.box).find("> div").css({width:$(this.box).width()+"px",height:$(this.box).height()+"px"}),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),this.topHTML!=""&&($(this.box).find(".w2ui-sidebar-top").html(this.topHTML),$(this.box).find(".w2ui-sidebar-div").css("top",$(this.box).find(".w2ui-sidebar-top").height()+"px")),this.bottomHTML!=""&&($(this.box).find(".w2ui-sidebar-bottom").html(this.bottomHTML),$(this.box).find(".w2ui-sidebar-div").css("bottom",$(this.box).find(".w2ui-sidebar-bottom").height()+"px")),this.trigger($.extend(t,{phase:"after"})),this.refresh()},refresh:function(e){function a(e){var t="",r=e.img;r==null&&(r=this.img);var i=e.icon;i==null&&(i=this.icon);var s=e.parent,o=0;while(s&&s.parent!=null)s.group&&o--,s=s.parent,o++;typeof e.caption!="undefined"&&(e.text=e.caption);if(e.group)t='<div class="w2ui-node-group"  id="node_'+e.id+'"'+"		onclick=\"w2ui['"+n.name+"'].toggle('"+e.id+"'); "+"				 var sp=$(this).find('span:nth-child(1)'); if (sp.html() == '"+w2utils.lang("Hide")+"') sp.html('"+w2utils.lang("Show")+"'); else sp.html('"+w2utils.lang("Hide")+"');\""+"		onmouseout=\"$(this).find('span:nth-child(1)').css('color', 'transparent')\" "+"		onmouseover=\"$(this).find('span:nth-child(1)').css('color', 'inherit')\">"+"	<span>"+(!e.hidden&&e.expanded?w2utils.lang("Hide"):w2utils.lang("Show"))+"</span>"+"	<span>"+e.text+"</span>"+"</div>"+'<div class="w2ui-node-sub" id="node_'+e.id+'_sub" style="'+e.style+";"+(!e.hidden&&e.expanded?"":"display: none;")+'"></div>';else{e.selected&&!e.disabled&&(n.selected=e.id);var s="";r&&(s='<div class="w2ui-node-image w2ui-icon '+r+(e.selected&&!e.disabled?" w2ui-icon-selected":"")+'"></div>'),i&&(s='<div class="w2ui-node-image"><span class="'+i+'"></span></div>'),t='<div class="w2ui-node '+(e.selected?"w2ui-selected":"")+" "+(e.disabled?"w2ui-disabled":"")+'" id="node_'+e.id+'" style="'+(e.hidden?"display: none;":"")+'"'+"	ondblclick=\"w2ui['"+n.name+"'].doDblClick('"+e.id+"', event);\""+"	oncontextmenu=\"w2ui['"+n.name+"'].doContextMenu('"+e.id+"', event); "+'		if (event.preventDefault) event.preventDefault();"'+"	onClick=\"w2ui['"+n.name+"'].doClick('"+e.id+"', event); \">"+'<table cellpadding="0" cellspacing="0" style="margin-left:'+o*18+"px; padding-right:"+o*18+'px"><tr>'+'<td class="w2ui-node-dots" nowrap onclick="w2ui[\''+n.name+"'].toggle('"+e.id+"'); "+'		if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;">'+'	<div class="w2ui-expand">'+
(e.nodes.length>0?e.expanded?"-":"+":e.plus?"+":"")+"</div>"+"</td>"+'<td class="w2ui-node-data" nowrap>'+s+(e.count!==""?'<div class="w2ui-node-count">'+e.count+"</div>":"")+'<div class="w2ui-node-caption">'+e.text+"</div>"+"</td>"+"</tr></table>"+"</div>"+'<div class="w2ui-node-sub" id="node_'+e.id+'_sub" style="'+e.style+";"+(!e.hidden&&e.expanded?"":"display: none;")+'"></div>'}return t}window.getSelection&&window.getSelection().removeAllRanges();var t=this.trigger({phase:"before",type:"refresh",target:typeof e!="undefined"?e:this.name});if(t.stop===!0)return!1;this.topHTML!=""&&($(this.box).find(".w2ui-sidebar-top").html(this.topHTML),$(this.box).find(".w2ui-sidebar-div").css("top",$(this.box).find(".w2ui-sidebar-top").height()+"px")),this.bottomHTML!=""&&($(this.box).find(".w2ui-sidebar-bottom").html(this.bottomHTML),$(this.box).find(".w2ui-sidebar-div").css("bottom",$(this.box).find(".w2ui-sidebar-bottom").height()+"px")),$(this.box).find("> div").css({width:$(this.box).width()+"px",height:$(this.box).height()+"px"});var n=this;if(typeof e=="undefined")var r=this,i=".w2ui-sidebar-div";else{var r=this.get(e);if(r==null)return;var i="#node_"+w2utils.escapeId(r.id)+"_sub"}if(r!=this){var s="#node_"+w2utils.escapeId(r.id),o=a(r);$(this.box).find(s).before('<div id="sidebar_'+this.name+'_tmp"></div>'),$(this.box).find(s).remove(),$(this.box).find(i).remove(),$("#sidebar_"+this.name+"_tmp").before(o),$("#sidebar_"+this.name+"_tmp").remove()}$(this.box).find(i).html("");for(var u=0;u<r.nodes.length;u++){var o=a(r.nodes[u]);$(this.box).find(i).append(o),r.nodes[u].nodes.length!=0&&this.refresh(r.nodes[u].id)}this.trigger($.extend(t,{phase:"after"}))},resize:function(){window.getSelection&&window.getSelection().removeAllRanges();var e=this.trigger({phase:"before",type:"resize",target:this.name});if(e.stop===!0)return!1;$(this.box).css("overflow","hidden"),$(this.box).find("> div").css({width:$(this.box).width()+"px",height:$(this.box).height()+"px"}),this.trigger($.extend(e,{phase:"after"}))},destroy:function(){var e=this.trigger({phase:"before",type:"destroy",target:this.name});if(e.stop===!0)return!1;$(this.box).find("> div > div.w2ui-sidebar-div").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-sidebar").html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"}))}},$.extend(e.prototype,$.w2event),w2obj.sidebar=e}(),function(e){var t=new function(){this.customTypes=[]};e.fn.w2field=function(e){if(t[e])return t[e].apply(this,Array.prototype.slice.call(arguments,1));if(typeof e=="object")return t.init.apply(this,arguments);if(typeof e=="string")return t.init.apply(this,[{type:e}]);console.log("ERROR: Method "+e+" does not exist on jQuery.w2field")},e.extend(t,{init:function(n){var r=t;return e(this).each(function(r,i){if(typeof t.customTypes[n.type.toLowerCase()]=="function"){t.customTypes[n.type.toLowerCase()].call(this,n);return}switch(n.type.toLowerCase()){case"clear":e(this).off("keypress").off("focus").off("blur"),e(this).removeData(),e(this).prev().hasClass("w2ui-list")&&(e(this).prev().remove(),e(this).removeAttr("tabindex").css("border-color","").show()),e(this).prev().hasClass("w2ui-upload")&&(e(this).prev().remove(),e(this).removeAttr("tabindex").css("border-color","").show());break;case"text":break;case"int":e(this).on("keypress",function(e){if(e.metaKey||e.ctrlKey||e.altKey||e.charCode!=e.keyCode&&e.keyCode>0)return;var t=String.fromCharCode(e.charCode);if(!w2utils.isInt(t)&&t!="-")return e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1}),e(this).on("blur",function(t){this.value!=""&&!w2utils.isInt(this.value)&&e(this).w2tag(w2utils.lang("Not an integer"))});break;case"float":e(this).on("keypress",function(e){if(e.metaKey||e.ctrlKey||e.altKey||e.charCode!=e.keyCode&&e.keyCode>0)return;var t=String.fromCharCode(e.charCode);if(!w2utils.isInt(t)&&t!="."&&t!="-")return e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1}),e(this).on("blur",function(t){this.value!=""&&!w2utils.isFloat(this.value)&&e(this).w2tag(w2utils.lang("Not a float"))});break;case"money":e(this).on("keypress",function(e){if(e.metaKey||e.ctrlKey||e.altKey||e.charCode!=e.keyCode&&e.keyCode>0)return;var t=String.fromCharCode(e.charCode);if(!w2utils.isInt(t)&&t!="."&&t!="-"&&t!="$"&&t!="€"&&t!="£"&&t!="¥")return e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1}),e(this).on("blur",function(t){this.value!=""&&!w2utils.isMoney(this.value)&&e(this).w2tag(w2utils.lang("Not in money format"))});break;case"hex":e(this).on("keypress",function(e){if(e.metaKey||e.ctrlKey||e.altKey||e.charCode!=e.keyCode&&e.keyCode>0)return;var t=String.fromCharCode(e.charCode);if(!w2utils.isHex(t))return e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1}),e(this).on("blur",function(t){this.value!=""&&!w2utils.isHex(this.value)&&e(this).w2tag(w2utils.lang("Not a hex number"))});break;case"alphanumeric":e(this).on("keypress",function(e){if(e.metaKey||e.ctrlKey||e.altKey||e.charCode!=e.keyCode&&e.keyCode>0)return;var t=String.fromCharCode(e.charCode);if(!w2utils.isAlphaNumeric(t))return e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1}),e(this).on("blur",function(t){this.value!=""&&!w2utils.isAlphaNumeric(this.value)&&e(this).w2tag(w2utils.lang("Not alpha-numeric"))});break;case"date":var s=this,o={format:w2utils.settings.date_format,start:"",end:"",blocked:{},colored:{}};n=e.extend({},o,n),e(this).css({transition:"none","-webkit-transition":"none","-moz-transition":"none","-ms-transition":"none","-o-transition":"none"}).data("options",n).on("focus",function(){var t=parseFloat(e(s).offset().top)+parseFloat(s.offsetHeight),r=parseFloat(e(s).offset().left);clearInterval(e(s).data("mtimer")),e("#global_calendar_div").remove(),e("body").append('<div id="global_calendar_div" style="top: '+(t+parseInt(s.offsetHeight))+"px; left: "+r+'px;" '+' class="w2ui-reset w2ui-calendar" '+' onmousedown="'+"		if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; "+'		if (event.preventDefault) event.preventDefault(); else return false;">'+"</div>"),e("#global_calendar_div").html(e().w2field("calendar_get",s.value,n)).css({left:r+"px",top:t+"px"}).data("el",s).show();var i=setInterval(function(){e("#global_calendar_div").data("position")!=e(s).offset().left+"x"+(e(s).offset().top+s.offsetHeight)&&e("#global_calendar_div").css({"-webkit-transition":".2s",left:e(s).offset().left+"px",top:e(s).offset().top+s.offsetHeight+"px"}).data("position",e(s).offset().left+"x"+(e(s).offset().top+s.offsetHeight));if(e(s).length==0||e(s).offset().left==0&&e(s).offset().top==0){clearInterval(i),e("#global_calendar_div").remove();return}},100);e(s).data("mtimer",i)}).on("blur",function(t){e(s).val(e.trim(e(s).val())),e.trim(e(s).val())!=""&&!w2utils.isDate(e(s).val(),n.format)&&e(this).w2tag(w2utils.lang("Not a valid date")+": "+n.format),clearInterval(e(s).data("mtimer")),e("#global_calendar_div").remove()}).on("keypress",function(t){var r=this;setTimeout(function(){e("#global_calendar_div").html(e().w2field("calendar_get",r.value,n))},10)});break;case"time":break;case"datetime":break;case"color":break;case"select":case"list":if(this.tagName!="SELECT"){console.log("ERROR: You can only apply $().w2field('list') to a SELECT element");return}var o={url:"",items:[],value:null,showNone:!0},u=e.extend({},o,n),a="",f=t.cleanItems(u.items);if(u.url!="")e.ajax({type:"GET",dataType:"text",context:e(this),url:u.url,data:{max:u.maxCache},complete:function(t,n){u.last_total=0;if(n=="success"){var r=e.parseJSON(t.responseText);u.last_total=r.total,u.items=r.items,f=u.items,u.showNone&&(a='<option value="">- '+w2utils.lang("none")+" -</option>");for(var i in f)!u.showNone&&u.value==null&&(u.value=f[i].id),a+='<option value="'+f[i].id+'">'+f[i].text+"</option>";u.items=f,e(this).data("settings",u),e(this).html(a),e(this).val(u.value),e(this).val()!=u.value&&e(this).change()}}});else{u.showNone&&(a='<option value="">- '+w2utils.lang("none")+" -</option>");for(var l in f)!u.showNone&&u.value==null&&(u.value=f[l].id),a+='<option value="'+f[l].id+'">'+f[l].text+"</option>";u.items=f,e(this).data("settings",u),e(this).html(a),e(this).val(u.value),e(this).val()!=u.value&&e(this).change()}break;case"enum":if(this.tagName!="INPUT"){console.log("ERROR: You can only apply $().w2field('enum') to an INPUT element");return}var o={url:"",items:[],selected:[],max:0,maxHeight:72,showAll:!1,maxCache:500,onRender:null,onSelect:null},s=this,u=e.extend({},o,n);u.items=t.cleanItems(u.items),u.selected=t.cleanItems(u.selected),e(this).data("selected",u.selected),e(this).css({"border-color":"transparent"}),this.add=function(t){var n=e(this).data("selected");e.isArray(n)||(n=[]),u.max!=0&&u.max<=n.length&&n.splice(n.length-1,1),n.push(t),e(this).data("selected",n),e(this).data("last_del",null),e(this).trigger("change")},this.show=function(){if(e("#w2ui-global-items").length!=0)return;e("body").append('<div id="w2ui-global-items" class="w2ui-reset w2ui-items"></div>');var n=e("#w2ui-global-items");n.css({display:"block",left:e(s).offset().left+"px",top:e(s).offset().top+s.offsetHeight+"px"}).width(w2utils.getSize(s,"width")).data("position",e(s).offset().left+"x"+(e(s).offset().top+s.offsetHeight)),t.list_render.call(s);var r=function(){var n=e("#w2ui-global-items");if(e(s).length==0||e(s).offset().left==0&&e(s).offset().top==0){clearInterval(e(s).data("mtimer")),hide();return}n.data("position")!=e(s).offset().left+"x"+(e(s).offset().top+s.offsetHeight)&&(n.css({"-webkit-transition":".2s",left:e(s).offset().left+"px",top:e(s).offset().top+s.offsetHeight+"px"}).data("position",e(s).offset().left+"x"+(e(s).offset().top+s.offsetHeight)),setTimeout(function(){t.list_render.call(s,e(s).data("last_search"))},200)),n.length>0&&e(s).data("mtimer",setTimeout(r,100))};e(s).data("mtimer",setTimeout(r,100))},this.hide=function(){clearTimeout(e(s).data("mtimer")),e("#w2ui-global-items").remove()},this.refresh=function(){var n=this;e(e(this).data("div")).remove();var r="margin-top: "+e(this).css("margin-top")+"; "+"margin-bottom: "+e(this).css("margin-bottom")+"; "+"margin-left: "+e(this).css("margin-left")+"; "+"margin-right: "+e(this).css("margin-right")+"; "+"width: "+(w2utils.getSize(this,"width")-parseInt(e(this).css("margin-left"))-parseInt(e(this).css("margin-right")))+"px; ",i='<div class="w2ui-list" style="'+r+';">'+"<ul>",s=e(this).data("selected");for(var o in s)i+='<li style="'+(e(this).data("last_del")==o?"opacity: 0.5":"")+'">'+'<div title="'+w2utils.lang("Remove")+'" index="'+o+'">&nbsp;&nbsp;</div>'+s[o].text+"</li>";i+='<li><input type="text"></li>',i+="</ul></div>",e(this).before(i);var a=e(this).prev()[0];e(this).data("div",a);var f=w2utils.getSize(a,"height")-parseInt(e(a).css("margin-top"))-parseInt(e(a).css("margin-bottom"));f<23&&(f=23),f>u.maxHeight&&(f=u.maxHeight),e(a).height(f),a.length>0&&(a[0].scrollTop=1e3),e(this).height(f),e(a).on("click",function(r){var i=r.target;i.title==w2utils.lang("Remove")&&(e(n).data("selected").splice(e(i).attr("index"),1),e(i.parentNode).remove(),n.refresh(),t.list_render.call(n),e(n).trigger("change"),r.stopPropagation?r.stopPropagation():r.cancelBubble=!0),e(this).find("input").focus()}),e(a).find("input").on("focus",function(t){e(a).css({outline:"auto 5px -webkit-focus-ring-color","outline-offset":"-2px"}),n.show(),t.stopPropagation?t.stopPropagation():t.cancelBubble=!0}).on("blur",function(t){e(a).css("outline","none"),n.hide(),t.stopPropagation?t.stopPropagation():t.cancelBubble=!0})},e(this).data("settings",u).attr("tabindex",-1),this.refresh();break;case"upload":if(this.tagName!="INPUT"){console.log("ERROR: You can only apply $().w2field('upload') to an INPUT element");return}var o={url:"",base64:!0,hint:w2utils.lang("Attach files by dragging and dropping or Click to Select"),max:0,maxSize:0,maxFileSize:0,onAdd:null,onRemove:null,onItemClick:null,onItemDblClick:null,onItemOver:null,onItemOut:null,onProgress:null,onComplete:null},s=this,u=e.extend({},o,n);u.base64===!0&&(u.maxSize==0&&(u.maxSize=20971520),u.maxFileSize==0&&(u.maxFileSize=20971520));var c=u.selected;delete u.selected,e.isArray(c)||(c=[]),e(this).data("selected",c).data("settings",u).attr("tabindex",-1),t.upload_init.call(this),this.refresh=function(){var t=this,n=e(this).data("div"),r=e(this).data("settings"),i=e(this).data("selected");e(n).find("li").remove();for(var s in i){var o=i[s],u=e(n).find(".file-list li").length;e(n).find("> span:first-child").remove(),e(n).find(".file-list").append('<li id="file-'+u+'">'+'	<div class="file-delete" onmouseover="event.stopPropagation();">&nbsp;&nbsp;</div>'+'	<span class="file-name">'+o.name+"</span>"+'	<span class="file-size"> - '+w2utils.size(o.size)+"</span>"+"</li>");var a=e(n).find(".file-list #file-"+u),f="";/image/i.test(o.type)&&(f='<div style="padding: 2px;">	<img src="##FILE##" onload="var w = $(this).width(); var h = $(this).height(); 		if (w < 300 & h < 300) return; 		if (w >= h && w > 300) $(this).width(300);		if (w < h && h > 300) $(this).height(300);	" onerror="this.style.display = \'none\'"></div>');var l='style="padding: 3px; text-align: right; color: #777;"',c='style="padding: 3px"';f+='<div style="padding: 5px;">	<table cellpadding="2">	<tr><td '+l+">Name:</td><td "+c+">"+o.name+"</td></tr>"+"	<tr><td "+l+">Size:</td><td "+c+">"+w2utils.size(o.size)+"</td></tr>"+"	<tr><td "+l+">Type:</td><td "+c+">"+'		<span style="width: 200px; display: block-inline; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">'+o.type+"</span>"+"	</td></tr>"+"	<tr><td "+l+">Modified:</td><td "+c+">"+w2utils.date(o.modified)+"</td></tr>"+"	</table>"+"</div>",a.data("file",o).on("click",function(n){if(typeof r.onItemClick=="function"){var i=r.onItemClick.call(t,e(this).data("file"));if(i===!1)return}e(n.target).hasClass("file-delete")||n.stopPropagation()}).on("dblclick",function(n){if(typeof r.onItemDblClick=="function"){var i=r.onItemDblClick.call(t,e(this).data("file"));if(i===!1)return}n.stopPropagation(),document.selection?document.selection.empty():document.defaultView.getSelection().removeAllRanges()}).on("mouseover",function(n){if(typeof r.onItemOver=="function"){var i=r.onItemOver.call(t,e(this).data("file"));if(i===!1)return}var s=e(this).data("file");e(this).w2overlay(f.replace("##FILE##",s.content?"data:"+s.type+";base64,"+s.content:""),{top:-4})}).on("mouseout",function(){if(typeof r.onItemOut=="function"){var n=r.onItemOut.call(t,e(this).data("file"));if(n===!1)return}e(this).w2overlay()})}},this.refresh();break;default:console.log('ERROR: w2field does not recognize "'+n.type+'" field type.')}})},addType:function(e,n){t.customTypes[String(e).toLowerCase()]=n},cleanItems:function(t){var n=[];for(var r in t){var i="",s="",o=t[r];if(o==null)continue;if(e.isPlainObject(t))i=r,s=o;else{if(typeof o=="string"){if(String(o)=="")continue;i=o,s=o}typeof o=="object"&&(typeof o.id!="undefined"&&(i=o.id),typeof o.value!="undefined"&&(i=o.value),typeof o.txt!="undefined"&&(s=o.txt),typeof o.text!="undefined"&&(s=o.text))}w2utils.isInt(i)&&(i=parseInt(i)),w2utils.isFloat(i)&&(i=parseFloat(i)),n.push({id:i,text:s})}return n},upload_init:function(){var n=this,r=e(this).data("settings"),i=e(n).prev();i.length>0&&i[0].tagName=="DIV"&&i.hasClass("w2ui-upload")&&i.remove();var s="margin-top: "+e(n).css("margin-top")+"; "+"margin-bottom: "+e(n).css("margin-bottom")+"; "+"margin-left: "+e(n).css("margin-left")+"; "+"margin-right: "+e(n).css("margin-right")+"; "+"width: "+(w2utils.getSize(n,"width")-parseInt(e(n).css("margin-left"))-parseInt(e(n).css("margin-right")))+"px; "+"height: "+(w2utils.getSize(n,"height")-parseInt(e(n).css("margin-top"))-parseInt(e(n).css("margin-bottom")))+"px; ",o='<div style="'+s+'" class="w2ui-upload">'+"	<span>"+r.hint+"</span>"+'	<ul class="file-list"></ul>'+'	<input class="file-input" type="file" name="attachment" multiple style="display: none">'+"</div>";e(n).css({display1:"none","border-color":"transparent"}).before(o),e(n).data("div",e(n).prev()[0]);var u=e(n).data("div");e(u).find(".file-input").off("change").on("change",function(){if(typeof this.files!="undefined")for(var e=0,r=this.files.length;e<r;e++)t.upload_add.call(n,this.files[e])}),e(u).off("click").on("click",function(r){e(u).w2tag();if(r.target.tagName=="LI"||e(r.target).hasClass("file-size"))return;if(e(r.target).hasClass("file-delete")){t.upload_remove.call(n,r.target.parentNode);return}r.target.tagName!="INPUT"&&e(u).find(".file-input").click()}).off("dragenter").on("dragenter",function(t){e(u).addClass("dragover")}).off("dragleave").on("dragleave",function(t){e(u).removeClass("dragover")}).off("drop").on("drop",function(r){e(u).removeClass("dragover");var i=r.originalEvent.dataTransfer.files;for(var s=0,o=i.length;s<o;s++)t.upload_add.call(n,i[s]);r.preventDefault(),r.stopPropagation()}).off("dragover").on("dragover",function(e){e.preventDefault(),e.stopPropagation()})},upload_add:function(t){var n=this,r=e(n).data("div"),i=e(n).data("settings"),s=e(n).data("selected"),o={name:t.name,type:t.type,modified:t.lastModifiedDate,size:t.size,content:null},u=0,a=0;for(var f in s)u+=s[f].size,a++;if(i.maxFileSize!=0&&o.size>i.maxFileSize){var l="Maximum file size is "+w2utils.size(i.maxFileSize);e(r).w2tag(l),console.log("ERROR: "+l);return}if(i.maxSize!=0&&u+o.size>i.maxSize){var l="Maximum total size is "+w2utils.size(i.maxFileSize);e(r).w2tag(l),console.log("ERROR: "+l);return}if(i.max!=0&&a>=i.max){var l="Maximum number of files is "+i.max;e(r).w2tag(l),console.log("ERROR: "+l);return}if(typeof i.onAdd=="function"){var c=i.onAdd.call(n,o);if(c===!1)return}s.push(o);if(typeof FileReader!="undefined"&&i.base64===!0){var h=new FileReader;h.onload=function(){return function(t){var r=t.target.result,i=r.indexOf(",");o.content=r.substr(i+1),n.refresh(),e(n).trigger("change")}}(),h.readAsDataURL(t)}else n.refresh(),e(n).trigger("change")},upload_remove:function(t){var n=this,r=e(n).data("div"),i=e(n).data("settings"),s=e(n).data("selected"),o=e(t).data("file");if(typeof i.onRemove=="function"){var u=i.onRemove.call(n,o);if(u===!1)return!1}for(var a=s.length-1;a>=0;a--)s[a].name==o.name&&s[a].size==o.size&&s.splice(a,1);e(t).fadeOut("fast"),setTimeout(function(){e(t).remove(),s.length==0&&e(r).prepend("<span>"+i.hint+"</span>"),e(n).trigger("change")},300)},list_render:function(n){var r=this,i=e("#w2ui-global-items"),s=e(this).data("settings"),o=s.items,u=e(this).data("selected");if(i.length==0)return;if(typeof n=="undefined"){var a="";a+='<div class="w2ui-items-list"></div>',i.html(a),n=""}e(this).data("last_search",n),(typeof e(r).data("last_index")=="undefined"||e(r).data("last_index")==null)&&e(r).data("last_index",0),typeof s.last_total=="undefined"&&(s.last_total=-1),typeof s.last_search_len=="undefined"&&(s.last_search_len=0),typeof s.last_search_match=="undefined"&&(s.last_search_match=-1);if(s.url!=""&&(o.length==0&&s.last_total!=0||n.length>s.last_search_len&&s.last_total>s.maxCache||n.length<s.last_search_match&&n.length!=s.last_search_len)){var f=!1;s.last_total<s.maxCache&&(f=!0),e.ajax({type:"GET",dataType:"text",url:s.url,data:{search:n,max:s.maxCache},complete:function(i,o){s.last_total=0;if(o=="success"){var u=e.parseJSON(i.responseText);f==0&&u.total<s.maxCache&&(s.last_search_match=n.length),s.last_search_len=n.length,s.last_total=u.total,s.items=u.items,t.list_render.call(r,n)}}})}var l=0,c="<ul>",h=[];for(var p in u)h.push(w2utils.isInt(u[p].id)?parseInt(u[p].id):String(u[p].id));for(var p in o){var d=o[p].id,v=o[p].text;if(e.inArray(w2utils.isInt(d)?parseInt(d):String(d),h)!=-1&&s.showAll!==!0)continue;var m=String(n).toLowerCase(),g=v.toLowerCase();m.length<=g.length&&g.substr(0,m.length)==m&&(typeof s["render"]=="function"&&(v=s.render(o[p])),c+='\n<li index="'+p+'" value="'+d+'" '+"  onmouseover=\"$(this).parent().find('li').removeClass('selected'); $(this).addClass('selected'); \""+'	class="'+(l%2?"w2ui-item-even":"w2ui-item-odd")+(l==e(r).data("last_index")?" selected":"")+'">'+v+"</li>",l==e(r).data("last_index")&&e(r).data("last_item",o[p]),l++)}c+="</ul>";if(l==0){c='<div class="w2ui-empty-list">'+w2utils.lang("No items found")+"</div>";var y=!0}i.find(".w2ui-items-list").html(c),e(this).data("last_max",l-1),i.find("li.selected").length>0&&i.find("li.selected")[0].scrollIntoView(!1),i.css({"-webkit-transition":"0s",height:"auto"});var b=parseInt(e(document).height())-parseInt(i.offset().top)-8;parseInt(i.height())>b&&(i.css({height:b-5+"px",overflow:"show"}),e(i).find(".w2ui-items-list").css({height:b-15+"px",overflow:"auto"})),e(i).off("mousedown").on("mousedown",function(n){if(n.target&&n.target.tagName!="LI")return;var i=e(n.target).attr("index"),o=s.items[i];if(typeof i=="undefined"){if(!n.preventDefault)return!1;n.preventDefault()}r.add(o),e(r).data("last_index",0),r.refresh(),t.list_render.call(r,"")}),e(r).prev().find("li > input").val(n).css("max-width",e(i).width()-25+"px").width((n.length+2)*6+"px").focus().on("click",function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}).off("keyup").on("keyup",function(n){var i=this;setTimeout(function(){var o=e(r).data("last_index");switch(n.keyCode){case 38:o--,o<0&&(o=0),e(r).data("last_index",o),n.preventDefault&&n.preventDefault();break;case 40:o++,o>e(r).data("last_max")&&(o=e(r).data("last_max")),e(r).data("last_index",o),n.preventDefault&&n.preventDefault();break;case 13:if(typeof e(r).data("last_item")=="undefined"||e(r).data("last_item")==null||y===!0)break;var u=e(r).data("selected");r.add(e(r).data("last_item")),o>e(r).data("last_max")-1&&(o=e(r).data("last_max")-1),e(r).data("last_index",o),e(r).data("last_item",null),e(i).val(""),r.refresh(),n.preventDefault&&n.preventDefault();break;case 8:if(String(i.value)=="")if(typeof e(r).data("last_del")=="undefined"||e(r).data("last_del")==null){var u=e(r).data("selected");e.isArray(u)||(u=[]),e(r).data("last_del",u.length-1),r.refresh()}else{var u=e(r).data("selected");e.isArray(u)||(u=[]),u.length>0&&u.splice(u.length-1,1),e(r).data("selected",u),e(r).data("last_del",null),r.refresh(),e(r).trigger("change")}break;default:e(r).data("last_index",0),e(r).data("last_del",null)}var a=e(r).prev();a.css("height","auto");var f=w2utils.getSize(a,"height")-parseInt(e(a).css("margin-top"))-parseInt(e(a).css("margin-bottom"));f<23&&(f=23),f>s.maxHeight&&(f=s.maxHeight),e(a).height(f),a.length>0&&(a[0].scrollTop=1e3),e(r).height(f);if(n.keyCode!=8||String(i.value)!="")e(r).prev().find("li").css("opacity","1"),e(r).data("last_del",null);e.inArray(n.keyCode,[16,91,37,39])==-1&&t.list_render.call(r,i.value)},10)})},calendar_get:function(t,n){var r=new Date,i=Number(r.getMonth())+1+"/"+r.getDate()+"/"+(String(r.getYear()).length>3?r.getYear():r.getYear()+1900);if(String(t)==""||String(t)=="undefined")t=w2utils.formatDate(i,n.format);w2utils.isDate(t,n.format)||(t=w2utils.formatDate(i,n.format));var s=t.replace(/-/g,"/").replace(/\./g,"/").toLowerCase().split("/"),o=n.format.replace(/-/g,"/").replace(/\./g,"/").toLowerCase(),u=new Date;o=="mm/dd/yyyy"&&(u=new Date(s[0]+"/"+s[1]+"/"+s[2])),o=="dd/mm/yyyy"&&(u=new Date(s[1]+"/"+s[0]+"/"+s[2])),o=="yyyy/dd/mm"&&(u=new Date(s[2]+"/"+s[1]+"/"+s[0])),o=="yyyy/mm/dd"&&(u=new Date(s[1]+"/"+s[2]+"/"+s[0]));var a='<table cellpadding="0" cellspacing="0"><tr><td>'+e().w2field("calendar_month",u.getMonth()+1,u.getFullYear(),n)+"</td>"+"</tr></table>";return a},calendar_next:function(t){var n=String(t).split("/"),r=n[0],i=n[1];parseInt(r)<12?r=parseInt(r)+1:(r=1,i=parseInt(i)+1);var s=e(e("#global_calendar_div.w2ui-calendar").data("el")).data("options");e("#global_calendar_div.w2ui-calendar").html(e().w2field("calendar_get",w2utils.formatDate(r+"/1/"+i,s.format),s))},calendar_previous:function(t){var n=String(t).split("/"),r=n[0],i=n[1];parseInt(r)>1?r=parseInt(r)-1:(r=12,i=parseInt(i)-1);var s=e(e("#global_calendar_div.w2ui-calendar").data("el")).data("options");e("#global_calendar_div.w2ui-calendar").html(e().w2field("calendar_get",w2utils.formatDate(r+"/1/"+i,s.format),s))},calendar_month:function(t,n,r){var i=new Date,s=w2utils.settings.fullmonths,o=w2utils.settings.fulldays,u=["31","28","31","30","31","30","31","31","30","31","30","31"],a=Number(i.getMonth())+1+"/"+i.getDate()+"/"+(String(i.getYear()).length>3?i.getYear():i.getYear()+1900);n=Number(n),t=Number(t);if(n===null||n==="")n=String(i.getYear()).length>3?i.getYear():i.getYear()+1900;if(t===null||t==="")t=Number(i.getMonth())+1;t>12&&(t-=12,n++);if(t<1||t==0)t+=12,n--;n/4==Math.floor(n/4)?u[1]="29":u[1]="28",n==null&&(n=i.getYear()),t==null&&(t=i.getMonth()-1);var i=new Date;i.setDate(1),i.setMonth(t-1),i.setYear(n);var f=i.getDay(),l=w2utils.settings.shortdays,c="";for(var h=0,p=l.length;h<p;h++)c+="<td>"+l[h]+"</td>";var d='<div class="w2ui-calendar-title">	<div class="w2ui-calendar-previous" onclick="$().w2field(\'calendar_previous\', \''+t+"/"+n+"')\"> <- </div>"+"	<div class=\"w2ui-calendar-next\" onclick=\"$().w2field('calendar_next', '"+t+"/"+n+"')\"> -> </div> "+s[t-1]+", "+n+"</div>"+'<table class="w2ui-calendar-days" onclick="" cellspacing="0">'+'	<tr class="w2ui-day-title">'+c+"</tr>"+"	<tr>",v=1;for(var m=1;m<43;m++){if(f==0&&m==1){for(var g=0;g<6;g++)d+='<td class="w2ui-day-empty">&nbsp;</td>';m+=6}else if(m<f||v>u[t-1]){d+='<td class="w2ui-day-empty">&nbsp;</td>',m%7==0&&(d+="</tr><tr>");continue}var y=t+"/"+v+"/"+n,b="";m%7==6&&(b="w2ui-saturday"),m%7==0&&(b="w2ui-sunday"),y==a&&(b+=" w2ui-today");var w=v,E="",S="",x="";r.colored&&r.colored[y]!=undefined&&(tmp=r.colored[y].split(":"),S="background-color: "+tmp[0]+";",E="color: "+tmp[1]+";");var T=!1;if(r.start||r.end){var N=new Date(r.start),C=new Date(r.end),k=new Date(y);if(k<N||k>C)x=" w2ui-blocked-date",T=!0}r.blocked&&e.inArray(y,r.blocked)!=-1&&(x=" w2ui-blocked-date",T=!0),d+='<td class="'+b+x+'" style="'+E+S+'" id="'+this.name+"_date_"+y+'" date="'+y+'"',T===!1&&(d+="onclick=\"var el = $('#global_calendar_div.w2ui-calendar').data('el'); 	$(el).val('"+w2utils.formatDate(y,r.format)+"').trigger('change').trigger('blur'); "+"	 if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;"+"	 if (event.preventDefault) event.preventDefault(); else return false;"+'"'),d+=">"+w+"</td>";if(m%7==0||f==0&&m==1)d+="</tr><tr>";v++}return d+="</tr></table>",d}}),w2obj.field=t}(jQuery),function(){var w2form=function(e){this.name=null,this.header="",this.box=null,this.url="",this.formURL="",this.formHTML="",this.page=0,this.recid=0,this.fields=[],this.actions={},this.record={},this.original={},this.postData={},this.tabs={},this.style="",this.focusFirst=!0,this.msgNotJSON=w2utils.lang("Return data is not in JSON format."),this.msgRefresh=w2utils.lang("Refreshing..."),this.msgSaving=w2utils.lang("Saving..."),this.onRequest=null,this.onLoad=null,this.onValidate=null,this.onSubmit=null,this.onSave=null,this.onChange=null,this.onRender=null,this.onRefresh=null,this.onResize=null,this.onDestroy=null,this.onAction=null,this.onError=null,this.isGenerated=!1,this.last={xhr:null},$.extend(!0,this,e,w2obj.form)};$.fn.w2form=function(e){if(typeof e=="object"||!e){var t=this;if(!e||typeof e.name=="undefined"){console.log('ERROR: The parameter "name" is required but not supplied in $().w2form().');return}if(typeof w2ui[e.name]!="undefined"){console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+e.name+").");return}if(!w2utils.isAlphaNumeric(e.name)){console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). ');return}var n=e.record,r=e.original,i=e.fields,s=e.tabs,o=new w2form(e);$.extend(o,{record:{},original:{},fields:[],tabs:{},handlers:[]});if($.isArray(s)){$.extend(!0,o.tabs,{tabs:[]});for(var u in s){var a=s[u];typeof a=="object"?o.tabs.tabs.push(a):o.tabs.tabs.push({id:a,caption:a})}}else $.extend(!0,o.tabs,s);for(var f in i)o.fields[f]=$.extend(!0,{},i[f]);for(var f in n)$.isPlainObject(n[f])?o.record[f]=$.extend(!0,{},n[f]):o.record[f]=n[f];for(var f in r)$.isPlainObject(r[f])?o.original[f]=$.extend(!0,{},r[f]):o.original[f]=r[f];return o.initTabs(),o.formURL!=""?$.get(o.formURL,function(e){o.formHTML=e;if($(t).length!=0||e.length!=0)$(t).html(o.formHTML),o.init(t),o.render($(t)[0])}):o.formHTML==""&&($(this).length!=0&&$.trim($(this).html())!=""?o.formHTML=$(this).html():(o.formHTML=o.generateHTML(),o.isGenerated=!0,$(t).html(o.formHTML))),w2ui[o.name]=o,o.formURL==""&&(String(o.formHTML).indexOf("w2ui-page")==-1&&(o.formHTML='<div class="w2ui-page page-0">'+o.formHTML+"</div>"),o.init(this),o.render($(this)[0])),o}if(w2ui[$(this).attr("name")]){var t=w2ui[$(this).attr("name")];return t[e].apply(t,Array.prototype.slice.call(arguments,1)),this}console.log("ERROR: Method "+e+" does not exist on jQuery.w2form")},w2form.prototype={init:function(e){var t=this;$(e).find("input, textarea, select").each(function(e,n){var r="text",i=typeof $(n).attr("name")!="undefined"?$(n).attr("name"):$(n).attr("id");n.type=="checkbox"&&(r="checkbox"),n.type=="radio"&&(r="radio"),n.type=="password"&&(r="password"),n.type=="button"&&(r="button"),n.tagName=="select"&&(r="list"),n.tagName=="textarea"&&(r="textarea");var s=r=="checkbox"||r=="radio"?$(n).prop("checked")?!0:!1:$(n).val(),o=t.get(i);if(o&&r!="button"){var u=$(n).parents(".w2ui-page");if(u.length>0)for(var a=0;a<100;a++)if(u.hasClass("page-"+a)){o.page=a;break}}else r!="button"&&console.log('WARNING: Field "'+i+'" is present in HTML, but not defined in w2form.')})},initTabs:function(){if(typeof this.tabs["render"]=="undefined"){var e=this;this.tabs=$().w2tabs($.extend({},this.tabs,{name:this.name+"_tabs",owner:this})),this.tabs.on("click",function(t,n){e.goto(this.get(t,!0))})}return},get:function(e,t){for(var n in this.fields)if(this.fields[n].name==e)return t===!0?n:this.fields[n];return null},set:function(e,t){for(var n in this.fields)if(this.fields[n].name==e)return $.extend(this.fields[n],t),this.refresh(),!0;return!1},reload:function(e){this.url!=""&&this.recid!=0?this.request(e):(this.refresh(),typeof e=="function"&&e())},clear:function(){this.recid=0,this.record={};for(var e in this.fields){var t=this.fields[e];t.options&&t.options.selected&&delete t.options.selected}$().w2tag(),this.refresh()},error:function(e){var t=this,n=this.trigger({target:this.name,type:"error",message:e,xhr:this.last.xhr});if(n.stop===!0)return typeof callBack=="function"&&callBack(),!1;setTimeout(function(){$("#w2ui-popup").length>0?$().w2popup("message",{width:370,height:140,html:'<div class="w2ui-grid-error-msg" style="font-size: 11px;">ERROR: '+e+"</div>"+'<div style="position: absolute; bottom: 7px; left: 0px; right: 0px; text-align: center;">'+'	<input type="button" value="Ok" onclick="$().w2popup(\'message\');" class="w2ui-grid-popup-btn">'+"</div>"}):$().w2popup("open",{width:420,height:200,showMax:!1,title:"Error",body:'<div class="w2ui-grid-error-msg">'+e+"</div>",buttons:'<input type="button" value="Ok" onclick="$().w2popup(\'close\');" class="w2ui-grid-popup-btn">'}),console.log("ERROR: "+e)},1),this.trigger($.extend(n,{phase:"after"}))},validate:function(e){typeof e=="undefined"&&(e=!0);var t=[];for(var n in this.fields){var r=this.fields[n];this.record[r.name]==null&&(this.record[r.name]="");switch(r.type){case"int":this.record[r.name]&&!w2utils.isInt(this.record[r.name])&&t.push({field:r,error:w2utils.lang("Not an integer")});break;case"float":this.record[r.name]&&!w2utils.isFloat(this.record[r.name])&&t.push({field:r,error:w2utils.lang("Not a float")});break;case"money":this.record[r.name]&&!w2utils.isMoney(this.record[r.name])&&t.push({field:r,error:w2utils.lang("Not in money format")});break;case"hex":this.record[r.name]&&!w2utils.isHex(this.record[r.name])&&t.push({field:r,error:w2utils.lang("Not a hex number")});break;case"email":this.record[r.name]&&!w2utils.isEmail(this.record[r.name])&&t.push({field:r,error:w2utils.lang("Not a valid email")});break;case"checkbox":this.record[r.name]==1?this.record[r.name]=1:this.record[r.name]=0;break;case"date":this.record[r.name]&&!w2utils.isDate(this.record[r.name],r.options.format)&&t.push({field:r,error:w2utils.lang("Not a valid date")+": "+r.options.format});break;case"select":case"list":break;case"enum":}var i=this.record[r.name];r.required&&(i===""||$.isArray(i)&&i.length==0)&&t.push({field:r,error:w2utils.lang("Required field")})}var s=this.trigger({phase:"before",target:this.name,type:"validate",errors:t});if(s.stop===!0)return t;if(e)for(var o in s.errors){var u=s.errors[o];$(u.field.el).w2tag(u.error,{"class":"w2ui-error"})}return this.trigger($.extend(s,{phase:"after"})),t},request:function(postData,callBack){var obj=this;typeof postData=="function"&&(callBack=postData,postData=null);if(typeof postData=="undefined"||postData==
null)postData={};if(!this.url)return;if(this.recid==null||typeof this.recid=="undefined")this.recid=0;var params={};params.cmd="get-record",params.name=this.name,params.recid=this.recid,$.extend(params,this.postData),$.extend(params,postData);var eventData=this.trigger({phase:"before",type:"request",target:this.name,url:this.url,postData:params});if(eventData.stop===!0)return typeof callBack=="function"&&callBack({status:"error",message:"Request aborted."}),!1;this.record={},this.original={},this.lock(this.msgRefresh);if(this.last.xhr)try{this.last.xhr.abort()}catch(e){}this.last.xhr=$.ajax({type:"GET",url:eventData.url,data:String($.param(eventData.postData,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]"),dataType:"text",complete:function(xhr,status){obj.unlock();var eventData=obj.trigger({phase:"before",target:obj.name,type:"load",xhr:xhr,status:status});if(eventData.stop===!0)return typeof callBack=="function"&&callBack({status:"error",message:"Request aborted."}),!1;var responseText=obj.last.xhr.responseText;if(status!="error"){if(typeof responseText!="undefined"&&responseText!=""){var data;if(typeof responseText=="object")data=responseText;else try{eval("data = "+responseText)}catch(e){}typeof data=="undefined"&&(data={status:"error",message:obj.msgNotJSON,responseText:responseText}),data["status"]=="error"?obj.error(data.message):(obj.record=$.extend({},data.record),obj.original=$.extend({},data.record))}}else obj.error("AJAX Error "+xhr.status+": "+xhr.statusText);obj.trigger($.extend(eventData,{phase:"after"})),obj.refresh(),typeof callBack=="function"&&callBack(data)}}),this.trigger($.extend(eventData,{phase:"after"}))},submit:function(e,t){return this.save(e,t)},save:function(postData,callBack){var obj=this;typeof postData=="function"&&(callBack=postData,postData=null);var errors=obj.validate(!0);if(errors.length!==0){obj.goto(errors[0].field.page);return}if(typeof postData=="undefined"||postData==null)postData={};if(!obj.url){console.log("ERROR: Form cannot be saved because no url is defined.");return}obj.lock(obj.msgSaving+' <span id="'+obj.name+'_progress"></span>'),setTimeout(function(){var params={};params.cmd="save-record",params.name=obj.name,params.recid=obj.recid,$.extend(params,obj.postData),$.extend(params,postData),params.record=$.extend(!0,{},obj.record);for(var f in obj.fields){var field=obj.fields[f];switch(String(field.type).toLowerCase()){case"date":var dt=params.record[field.name];if(field.options.format.toLowerCase()=="dd/mm/yyyy"||field.options.format.toLowerCase()=="dd-mm-yyyy"||field.options.format.toLowerCase()=="dd.mm.yyyy")var tmp=dt.replace(/-/g,"/").replace(/\./g,"/").split("/"),dt=new Date(tmp[2]+"-"+tmp[1]+"-"+tmp[0]);params.record[field.name]=w2utils.formatDate(dt,"yyyy-mm-dd")}}var eventData=obj.trigger({phase:"before",type:"submit",target:obj.name,url:obj.url,postData:params});if(eventData.stop===!0)return typeof callBack=="function"&&callBack({status:"error",message:"Saving aborted."}),!1;if(obj.last.xhr)try{obj.last.xhr.abort()}catch(e){}obj.last.xhr=$.ajax({type:w2utils.settings.RESTfull?obj.recid==0?"POST":"PUT":"POST",url:eventData.url,data:String($.param(eventData.postData,!1)).replace(/%5B/g,"[").replace(/%5D/g,"]"),dataType:"text",xhr:function(){var e=new window.XMLHttpRequest;return e.upload.addEventListener("progress",function(e){if(e.lengthComputable){var t=Math.round(e.loaded/e.total*100);$("#"+obj.name+"_progress").text(""+t+"%")}},!1),e},complete:function(xhr,status){obj.unlock();var eventData=obj.trigger({phase:"before",target:obj.name,type:"save",xhr:xhr,status:status});if(eventData.stop===!0)return typeof callBack=="function"&&callBack({status:"error",message:"Saving aborted."}),!1;var responseText=xhr.responseText;if(status!="error"){if(typeof responseText!="undefined"&&responseText!=""){var data;if(typeof responseText=="object")data=responseText;else try{eval("data = "+responseText)}catch(e){}typeof data=="undefined"&&(data={status:"error",message:obj.msgNotJSON,responseText:responseText}),data["status"]=="error"?obj.error(data.message):obj.original=$.extend({},obj.record)}}else obj.error("AJAX Error "+xhr.status+": "+xhr.statusText);obj.trigger($.extend(eventData,{phase:"after"})),obj.refresh(),typeof callBack=="function"&&callBack(data)}}),obj.trigger($.extend(eventData,{phase:"after"}))},50)},lock:function(e,t){var n=this;typeof e=="undefined"||e==""?setTimeout(function(){$("#form_"+n.name+"_lock").remove(),$("#form_"+n.name+"_status").remove()},25):($("#form_"+n.name+"_lock").remove(),$("#form_"+n.name+"_status").remove(),$(this.box).find("> div :first-child").before('<div id="form_'+n.name+'_lock" class="w2ui-form-lock"></div>'+'<div id="form_'+n.name+'_status" class="w2ui-form-status"></div>'),setTimeout(function(){var t=$("#form_"+n.name+"_lock"),r=$("#form_"+n.name+"_status");r.data("old_opacity",r.css("opacity")).css("opacity","0").show(),t.data("old_opacity",t.css("opacity")).css("opacity","0").show(),setTimeout(function(){var i=($(n.box).width()-w2utils.getSize(r,"width"))/2,s=($(n.box).height()*.9-w2utils.getSize(r,"height"))/2;t.css({opacity:t.data("old_opacity"),width:$(n.box).width()+"px",height:$(n.box).height()+"px"}),r.html(e).css({opacity:r.data("old_opacity"),left:i+"px",top:s+"px"})},10)},10))},unlock:function(){this.lock()},"goto":function(e){typeof e!="undefined"&&(this.page=e),$(this.box).data("auto-size")===!0&&$(this.box).height(0),this.refresh()},generateHTML:function(){var e=[];for(var t in this.fields){var n="",r=this.fields[t];typeof r.html=="undefined"&&(r.html={}),r.html=$.extend(!0,{caption:"",span:6,attr:"",text:"",page:0},r.html),r.html.caption==""&&(r.html.caption=r.name);var i='<input name="'+r.name+'" type="text" '+r.html.attr+"/>";r.type=="list"&&(i='<select name="'+r.name+'" '+r.html.attr+"></select>"),r.type=="checkbox"&&(i='<input name="'+r.name+'" type="checkbox" '+r.html.attr+"/>"),r.type=="textarea"&&(i='<textarea name="'+r.name+'" '+r.html.attr+"></textarea>"),n+='\n   <div class="w2ui-label '+(typeof r.html.span!="undefined"?"w2ui-span"+r.html.span:"")+'">'+r.html.caption+":</div>"+'\n   <div class="w2ui-field '+(typeof r.html.span!="undefined"?"w2ui-span"+r.html.span:"")+'">'+i+r.html.text+"</div>",typeof e[r.html.page]=="undefined"&&(e[r.html.page]='<div class="w2ui-page page-'+r.html.page+'">'),e[r.html.page]+=n}for(var s in e)e[s]+="\n</div>";var o="";if(this.actions.length>0){o+='\n<div class="w2ui-buttons">';for(var u in this.actions)o+='\n    <input type="button" value="'+u+'" name="'+u+'">';o+="\n</div>"}return e.join("")+o},doAction:function(e,t){var n=this.trigger({phase:"before",target:e,type:"action",event:t});if(n.stop===!0)return!1;typeof this.actions[e]=="function"&&this.actions[e].call(this,t),this.trigger($.extend(n,{phase:"after"}))},resize:function(){function f(){n.width($(e.box).width()).height($(e.box).height()),i.css("top",e.header!=""?w2utils.getSize(r,"height"):0),s.css("top",(e.header!=""?w2utils.getSize(r,"height"):0)+(e.tabs.tabs.length>0?w2utils.getSize(i,"height")+5:0)),s.css("bottom",a.length>0?w2utils.getSize(a,"height"):0)}var e=this,t=this.trigger({phase:"before",target:this.name,type:"resize"});if(t.stop===!0)return!1;var n=$(this.box).find("> div"),r=$(this.box).find("> div .w2ui-form-header"),i=$(this.box).find("> div .w2ui-form-tabs"),s=$(this.box).find("> div .w2ui-page"),o=$(this.box).find("> div .w2ui-page.page-"+this.page),u=$(this.box).find("> div .w2ui-page.page-"+this.page+" > div"),a=$(this.box).find("> div .w2ui-buttons");f();if($(this.box).height()==0||$(this.box).data("auto-size")===!0)$(this.box).height((r.length>0?w2utils.getSize(r,"height"):0)+(this.tabs.tabs.length>0?w2utils.getSize(i,"height"):0)+(s.length>0?w2utils.getSize(u,"height")+w2utils.getSize(o,"+height")+12:0)+(a.length>0?w2utils.getSize(a,"height"):0)),$(this.box).data("auto-size",!0);f(),e.trigger($.extend(t,{phase:"after"}))},refresh:function(){var e=this;if(!this.box)return;var t=this.trigger({phase:"before",target:this.name,type:"refresh",page:this.page});if(t.stop===!0)return!1;$(this.box).find(".w2ui-page").hide(),$(this.box).find(".w2ui-page.page-"+this.page).show(),typeof this.tabs=="object"&&this.tabs.tabs.length>0?($("#form_"+this.name+"_tabs").show(),this.tabs.active=this.tabs.tabs[this.page].id,this.tabs.refresh()):$("#form_"+this.name+"_tabs").hide();for(var n in this.fields){var r=this.fields[n];r.el=$(this.box).find('[name="'+String(r.name).replace(/\\/g,"\\\\")+'"]')[0],typeof r.el=="undefined"&&console.log('ERROR: Cannot associate field "'+r.name+'" with html control. Make sure html control exists with the same name.'),r.el&&(r.el.id=r.name),$(r.el).off("change").on("change",function(){var t=this.value,n=e.record[this.name]?e.record[this.name]:"",r=e.get(this.name);if((r.type=="enum"||r.type=="upload")&&$(this).data("selected")){var i=$(this).data("selected"),s=e.get(this.name).selected,t=[],n=[];if($.isArray(i))for(var o in i)t[o]=$.extend(!0,{},i[o]);if($.isArray(s))for(var o in s)n[o]=$.extend(!0,{},s[o]);e.get(this.name).selected=t}var u=e.trigger({phase:"before",target:this.name,type:"change",value_new:t,value_previous:n});if(u.stop===!0)return $(this).val(e.record[this.name]),!1;var a=this.value;this.type=="checkbox"&&(a=this.checked?!0:!1),this.type=="radio"&&(a=this.checked?!0:!1),r.type=="enum"&&(a=t),r.type=="upload"&&(a=t),e.record[this.name]=a,e.trigger($.extend(u,{phase:"after"}))}),r.required?$(r.el).parent().addClass("w2ui-required"):$(r.el).parent().removeClass("w2ui-required")}$(this.box).find("button, input[type=button]").each(function(t,n){$(n).off("click").on("click",function(t){var n=this.value;this.name&&(n=this.name),this.id&&(n=this.id),e.doAction(n,t)})});for(var n in this.fields){var r=this.fields[n],i=typeof this.record[r.name]!="undefined"?this.record[r.name]:"";if(!r.el)continue;switch(String(r.type).toLowerCase()){case"email":case"text":case"textarea":r.el.value=i;break;case"date":r.options||(r.options={}),r.options.format||(r.options.format="mm/dd/yyyy"),r.el.value=i,this.record[r.name]=i,$(r.el).w2field($.extend({},r.options,{type:"date"}));break;case"int":r.el.value=i,$(r.el).w2field("int");break;case"float":r.el.value=i,$(r.el).w2field("float");break;case"money":r.el.value=i,$(r.el).w2field("money");break;case"hex":r.el.value=i,$(r.el).w2field("hex");break;case"alphanumeric":r.el.value=i,$(r.el).w2field("alphaNumeric");break;case"checkbox":this.record[r.name]==1||this.record[r.name]==1||this.record[r.name]=="t"?$(r.el).prop("checked",!0):$(r.el).prop("checked",!1);break;case"password":r.el.value=i;break;case"select":case"list":$(r.el).w2field($.extend({},r.options,{type:"list",value:i}));break;case"enum":if(typeof r.options=="undefined"||typeof r.options.url=="undefined"&&typeof r.options.items=="undefined"){console.log("ERROR: (w2form."+e.name+") the field "+r.name+" defined as enum but not field.options.url or field.options.items provided.");break}var s=i;$(r.el).w2field($.extend({},r.options,{type:"enum",selected:i}));break;case"upload":$(r.el).w2field($.extend({},r.options,{type:"upload",selected:i}));break;default:console.log('ERROR: field type "'+r.type+'" is not recognized.')}}var o=$(this.box).find(".w2ui-page");for(var u=0;u<o.length;u++)$(o[u]).find("> *").length>1&&$(o[u]).wrapInner("<div></div>");this.trigger($.extend(t,{phase:"after"})),this.resize()},render:function(e){function i(){var e=$(t.box).find("input, select");e.length>0&&e[0].focus()}var t=this;e&&$(e).html()!=""&&this.isGenerated&&(this.formHTML=$(e).html(),this.isGenerated=!1);var n=this.trigger({phase:"before",target:this.name,type:"render",box:typeof e!="undefined"?e:this.box});if(n.stop===!0)return!1;typeof e!="undefined"&&e!=null&&($(this.box).find("#form_"+this.name+"_tabs").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-form").html(""),this.box=e);var r="<div>"+(this.header!=""?'<div class="w2ui-form-header">'+this.header+"</div>":"")+'	<div id="form_'+this.name+'_tabs" class="w2ui-form-tabs"></div>'+this.formHTML+"</div>";$(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-form").html(r),$(this.box).length>0&&($(this.box)[0].style.cssText+=this.style),this.initTabs(),typeof this.tabs=="object"&&typeof this.tabs.render=="function"&&this.tabs.render($("#form_"+this.name+"_tabs")[0]),this.trigger($.extend(n,{phase:"after"})),this.resize(),this.url!=""&&this.recid!=0?this.request():this.refresh(),$(".w2ui-layout").length==0&&(this.tmp_resize=function(e){w2ui[t.name].resize()},$(window).off("resize","body").on("resize","body",this.tmp_resize)),setTimeout(function(){t.resize(),t.refresh()},150),this.focusFirst===!0&&setTimeout(i,500)},destroy:function(){var e=this.trigger({phase:"before",target:this.name,type:"destroy"});if(e.stop===!0)return!1;typeof this.tabs=="object"&&this.tabs.destroy&&this.tabs.destroy(),$(this.box).find("#form_"+this.name+"_tabs").length>0&&$(this.box).removeAttr("name").removeClass("w2ui-reset w2ui-form").html(""),delete w2ui[this.name],this.trigger($.extend(e,{phase:"after"})),$(window).off("resize","body")}},$.extend(w2form.prototype,$.w2event),w2obj.form=w2form}();
