var modifyCounter = 0; function getCheckedRadio(radioObj) { if(!radioObj) return ""; for(var i = 0; i < radioObj.length; i++) { if(radioObj[i].checked) return radioObj[i].value; } return ""; } function incModCount() { modifyCounter++; } function flipValue(box) { if (!box.checked) { box.value=0; // alert("t -> f"); } else { box.value=1; // alert("f -> t"); } incModCount(); } function clearSelected(name){ var elements = document.getElementById(name).options; for(var i = 0; i < elements.length; i++){ if (elements[i].selected) { elements[i].selected = false; incModCount(); } } } function uncheckRadio(name) { var radios = document.getElementsByName(name); for(var i=0; i0) { if (confirm("You have unsaved changes on your form.\n"+ "Click 'OK' to return to your form to save your changes.\n"+ "Click 'Cancel' to cancel your changes and continue.\n"+ "YOU WILL LOSE ALL UNSAVED CHANGES IF YOU CLICK 'Cancel'.")) { return true; } modifyCounter=0; } return false; } function popMeUp(aURL,aName,width,height) { if (width==null) { width = 600; } if (height==null) { height = 400; } var param = "width="+width+",height="+height+",toolbar=0,directories=0,menubar=0,status=1,resizable=yes,location=0,scrollbars=yes"; var myName = window.open(aURL,aName,param); if (myName!=null) myName.focus(); } function checkHtlm5Submit() { if ((document.getElementById('Html5SubmitButton')) && (typeof form1.checkValidity=='function') ) { if (form1.checkValidity()) return true; else { document.querySelector('#Html5SubmitButton').click(); return false; } } else return true; } function saveChanges1() { SaveChanges(document.form1.service.value); } function SaveChanges(svc) { if (checkHtlm5Submit()) SaveChanges2(svc); } function SaveChanges2(svc) { if ((typeof form_dep_onsave== "undefined") || form_dep_onsave()) { if (svc==null || svc=='') document.form1.service.value=2; // 2 => FormsValidateServlet.ACTION_UPDATE_THE_FORM else document.form1.service.value=svc; if (ecValidateForm) { if ( ecValidateForm(document.form1)) { document.form1.submit(); } } else { document.form1.submit(); } modifyCounter = 0; self.focus(); } } function goPropPage(id,iFormDirId) { location.href='/rims/servlet/ec_properties?page_type=formdata&id='+id+'&iFormDirId='+iFormDirId; } function deleteInst(subCount,action,id,pkgId,saveAct) { deleteInst1(subCount,0,action,id,pkgId,saveAct); } function deleteInst1(subCount,iformdirid,action,id,pkgId,saveAct) { deleteInst2(subCount,iformdirid,action,id,pkgId,saveAct, ''); } function deleteInst2(subCount,iformdirid,action,id,pkgId,saveAct, returnurl) { var confirmString; if (subCount==0) { confirmString = "Permanently delete this form?"; } else { confirmString = "This form has related data.\n Permanently delete this form and all related forms?"; } if (confirm(confirmString)) { changeCount = 0; document.form1.removed.value='true'; var url = '/servlet/forms?action='+action+'&formDataId='+id+'&saveAction='+saveAct; if (pkgId>0) url = url +'&pkg='+pkgId; if ('' != returnurl) url = url + '&returnURL='+returnurl; //alert(url); location.href= '/rims'+url; } return; } function newInst(action,id,pkgId,saveAct) { if (document.form1) { if (document.form1.removed.value=='true') { location.href='/rims/form_views/DataExpired.jsp'; return; } } if (pkgId>0) { location.href='/rims/servlet/forms?action='+action+'&formDataId='+id+'&saveAction='+saveAct+'&pkg='+pkgId; } else { location.href='/rims/servlet/forms?action='+action+'&formDataId='+id+'&saveAction='+saveAct; } } function formatElement(name, value) { return "
  • " + "" + name + ": " + value + "\n"; } function blocking(nr) { if (document.getElementById) // Netscape 5 and Explorer 5 { current = (document.getElementById(nr).style.display == 'block') ? 'none' : 'block'; document.getElementById(nr).style.display = current; } else if (document.all) // Explorer 4 { current = (document.all[nr].style.display == 'block') ? 'none' : 'block' document.all[nr].style.display = current; } else alert ('This link does not work in your browser.'); } function doPopupRefresh() { changeCount = 0; if (window.opener.document.text_search_home) window.opener.document.text_search_home.submit(); self.focus(); } function doIFrameRefresh(id) { changeCount = 0; if (id==0) { parent.document.text_search_home.submit(); } else { parent.setSelectedIForm(id); } self.focus(); } function refreshFields() { changeCount = 0; /* Because we need to keep some form elements, we don't want to just do a relocation. */ document.form1.service.value=1; // 1 => FormsValidateServlet.ACTION_RELOAD document.form1.submit(); } function popMeUpMax(aURL,aName,style) { var myName; if (style=='full') myName = window.open(aURL,aName); else myName = window.open(aURL,aName,"toolbar=0,directories=0,menubar=0,status=1,resizable=yes,location=0,scrollbars=yes"); if (myName!=null) myName.focus(); } function getNowStr() { var mydate=new Date(); var year=mydate.getYear(); if (year < 1000) year+=1900; var day=mydate.getDay(); var month=mydate.getMonth()+1; if (month<10) month="0"+month; var daym=mydate.getDate(); if (daym<10) daym="0"+daym; return (month+"/"+daym+"/"+year); } function now(field) { field.value = getNowStr(); } function isNumeric(passedVal) { if (passedVal == "") { return true; } for (i = 0; i < passedVal.length; i++) { var pointCnt = 0; if (passedVal.charAt(i) < "0") { if (i==0 && passedVal.charAt(i) != "-" && passedVal.charAt(i) != "+" && passedVal.charAt(i) != ".") { return false; } else if (passedVal.charAt(i) == ".") { pointCnt ++; if (pointCnt > 1) { return false; } } } if (passedVal.charAt(i) > "9") { return false; } } return true; } /** * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */ // Declaring valid date character, minimum year and maximum year var dtCh= "/"; var minYear=1900; var maxYear=2100; function isInteger(s){ var i; for (i = 0; i < s.length; i++){ // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } function stripCharsInBag(s, bag){ var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. for (i = 0; i < s.length; i++){ var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString; } function daysInFebruary (year){ // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); } function DaysArray(n) { for (var i = 1; i <= n; i++) { this[i] = 31 if (i==4 || i==6 || i==9 || i==11) {this[i] = 30} if (i==2) {this[i] = 29} } return this } function isDate(dtStr){ var daysInMonth = DaysArray(12) var pos1=dtStr.indexOf(dtCh) var pos2=dtStr.indexOf(dtCh,pos1+1) var strMonth=dtStr.substring(0,pos1) var strDay=dtStr.substring(pos1+1,pos2) var strYear=dtStr.substring(pos2+1) strYr=strYear if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1) if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1) for (var i = 1; i <= 3; i++) { if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1) } month=parseInt(strMonth) day=parseInt(strDay) year=parseInt(strYr) if (pos1==-1 || pos2==-1){ alert("The date format should be : mm/dd/yyyy") return false } if (strMonth.length<1 || month<1 || month>12){ alert("Please enter a valid month") return false } if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){ alert("Please enter a valid day") return false } if (strYear.length != 4 || year==0 || yearmaxYear){ alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear) return false } if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){ alert("Please enter a valid date") return false } return true } /* * hdn_name is used for SengIFormInclude.jsp */ function validateNumeric(fld,hdn_name) { if (fld.value != "") { var mydata = parseFloat(fld.value); if (isNaN(mydata)) { alert('Please input a number for this field.'); fld.focus(); } else { fld.value = mydata; incModCount(); if (hdn_name!=null) { hdn_name.value=1; } } } else { incModCount(); if (hdn_name!=null) { hdn_name.value=1; } } } /* * hdn_name is used for SengIFormInclude.jsp */ function validateDate(fld,hdn_name) { if (fld.value != "") { if (isDate(fld.value)==false){ fld.focus(); } else { incModCount(); if (hdn_name!=null) { hdn_name.value=1; } } } else { incModCount(); if (hdn_name!=null) { hdn_name.value=1; } } } function validateTextareaLength(fld, limit) { if (fld.value.length <= limit) { incModCount(); } else { alert("Your data has exceeded the maximum capacity "+limit); fld.focus(); } } function openImageViewerWindow(fileId) { if (fileId > 0) { var aURL = '/rims/form_views/SimpleImageDisplay.jsp?fileId='+fileId; var myName = window.open(aURL); myName.focus(); } else { var w = window.open(); w.document.writeln("\x3Chtml>"); w.document.writeln("\x3Chead>"); w.document.writeln("\x3Ctitle>Image Viewer\x3C/title>"); w.document.writeln("\x3C/head>"); w.document.writeln("\x3Cbody"); w.document.writeln("There\'s no images to display, because none had been uploaded."); w.document.writeln("\x3C/body>"); w.document.writeln("\x3C/html>"); w.document.close(); w.focus(); } } function showReferencedIForm(grandformId, formId, metaId, iformDir) { if (document.form1.saveAction.value==2 || document.form1.saveAction.value==1) { location.href='/rims/servlet/forms?action=2&formDataId='+formId+'&saveAction=2'+'&iFormDirId='+iformDir; } else if (document.form1.saveAction.value==4) { if (grandformId != 0) { parent.doInstanceSearch(grandformId, formId); } else { parent.doMetaSearch(metaId, formId); } } else if (document.form1.saveAction.value==7) { if (document.form1.protosubmission.value > 0 ) { var url = '/rims/ezsearch?proto_submission='+ document.form1.protosubmission.value+'&selected_iform='+formId; if (grandformId != 0) { url += '&iform='+grandformId; } url += '&vform='+metaId; setForwardJsp(url); } } } function openLink(field, name) { popMeUpMax(field.value,name,'full'); } function printThis() { printThisFromSubmission(0,0); } function do_quick_save(svc) { document.form1.service.value=svc; if (ecValidateForm) { if ( ecValidateForm(document.form1)) { document.form1.submit(); } } else { document.form1.submit(); } modifyCounter = 0; self.focus(); } function doAdditionalForm() { doAdditionalForm(0); } function doAdditionalForm(pkgId) { if (!notifyImminentUnload()) { newInst(4,document.form1.formDataId.value, pkgId, 2); // location.href='/servlet/forms?IFormDirId='+document.form1.IFormDirId.value+'&action=4&formDataId='+document.form1.formDataId.value+'&SaveAction=2'; } } function doCloneForm() { doCloneFormWithPkg(0); } function doCloneFormWithPkg(pkgId) { if (!notifyImminentUnload()) { newInst(9, document.form1.formDataId.value, pkgId, 2); // location.href='/servlet/forms?IFormDirId='+document.form1.IFormDirId.value+'&action=9&formDataId='+document.form1.formDataId.value+'&SaveAction=2'; } } function setElementDisplay(fld, id, val, state) { var obj = document.getElementById(id); if (obj && fld.value == val) { obj.style.display=state; } else if (obj){ if (state=='' || state=='inline') { obj.style.display='none'; } else { obj.style.display=''; } } } function checkDigits(aField,digits) { return checkDigitsWMsg(aField,digits,digits+" digits please.","Numbers only please."); } function checkphone(fld) { return checkDigitsWMsg(fld,10,'Please input numbers only and include the area code. For example 415-555-1212 would be 4155551212', 'Please input numbers only and include the area code. For example 415-555-1212 would be 4155551212'); } function checkDigitsWMsg(aField,digits,msg1, msg2) { if (aField.value=='') { return true; } if (isInteger(aField.value)) { if (aField.value.length!=digits ) { alert (msg1); setTimeout(function(){refocusElement(aField)},100); return false; } return true; } alert (msg2); setTimeout(function(){refocusElement(aField)},100); return false; } function refocusElement(fld) { fld.focus(); } function processTimeDisplayChange(name, changer) { var hidden = document.getElementById(name); var hours = document.getElementById(name + "_select_hours"); var minutes = document.getElementById(name + "_select_minutes"); var amOrPm = document.getElementById(name + "_select_am_pm"); var other = new Array(2); var i; if (changer == hours) { other[0] = minutes; other[1] = amOrPm; } else if (changer == minutes) { other[0] = hours; other[1] = amOrPm; } else // changer == amOrPm { other[0] = hours; other[1] = minutes; } if (changer.selectedIndex == 0) { for (i in other) other[i].selectedIndex = 0; hidden.value = ""; } else { for (i in other) { var o = other[i]; if (o.selectedIndex <= 0) o.selectedIndex = 1; } hidden.value = hours.value + ":" + minutes.value + " " + amOrPm.value; } incModCount(); } function checkRange (el,min,max) { var val = el.value; var elname = el.name; if(isNaN(val)) return false; if ((val >= min && val <= max) || (val == "")) return true; alert ('Please enter a value between '+min+' and '+max+'.'); setTimeout("document.form1."+ elname +".focus();",1); setTimeout("document.form1."+ elname +".select();",1); return false; }