﻿function df_CheckGlobals(){document.form||(document.form=document.form);document.form||(document.form=document.aspnetForm);df_subformLabelSepChar||(df_subformLabelSepChar="__")}function df_InitDirtyWarning(n){window.df_warnNotSaved=!1;n+""!=""&&(df_dirtyWarningText=n);document.form&&document.form.method.toUpperCase()=="POST"&&(typeof jQuery!="undefined"?jQuery("input,textarea,select").change(function(){window.df_warnNotSaved=!0}):document.onkeyup=function(){window.df_warnNotSaved=!0},window.onbeforeunload=function(){if(window.df_warnNotSaved)return df_dirtyWarningText})}function E$(n){var i=document.getElementById(n),t;return i||(t="bewebcma.js E$: Element ID not found.",typeof n=="function"?(t+="\nelementID parameter is a function.",t+="\nPossibly this is a $ call which was supposed to be jquery and was taken by beweb-cma E$ instead. You may not have jquery on the page? Or are you calling jQuery.noConflict when you should not be?\n",t+="\n",t+=n.toString()):(t+="\nelementID parameter is "+typeof n+".",t+="\n",t+=n.toString()),E$.caller&&(t+="\nCalled by: "+E$.caller),alert(t)),i}function df_GetObjInSameRow(n,t){var i="",r;return n.df_subformCode&&(i=df_subformLabelSepChar+n.df_subformCode+df_subformLabelSepChar+n.df_rowIndex),r=n.document,document.getElementById?document.getElementById(t+i):document.all?document.all(t+i):(alert("Your web browser does not meet the minimum requirements for features on this form. Please use a recent version of a mainstream browser."),null)}function df_GetFieldInSameRow(n,t){var i="",r;return n==undefined||t==undefined?(alert("df_GetFieldInSameRow: Parameter not supplied. currentFieldObj=["+n+"], fieldName["+t+"]"),null):!n||!t?(alert("df_GetFieldInSameRow: Parameter is blank. currentFieldObj=["+n+"], fieldName["+t+"]"),null):(n=df_GetField(n),i=n.df_suffix,r=n.form.elements[t+i],r||(i?alert("df_GetFieldInSameRow: Cannot find form field for return value. currentFieldObj=["+n+"], fieldName["+t+"], suffix["+i+"], currentFieldObj["+n+"], returnField["+r+"]"):alert("df_GetFieldInSameRow: Cannot find form field for return value. The supplied field was found, but it did not have a df_subformCode attribute, so you must supply the suffix as part of the field name. currentFieldObj=["+n+"], currentFieldName=["+n.name+"], to find fieldName["+t+"], suffix["+i+"], currentFieldObj["+n+"], returnField["+r+"]")),r)}function df_GetField(n,t,i){var r,u,s,f,e,h,o;return window.jQuery&&n instanceof jQuery&&(n=n[0]),typeof n=="string"?(t?(e=n,h=n.indexOf("__suffix__")==-1?e+"__suffix__":e+"",i||(i=1),o=df_subformLabelSepChar+t+df_subformLabelSepChar+i,r=h.replace("__suffix__",o),window.jQuery?($field=$(":input[name='"+r+"']"),$field.length>0&&(n=$field[0],u=n.form)):u=document.form,u[r]?n=u[r]:(o=df_subformLabelSepChar+t+df_subformLabelSepChar+"newindex",r=h.replace("__suffix__",o),u[r]?n=u[r]:(r=e,n=u[r]))):(r=n,window.jQuery?($field=$(":input[name='"+r+"']"),$field.length>0?(n=$field[0],u=n.form):alert("df_GetField: field not found with name "+r)):(u=document.form,n=u[r])),n||(alert("SAVVY ERROR: df_GetField - field name not found. If using subforms you must supply the full field name with suffix."),alert("df_GetField: Debug. field=["+n+"], fieldName=["+r+"], origFieldName=["+e+"], subformCode["+t+"], rowIndex["+i+"]"))):n&&n.name?(r=n.name,u=n.form):(alert("SAVVY ERROR: df_GetField - field name not found. If using subforms you must supply the full field name with suffix."),alert("df_GetField: Debug. field=["+n+"], fieldName=["+r+"], origFieldName=["+e+"], subformCode["+t+"], rowIndex["+i+"]")),n.df_subformCode||(n.df_subformCode=n.getAttribute("df_subformCode"),n.df_subformCode=="null"&&(n.df_subformCode=null)),n.df_rowIndex||(n.df_rowIndex=n.getAttribute("df_rowIndex"),n.df_subformCode=="null"&&(n.df_subformCode=null)),n.df_suffix||(n.df_suffix=n.getAttribute("df_suffix"),n.df_suffix=="null"&&(n.df_suffix=null)),n.df_fieldName||(n.df_fieldName=n.getAttribute("df_fieldName"),n.df_fieldName=="null"&&(n.df_fieldName=null)),n.df_subformCode&&n.df_suffix&&n.df_rowIndex||(f=r.split(df_subformLabelSepChar),f.length>2?(s=parseInt(f[f.length-1],10),isNaN(s)||(n.df_rowIndex=s,n.df_subformCode=f[f.length-2],n.df_suffix=df_subformLabelSepChar+n.df_subformCode+df_subformLabelSepChar+n.df_rowIndex,suffixLen=n.df_suffix.length,n.df_fieldName||(n.df_fieldName=r.substring(0,r.length-suffixLen)))):n.df_fieldName||(n.df_fieldName=r)),n.df_fieldType=n.getAttribute("df_fieldType"),n.df_decimalPlaces=n.getAttribute("df_decimalPlaces"),n.df_groupDigits=n.getAttribute("df_groupDigits"),n.df_allowNegative=n.getAttribute("df_allowNegative"),n.df_format=n.getAttribute("df_format"),n}function df_GetFields(n,t){var r,i;if(typeof n=="string"&&typeof t=="string"?(i=n,r=document.form):(n=df_GetField(n,t),i=n.df_fieldName,t=n.df_subformCode,r=n.form),jQuery!==undefined){var e=i+df_subformLabelSepChar+t,u=[],f=0;return jQuery('[name^="'+e+'"]').each(function(){if(this&&this.name&&this.name.indexOf("newindex")==-1){var n=df_GetField(this),t=n.df_suffix;n.form["df_status"+t]&&n.form["df_status"+t].value!="deleted"&&(u[f]=n,f++)}}),u}return df_GetFieldsInAllRows(n,t)}function df_GetFieldsInAllRows(n,t){var i,u,f,s,e,r,o,n;for(typeof n=="string"&&typeof t=="string"?(u=n,i=document.form):(n=df_GetField(n,t),u=n.df_fieldName,t=n.df_subformCode,i=n.form),f=i["df_MaxRow"+df_subformLabelSepChar+t],f||alert("SAVVY ERROR: df_GetFieldsInAllRows - hidden field MaxRow not found for subform ["+t+"]. This may not be a valid subform name."),s=f.value,e=[],r=0;r<=s;r++)o=df_subformLabelSepChar+t+df_subformLabelSepChar+r,n=i["df_status"+o],n&&n.value!="deleted"&&(n=i[u+o],n=df_GetField(n),n&&(e[r]=n));return e}function df_GetSubformTotal(n,t){return df_GetSubformTotal_Internal(n,t,!1)}function df_GetSubformTotalString(n,t){return df_GetSubformTotal_Internal(n,t,!0)}function df_GetSubformTotal_Internal(n,t,i){var r=0,u=df_GetFieldsInAllRows(n,t);for(rowIndex in u)n=u[rowIndex],r+=df_GetNumberFieldValue(n);return i&&(r=n&&n.df_decimalPlaces!=undefined?df_FmtNumber(r,n.df_decimalPlaces,n.df_groupDigits):Math.round(r*1e6)/1e6),r}function df_GetDropDownValue(n){return n.options[n.selectedIndex].value}function df_GetDropDownText(n){return n.options[n.selectedIndex].text}function df_SetDropDownValue(n,t){for(var i=0;i<n.options.length;i++)n.options[i].value+""==t+""&&(n.selectedIndex=i)}function df_SetDropDownText(n,t){for(var i=0;i<n.options.length;i++)n.options[i].text+""==t+""&&(n.selectedIndex=i)}function df_SetFieldReadOnly(n,t){n||alert("df_SetFieldReadOnly: Field does not exist ["+n+"]");t==undefined&&alert("df_SetFieldReadOnly: second parameter missing (true or false)");typeof n=="string"&&(n=df_GetField(n));n.type=="hidden"&&n.form["chbox_"+n.name]&&(n.form["chbox_"+n.name].disabled=t);t?(n.readOnly=!0,n.style.backgroundColor="#dddddd"):(n.readOnly=!1,n.style.backgroundColor="#ffffff")}function df_DisableAllFields(){df_EnableAllFields(!1)}function df_EnableAllFields(n){var i,r,t;if(n=n||!0,window.jQuery)$(":input").each(function(){var t=this;t&&(t.type||t.name)&&(t.type=="text"||t.type=="button"||t.type=="submit"||t.type=="textarea"?df_SetFieldReadOnly(t,n):(t.type=="checkbox"||t.type=="select-one"||t.type=="select-multiple"||t.type=="radio")&&(t.disabled=n))});else{i=document.form;for(r in i.elements)t=i.elements[r],t&&(t.type||t.name)&&(t.type=="text"||t.type=="textarea"?df_SetFieldReadOnly(t,n):(t.type=="button"||t.type=="submit"||t.type=="checkbox"||t.type=="select-one"||t.type=="select-multiple"||t.type=="radio")&&(t.disabled=n))}}function df_GetNumberFieldValue(n){n=df_GetField(n);var t=StripNumber(n);return t!=""?parseFloat(t):0}function df_FmtNumber(n,t,i){var s,h,c,o,r;if(t==undefined&&(t=n.value&&n.getAttribute("df_decimalPlaces")?parseInt(n.getAttribute("df_decimalPlaces"),10):0),i==undefined&&(i=n.value&&n.getAttribute("df_groupDigits")?n.getAttribute("df_groupDigits")=="true":!0),num=n.value?df_GetNumberFieldValue(n):parseFloat(n),t==-1?num=Math.round(num*1e6)/1e6:(s=num<0,s&&(num*=-1),num=Math.round(Math.pow(10,t)*num)/Math.pow(10,t),s&&(num*=-1)),num==Number.POSITIVE_INFINITY||num==Number.NEGATIVE_INFINITY)u=num;else if(num==0)for(u="0",t>0&&(u+="."),r=0;r<t;r++)u+="0";else{var u=num+"",l=u.indexOf(".")>-1,f="",e=u;if(l&&(e=u.split(".")[0],f=u.split(".")[1]),t>0)for(f=f.substring(0,t),h=t-f.length,r=0;r<h;r++)f=f+"0";if(i){for(c=e.substr(0,1)=="-"?1:0,o="",r=0;r<e.length;r++)r>c&&(e.length-r)%3==0&&(o+=","),o+=e.substr(r,1);e=o}u=e;f!=""&&(u+="."+f)}return u}function df_KeyPressFieldHandler(event,fieldObj){var keyCode,nextField,functionName,func;if(event.type!="keydown"&&(fieldObj=event,window.event?event=window.event:alert("This page will only work in Internet Explorer. You are running Firefox or another browser. Please use Internet Explorer instead.")),fieldObj=df_GetField(fieldObj),df_currentForm=fieldObj.form,fieldObj.df_subformCode?(df_currentSubformCode=fieldObj.df_subformCode,df_currentRowSuffix=df_subformLabelSepChar+fieldObj.df_subformCode+df_subformLabelSepChar+fieldObj.df_rowIndex):df_currentRowSuffix="",event){if(df_currentRowSuffix)if(keyCode=event.keyCode||event.which,keyCode==40&&fieldObj.df_fieldType!="Text"){if(nextField=df_GetFieldBelow(fieldObj),nextField)try{nextField.focus();nextField.select()}catch(e){}}else if(keyCode==38&&fieldObj.df_fieldType!="Text"&&(nextField=df_GetFieldAbove(fieldObj),nextField))try{nextField.focus();nextField.select()}catch(e){}return event.keyCode==27?!1:(functionName=fieldObj.df_fieldName+"",functionName=functionName.replace(" ",""),func=eval("window.cf_OnKeyPress"+functionName),!func)?!0:func(fieldObj,event)}}function df_GetNextField(n){for(var i=!1,t=0;t<n.form.length;t++){if(i)return n.form[t];i=n.form[t]==n}return null}function df_GetFieldAbove(n,t){var n=df_GetField(n,t),r=df_GetFields(n,t),u=null,f,i;for(f in r){if(i=r[f],i.df_suffix==n.df_suffix)return u;u=i}return null}function df_GetFieldBelow(n,t){var n=df_GetField(n,t),r=df_GetFields(n,t),u=!1,f,i;for(f in r)if(i=r[f],i.df_suffix==n.df_suffix)u=!0;else if(u)return i;return null}function df_GetRowIndexFromSuffix(n){var t=n.split(df_subformLabelSepChar),i=t[t.length-1];return parseInt(i,10)}function df_GetSubformCodeFromSuffix(n){var t=n.split(df_subformLabelSepChar);return t[t.length-2]}function df_GetRowBySuffix(n){var t=document.getElementById("df_SubformRow"+n);return t.df_suffix=n,t.df_rowIndex=df_GetRowIndexFromSuffix(n),t}function df_SetRowBgColor(n,t){for(var r=document.getElementById("df_SubformRow"+n),u,i=0;i<r.cells.length;i++)u=r.cells[i],u.style.backgroundColor=t}function df_ChangeFieldHandler(event,fieldObj){var isEvent,functionName,func,isOK;if(event&&(isEvent=event.clientX||event.type=="change"||event.type=="click"||event.type=="blur"||event.type=="DOMContentLoaded"||event.bubbles+""=="",isEvent||(fieldObj=event,window.event&&(event=window.event))),fieldObj=df_GetField(fieldObj),df_currentForm=fieldObj.form,df_currentRowSuffix=fieldObj.df_subformCode?df_subformLabelSepChar+fieldObj.df_subformCode+df_subformLabelSepChar+fieldObj.df_rowIndex:"",functionName=fieldObj.df_fieldName+"",functionName=functionName.replace(" ",""),func=eval("window.cf_OnBeforeChange"+functionName),func&&func(fieldObj)==!1)return fieldObj.df_isInvalid=!0,!1;if(fieldObj.df_fieldType)if(fieldObj.df_fieldType=="Number"){if(fieldObj.value=df_Trim(fieldObj.value),fieldObj.value!=""){fieldObj.value=fieldObj.value.replace(/,/g,"");fieldObj.value=fieldObj.value.replace(/\$/g,"");try{fieldObj.value=eval(fieldObj.value)}catch(e){}}if(!CheckNumberField(fieldObj,parseInt(fieldObj.df_decimalPlaces,10),fieldObj.df_allowNegative=="true",fieldObj.df_groupDigits=="true"))return fieldObj.df_isInvalid=!0,fieldObj.select(),!1}else if(fieldObj.df_fieldType=="TimeEntry"){if(!CheckTimeEntryField(fieldObj))return fieldObj.df_isInvalid=!0,fieldObj.select(),!1}else if(fieldObj.df_fieldType=="URL"){if(!CheckURLField(fieldObj))return fieldObj.df_isInvalid=!0,fieldObj.select(),!1}else if(fieldObj.df_fieldType=="Date"&&!CheckDateField(fieldObj))return fieldObj.df_isInvalid=!0,fieldObj.select(),!1;if(functionName=fieldObj.df_fieldName+"",functionName=functionName.replace(" ","").replace("timefield_",""),func=eval("window.cf_OnChange"+functionName),!func)return fieldObj.df_isInvalid=!1,!0;if(isOK=func(fieldObj),isOK)fieldObj.df_isInvalid=!1;else if(isOK==!1){fieldObj.df_isInvalid=!0;"defaultValue"in fieldObj&&(fieldObj.value=fieldObj.defaultValue);try{fieldObj.focus();fieldObj.select()}catch(e){}}else fieldObj.df_isInvalid=!1;return isOK}function df_BlurFieldHandler(event,fieldObj){var functionName,func,isOK;return(fieldObj=df_GetField(fieldObj),fieldObj.df_isInvalid&&(fieldObj.df_isInvalid=!df_ChangeFieldHandler(event,fieldObj),fieldObj.df_isInvalid))?(fieldObj.select(),!1):(df_currentForm=fieldObj.form,fieldObj.df_subformCode?(df_currentSubformCode=fieldObj.df_subformCode,df_currentRowSuffix=df_subformLabelSepChar+fieldObj.df_subformCode+df_subformLabelSepChar+fieldObj.df_rowIndex):df_currentRowSuffix="",functionName=fieldObj.df_fieldName+"",functionName=functionName.replace(" ",""),func=eval("window.cf_OnBlur"+functionName),!func)?!0:(isOK=func(fieldObj),isOK?fieldObj.df_isInvalid=!1:isOK==!1?(fieldObj.df_isInvalid=!0,fieldObj.focus()):fieldObj.df_isInvalid=!1,isOK)}function df_ClickFieldHandler(event,fieldObj){var functionName,func;return(fieldObj=df_GetField(fieldObj),df_currentForm=fieldObj.form,fieldObj.df_subformCode?(df_currentSubformCode=fieldObj.df_subformCode,df_currentRowSuffix=df_subformLabelSepChar+fieldObj.df_subformCode+df_subformLabelSepChar+fieldObj.df_rowIndex):df_currentRowSuffix="",functionName=fieldObj.df_fieldName+"",functionName=functionName.replace(" ",""),func=eval("window.cf_OnClick"+functionName),!func)?!0:func(fieldObj)}function df_FocusFieldHandler(event,fieldObj){var functionName,func;if(fieldObj=df_GetField(fieldObj),df_autoSelectOnFocus&&fieldObj&&fieldObj.select&&fieldObj.tagName&&fieldObj.tagName=="INPUT")try{fieldObj.select()}catch(e){}return(df_currentForm=fieldObj.form,fieldObj.df_subformCode?(df_currentSubformCode=fieldObj.df_subformCode,df_currentRowSuffix=df_subformLabelSepChar+fieldObj.df_subformCode+df_subformLabelSepChar+fieldObj.df_rowIndex):df_currentRowSuffix="",functionName=fieldObj.df_fieldName+"",functionName=functionName.replace(" ",""),func=eval("window.cf_OnFocus"+functionName),!func)?!0:func(fieldObj)}function df_DeleteRow(field,suffix,subformCode,dontPromptUser){var row=df_GetRowBySuffix(suffix),isTable=row.tagName=="TR",cellIndex,cell,form,statusFld,func;if(isTable)for(cellIndex=0;cellIndex<row.cells.length;cellIndex++)cell=row.cells[cellIndex],cell.oldBackgroundColor=cell.style.backgroundColor,cell.style.backgroundColor=df_deleteRowColour;if(dontPromptUser||confirm("Are you sure you want to delete this row?"))form=document.form,field&&field.form&&(form=field.form),!form&&field&&(form=$(field).closest("form")),statusFld=form["df_status"+suffix],statusFld&&(statusFld.value="deleted"),func=eval("window.cf_OnDelete"+subformCode),df_useJQueryClone&&jQuery!==undefined&&jQuery.support.opacity?(jQuery(row).children().animate({opacity:0},400,function(){row.style.display="none"}),func&&window.setTimeout(function(){func(row)},400)):(row.style.display="none",func&&func(row));else for(cellIndex=0;cellIndex<row.cells.length;cellIndex++)cell=row.cells[cellIndex],cell.style.backgroundColor=cell.oldBackgroundColor}function df_GetMaxRowIndex(n){var r,t,i;return n.df_subformCode?(t=n.df_subformCode,r=n.form):(t=n,r=document.form),i=null,i=window.jQuery?$("input[name=df_MaxRow"+df_subformLabelSepChar+t+"]")[0]:r["df_MaxRow"+df_subformLabelSepChar+t],i||alert("SAVVY ERROR: df_GetMaxRowIndex - hidden field MaxRow not found for subform ["+t+"]. This may not be a valid subform name."),parseInt(i.value,10)}function df_GetMaxRowSuffix(n){var r,t,u,i;for(n==undefined?alert("df_GetMaxRowSuffix() called without parameter subformCodeOrField"):n.df_subformCode?(t=n.df_subformCode,r=n.form):(t=n,r=document.form),u=null,u=window.jQuery?$("input[name=df_MaxRow"+df_subformLabelSepChar+t+"]")[0]:r["df_MaxRow"+df_subformLabelSepChar+t],u||alert("SAVVY ERROR: df_GetMaxRowSuffix - hidden field MaxRow not found for subform ["+t+"]. This may not be a valid subform name."),i=parseInt(u.value,10);i>-1;)if(suffix=df_subformLabelSepChar+t+df_subformLabelSepChar+i,statusField=r["df_status"+suffix],statusField&&statusField.value!="deleted")break;else i--;return i<0?"":suffix}function df_AddRow(subformCode){var func=eval("window.cf_OnAddRow"+subformCode);return func&&func(subformCode),df_InsertRow(subformCode,-1)}function df_InsertRow(subformCode,rowIndexToInsertBefore){var maxRowField=null,newindex,table$,newRow,cloneRow,html,df_suff,df_rowindex,visibleCells,selector,func;maxRowField=window.jQuery?$("input[name=df_MaxRow"+df_subformLabelSepChar+subformCode+"]")[0]:form["df_MaxRow"+df_subformLabelSepChar+subformCode];maxRowField||alert("SAVVY ERROR: df_AddRow - hidden field MaxRow not found for subform ["+subformCode+"]. This may not be a valid subform name.");newindex=parseInt(maxRowField.value,10);newindex++;maxRowField.value=newindex;var templateRow=document.getElementById("df_SubformRow"+df_subformLabelSepChar+subformCode+df_subformLabelSepChar+"newindex"),totalsRow=document.getElementById("df_SubformRow"+df_subformLabelSepChar+subformCode+df_subformLabelSepChar+"totals"),table=document.getElementById("df_SubformTable_"+subformCode);if(table||(table$=jQuery("#df_SubformTable_"+subformCode),table$.length>-1&&(table=table$[0])),table||alert("Subform not found: "+subformCode),table){if(table.tagName=="TABLE")rowIndexToInsertBefore==-1?(newRow=table.insertRow(templateRow.rowIndex),totalsRow!=null&&(totalsRow.style="display:table-row",svyCalcSubformTotals())):newRow=table.insertRow(rowIndexToInsertBefore);else if(rowIndexToInsertBefore==-1)newRow=$("<div>Placeholder<\/div>").insertBefore(templateRow)[0];else throw new Error("not implemented yet");if(df_useJQueryClone)cloneRow=jQuery(templateRow).clone(!0,!0),$("select.svySelect2",cloneRow).length>0&&($("select.svySelect2",cloneRow).width($(".select2-container",cloneRow).width()),$(".select2-container",cloneRow).remove()),html=cloneRow.html(),html=html.replace(/newindex/ig,""+newindex),jQuery(newRow).html(html),templateRow.className&&(newRow.className=templateRow.className),templateRow.colSpan&&(newRow.colSpan=templateRow.colSpan),templateRow.rowSpan&&(newRow.rowSpan=templateRow.rowSpan),templateRow.align&&(newRow.align=templateRow.align),templateRow.vAlign&&(newRow.vAlign=templateRow.vAlign),templateRow.id&&(newRow.id=templateRow.id.replace("newindex",""+newindex)),df_suff=jQuery(templateRow).attr("df_suffix"),df_suff&&(newRow.df_suffix=df_suff.replace("newindex",""+newindex)),df_rowindex=jQuery(templateRow).attr("df_rowIndex"),df_rowindex&&(newRow.df_rowIndex=df_rowindex.replace("newindex",""+newindex)),newRow.setAttribute("df_suffix",newRow.df_suffix),newRow.setAttribute("df_rowIndex",newRow.df_rowIndex),window.jQuery.support.opacity&&(visibleCells=jQuery(newRow).children().filter(":visible"),visibleCells.hide(),visibleCells.fadeIn().show()),newRow.style.display="";else for(templateRow.className&&(newRow.className=templateRow.className),templateRow.colSpan&&(newRow.colSpan=templateRow.colSpan),templateRow.rowSpan&&(newRow.rowSpan=templateRow.rowSpan),templateRow.align&&(newRow.align=templateRow.align),templateRow.vAlign&&(newRow.vAlign=templateRow.vAlign),templateRow.id&&(newRow.id=templateRow.id.replace("newindex",""+newindex)),newRow.df_suffix=templateRow.getAttribute("df_suffix").replace("newindex",""+newindex),newRow.df_rowIndex=templateRow.getAttribute("df_rowIndex").replace("newindex",""+newindex),newRow.setAttribute("df_suffix",newRow.df_suffix),newRow.setAttribute("df_rowIndex",newRow.df_rowIndex),curr_cell=0;curr_cell<templateRow.cells.length;curr_cell++){for(newCell=newRow.insertCell(-1),templateCell=templateRow.cells[curr_cell],templateCell.className&&(newCell.className=templateCell.className),templateCell.colSpan&&(newCell.colSpan=templateCell.colSpan),templateCell.rowSpan&&(newCell.rowSpan=templateCell.rowSpan),templateCell.align&&(newCell.align=templateCell.align),templateCell.vAlign&&(newCell.vAlign=templateCell.vAlign),templateCell.style.display&&(newCell.style.display=templateCell.style.display),templateCell.onclick&&(newCell.onclick=templateCell.onclick),templateCell.onmouseover&&(newCell.onmouseover=templateCell.onmouseover),templateCell.onmouseout&&(newCell.onmouseout=templateCell.onmouseout),templateCell.onkeyup&&(newCell.onkeyup=templateCell.onkeyup),templateCell.onkeydown&&(newCell.onkeydown=templateCell.onkeydown),templateCell.onkeypress&&(newCell.onkeypress=templateCell.onkeypress),templateCell.id&&(newCell.id=templateCell.id.replace("newindex",""+newindex)),templateCell.df_suffix&&(newCell.df_suffix=templateCell.df_suffix.replace("newindex",""+newindex)),templateCell.df_rowIndex&&(newCell.df_rowIndex=templateCell.df_rowIndex.replace("newindex",""+newindex)),html=templateCell.innerHTML;html.indexOf("newindex")>-1;)html=html.replace("newindex",""+newindex);newCell.innerHTML=html}return window.BewebInitForm,window.BewebInitDatePickers&&BewebInitDatePickers(),typeof jQuery!="undefined"&&($.fn.hasOwnProperty("select2")&&$(".svySelect2",newRow).length>0&&($("select.svySelect2",newRow).select2(),window.initSvySelect2&&initSvySelect2()),$(".svyNeedsInit",newRow).length>0),window.REDIPS&&REDIPS.drag&&(selector=document.getElementById("drag_df_SubformTable_"+subformCode),selector?(REDIPS.drag.init("drag_df_SubformTable_"+subformCode),window.svyRenumberSortPositionTableDragSubForm&&svyRenumberSortPositionTableDragSubForm(table)):(selector=document.getElementById("drag"),selector&&REDIPS.drag.init("drag"))),window.tinyMCE&&window.jQuery&&$(".mceEditor_adding",newRow).each(function(){$(this).removeClass("mceEditor_adding");window.tinyMCE.EditorManager.execCommand("mceAddControl",!1,this.id)}),func=eval("window.cf_OnAddedRow"+subformCode),func&&func(subformCode),df_subformLabelSepChar+subformCode+df_subformLabelSepChar+newindex}}function df_Callback(n,t,i,r){df_isCallbackInProgress?df_pendingCallbacksQueue.push([n,t,i,r]):(df_CallbackNow(n,t,i,r),df_pendingWaitGraphicTimeout||(df_pendingWaitGraphicTimeout=window.setTimeout("df_ShowCallbackWaitGraphic()",500)))}function df_CallbackFinished(){df_pendingCallbacksQueue.length>0?(params=df_pendingCallbacksQueue.shift(),df_CallbackNow(params[0],params[1],params[2],params[3])):(df_isCallbackInProgress=!1,df_HideCallbackWaitGraphic())}function df_ShowCallbackWaitGraphic(){return}function df_HideCallbackWaitGraphic(){return}function df_CallbackNow(n,t,i,r){var f,u,e,o;if(typeof n=="function"){e=n;o=df_CallbackFinished;e(o);return}n=df_GetField(n,i,r);f=n.name;u=n.form;callbackFieldName=n.df_fieldName?n.df_fieldName:f;t==undefined&&(t="");i||(i=n.df_subformCode);i==undefined&&(i="");r||(r=n.df_rowIndex);r==undefined&&(r="");df_isCallbackInProgress=!0;u.df_callbackfield.value=callbackFieldName;u.df_callbackparam.value=t;u.df_callbacksubformcode.value=i;u.df_callbackrowindex.value=r;u.df_mode.value="callback";u.target="df_hiddeniframe";df_BeforeSubmit();u.submit();u.target="_self";u.df_mode.value="save"}function df_SubmitForm(n,t){n?n.type&&(n.type=="button"||n.type=="submit")?window.df_SubmitForm_buttonObj=n:alert("Savvy CMS Error: df_SubmitForm called with incorrect param. Should be buttonObj. Param was of type: "+n.type):window.df_SubmitForm_buttonObj=null;window.df_SubmitForm_funcNameScript=t;df_SubmitForm_Internal()}function df_SubmitForm_Internal(){var form=document.form;if(window.jQuery&&window.df_SubmitForm_buttonObj&&window.df_SubmitForm_buttonObj.form&&(form=window.df_SubmitForm_buttonObj.form),!form){alert("Error: Form not found");return}df_isCallbackInProgress?window.df_SubmitForm_TimeoutID=window.setTimeout("df_SubmitForm_Internal()",100):(buttonObj=window.df_SubmitForm_buttonObj,funcNameScript=window.df_SubmitForm_funcNameScript,df_BeforeSubmit(),CheckForm(form)&&(buttonObj&&(buttonObj.disabled=!0),funcNameScript&&eval(funcNameScript),window.SetWaitboxMessage&&(SetWaitboxMessage("Saving - please wait."),ShowWaitbox()),buttonObj&&(form.df_savebutton.value=df_Trim(buttonObj.value)),window.df_warnNotSaved=!1,window.onbeforeunload=null,form.submit()))}function df_CancelFormSubmit(){window.clearTimeout(window.df_SubmitForm_TimeoutID)}function df_CancelButtonClick(){window.df_warnNotSaved=!1;window.onbeforeunload=null;eval(df_returnpageJs)}function df_AddLoadEvent(n){var t=window.onload;window.onload=typeof onload!="function"?n:function(){t();n()}}function StripNumber(n){var t,i,r,u;if(n){if(n.value&&(n=n.value),typeof n=="function")return alert("Savvy CMS Error: StripNumber() parameter must be a string or a field. It is a 'function'."),"";if(typeof n=="object"&&typeof n.value=="undefined")return alert("Savvy CMS Error: StripNumber() parameter must be a string or a field. It is an 'object'. Possible cause: You may have two form elements with the same name."),"";for(t="",r=0;r<n.length;r++)i=n.substring(r,r+1),i>="0"&&i<="9"?t+=i:i!="."||u?i=="-"&&t.length==0?t+=i:i=="("&&t.length==0&&(t+="-"):(t+=i,u=!0);return(t=="."||t=="-")&&(t=""),t}return""}function CheckNumberField(n,t,i,r){var f,u,e,o;if(n.value.length==0)return!0;if((n.value=df_FmtNumber(n,t,r),StripNumber(n.value)!=n.value&&df_FmtNumber(n)!=n.value)||isNaN(parseFloat(n.value)))return alert("The value in this field should be a number, without any other characters. Please change the value."),!1;if(t==0&&isNaN(parseInt(n.value,10)))return alert("The value in this field should be a whole number, without any decimal places or other characters. Please change the value."),!1;if(f=n.value.indexOf(".")>-1,f&&t==0)return alert("The value in this field should be a whole number, without any decimal places. Please change the value."),!1;if(u="",f&&(u=n.value.split(".")[1]),t!=-1&&u.length>t)return alert("The value in this field is limited to "+t+" decimal places. Please change the value."),!1;if(!i&&parseFloat(n.value)<0)return alert("The value in this field should be a positive number. Please change the value."),!1;if(t>0){for(o=t-u.length,e=0;e<o;e++)u=u+"0";n.value=n.value.split(".")[0]+"."+u}return!0}function CheckTimeEntryField(n){var r,i,t,u;if(n.value.length==0)return!0;if(n.value.length>10&&(r=n.value.replace(new RegExp("\n","gm"),""),r=r.replace(new RegExp(".*?([0-9][0-9]:[0-9][0-9][a|p]).*","gi"),"$1"),n.value=r),(n.value.toLowerCase()=="n"||n.value.toLowerCase()=="now")&&(i=(new Date).getHours(),t=(new Date).getMinutes(),n.value=df_FmtTime(i+":"+t)),n.value.toLowerCase().substring(0,2)=="n-"){var i=(new Date).getHours(),t=(new Date).getMinutes(),f=parseInt(n.value.replace("n-",""));t-=f;t<0&&(i--,t+=60);n.value=df_FmtTime(i+":"+t)}if(n.value.toLowerCase().substring(0,2)=="n+"){var i=(new Date).getHours(),t=(new Date).getMinutes(),e=parseInt(n.value.replace("n+",""));t+=e;t>60&&(i++,t-=60);n.value=df_FmtTime(i+":"+t)}return(u=df_FmtTime(n),u.length==0)?(alert("The value in this field should be a time, without any other characters. Please change the value."),!1):(n.value=u,!0)}function CheckURLField(n){if(n.value.length==0)return!0;var t=n.value;return t.indexOf("http://")==0||t.indexOf("~")==0||t.indexOf("/")==0||t.indexOf("#")==0||t.indexOf("file://")==0||t.indexOf("rtsp://")==0||t.indexOf("https://")==0||t.indexOf("mailto:")==0||t.indexOf("asfunction:")==0||(n.value="http://"+n.value),!0}function df_FmtTime(n){var r,f,i,t,u,e;return(n.value?(f=n,r=n.value+""):(f=null,r=n+""),r=r.toLowerCase(),u="",r.indexOf(":")>-1?(i=r.split(":")[0],t=r.split(":")[1],i=parseInt(i,10),t.indexOf("a")>-1&&(t=t.substring(0,t.indexOf("a"))),t.indexOf("p")>-1&&(t=t.substring(0,t.indexOf("p"))),t=parseInt(t,10)):(i=parseInt(r,10),t=0,i>100&&(t=i%100,i=(i-t)/100)),isNaN(parseInt(i,10)))?"":isNaN(parseInt(t,10))?"":(t>59&&(t=59),i>=24&&(i=23,t=59),r.indexOf("a")>-1?u="am":r.indexOf("p")>-1?u="pm":i>24?f&&(f.style.color="red"):i>12?(i-=12,u="pm"):i==12?u="pm":i==0?(i=12,u="am"):u="am",e=i+":"+df_Right("0"+t,2)+u,f&&(f.df_hours=i,f.df_minutes=t,f.df_ampm=u),e)}function df_GetTimeEntryFieldValue(n){var u=F$(n).value,t,i,r;return(u.indexOf(":")>-1?(t=u.split(":")[0],i=u.split(":")[1],t=parseInt(t,10),i.indexOf("a")>-1&&(i=i.substring(0,i.indexOf("a"))),i.indexOf("p")>-1&&(i=i.substring(0,i.indexOf("p"))),i=parseInt(i,10)):(t=parseInt(u,10),i=0),isNaN(parseInt(t,10)))?"":isNaN(parseInt(i,10))?"":(u.indexOf("a")>-1?r="am":u.indexOf("p")>-1?r="pm":t>12?(t-=12,r="pm"):t==12?r="pm":t==0?(t=12,r="am"):r="am",t==12&&(t=0),r=="pm"&&(t+=12),t*60+i)}function df_SetTimeEntryFieldValue(n,t){var i=Math.floor(t/60),r=Math.floor(t%60);n.value=df_FmtTime(i+":"+r)}function LimitLength(n,t){if(t<=0)return!0;var i=n.value.length<=t;return i||alert("This text field cannot contain more than "+t+" characters."),i}function Postback(n,t){df_isPostbackUnderway||(df_isPostbackUnderway=!0,n!=undefined&&(n.name&&(n=n.name),document.form.df_postbackfield.value=n),t!=undefined&&(document.form.df_postbackparam.value=t),document.form.df_mode.value="postback",document.form.df_mode.value!="postback"&&alert("Postback Error: could not set mode."),window.df_warnNotSaved=!1,window.onbeforeunload=null,document.form.submit())}function df_BeforeSubmit(){var t=document.form,n,r,i;if(t.df_fieldlist){for(n="",r=t.length,i=0;i<r;i++)n.length>0&&(n+=","),n+=t[i].name;t.df_fieldlist.value=n}}function df_Right(n,t){return n.substr(n.length-t)}function df_RightFrom(n,t){return n==null?null:n.indexOf(t)>-1?n.substr(n.lastIndexOf(t)+t.length):n}function df_Trim(n){return n.replace(/(^\s*)|(\s*$)/g,"")}function df_TrimStart(n,t){var r,i;for(t||(t=" \t\r\n"),r=n.length,i=0;i<n.length;i++)if(t.indexOf(n[i])==-1){r=i;break}return n.substring(r)}function df_Replace(n,t,i){return n==null?null:n.split(t).join(i)}function df_IsBlank(n){for(var i,r="",t=0;t<n.length;t++)if(i=n.substring(t,t+1),i!=" ")return!1;return!0}function df_GetText(n){var t=df_GetField(n);return t.type=="select-one"?t.options[t.selectedIndex].text:df_GetValue(t)}function df_SetText(n,t){var i=df_GetField(n);i.type=="select-one"?df_SetDropDownText(i,t):df_SetValue(i,t)}function df_GetValue(n){var i,t;if(typeof n=="string"){if(t=df_GetField(n),!t){alert("df_GetValue Error: form field not found. ["+n+"]");return}}else n===undefined?alert("df_GetValue: field parameter is undefined"):t=n;return t?t.type?i=t.type:t.length&&t.length>0&&t[0]&&t[0].type?i=t[0].type:alert("df_GetValue Error: invalid param type."):alert("df_GetValue Error: invalid param type. ["+n+"]["+t+"]"),i=="select-one"?t.options[t.selectedIndex==-1?0:t.selectedIndex].value:i=="radio"?df_GetRadioValue(t):i=="checkbox"?df_GetCheckboxValue(t):t.form&&t.form["chbox_"+t.name]?t.form["chbox_"+t.name].checked:t.df_fieldType=="Number"?df_GetNumberFieldValue(t):t.value}function df_SetValue(n,t){var r,i;if(typeof n=="string"){if(i=df_GetField(n),!i){alert("df_SetValue Error: form field not found. ["+n+"]");return}}else i=n;if(i?i.type?r=i.type:i.length&&i.length>0&&i[0]&&i[0].type?r=i[0].type:alert("df_SetValue Error: invalid param type."):alert("df_SetValue Error: fieldObj does not exist ["+n+"]"),!i.form&&i.length&&alert("df_SetValue Error: The supplied object is not a form field. It could be an array of form fields. Do you have several fields named the same thing? ["+n+"]"),r=="select-one")df_SetDropDownValue(i,t);else if(i.form&&i.form["chbox_"+i.name])df_SetCheckboxValue(i,t);else if(r=="hidden")df_SetHiddenValue(i,t);else if(i.df_fieldType=="Number")df_SetNumberFieldValue(i,t);else{if(r=="radio")return df_SetRadioValue(i,t);if(r=="checkbox")return df_SetCheckboxValue(i);window.SetDateFieldValue&&(i.df_fieldType=="DateEntry"||i.getAttribute("df_fieldType")=="DateEntry")?window.SetDateFieldValue(i,t):i.value=t}}function df_ToDate(n){return n?n.indexOf("/Date(")==0?new Date(parseInt(n.replace("/Date(","").replace(")/",""))):new Date(n):null}function df_ToNumber(n){if(n){if(typeof n=="number")return n;n=StripNumber(n);n=n.indexOf(".")>-1?parseFloat(n):parseInt(n)}else n=0;return n}function df_SetNumberFieldValue(n,t){if(n=df_GetField(n),t+""=="")n.value="";else{var i=StripNumber(t+"");n.value=i;n.value=df_FmtNumber(n)}}function df_SetHiddenValue(n,t){n.value=t;var r=n.name,i=document.getElementById(r+"_Display");i||(i=document.getElementById(r+"_span"),i&&(!i.className||i.className!="displayfield")&&(i=null));i&&(i.length&&(i=i[0]),i.innerHTML=t)}function df_GetRadioValue(n){var i="",t;if(n.length||(n=n.form[n.name]),n.length){for(t=0;t<n.length;t++)if(n[t].checked){i=n[t].value;break}}else i=n.checked?n.value:"";return i}function df_SetRadioValue(n,t){if(n.length||(n=n.form[n.name]),n.length)for(var i=0;i<n.length;i++)n[i].checked=n[i].value==t?!0:!1;else n.checked=n.value==t?!0:!1}function df_GetCheckboxValue(n){var t="",i;if(n.length||(n=n.form[n.name]),n.length)for(i=0;i<n.length;i++)n[i].checked&&(t!=""&&(t+=", "),t+=n[i].value);else t=n.checked?n.value:"";return t}function df_SetCheckboxValue(n,t){var i=n,u,r;if(i.form["chbox_"+i.name])typeof t=="string"&&(t=t.toLowerCase(),t=="true"||t=="1"?t=!0:t=="false"||t=="0"||t==""?t=!1:(alert("df_SetCheckboxValue: invalid value for a boolean ["+t+"]"),t=!1)),i.value=t==!0?"1":"0",i.form["chbox_"+i.name].checked=t;else if(i.name.indexOf("chbox_")==0)u=i.form[i.name.replace("chbox_","")],u.value=t==!0?"1":"0",i.checked=t;else if(!i.length&&i.form&&(i=i.form[i.name]),i.length&&n.length>0)for(r=0;r<n.length;r++)n[r].checked=n[r].value==t||(","+t+",").indexOf(","+n[r].value+",")>-1||(", "+t+",").indexOf(", "+n[r].value+",")>-1?!0:!1;else i.type&&i.type=="checkbox"?i.checked=t:alert("Savvy Error: df_SetCheckboxValue expects a checkbox and was passed something else ["+i+"].")}function df_FocusFirstField(){var n,t;try{for(t=!1,f=0;f<document.forms.length;f++){for(i=0;i<document.forms[f].length;i++)if(n=document.forms[f][i],n.type!="hidden"&&document.forms[f][i].type!="button"&&n.disabled!=!0&&(n.focus(),n.select&&n.select(),t=!0),t==!0)break;if(t==!0)break}}catch(r){}}function df_SaveAndRefresh(){var n=document.forms.form;n.df_returnpage.value.indexOf("self:")!=0&&(n.df_returnpage.value="self:"+n.df_returnpage.value);df_SubmitForm()}function df_SaveAndGoURL(n){var t=document.form;t.df_returnpage.value=n;df_SubmitForm()}function df_CopyValueAbove(n){var t=df_GetFieldAbove(n);t?df_SetValue(n,df_GetValue(t)):df_SetValue(n,"")}function df_CopyValueToNextField(n){var t=df_GetNextField(n);t&&df_SetValue(t,df_GetValue(n))}function df_SetAutoSave(n){window.setInterval(df_AutoSave,n*1e3)}function df_AutoSave(){var n=df_GetValue("df_mode");n!="view"&&(window.df_warnNotSaved=!1,window.onbeforeunload=null,window.status="Autosaving...",df_Callback("df_tablename","autosave",""))}function V$(n,t){if(t===undefined)return df_GetValue(n);df_SetValue(n,t)}function df_SetDisplay(n,t){typeof n=="string"&&(n=E$(n));n.style.display=t?"none":""}function df_GetDateFieldValue(n){var t=df_GetValue(n);return t==""?"":(t=df_Replace(t,"-"," "),new Date(t))}function df_GetMonthEnd(n){var t=new Date(n);return t.setDate(1),t.setMonth(t.getMonth()+1),t.setDate(t.getDate()-1),t}function df_ForEachRow(n,t){var i,u,r;n===undefined&&alert("df_ForEachRow(subformCode, func): Error - subformCode is undefined");n==""&&alert("df_ForEachRow(subformCode, func): Error - subformCode is blank");t===undefined&&alert("df_ForEachRow(subformCode, func): Error - func is undefined");i=df_GetFields("df_status",n);for(u in i)r=i[u],t(r,r.df_suffix)}function df_RoundCents(n){return Math.round(n*100)/100}function df_FixRounding(n){return Math.round(n*1e6)/1e6}function SplitTitleCase(n){var t=n+"";return t=t.replace("_day"," Day"),t=t.replace("_month"," Month"),t=t.replace("_year"," Year"),t.replace(/([a-z])([A-Z])/g,"$1 $2")}function df_SafeDivide(n,t){return t==0||t+""==""||n==0||n+""==""?0:n/t}function df_RowCount(n){return jQuery!==undefined?jQuery("#df_SubformTable_"+n+" tr.svySubformRow:visible").length:df_GetMaxRowIndex(n)}function df_AddRowIfNone(n){if(jQuery!==undefined){var t=jQuery("#df_SubformTable_"+n+" tr.svySubformRow:visible").length;if(t==0)return df_AddRow(n)}else if(df_GetMaxRowIndex(n)==0)return df_AddRow(n);return null}function df_FmtDate(n){typeof n=="string"?n=n.indexOf("/Date(")==0?new Date(parseInt(n.replace("/Date(","").replace(")/",""))):new Date(n):typeof n=="number"&&(n=new Date(n));return n==null?"":n.getDate()+" "+df_FmtMonth(n.getMonth())+" "+n.getFullYear()}function df_FmtMonth(n){return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n]}function df_FmtDateTime(n){return df_FmtDate(n)+" "+df_Right("0"+n.getHours(),2)+":"+df_Right("0"+n.getMinutes(),2)}function df_SetViewMode(){var n=document.form||document.forms.form,t;if(df_DisableAllFields(),n.CancelButton&&(n.CancelButton.disabled=!1,n.CancelButton.style.fontWeight="bold",n.CancelButton.value="< Back"),n.SaveButton)if(n.SaveButton.length)for(t=0;t<n.SaveButton.length;t++)n.SaveButton[t].style.display="none";else n.SaveButton.style.display="none";n.DeleteButton&&(n.DeleteButton.style.display="none")}function df_SetEditMode(){var n=document.form||document.forms.form,t;if(df_EnableAllFields(),n.CancelButton&&(n.CancelButton.disabled=!1,n.CancelButton.style.fontWeight="normal",n.CancelButton.value="Cancel"),n.SaveButton)if(n.SaveButton.length)for(t=0;t<n.SaveButton.length;t++)n.SaveButton[t].style.display="inline-block";else n.SaveButton.style.display="inline-block";n.DeleteButton&&(n.DeleteButton.style.display="inline-block")}function df_HandleLineChange(formName){var func=eval("window.cf_HandleLineChange"+formName);return func?func(formName,event):!0}function df_HandleAddNewRow(formName,row){df_AddRow(formName);window.setTimeout(function(){var n=df_GetMaxRowIndex(formName)},500);var func=eval("window.cf_HandleAddNewRow"+formName);return func?func(formName,row,event):!0}function df_AutoSaveChildForm(n){$("#df_SubformTable_"+n+" input").unbind("change");$("#df_SubformTable_"+n+" input").unbind("keydown");$("#df_SubformTable_"+n+" input").bind("change",function(){df_HandleLineChange(n)});$("#df_SubformTable_"+n+" input").bind("keydown",function(t){var r=t.keyCode||t.which,i;if(r==13)return i=$(this).closest("tr"),df_HandleAddNewRow(n,i),t.preventDefault(),!1})}function df_AjaxSaveCall(n,t){var i=$(t).attr("df_suffix"),r=i.split("__")[2],u=$(t).find("input[name='df_status"+i+"']").val(),f=$(t).find("input[name='df_recordId"+i+"']").val()}function SetupAdminIsotopeMenu(n){n&&$(".admin-menu-box-wrapper").isotope({itemSelector:".admin-menu-section-box",percentPosition:!1,masonry:{columnWidth:".admin-menu-section-box"}})}var df_currentForm,df_currentSubformCode,df_currentRowIndex,df_currentRowSuffix,df_subformLabelSepChar="__",df_deleteRowColour="#ffffcc",df_dirtyWarningText="Any changes you made will NOT be saved.",df_useJQueryClone=!0,df_autoSelectOnFocus=!1,df_isPostbackUnderway,F$,df_GLOBAL_lineChangeInProgress;window.jQuery&&jQuery(document).ready(df_CheckGlobals);df_AddLoadEvent(df_CheckGlobals);typeof $!="function"&&($=E$);var df_pendingCallbacksQueue=[],df_isCallbackInProgress=!1,df_pendingWaitGraphicTimeout=null,df_waitGraphicIframe=null;df_isPostbackUnderway=!1;F$=df_GetField;df_GLOBAL_lineChangeInProgress=!1;
//# sourceMappingURL=beweb-cma.min.js.map
