/** * JavaScript for PHPMaker 10 * (C)2002-2013 e.World Technology Ltd. */function ew_DefaultLookup(e,t){var n=t.data,r=t.parents;for(var i=0,s=r.length;i1&&i.each(function(e,n){t(n).find(":input").each(function(e,s){if(/^(fn_)?(x|o)\d*_/.test(s.name)){var o=i.not(n).find(":input[name='"+s.name+"']");if(o.length){var u=t(s).serializeArray();t.each(u,function(e,i){t("").val(i.value).appendTo(r)})}}})}),n.submit()}else this.EnableForm();return!1},this.EmptyRow=null,this.MultiPage=null,this.Lists={},this.AutoSuggests={},this.GetForm=function(){return this.Form||(this.$Element=t("#"+this.ID),this.$Element.is("form")?this.Form=this.$Element[0]:this.$Element.is("div")&&(this.Form=this.$Element.closest("form")[0])),this.Form},this.GetElements=function(e){var t="[name='"+e+"']";t="input"+t+",select"+t+",textarea"+t+",button"+t;var n=this.$Element.find(t);return n.length==0?null:n.length==1&&n.is(":not(:checkbox):not(:radio)")?n[0]:n.get()},this.PostAutoSuggest=function(){},this.UpdateOpts=function(e){if(e===$rowindex$)return;var n=[],r=this.GetForm();for(var i in this.Lists){var s=this.Lists[i].ParentFields.slice(),o=this.Lists[i].Ajax;if(t.isValue(e)){i=i.replace(/^x_/,"x"+e+"_");for(var u=0,a=s.length;u-1||e&&i.name!=e)return!0;i.create();if(e)return!1})},this.UpdateTextArea=function(e){var n=this.GetForm();t(n.elements).filter("textarea.editor").each(function(n,r){var i=t(r).data("editor");if(!i||e&&i.name!=e)return!0;i.save();if(e)return!1})},this.DestroyEditor=function(e){var n=this.GetForm();t(n.elements).filter("textarea.editor").each(function(n,r){var i=t(r).data("editor");if(!i||e&&i.name!=e)return!0;i.destroy();if(e)return!1})},this.OnError=function(e,t){return ew_OnError(this,e,t)},this.InitUpload=function(){var e=this.GetForm();t(e.elements).filter("input:file").each(ew_Upload)},this.Init=function(){var e=this,n=this.GetForm(),r=t(n);if(!n)return;var i=/s(ea)?rch$/.test(this.ID);i&&this.InitSearchPanel&&!ew_HasFormData(n)&&r.find(".accordion-toggle[href$=_SearchBody]").click(),i&&r.find("select[id^=z_]").each(function(){var e=t(this).change();e.val()!="BETWEEN"&&r.find("#w_"+this.id.substr(2)).change()}),this.MultiPage&&this.MultiPage.Render(this.ID),this.CreateEditor(),this.UpdateOpts(),this.InitUpload(),this.$Element.is("form")&&r.submit(function(t){return e.Submit()}),this.$Element.data("form",this)},ewForms[this.ID]=this}function ew_GetForm(e){var t=jQuery,n=t(e),r=n.closest(".ewForm");return r[0]||(r=n.closest(".ewGrid").find(".ewForm")),r[0]}function ew_HasFormData(e){var t=jQuery,n=t(e).find("[name^=x_][value!=''],[name^=y_][value!=''],[name^=z_],[name^=w_],[name='psearch'][value!='']").get();for(var r=0,i=n.length;r0)if(i.isArray(t[0]))b=t;else if(i.isString(t[0]))for(var c=0,h=t.length;c[\s\S]*<\/td>)\s*$/i.test($scr.html())?$scr.next().before(t(""+RegExp.$1+"
").find("tr:first > td")):t(this).after(t("").addClass($scr.attr("class")).html($scr.html())),$scr.closest(".ewTable").show(),$scr.closest(".ewGrid").show()})}function ew_ConvertToBool(e){return ew_InArray(e.toLowerCase(),["1","y","t"])>-1}function ew_ValueChanged(e,t,n,r){var i=jQuery,s=ew_GetElements("x"+t+"_"+n,e),o=ew_GetElement("o"+t+"_"+n,e),u=ew_GetElement("fn_x"+t+"_"+n,e);if(!o&&(!s||i.isArray(s)&&s.length==0))return!1;var a=function(e){return ew_GetOptValues(e).join(",")};if(o&&s)if(r){if(ew_ConvertToBool(a(o))===ew_ConvertToBool(a(s)))return!1}else{var f=a(o),l=u?a(u):a(s);if(f==l)return!1}return!0}function ew_ReadOnlyTextArea(e,t,n){if(!e||!e.parentNode)return;var r=jQuery,i=r(e).hide().prop("readOnly",!0),s=r("
").addClass("ewReadOnlyTextArea").width(t).height(n).appendTo(i.parent()),o=r("
").addClass("ewResizeHandle").appendTo(s),u=r("
").html(i.val()).addClass("ewReadOnlyTextAreaData uneditable-textarea").appendTo(s);u.height(s.height()-5),s.drag("start",function(e,t){t.width=r(this).width(),t.height=r(this).height()}).drag(function(e,t){r(this).css({width:Math.max(20,t.width+t.deltaX),height:Math.max(20,t.height+t.deltaY)}),u.height(s.height()-5)},{handle:".ewResizeHandle"})}function ew_Get(e,t){t=t||window.location.search;var n=/(?:\?|&)([^&=]+)=?([^&]*)/g,r=/\+/g,i=function(e){return decodeURIComponent(e.replace(r," "))},s={},o;while(o=n.exec(t)){var u=i(o[1]),a=i(o[2]);u.substring(u.length-2)==="[]"&&(u=u.substring(0,u.length-2)),(s[u]||(s[u]=[])).push(a)}return s[e]}function ew_SubmitLanguageForm(e){if(!e||!e.language||!e.language.value)return;var t=window.location.href;if(window.location.search){var n=window.location.search,r={};n.replace(/(?:\?|&)([^&=]*)=?([^&]*)/g,function(e,t,n){t&&(r[t]=n)}),r.language=encodeURIComponent(e.language.value);var i="?";for(var s in r)i+=s+"="+r[s]+"&";i=i.substr(0,i.length-1);var o=t.lastIndexOf(window.location.search);t=t.substr(0,o)+i}else t+="?language="+encodeURIComponent(e.language.value);window.location=t}function ew_SubmitSelected(e,t,n,r){if(!e)return;if(!ew_KeySelected(e))alert(ewLanguage.Phrase("NoRecordSelected"));else if(n?ew_Confirm(n):!0){var i=jQuery,s=i(e);r&&i("").attr({type:"hidden",name:"useraction"}).val(r).appendTo(s),s.prop("action",t).submit()}}function ew_SubmitSelectedExport(e,t,n){if(!e)return;ew_KeySelected(e)?(e.exporttype&&n&&(e.exporttype.value=n),e.submit()):alert(ewLanguage.Phrase("NoRecordSelected"))}function ew_RemoveSpaces(e){return/^(<(p|br)\/?>( )?(<\/p>)?)?$/i.test(e.replace(/\s/g,""))?"":e}function ew_IsHiddenTextArea(e){var t=jQuery,n=t(e);return e&&n.is(":hidden")&&n.data("editor")}function ew_IsAutoSuggest(e){var t=jQuery,n=t(e);return e&&n.is(":hidden")&&n.data("typeahead")}function ew_GetAutoSuggest(e){return ewForms(e).AutoSuggests[e.id]}function ew_OnError(e,t,n){alert(n);if(e)if(e.MultiPage)e.MultiPage.GotoPageByElement(t);else if(e.$Element.is("div")){var r=e.$Element.closest(".tab-pane");r[0]&&!r.hasClass("active")&&r.closest(".tabbable").find("a[data-toggle=tab][href='#"+r.attr("id")+"']").click()}return jQuery.later(100,this,"ew_SetFocus",t),!1}function ew_SetFocus(e){if(!e)return;var t=jQuery,n=t(e);if(ew_IsHiddenTextArea(e))return n.data("editor").focus();!e.options&&e.length?e=n.filter("[value!='{value}']")[0]:ew_IsAutoSuggest(e)&&(e=ew_GetAutoSuggest(e).input);var r=n.closest(".control-group").addClass("error");n.focus().select().one("click keypress",function(){r.removeClass("error")})}function ew_HasValue(e){return ew_GetOptValues(e).join("")!=""}function ew_Sort(e,t,n){return n==2&&e.ctrlKey&&(t+="&ctrl=1"),location=t,!0}function ew_Confirm(e){return confirm(e)}function ew_ConfirmDelete(e,t){var n=confirm(e);return n||ew_ClearDelete(t),n}function ew_KeySelected(e){return jQuery(e).find("input:checkbox[name='key_m[]']:checked",e).length>0}function ew_SelectAllKey(e){ew_SelectAll(e);var t=jQuery,n=t(e).closest("."+EW_TABLE_CLASSNAME)[0];if(!n)return;t(n.tBodies).each(function(){t(this.rows).each(function(n,r){var i=t(r);i.is(":not(."+EW_ITEM_TEMPLATE_CLASSNAME+"):not(."+EW_TABLE_PREVIEW_ROW_CLASSNAME+")")&&(i.data({selected:e.checked,checked:e.checked}),ew_SetColor(n,r))})})}function ew_SelectAll(e){if(!e||!e.form)return;$(e.form.elements).filter("input:checkbox[name^="+e.name+"_], :checkbox[name="+e.name+"]").not(e).prop("checked",e.checked)}function ew_UpdateSelected(e){return jQuery(e).find("input:checkbox[name^=u_]:checked").length>0}function ew_AddClass(e,t){var n=jQuery,r=n(e);r.data("bgcolor")||r.data("bgcolor",r.css("backgroundColor")),r.data("color")||r.data("color",r.css("color")),r.css("backgroundColor","").css("color","").addClass(t)}function ew_RemoveClass(e,t){var n=jQuery,r=n(e).removeClass(t);r.data("bgcolor")&&r.css("backgroundColor",r.data("bgcolor")),r.data("color")&&r.css("color",r.data("color"))}function ew_UpdateRow(e,t){var n=jQuery,r=n(e),i=r.data("rowindex");if(!e||!n.isFunction(t))return;t(-1,e),i&&(r.prevUntil("tr[data-rowindex!='"+i+"']").each(t),r.nextUntil("tr[data-rowindex!='"+i+"']").each(t))}function ew_MouseOver(e){var t=jQuery,n=t(this);if(!n.data("selected")&&ew_InArray(n.data("rowtype"),[EW_ROWTYPE_ADD,EW_ROWTYPE_EDIT])==-1){var r=n.closest("."+EW_TABLE_CLASSNAME);if(!r[0])return;ew_UpdateRow(this,function(e,n){t(n).addClass(r.data("rowhighlightclass")||EW_TABLE_HIGHLIGHT_ROW_CLASSNAME)})}}function ew_MouseOut(e){var t=jQuery,n=t(this);!n.data("selected")&&ew_InArray(n.data("rowtype"),[EW_ROWTYPE_ADD,EW_ROWTYPE_EDIT])==-1&&ew_UpdateRow(this,ew_SetColor)}function ew_Click(e){var t=jQuery,n=t(this),r=n.closest("."+EW_TABLE_CLASSNAME)[0],i=t(e.target);if(!r||i.hasClass("btn")||i.hasClass("ewPreviewRowImage")||i.is(":input"))return;if(!n.data("checked")){var s=n.data("selected");ew_ClearSelected(r),ew_UpdateRow(this,function(e,n){t(n).data("selected",!s),ew_SetColor(e,n)})}}function ew_SetColor(e,t){var n=jQuery,r=n(t),i=r.closest("."+EW_TABLE_CLASSNAME);if(!i[0])return;r.data("selected")?r.removeClass(i.data("rowhighlightclass")||EW_TABLE_HIGHLIGHT_ROW_CLASSNAME).removeClass(i.data("roweditclass")||EW_TABLE_EDIT_ROW_CLASSNAME).addClass(i.data("rowselectclass")||EW_TABLE_SELECT_ROW_CLASSNAME):ew_InArray(r.data("rowtype"),[EW_ROWTYPE_ADD,EW_ROWTYPE_EDIT])>-1?r.removeClass(i.data("rowselectclass")||EW_TABLE_SELECT_ROW_CLASSNAME).removeClass(i.data("rowhighlightclass")||EW_TABLE_HIGHLIGHT_ROW_CLASSNAME).addClass(i.data("roweditclass")||EW_TABLE_EDIT_ROW_CLASSNAME):r.removeClass(i.data("rowselectclass")||EW_TABLE_SELECT_ROW_CLASSNAME).removeClass(i.data("roweditclass")||EW_TABLE_EDIT_ROW_CLASSNAME).removeClass(i.data("rowhighlightclass")||EW_TABLE_HIGHLIGHT_ROW_CLASSNAME)}function ew_ClearSelected(e){var t=jQuery;t(e.rows).each(function(e,n){var r=t(n);!r.data("checked")&&r.data("selected")&&(r.data("selected",!1),ew_SetColor(e,n))})}function ew_ClearDelete(e){var t=jQuery,n=t(e),r=n.closest("."+EW_TABLE_CLASSNAME)[0];if(!r)return;ew_UpdateRow(n.closest(".ewTable > tbody > tr")[0],function(e,n){var r=t(n);r.data("selected",r.data("checked"))})}function ew_ClickDelete(e){var t=jQuery,n=t(e),r=n.closest("."+EW_TABLE_CLASSNAME)[0];if(!r)return;ew_ClearSelected(r),ew_UpdateRow(n.closest(".ewTable > tbody > tr")[0],function(e,n){t(n).data("selected",!0),ew_SetColor(e,n)})}function ew_StopPropagation(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ew_ClickMultiCheckbox(e,t){var n=jQuery,r=n(t),i=r.closest("."+EW_TABLE_CLASSNAME)[0];if(!i)return;ew_ClearSelected(i),ew_UpdateRow(r.closest(".ewTable > tbody > tr")[0],function(e,r){n(r).data("checked",t.checked).data("selected",t.checked).find("input:checkbox[name='key_m[]']").each(function(){this!=t&&(this.checked=t.checked)}),ew_SetColor(e,r)}),ew_StopPropagation(e)}function ew_SetupTable(e,t,n){var r=jQuery,i=r(t),s=r(t.rows);if(!t||!t.rows||!n&&i.data("isset")||t.tBodies.length==0)return;var o=s.filter("[data-rowindex=1]").length||s.filter("[data-rowindex=0]").length||1,u=s.filter(":not(."+EW_ITEM_TEMPLATE_CLASSNAME+")").map(function(){return r(this.cells).removeClass(EW_TABLE_LAST_ROW_CLASSNAME).last().addClass(EW_TABLE_LAST_COL_CLASSNAME),this}).get();if(u.length)for(var a=1;a<=o;a++){var f=u[u.length-a];r(f.cells).each(function(){this.rowSpan==a&&r(this).addClass(EW_TABLE_LAST_ROW_CLASSNAME)})}var l=i.closest("form")[0],c=l&&r(l.elements).filter("input#a_list:not([value^=grid])").length>0;u=r(t.tBodies[t.tBodies.length-1].rows).filter(":not(."+EW_ITEM_TEMPLATE_CLASSNAME+"):not(."+EW_TABLE_PREVIEW_ROW_CLASSNAME+")").each(function(){var e=r(this);return c&&!e.data("isset")&&(ew_InArray(e.data("rowtype"),[EW_ROWTYPE_ADD,EW_ROWTYPE_EDIT])>-1&&e.on("mouseover",function(){this.edit=!0}).addClass(EW_TABLE_EDIT_ROW_CLASSNAME),e.on("mouseover",ew_MouseOver).on("mouseout",ew_MouseOut).on("click",ew_Click),e.data("isset",!0)),f}),r(u).each(function(e){var t=e%(2*o)').wrap('
');var i=n.find("thead > tr"),s=n.find("tbody > tr");r.each(function(){var e=t(this);e.find("td:first").appendTo(i),e.find("td:last").appendTo(s)}),ew_SetupTable(-1,n[0])}function ew_Reflow(){if(!EW_IS_MOBILE)return;var e=jQuery;e(".ewGrid .table:first-child, .ewBasicSearch, .ewForm:has(div.control-group)").each(function(){$el=e(this);if($el.is("table.table")){var t=$el.parent();$el.hide().find("tr[id^=r_] > td").each(function(){var n=e(this);if(n.is(":first-child"))n.wrapInner("
").contents().first().addClass("ewLabelRow").appendTo(t).find("> label").addClass("pull-left");else if(n.is(":last-child")){var r=n.wrapInner("
").contents().first().addClass("ewInputRow").appendTo(t);r.find(".ewSearchCond, .ewSearchOperator").wrap('
'),r.find(".control-group").wrap('
')}else n.contents().appendTo(t.find(".ewLabelRow:last"))})}else $el.is(".ewBasicSearch")?$el.find(".ewRow:has(.ewCell)").each(function(){var t=e(this);t.find(".ewCell").hide().each(function(){var n=e(this);e("
").append(n.find(".ewSearchCaption:first")).addClass("ewLabelRow").appendTo(t),n.find(".ewSearchOperator:first").appendTo(t.find(".ewLabelRow:last")),e("
").append(n.contents()).addClass("ewInputRow").appendTo(t)})}):$el.is(".ewForm")&&e(this).removeClass("form-horizontal")})}function ew_SetupGrid(e,t,n){var r=jQuery,i=r(t);if(!t||!n&&i.data("isset"))return;var s=i.find("table.ewMultiColumnTable").length,o;s?o=i.find("td[data-rowindex]").length:o=i.find("table."+EW_TABLE_CLASSNAME+" > tbody:first > tr:not(."+EW_TABLE_PREVIEW_ROW_CLASSNAME+", ."+EW_ITEM_TEMPLATE_CLASSNAME+")").length;var u=i.find("div.ewGridUpperPanel"),a=i.find("div.ewGridMiddlePanel"),f=i.find("div.ewGridLowerPanel"),l=!s&&o==0;u[0]&&f[0]?(f.toggleClass("hide",o==0),u.toggleClass("ewNoBorderBottom",l)):u[0]&&!f[0]?u.toggleClass("ewNoBorderBottom",l):f[0]&&!u[0]&&f.toggleClass("ewNoBorderTop",l),i.data("isset",!0)}function ew_AddGridRow(e){var t=jQuery,n=t(e).closest("."+EW_GRID_CLASSNAME),r=n.find("table."+EW_TABLE_CLASSNAME),i=r.find("tr."+EW_ITEM_TEMPLATE_CLASSNAME);if(!e||!n[0]||!r[0]||!i[0])return;var s=t(r[0].rows).last().removeClass(EW_TABLE_LAST_ROW_CLASSNAME),o=i.clone(!0).removeClass(EW_ITEM_TEMPLATE_CLASSNAME),u=n.find("div.ewForm[id^=f][id$=grid]");u[0]||(u=n.find("form.ewForm[id^=f][id$=list]"));var a=u.is("div")?"_"+u.attr("id"):"",f=u.find("#key_count"+a),l=parseInt(f.val(),10)+1;o.attr({id:"r"+l+o.attr("id").substring(2),"data-rowindex":l});var c=i.find("script:contains('$rowindex$')");o.children("td").each(function(){this.innerHTML=this.innerHTML.replace(/\$rowindex\$/g,l)}),f.val(l).after(t("").attr({type:"hidden",id:"k"+l+"_action"+a,name:"k"+l+"_action"+a,value:"insert"})),s.after(o);var h=u.data("form");h&&(h.CreateEditor(),h.InitUpload()),c.each(function(){ew_AddScript(this.text.replace(/\$rowindex\$/g,l))}),ew_SetupTable(-1,r[0],!0)}function ew_DeleteGridRow(e,t){var n=jQuery,r=n(e).closest("."+EW_GRID_CLASSNAME),i=n(e).closest("tr"),s=i.closest("."+EW_TABLE_CLASSNAME);if(!e||!r[0]||!i[0]||!s[0])return;var o=parseInt(i.data("rowindex"),10),u=r.find("div.ewForm[id^=f][id$=grid]");u[0]||(u=r.find("form.ewForm[id^=f][id$=list]"));var a=u.data("form");if(!u[0]||!a)return;var f=u.is("div")?"_"+u.attr("id"):"",l="#key_count"+f,c=u.find(l),h=n.isFunction(a.EmptyRow)?!a.EmptyRow(t):!0;if(h&&!confirm(ewLanguage.Phrase("DeleteConfirmMsg")))return;i.remove(),ew_SetupTable(-1,s[0],!0);if(o>0){var p=u.find("#k"+o+"_action"+f);return p[0]?p.val(p.val()=="insert"?"insertdelete":"delete"):u.find(l).after(n("").attr({type:"hidden",id:"k"+o+"_action"+f,name:"k"+o+"_action"+f,value:"delete"})),!0}return!1}function ew_HtmlEncode(e){var t=String(e);return t=t.replace(/&/g,"&"),t=t.replace(/\"/g,"""),t=t.replace(//g,">"),t}function ew_ClearForm(e){var t=jQuery;t(e).find("[id^=x_],[id^=y_]").each(function(){if(this.type=="checkbox"||this.type=="radio")this.checked=!1;else if(this.type=="select-one")this.selectedIndex=0;else if(this.type=="select-multiple")t(this).find("option").prop("selected",!1);else if(this.type=="text"||this.type=="textarea"||this.type=="hidden"&&ew_IsAutoSuggest(this))this.value="",this.type=="hidden"&&(ew_GetAutoSuggest(this).input.value="")})}function ew_MultiPage(e,t){var n=jQuery,r=this;this.FormID=e,this.PageIndex=1,this.MaxPageIndex=0,this.MinPageIndex=0,this.Elements=t||[],this.$Pages=null,this.SubmitButton=null,this.LastPageSubmit=!1,this.HideDisabledButton=!0,this.Init=function(){n.each(this.Elements,function(e,t){t[1]>r.MaxPageIndex&&(r.MaxPageIndex=t[1])}),this.MinPageIndex=this.MaxPageIndex,n.each(this.Elements,function(e,t){t[1]this.MaxPageIndex)return;this.PageIndex!=e&&this.$Pages.eq(e-1).click()},this.GotoPageByElement=function(e){if(!e)return;var t=!e.type&&e[0]?e[0].id:e.id;if(t=="")return;var n=this.GetPageIndexByElementId(t);n>0&&this.GotoPageByIndex(n)},this.Render=function(e){var t=jQuery,n=this,r=t("#"+e);n.Init(),n.SubmitButton=r.find("#btnAction")[0];var i=r.find("[data-toggle=tab]");if(i[0]){this.$Pages=i,i.on("shown",function(e){n.PageIndex=i.index(e.target)+1,n.ShowPage()}).each(function(){if(t(this).parent("li").hasClass("active"))return n.PageIndex=i.index(this)+1,n.ShowPage(),!1});return}var s=r.find("[data-toggle=collapse]");if(s[0]){this.$Pages=s;var o=s.parent().next();o.on("shown",function(e){n.PageIndex=o.index(e.target)+1,n.ShowPage()}).each(function(){if(t(this).hasClass("in"))return n.PageIndex=o.index(this)+1,n.ShowPage(),!1})}}}function ew_GetElements(e,t){var n=jQuery,t=n.isString(t)?"#"+t:t,r="[name='"+e+"']";r="input"+r+",select"+r+",textarea"+r+",button"+r;var i=t?n(t).find(r):n(r);return i.length==1&&i.is(":not(:checkbox):not(:radio)")?i[0]:i.get()}function ew_GetElement(e,t){var n=jQuery,t=n.isString(t)?"#"+t:t,r="#"+e.replace(/([\$\[\]])/g,"\\$1")+",[name='"+e+"']";return t?n(t).find(r)[0]:n(r).first()[0]}function ew_SameText(e,t){return String(e).toLowerCase()==String(t).toLowerCase()}function ew_SameStr(e,t){return String(e)==String(t)}function ew_InArray(e,t){if(!t)return-1;for(var n=0,r=t.length;n=t;n--)e.options[n]=null}else if(e.length){var r=jQuery,i=ew_GetId(e),s=ew_GetElement("dsl_"+i,e[0].form);r(s).data("options",[]).find("table."+EW_ITEM_TABLE_CLASSNAME).remove()}else if(ew_IsAutoSuggest(e)){var o=ew_GetAutoSuggest(e);o._options=[],o.input.value="",e.value=""}}function ew_GetId(e,t){var n=jQuery,r="";return n.isString(e)?r=e:r=n(e).attr("name")||n(e).attr("id"),t!==!1&&/\[\]$/.test(r)&&(r=r.substr(0,r.length-2)),r}function ew_ValueSeparator(e,t){return", "}function ew_NewOpt(e,t,n){var r=jQuery,i={data:t,id:ew_GetId(e),form:n};r(document).trigger("newoption",[i]),t=i.data;var s=t[0],o=t[1];for(var u=2;u<=4;u++)t[u]&&t[u]!=""&&(o!=""&&(o+=ew_ValueSeparator(u-1,e)),o+=t[u]);if(e.options)e.options[e.length]=new Option(o,s,!1,!1);else if(e.length){var r=jQuery,a=r(ew_GetElement("dsl_"+ew_GetId(e),n)),f=a.data("options");a[0]&&f&&(f[f.length]={val:s,lbl:o})}else if(ew_IsAutoSuggest(e)){var l=ew_GetAutoSuggest(e);l._options[l._options.length]={val:s,lbl:o}}return o}function ew_RenderOpt(e,t){var n=ew_GetId(e),r=jQuery,i=ew_GetElement("dsl_"+n,t),s=r(i);if(!i||!s.data("options"))return;var o=ew_GetElement("tp_"+n,t);if(!o)return;var u=parseInt(s.data("repeatcolumn"),10)||5;EW_IS_MOBILE&&EW_MOBILE_REFLOW&&(u=1);var a=r(o).contents(),f=s.data("options"),l=a.attr("type"),c=r('
'),h;if(f&&f.length){for(var p=0,d=f.length;p"));var v=a.clone(!0).val(f[p].val),m=r('").prepend(v.attr("id",v.attr("id")+"_"+p));r("").append(m).appendTo(h);if(p%u==u-1)c.append(h);else if(p==d-1){for(var g=p%u+1;g ");c.append(h)}}s.append(c)}s.data("options",[])}function ew_SelectOpt(e,t){function o(e){if(!n(e).data("autoselect"))return!1;var t=ew_GetForm(e);if(t){if(/s(ea)?rch$/.test(t.id))return!1;var r=e.id.replace(/^([xy])(\d*)_/,"x_");return r in ewForms[t.id].Lists&&ewForms[t.id].Lists[r].ParentFields.length==0?!1:!0}return!1}if(!e||!t)return;var n=jQuery;if(e.options)n(e).val(t),e.type=="select-one"&&e.selectedIndex==-1&&(e.selectedIndex=0);else if(e.length)e.length==1&&e[0].type=="checkbox"&&e[0].value!="{value}"?e[0].checked=ew_ConvertToBool(e[0].value)===ew_ConvertToBool(t[0]):n(e).val(t);else if(ew_IsAutoSuggest(e)&&t.length==1){var r=ew_GetAutoSuggest(e);for(var i=0,s=r._options.length;i0)for(var n=0,r=h.length;n]*)>([\s\S]*?)<\/script\s*>/ig;while((n=i.exec(e))!=null){var s=RegExp.$2;/(\s+type\s*=\s*['"]*(text|application)\/(java|ecma)script['"]*)|^((?!\s+type\s*=).)*$/i.test(RegExp.$1)&&ew_AddScript(s,"scr_"+t+"_"+r++)}}function ew_StripScript(e){var t,n=/]*)>([\s\S]*?)<\/script\s*>/ig,r=e;while((t=n.exec(e))!=null){var i=RegExp.lastMatch;/(\s+type\s*=\s*['"]*(text|application)\/(java|ecma)script['"]*)|^((?!\s+type\s*=).)*$/i.test(RegExp.$1)&&(r=r.replace(i,""))}return r}function ew_AddScript(e,t){var n=document.createElement("SCRIPT");return t&&(n.id=t),n.type="text/javascript",n.text=e,document.body.appendChild(n)}function ew_RemoveScript(e){e&&jQuery("script[id^='scr_"+e+"_']").remove()}function ew_ElementsToRow(e){var t=jQuery,n=t(e),r=n.data("rowindex");r=t.isValue(r)?r:"";var i={index:r};return n.find("[name^=x"+r+"_]").each(function(){var e="x_"+this.name.substr(r.length+2);t.isObject(i[e])?t.isArray(i[e])?i[e][i[e].length]=this:i[e]=[i[e],this]:i[e]=this}),i}function ew_GetRow(e){var t=jQuery,n=t(e),r=n.data("rowindex");r=t.isValue(r)?r:"";var i={_index:r},s=n.find("[name^=x"+r+"_]").serializeArray();return t.each(s,function(){var e=this.name.substr(r.length+2).replace(/\[\]$/,"");t.isValue(i[e])?t.isArray(i[e])?i[e][i[e].length]=this.value:i[e]=[i[e],this.value]:i[e]=this.value}),i}function ew_AddOptSuccess(e){var t=jQuery,n=ewAddOptDialog,r;if(!n)return;if(e)try{r=t.parseJSON(e)}catch(i){}if(r&&r.length>0){var s=r[0],o=n.data("args").el,u="x_";o.match(/^(x\d+_)/)&&(u=RegExp.$1);var a=function(e){return e.replace(/^x_/,u)},f=ewForms(n.data("args").lnk);n.modal("hide");var l=f.Form,c=ew_GetElements(o,l);if(c){var h=o.replace(u,"x_"),p=f.Lists[h].LinkField,d=f.Lists[h].DisplayFields,v=f.Lists[h].FilterFields,m=f.Lists[h].ParentFields,g=p!=""?s[p]:"",y=[g];for(var b=0,w=d.length;b0&&y[1]){var E=ew_GetId(o,!1);if(f.Lists[E.replace(u,"x_")].Ajax===null){var S=f.Lists[E].Options;S[S.length]=y}var x=[];for(var b=0,w=m.length;b0&&ew_SelectOpt(c,N);if(c.length>0){var o=c[c.length-1];(o.type=="checkbox"||o.type=="radio")&&t(o).click(),o.focus()}}else if(ew_IsAutoSuggest(c)){var L=ew_GetAutoSuggest(c);t(c).val(g).change(),t(L.input).val(k).focus()}}}}}else{var A,O=n.find("div.ewMessageDialog").html(""),M=t("
").html(e).find("div.ewMessageDialog");if(M[0])A=M.html();else{A=e;if(!A||t.trim(A)=="")A=ewLanguage.Phrase("InsertFailed");A='

'+A+"

"}O.html(A).show()}}function ew_AddOptDialogHide(){if($dlg=ewAddOptDialog)ew_RemoveScript($dlg.data("args").el),$dlg.removeData("args").find(".modal-body form").data("form").DestroyEditor(),$dlg.find(".modal-body").html(""),$dlg.find(".modal-footer .btn-primary").unbind()}function ew_ModalDragStart(e,t){var n=jQuery,r=n(this),i=n("body");t.limit=i.offset(),t.limit.bottom=t.limit.top+i.outerHeight()-r.outerHeight(),t.limit.right=t.limit.left+i.outerWidth()-r.outerWidth()}function ew_ModalDrag(e,t){var n=jQuery,r=n(this),i=parseInt(r.css("margin-left"),10);r.css({top:Math.min(t.limit.bottom,Math.max(t.limit.top,t.offsetY)),left:Math.min(t.limit.right-i,Math.max(t.limit.left-i,t.offsetX-i))})}function ew_AddOptDialogShow(e){var t=jQuery,n=ewAddOptDialog||t("#ewAddOptDialog").on("hidden",ew_AddOptDialogHide).drag("start",ew_ModalDragStart).drag(ew_ModalDrag,{handle:".modal-header"}),r=function(e){n.modal("hide"),alert("Server Error "+e.status+": "+e.statusText)},i=function(){var e=ewAddOptDialog,n=e.find(".modal-body form")[0],i=ewForms[n.id];return i.UpdateTextArea(),i.Validate()&&(i.DestroyEditor(),t.post(n.action,t(n).serialize(),ew_AddOptSuccess).fail(r)),!1};n.modal("hide"),n.data("args",e);var s=function(r){var s=ewForms(e.lnk),o="x_";e.el.match(/^(x\d+_)/)&&(o=RegExp.$1);var u=e.el.replace(o,"x_"),a=s.Lists[u].ParentFields,f=s.Lists[u].FilterFields,l=s.Form,c=[];for(var h=0,p=a.length;h0&&r[0]!=""){var f={type:"autofill",form:n.id,name:i,target:o.value,q:r[0],s:s.value};t.post(EW_LOOKUP_FILE_NAME,f,a,"json")}else a()}function ew_Tooltip(e,t){var n=jQuery,r=n(t),i=n("#"+r.data("tooltip-id")),s=r.data("trigger")||"hover",o=r.data("placement")||"right";if(!i[0]||n.trim(i.text())==""&&!i.find("img[src!='']")[0])return;r.data("popover")||r.popover({html:!0,placement:o,trigger:s,delay:100,container:n("#ewTooltip")[0],content:i.html()}).on("show",function(e){var t=r.data("popover").tip();(wd=r.data("tooltip-width"))&&t.css("max-width",parseInt(wd,10)+"px")}).on("shown",function(e){if(o!="left"&&o!="right")return;var t=n(e.target),i=t.width(),s=t.height(),u=n(document),a=n(document.body),f=r.data("popover").tip(),l=f.width(),c=f.position(),h=u.scrollTop()+a.outerHeight()-f.outerHeight();c.top=Math.max(u.scrollTop(),Math.min(h,c.top)),f.css("top",c.top+"px");var p=f.find(".arrow"),d=t.position().top-c.top+s/2-p.height(),v=(parseInt(f.css("border-top-left-radius"),10)||6)-parseInt(p.css("margin-top"),10),m=f.height()-v-p.height();p.css("top",Math.max(v,Math.min(d,m))+"px")})}function ew_EmailDialogShow(e){var t=jQuery,n=ewEmailDialog||t("#ewEmailDialog").drag("start",ew_ModalDragStart).drag(ew_ModalDrag,{handle:".modal-header"});if(!n)return;if(e.sel&&!ew_KeySelected(e.f)){alert(ewLanguage.Phrase("NoRecordSelected"));return}var r=n.find(".modal-body form"),i=r.data("form");i||(i=new ew_Form(r.attr("id")),i.Validate=function(){var e,t=this.GetForm();return e=t.elements.sender,e&&!ew_HasValue(e)?this.OnError(e,ewLanguage.Phrase("EnterSenderEmail")):e&&!ew_CheckEmailList(e.value,1)?this.OnError(e,ewLanguage.Phrase("EnterProperSenderEmail")):(e=t.elements.recipient,e&&!ew_HasValue(e)?this.OnError(e,ewLanguage.Phrase("EnterRecipientEmail")):e&&!ew_CheckEmailList(e.value,EW_MAX_EMAIL_RECIPIENT)?this.OnError(e,ewLanguage.Phrase("EnterProperRecipientEmail")):(e=t.elements.cc,e&&!ew_CheckEmailList(e.value,EW_MAX_EMAIL_RECIPIENT)?this.OnError(e,ewLanguage.Phrase("EnterProperCcEmail")):(e=t.elements.bcc,e&&!ew_CheckEmailList(e.value,EW_MAX_EMAIL_RECIPIENT)?this.OnError(e,ewLanguage.Phrase("EnterProperBccEmail")):(e=t.elements.subject,e&&!ew_HasValue(e)?this.OnError(e,ewLanguage.Phrase("EnterSubject")):!0))))},i.Submit=function(){if(!this.Validate())return!1;var n=r.serialize(),i="";return e.f&&e.sel&&(i=t(e.f).find("input:checkbox[name='key_m[]']:checked").serialize()),e.key&&(n+="&"+t.param(e.key)),t.post(e.f.action+"?"+n,i,function(e){ew_ShowMessage(e)}),!0},r.data("form",i)),n.modal("hide").find(".modal-header h3").html(e.hdr),n.find(".modal-footer .btn-primary").unbind().click(function(e){e.preventDefault(),i.Submit()&&n.modal("hide")}),ewEmailDialog=n.modal("show")}function ew_Ajax(e,t,n){if(!e)return undefined;var r=jQuery,i={s:e};i=r.extend(i,r.isObject(t)?t:{q:t});if(!r.isFunction(n)){var s=r.ajax({async:!1,type:"POST",data:i}).responseText,o=r.parseJSON(s);return o.length==1?(o=o[0],r.isArray(o)&&o.length==1?o[0]:o):o}r.post(EW_LOOKUP_FILE_NAME,i,n,"json")}function ew_ToggleSrchOpr(e,t){var n=this.form.elements[e];if(!n)return;n.value=n.value!=t?t:"="}function ew_CheckUSDate(e){return ew_CheckDateEx(e,"us",EW_DATE_SEPARATOR)}function ew_CheckShortUSDate(e){return ew_CheckDateEx(e,"usshort",EW_DATE_SEPARATOR)}function ew_CheckDate(e){return ew_CheckDateEx(e,"std",EW_DATE_SEPARATOR)}function ew_CheckShortDate(e){return ew_CheckDateEx(e,"stdshort",EW_DATE_SEPARATOR)}function ew_CheckEuroDate(e){return ew_CheckDateEx(e,"euro",EW_DATE_SEPARATOR)}function ew_CheckShortEuroDate(e){return ew_CheckDateEx(e,"euroshort",EW_DATE_SEPARATOR)}function ew_CheckDateEx(e,t,n){if(!e||e.length=="")return!0;while(e.indexOf(" ")>-1)e=e.replace(/ /g," ");e=e.replace(/^\s*|\s*$/g,"");var r=e.split(" ");if(r.length>0){var i,s,o,u;i=/^(\d{4})-([0][1-9]|[1][0-2])-([0][1-9]|[1|2]\d|[3][0|1])$/;if(ar=i.exec(r[0]))s=ar[1],o=ar[2],u=ar[3];else{var a="\\"+n;switch(t){case"std":i=new RegExp("^(\\d{4})"+a+"([0]?[1-9]|[1][0-2])"+a+"([0]?[1-9]|[1|2]\\d|[3][0|1])$");break;case"stdshort":i=new RegExp("^(\\d{2})"+a+"([0]?[1-9]|[1][0-2])"+a+"([0]?[1-9]|[1|2]\\d|[3][0|1])$");break;case"us":i=new RegExp("^([0]?[1-9]|[1][0-2])"+a+"([0]?[1-9]|[1|2]\\d|[3][0|1])"+a+"(\\d{4})$");break;case"usshort":i=new RegExp("^([0]?[1-9]|[1][0-2])"+a+"([0]?[1-9]|[1|2]\\d|[3][0|1])"+a+"(\\d{2})$");break;case"euro":i=new RegExp("^([0]?[1-9]|[1|2]\\d|[3][0|1])"+a+"([0]?[1-9]|[1][0-2])"+a+"(\\d{4})$");break;case"euroshort":i=new RegExp("^([0]?[1-9]|[1|2]\\d|[3][0|1])"+a+"([0]?[1-9]|[1][0-2])"+a+"(\\d{2})$")}if(!i.test(r[0]))return!1;var f=r[0].split(n);switch(t){case"std":case"stdshort":s=ew_UnformatYear(f[0]),o=f[1],u=f[2];break;case"us":case"usshort":s=ew_UnformatYear(f[2]),o=f[0],u=f[1];break;case"euro":case"euroshort":s=ew_UnformatYear(f[2]),o=f[1],u=f[0]}}if(!ew_CheckDay(s,o,u))return!1}return r.length>1&&!ew_CheckTime(r[1])?!1:!0}function ew_UnformatYear(e){return e.length==2?e>EW_UNFORMAT_YEAR?"19"+e:"20"+e:e}function ew_CheckDay(e,t,n){e=parseInt(e,10),t=parseInt(t,10),n=parseInt(n,10);var r=ew_InArray(t,[4,6,9,11])>-1?30:31;return t==2&&(r=e%4>0||e%100==0&&e%400>0?28:29),ew_CheckRange(n,1,r)}function ew_CheckInteger(e){return!e||e.length==0?!0:e.indexOf(EW_DECIMAL_POINT)>-1?!1:ew_CheckNumber(e)}function ew_CheckNumber(e){e=String(e);if(!e||e.length==0)return!0;e=e.replace(/^\s*|\s*$/g,"");var t=new RegExp("^[+-]?(\\d{1,3}("+(EW_THOUSANDS_SEP?"\\"+EW_THOUSANDS_SEP+"?":"")+"\\d{3})*(\\"+EW_DECIMAL_POINT+"\\d+)?|\\"+EW_DECIMAL_POINT+"\\d+)$");return t.test(e)}function ew_StrToFloat(e){e=String(e);if(EW_THOUSANDS_SEP!=""){var t=new RegExp("\\"+EW_THOUSANDS_SEP,"g");e=e.replace(t,"")}return EW_DECIMAL_POINT!=""&&(e=e.replace(EW_DECIMAL_POINT,".")),parseFloat(e)}function ew_StrToDate(e){var t=/^(\d{4})-([0][1-9]|[1][0-2])-([0][1-9]|[1|2]\d|[3][0|1]) (?:(0\d|1\d|2[0-3]):([0-5]\d):([0-5]\d))?$/,n=e.replace(t,"$1 $2 $3 $4 $5 $6").split(" ");return new Date(n[0],n[1]-1,n[2],n[3],n[4],n[5])}function ew_CheckRange(e,t,n){if(!e||e.length==0)return!0;var r=jQuery;return(r.isNumber(t)||r.isNumber(n))&&ew_CheckNumber(e)&&(e=ew_StrToFloat(e)),!r.isNull(t)&&en?!1:!0}function ew_CheckTime(e){if(!e||e.length==0)return!0;e=e.replace(/^\s*|\s*$/g,"");var t=/^(0\d|1\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/;return t.test(e)}function ew_CheckPhone(e){if(!e||e.length==0)return!0;e=e.replace(/^\s*|\s*$/g,"");var t=/^\(\d{3}\) ?\d{3}( |-)?\d{4}|^\d{3}( |-)?\d{3}( |-)?\d{4}$/;return t.test(e)}function ew_CheckZip(e){if(!e||e.length==0)return!0;e=e.replace(/^\s*|\s*$/g,"");var t=/^\d{5}$|^\d{5}-\d{4}$/;return t.test(e)}function ew_CheckCreditCard(e){if(!e||e.length==0)return!0;var t=e.replace(/\D/g,"");if(t.length==0)return!1;var n=t.length%2==1?!1:!0,r,i=0;for(var s=0,o=t.length;s=1&&i++,n=!1):(i+=r,n=!0);return i%10==0}function ew_CheckSSC(e){if(!e||e.length==0)return!0;e=e.replace(/^\s*|\s*$/g,"");var t=/^(?!000)([0-6]\d{2}|7([0-6]\d|7[012]))([ -]?)(?!00)\d\d\3(?!0000)\d{4}$/;return t.test(e)}function ew_CheckEmailList(e,t){if(!e||e.length==0)return!0;var n=e.replace(/,/g,";").split(";");for(var r=0,i=n.length;r0&&i>t)return!1;if(!ew_CheckEmail(n[r]))return!1}return!0}function ew_CheckEmail(e){if(!e||e.length==0)return!0;e=e.replace(/^\s*|\s*$/g,"");var t=/^[\w.%+-]+@[\w.-]+\.[A-Z]{2,6}$/i;return t.test(e)}function ew_CheckGUID(e){if(!e||e.length==0)return!0;e=e.replace(/^\s*|\s*$/g,"");var t=/^\{\w{8}-\w{4}-\w{4}-\w{4}-\w{12}\}$/,n=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/;return t.test(e)||n.test(e)}function ew_CheckFileType(e){if(!e||e.length==0)return!0;if(!EW_UPLOAD_ALLOWED_FILE_EXT)return!0;if(EW_UPLOAD_ALLOWED_FILE_EXT.replace(/^\s*|\s*$/g,"")=="")return!0;var t=EW_UPLOAD_ALLOWED_FILE_EXT.toLowerCase().split(","),n=e.substr(e.lastIndexOf(".")+1).toLowerCase();return ew_InArray(n,t)>-1}function ew_CheckByRegEx(e,t){return!e||e.length==0?!0:e.match(t)?!0:!1}function ew_ShowMessage(e){var t=jQuery,n=t("div.ewMessageDialog:first"),r=e||(n.length?EW_IS_MOBILE?n.text():n.html():"");if(t.trim(r)=="")return;if(EW_IS_MOBILE)alert(r);else{var i=t("#ewMsgBox");i.find(".modal-body").html(r),i.modal("show")}}function ew_Random(){return Math.floor(Math.random()*100001)+1e5}function ew_Upload(e,t){var n=jQuery,r=n(t);if(r.data("blueimpFileupload"))return;var i=r.attr("name"),s=i.replace(/\$/g,"\\$"),o=r.is("[multiple]"),u=r.closest(".control-group"),a=u.find(".btn").css("display")=="none"||r.closest("form").find("#a_confirm").val()=="F",f=u.find("#ft_"+s),l=u.find("#fn_"+s),c=u.find("#fa_"+s),h=u.find("#fs_"+s),p=function(e,t){var n=t.result.files[0].name,r=o?l.val()?l.val().split(","):[]:[];r[r.length]=n,l.val(r.join(",")),c.val("0"),o||f.find("tr:not(:last)").remove()},d=function(e,t){var r={},i=n(e.originalEvent.target).data("url");i&&i.replace(/(?:\?|&)([^&=]*)=?([^&]*)/g,function(e,t,n){t&&(r[t]=n)});if(r.file){var s=r.file,o=l.val()?l.val().split(","):[];n.each(o,function(e,t){if(t==decodeURIComponent(s))return o.splice(e,1),!1}),l.val(o.join(",")),c.val("0")}},v=function(e,t){var r=l.val()?l.val().split(","):[];for(var i=0;is)return alert(ewLanguage.Phrase("UploadErrMsgMaxNumberOfFiles")),!1;var o=parseInt(h.val(),10);if(n.isNumber(o)&&o>0&&r.join(",").length>o)return alert(ewLanguage.Phrase("UploadErrMsgMaxFileLength")),!1},m=function(e){!o&&l.val()&&(confirm(ewLanguage.Phrase("UploadOverwrite"))||(e.preventDefault(),e.stopPropagation()))},g=function(e){var t=n();return n.each(e.files,function(r,i){var s=n(''+(i.error?'':'
")+'");s.find(".name").text(i.name),s.find(".size").text(e.formatFileSize(i.size)),s.find(".start").click(m),s.find(".error").text(i.error),t=t.add(s)}),t},y=function(e){var t=n();return n.each(e.files,function(r,i){var s=n(''+(i.error?'':'')+(a?"":'")+"");s.find(".size").text(e.formatFileSize(i.size));if(i.error)s.find(".name").text(i.name),s.find(".error").text(i.error),i.delete_url||s.find(".delete").click(function(){n(this).closest(".template-download").remove(),b()});else{var o=s.find(".name a").text(i.name);i.url&&o.attr("href",i.url).attr("target","_blank"),i.thumbnail_url&&/\.(bmp|gif|jpe?g|png)$/i.test(i.name)&&s.find(".preview").append('').find("img").prop("src",i.thumbnail_url),s.find(".delete").attr("data-type",i.delete_type).attr("data-url",i.delete_url)}t=t.add(s)}),t},b=function(){f.css("margin-top",f.find("tr")[0]&&!a?"10px":"0")},w=ew_GetForm(t),E=n(w),S=E.find("#a_confirm").val()=="F";S&&E.find("span.fileinput-button").hide(),r.fileupload({url:EW_UPLOAD_URL,autoUpload:!0,loadImageFileTypes:/^image\/(gif|jpe?g|png)$/i,acceptFileTypes:new RegExp(".("+EW_UPLOAD_ALLOWED_FILE_EXT.replace(/,/g,"|")+")$","i"),maxFileSize:EW_MAX_FILE_SIZE,filesContainer:f,formData:{id:i,replace:o?"0":"1"},uploadTemplateId:null,downloadTemplateId:null,uploadTemplate:g,downloadTemplate:y,previewMaxWidth:EW_UPLOAD_THUMBNAIL_WIDTH,previewMaxHeight:EW_UPLOAD_THUMBNAIL_HEIGHT,dropZone:u,pasteZone:u}).on("fileuploaddone",p).on("fileuploaddestroy",d).on("fileuploadchange",v).on("fileuploadadded fileuploadfinished fileuploaddestroyed",b),l.val()&&n.ajax({url:EW_UPLOAD_URL,data:{id:i},dataType:"json",context:this,success:function(e){e&&e[i]&&r.fileupload("option","done").call(t,null,{result:{files:e[i]}}),S&&f.find("td.delete").hide()}})}function ew_UserAgent(e){var t=function(e){var t=0;return parseFloat(e.replace(/\./g,function(){return t++===1?"":"."}))},n=window,r=n&&n.navigator,i={ie:0,opera:0,gecko:0,webkit:0,safari:0,chrome:0,mobile:null,air:0,phantomjs:0,ipad:0,iphone:0,ipod:0,ios:null,android:0,silk:0,accel:!1,webos:0,caja:r&&r.cajaVersion,secure:!1,os:null,nodejs:0,winjs:typeof Windows!="undefined"&&!!Windows.System,touchEnabled:!1},s=e||r&&r.userAgent,o=n&&n.location,u=o&&o.href,a;return i.userAgent=s,i.secure=u&&u.toLowerCase().indexOf("https")===0,s&&(/windows|win32/i.test(s)?i.os="windows":/macintosh|mac_powerpc/i.test(s)?i.os="macintosh":/android/i.test(s)?i.os="android":/symbos/i.test(s)?i.os="symbos":/linux/i.test(s)?i.os="linux":/rhino/i.test(s)&&(i.os="rhino"),/KHTML/.test(s)&&(i.webkit=1),/IEMobile|XBLWP7/.test(s)&&(i.mobile="windows"),/Fennec/.test(s)&&(i.mobile="gecko"),a=s.match(/AppleWebKit\/([^\s]*)/),a&&a[1]&&(i.webkit=t(a[1]),i.safari=i.webkit,/PhantomJS/.test(s)&&(a=s.match(/PhantomJS\/([^\s]*)/),a&&a[1]&&(i.phantomjs=t(a[1]))),/ Mobile\//.test(s)||/iPad|iPod|iPhone/.test(s)?(i.mobile="Apple",a=s.match(/OS ([^\s]*)/),a&&a[1]&&(a=t(a[1].replace("_","."))),i.ios=a,i.os="ios",i.ipad=i.ipod=i.iphone=0,a=s.match(/iPad|iPod|iPhone/),a&&a[0]&&(i[a[0].toLowerCase()]=i.ios)):(a=s.match(/NokiaN[^\/]*|webOS\/\d\.\d/),a&&(i.mobile=a[0]),/webOS/.test(s)&&(i.mobile="WebOS",a=s.match(/webOS\/([^\s]*);/),a&&a[1]&&(i.webos=t(a[1]))),/ Android/.test(s)&&(/Mobile/.test(s)&&(i.mobile="Android"),a=s.match(/Android ([^\s]*);/),a&&a[1]&&(i.android=t(a[1]))),/Silk/.test(s)&&(a=s.match(/Silk\/([^\s]*)\)/),a&&a[1]&&(i.silk=t(a[1])),i.android||(i.android=2.34,i.os="Android"),/Accelerated=true/.test(s)&&(i.accel=!0))),a=s.match(/(Chrome|CrMo|CriOS)\/([^\s]*)/),a&&a[1]&&a[2]?(i.chrome=t(a[2]),i.safari=0,a[1]==="CrMo"&&(i.mobile="chrome")):(a=s.match(/AdobeAIR\/([^\s]*)/),a&&(i.air=a[0]))),i.webkit||(/Opera/.test(s)?(a=s.match(/Opera[\s\/]([^\s]*)/),a&&a[1]&&(i.opera=t(a[1])),a=s.match(/Version\/([^\s]*)/),a&&a[1]&&(i.opera=t(a[1])),/Opera Mobi/.test(s)&&(i.mobile="opera",a=s.replace("Opera Mobi","").match(/Opera ([^\s]*)/),a&&a[1]&&(i.opera=t(a[1]))),a=s.match(/Opera Mini[^;]*/),a&&(i.mobile=a[0])):(a=s.match(/MSIE\s([^;]*)/),a&&a[1]?i.ie=t(a[1]):(a=s.match(/Gecko\/([^\s]*)/),a&&(i.gecko=1,a=s.match(/rv:([^\s\)]*)/),a&&a[1]&&(i.gecko=t(a[1]))))))),n&&r&&!(i.chrome&&i.chrome<6)&&(i.touchEnabled="ontouchstart"in n||"msMaxTouchPoints"in r&&r.msMaxTouchPoints>0),e||typeof process=="object"&&process.versions&&process.versions.node&&(i.os=process.platform,i.nodejs=t(process.versions.node)),i}var ewAddOptDialog,ewEmailDialog,$rowindex$=null,EW_TABLE_CLASSNAME="ewTable",EW_GRID_CLASSNAME="ewGrid",EW_TABLE_ROW_CLASSNAME="ewTableRow",EW_TABLE_ALT_ROW_CLASSNAME="ewTableAltRow",EW_ITEM_TEMPLATE_CLASSNAME="ewTemplate",EW_ITEM_TABLE_CLASSNAME="ewItemTable",EW_TABLE_LAST_ROW_CLASSNAME="ewTableLastRow",EW_TABLE_LAST_COL_CLASSNAME="ewTableLastCol",EW_TABLE_PREVIEW_ROW_CLASSNAME="ewTablePreviewRow",EW_TABLE_EDIT_ROW_CLASSNAME="ewTableEditRow",EW_TABLE_SELECT_ROW_CLASSNAME="ewTableSelectRow",EW_TABLE_HIGHLIGHT_ROW_CLASSNAME="ewTableHighlightRow",EW_REPORT_CONTAINER_ID="ewContainer",EW_ROWTYPE_ADD=2,EW_ROWTYPE_EDIT=3,EW_UNFORMAT_YEAR=50,ew_ClientScriptInclude=jQuery.getScript;jQuery(document).on("addoption",ew_DefaultLookup),jQuery(function(e){e("input[data-toggle=tooltip],textarea[data-toggle=tooltip],select[data-toggle=tooltip]").each(function(){var t=e(this);t.tooltip(e.extend({html:!0,placement:"bottom"},t.data()))}),e("a.ewTooltipLink").each(ew_Tooltip),e("table."+EW_TABLE_CLASSNAME+":not(.ewExportTable):not(#"+EW_REPORT_CONTAINER_ID+" table)").each(ew_SetupTable),e("table."+EW_GRID_CLASSNAME+":not(.ewExportTable):not(#"+EW_REPORT_CONTAINER_ID+" table)").each(ew_SetupGrid),e.later(e("textarea.editor")[0]?250:0,null,function(){var t=e(window),n=e("#ewContentTable").outerHeight();t.resize(function(){e("#ewContentTable").height(Math.max(n,t.height()-(e("#ewHeaderRow").is(":hidden")?0:e("#ewHeaderRow").height())-(e("#ewMenuRow").height()||0)-(e("#ewFooterRow").is(":hidden")?0:e("#ewFooterRow").height())))}).triggerHandler("resize")}),e("input[name=pageno]").keypress(function(e){if(e.which==13){var t=window.location.href,n=t.lastIndexOf(window.location.search);return window.location=t.substr(0,n)+"?"+this.name+"="+parseInt(this.value),!1}}),typeof EW_USE_JAVASCRIPT_MESSAGE!="undefined"&&EW_USE_JAVASCRIPT_MESSAGE&&ew_ShowMessage()});var ewEvent={on:ew_On},ewForms=function(e){if(e){var t=jQuery,n;t.isString(e)?n=e:n=t(ew_GetForm(e)).attr("id");if(n&&ewForms[n])return ewForms[n]}return undefined};jQuery.extend({isBoolean:function(e){return typeof e=="boolean"},isNull:function(e){return e===null},isNumber:function(e){return typeof e=="number"&&isFinite(e)},isObject:function(e){return e&&(typeof e=="object"||this.isFunction(e))||!1},isString:function(e){return typeof e=="string"},isUndefined:function(e){return typeof e=="undefined"},isValue:function(e){return this.isObject(e)||this.isString(e)||this.isNumber(e)||this.isBoolean(e)},isDate:function(e){return this.type(e)==="date"&&e.toString()!=="Invalid Date"&&!isNaN(e)},later:function(e,t,n,r,i){e=e||0,t=t||{};var s=n,o=r,u,a;this.isString(n)&&(s=t[n]);if(!s)return;return!this.isUndefined(r)&&!this.isArray(o)&&(o=[r]),u=function(){s.apply(t,o||[])},a=i?setInterval(u,e):setTimeout(u,e),{interval:i,cancel:function(){this.interval?clearInterval(a):clearTimeout(a)}}},ua:ew_UserAgent()}),function(e){e.fn.drag=function(e,t,n){var r=typeof e=="string"?e:"",i=jQuery.isFunction(e)?e:jQuery.isFunction(t)?t:null;return r.indexOf("drag")!==0&&(r="drag"+r),n=(e==i?t:n)||{},i?this.bind(r,n,i):this.trigger(r)};var t=e.event,n=t.special,r=n.drag={defaults:{which:1,distance:0,not:":input",handle:null,relative:!1,drop:!0,click:!1},datakey:"dragdata",noBubble:!0,add:function(t){var n=e.data(this,r.datakey),i=t.data||{};n.related+=1,e.each(r.defaults,function(e,t){i[e]!==undefined&&(n[e]=i[e])})},remove:function(){e.data(this,r.datakey).related-=1},setup:function(){if(e.data(this,r.datakey))return;var n=e.extend({related:0},r.defaults);e.data(this,r.datakey,n),t.add(this,"touchstart mousedown",r.init,n),this.attachEvent&&this.attachEvent("ondragstart",r.dontstart)},teardown:function(){var n=e.data(this,r.datakey)||{};if(n.related)return;e.removeData(this,r.datakey),t.remove(this,"touchstart mousedown",r.init),r.textselect(!0),this.detachEvent&&this.detachEvent("ondragstart",r.dontstart)},init:function(i){if(r.touched)return;var s=i.data,o;if(i.which!=0&&s.which>0&&i.which!=s.which)return;if(e(i.target).is(s.not))return;if(s.handle&&!e(i.target).closest(s.handle,i.currentTarget).length)return;r.touched=i.type=="touchstart"?this:null,s.propagates=1,s.mousedown=this,s.interactions=[r.interaction(this,s)],s.target=i.target,s.pageX=i.pageX,s.pageY=i.pageY,s.dragging=null,o=r.hijack(i,"draginit",s);if(!s.propagates)return;o=r.flatten(o),o&&o.length&&(s.interactions=[],e.each(o,function(){s.interactions.push(r.interaction(this,s))})),s.propagates=s.interactions.length,s.drop!==!1&&n.drop&&n.drop.handler(i,s),r.textselect(!1),r.touched?t.add(r.touched,"touchmove touchend",r.handler,s):t.add(document,"mousemove mouseup",r.handler,s);if(!r.touched||s.live)return!1},interaction:function(t,n){var i=e(t)[n.relative?"position":"offset"]()||{top:0,left:0};return{drag:t,callback:new r.callback,droppable:[],offset:i}},handler:function(i){var s=i.data;switch(i.type){case!s.dragging&&"touchmove":i.preventDefault();case!s.dragging&&"mousemove":if(Math.pow(i.pageX-s.pageX,2)+Math.pow(i.pageY-s.pageY,2)0){e.removeData(this,"suppress."+t.type);return}return i.apply(this,arguments)};var s=t.fixHooks.touchstart=t.fixHooks.touchmove=t.fixHooks.touchend=t.fixHooks.touchcancel={props:"clientX clientY pageX pageY screenX screenY".split(" "),filter:function(t,n){if(n){var r=n.touches&&n.touches[0]||n.changedTouches&&n.changedTouches[0]||null;r&&e.each(s.props,function(e,n){t[n]=r[n]})}return t}};n.draginit=n.dragstart=n.dragend=r}(jQuery);var xPad=function(e,t,n){typeof n=="undefined"&&(n=10),t+="";for(;parseInt(e,10)1;n/=10)e=t+e;return e.toString()},ewDate=Dt={formats:{a:function(e,t){return t.a[e.getDay()]},A:function(e,t){return t.A[e.getDay()]},b:function(e,t){return t.b[e.getMonth()]},B:function(e,t){return t.B[e.getMonth()]},C:function(e){return xPad(parseInt(e.getFullYear()/100,10),0)},d:["getDate","0"],e:["getDate"," "],g:function(e){return xPad(parseInt(Dt.formats.G(e)%100,10),0)},G:function(e){var t=e.getFullYear(),n=parseInt(Dt.formats.V(e),10),r=parseInt(Dt.formats.W(e),10);return r>n?t++:r===0&&n>=52&&t--,t},H:["getHours","0"],I:function(e){var t=e.getHours()%12;return xPad(t===0?12:t,0)},j:function(e){var t=new Date(""+e.getFullYear()+"/1/1 GMT"),n=new Date(""+e.getFullYear()+"/"+(e.getMonth()+1)+"/"+e.getDate()+" GMT"),r=n-t,i=parseInt(r/6e4/60/24,10)+1;return xPad(i,0,100)},k:["getHours"," "],l:function(e){var t=e.getHours()%12;return xPad(t===0?12:t," ")},m:function(e){return xPad(e.getMonth()+1,0)},M:["getMinutes","0"],p:function(e,t){return t.p[e.getHours()>=12?1:0]},P:function(e,t){return t.P[e.getHours()>=12?1:0]},s:function(e,t){return parseInt(e.getTime()/1e3,10)},S:["getSeconds","0"],u:function(e){var t=e.getDay();return t===0?7:t},U:function(e){var t=parseInt(Dt.formats.j(e),10),n=6-e.getDay(),r=parseInt((t+n)/7,10);return xPad(r,0)},V:function(e){var t=parseInt(Dt.formats.W(e),10),n=(new Date(""+e.getFullYear()+"/1/1")).getDay(),r=t+(n>4||n<=1?0:1);return r===53&&(new Date(""+e.getFullYear()+"/12/31")).getDay()<4?r=1:r===0&&(r=Dt.formats.V(new Date(""+(e.getFullYear()-1)+"/12/31"))),xPad(r,0)},w:"getDay",W:function(e){var t=parseInt(Dt.formats.j(e),10),n=7-Dt.formats.u(e),r=parseInt((t+n)/7,10);return xPad(r,0,10)},y:function(e){return xPad(e.getFullYear()%100,0)},Y:"getFullYear",z:function(e){var t=e.getTimezoneOffset(),n=xPad(parseInt(Math.abs(t/60),10),0),r=xPad(Math.abs(t%60),0);return(t>0?"-":"+")+n+r},Z:function(e){var t=e.toString().replace(/^.*:\d\d( GMT[+-]\d+)? \(?([A-Za-z ]+)\)?\d*$/,"$2").replace(/[a-z ]/g,"");return t.length>4&&(t=Dt.formats.z(e)),t},"%":function(e){return"%"}},aggregates:{c:"locale",D:"%m/%d/%y",F:"%Y-%m-%d",h:"%b",n:"\n",r:"%I:%M:%S %p",R:"%H:%M",t:" ",T:"%H:%M:%S",x:"locale",X:"locale"},resources:{a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],c:"%a, %b %d, %Y %l:%M:%S %p %Z",p:["AM","PM"],P:["am","pm"],x:"%m/%d/%y",X:"%l:%M:%S %p"},format:function(e,t){t=t||{};if(!jQuery.isDate(e))return jQuery.isValue(e)?e:"";var n,r,i,s,o;n=t.format||"%Y-%m-%d",r=Dt.resources;var u=function(e,t){if(i&&t==="r")return r[t];var n=Dt.aggregates[t];return n==="locale"?r[t]:n},a=function(t,n){var i=Dt.formats[n];switch($.type(i)){case"string":return e[i]();case"function":return i.call(e,e,r);case"array":if($.type(i[0])==="string")return xPad(e[i[0]](),i[1]);default:return n}};while(n.match(/%[cDFhnrRtTxX]/))n=n.replace(/%([cDFhnrRtTxX])/g,u);var f=n.replace(/%([aAbBCdegGHIjklmMpPsSuUVwWyYzZ%])/g,a);return u=a=undefined,f},isValidDate:function(e){return jQuery.isDate(e)&&isFinite(e)&&e!="Invalid Date"&&!isNaN(e)&&e!=null?!0:!1},areEqual:function(e,t){return this.isValidDate(e)&&this.isValidDate(t)&&e.getTime()==t.getTime()},isGreater:function(e,t){return this.isValidDate(e)&&this.isValidDate(t)&&e.getTime()>t.getTime()},isGreaterOrEqual:function(e,t){return this.isValidDate(e)&&this.isValidDate(t)&&e.getTime()>=t.getTime()},isInRange:function(e,t,n){return this.isGreaterOrEqual(e,t)&&this.isGreaterOrEqual(n,e)},addDays:function(e,t){return new Date(e.getTime()+864e5*t)},addMonths:function(e,t){var n=e.getFullYear(),r=e.getMonth()+t;n=Math.floor(n+r/12),r=(r%12+12)%12;var i=new Date(e.getTime());return i.setFullYear(n),i.setMonth(r),i},addYears:function(e,t){var n=e.getFullYear()+t,r=new Date(e.getTime());return r.setFullYear(n),r},listOfDatesInMonth:function(e){if(!this.isValidDate(e))return[];var t=this.daysInMonth(e),n=e.getFullYear(),r=e.getMonth(),i=[];for(var s=1;s<=t;s++)i.push(new Date(n,r,s,12,0,0));return i},daysInMonth:function(e){if(!this.isValidDate(e))return 0;var t=e.getMonth(),n=[31,28,31,30,31,30,31,31,30,31,30,31];if(t!=1)return n[t];var r=e.getFullYear();return r%400===0?29:r%100===0?28:r%4===0?29:28},parse:function(e){var t=new Date(+e||e);return jQuery.isDate(t)?t:null}},ewNumber={format:function(e,t){if(jQuery.isNumber(e)){t=t||{};var n=e<0,r=e+"",i=t.decimalPlaces,s=t.decimalSeparator||".",o=t.thousandsSeparator,u,a,f,l;jQuery.isNumber(i)&&i>=0&&i<=20&&(r=e.toFixed(i)),s!=="."&&(r=r.replace(".",s));if(o){u=r.lastIndexOf(s),u=u>-1?u:r.length,a=r.substring(u);for(f=0,l=u;l>0;l--)f%3===0&&l!==u&&(!n||l>1)&&(a=o+a),a=r.charAt(l-1)+a,f++;r=a}return r=t.prefix?t.prefix+r:r,r=t.suffix?r+t.suffix:r,r}return jQuery.isValue(e)&&e.toString?e.toString():""},parse:function(e){var t=e===null||e===""?e:+e;return jQuery.isNumber(t)?t:null}};