ns4 = (document.layers)? true:false ie4 = (document.all)? true:false // Show/Hide functions for non-pointer layer/objects function show(id) { if (ns4) document.layers[id].visibility = "show" else if (ie4) document.all[id].style.display = "inline" } function hide(id) { if (ns4) document.layers[id].visibility = "hide" else if (ie4) document.all[id].style.display = "none" } function checkPhoneField(phoneField) { //INITIALIZE VARS var firstThree = ""; var middleThree = ""; var lastNumbers = ""; var errors = ""; var phone=phoneField.value; // CLEAR ALL NON NUMBER CHARACTERS phone = phone.replace(/[\(\)\- ,\.]/g,""); // CLEAR LEADING 1 if (phone.length > 10){ phone = (phone.charAt(0)=="1"?phone.substr(1,phone.length):phone); } // CHECK LENGTH OF PHONE NUMBER if (phone.length < 10 && phone.length > 0){ errors += "Invalid phone format: Not enough numbers\n" } // CHECK if INPUT IS A NUMBER if (isNaN(phone)){ errors += "Invalid phone format: Invalid characters\n" } // SHOW ERRORS if (errors.length > 0){ errors += "\nMust use following format: ###-###-####"; alert(errors); phoneField.focus(); return false; } // GET FIRST THREE if (phone.length > 2){ firstThree = "(" + phone.substr(0,3) + ") "; // GET SECOND THREE if (phone.length > 5){ middleThree = phone.substr(3,3) + "-"; // GET REST OF NUMBER if (phone.length > 5){ lastNumbers = phone.substr(6,phone.length); } }else{ lastNumbers = phone.substr(3,phone.length); } }else{ lastNumbers = phone; } // PUT NUMBERS TOGETHER newPhone = firstThree + middleThree + lastNumbers; // return VALUE phoneField.value = newPhone; } function GetRadioValue( radioObject ) { var value = null; // Validate parameter value //*** if (radioObject+"" == "undefined" || radioObject == null) if (radioObject == null) return null; for (var i=0; i < radioObject.length; i++) { if (radioObject[i].checked) { value = radioObject[i].value; break; } } // end for loop return value; } // end GetRadioValue function getCheckValues (checkObject){ var vals = new Array(); var form = (checkObject.form != null) ? checkObject.form : checkObject[0].form; var checkObjectName = (checkObject.name != null) ? checkObject.name : checkObject[0].name; for (var i = 0; i < form.elements.length;i++){ obj = eval("document." + form.name + ".elements[" + i + "]"); if ((obj.name == checkObjectName) && (obj.type == "checkbox")) if (obj.checked) vals[vals.length] = obj.value; } return vals; } //end getCheckValue function replace(target, oldTerm, newTerm, caseSens, wordOnly) { var work = target; var ind = 0; var next = 0; if (!caseSens) { oldTerm = oldTerm.toLowerCase(); work = target.toLowerCase(); } while ((ind = work.indexOf(oldTerm,next)) >= 0) { if (wordOnly) { var before = ind - 1; var after = ind + oldTerm.length; if (!(space(work.charAt(before)) && space(work.charAt(after)))) { next = ind + oldTerm.length; continue; } } target = target.substring (0,ind) + newTerm + target.substring(ind+oldTerm.length,target.length); work = work.substring(0,ind) + newTerm + work.substring(ind+oldTerm.length,work.length); next = ind + newTerm.length; if (next >= work.length) { break; } } return target; } function space (check) { var space = " .,/<>?!`';:@#$%^&*()=-|[]{}" + '"' + "\\\n\t"; for (var i = 0; i < space.length; i++) if (check == space.charAt(i)) { return true; } if (check == "") { return true; } if (check == null) { return true; } return false; } function isValidDate(dateStr) { var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year var matchArray = dateStr.match(datePat); // is the format ok? if (matchArray == null) { alert(dateStr + " Date is not in a valid format.") return false; } month = matchArray[1]; // parse date into variables day = matchArray[3]; year = matchArray[4]; if (month < 1 || month > 12) { // check month range alert("Month must be between 1 and 12."); return false; } if (day < 1 || day > 31) { alert("Day must be between 1 and 31."); return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { alert("Month "+month+" doesn't have 31 days!") return false; } if (month == 2) { // check for february 29th var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day>29 || (day==29 && !isleap)) { alert("February " + year + " doesn't have " + day + " days!"); return false; } } return true; } function isValidTime(timeStr) { var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/; var matchArray = timeStr.match(timePat); if (matchArray == null) { alert("Time is not in a valid format."); return false; } hour = matchArray[1]; minute = matchArray[2]; second = matchArray[4]; ampm = matchArray[6]; if (second=="") { second = null; } if (ampm=="") { ampm = null } if (hour < 0 || hour > 23) { alert("Hour must be between 1 and 12. (or 0 and 23 for military time)"); return false; } if (hour <= 12 && ampm == null) { if (confirm("Please indicate which time format you are using. OK = Standard Time, CANCEL = Military Time")) { alert("You must specify AM or PM."); return false; } } if (hour > 12 && ampm != null) { alert("You can't specify AM or PM for military time."); return false; } if (minute < 0 || minute > 59) { alert ("Minute must be between 0 and 59."); return false; } if (second != null && (second < 0 || second > 59)) { alert ("Second must be between 0 and 59."); return false; } return true; } function dateDiff(pDate1, pTime1, pTime2) { date1 = new Date(); date2 = new Date(); diff = new Date(); if (isValidDate(pDate1) && isValidTime(pTime1)) { date1temp = new Date(pDate1 + " " + pTime1); date1.setTime(date1temp.getTime()); } else return false; // otherwise exits if (isValidDate(pDate1) && isValidTime(pTime2)) { date2temp = new Date(pDate1 + " " + pTime2); date2.setTime(date2temp.getTime()); } else return false; // otherwise exits diff.setTime(Math.abs(date1.getTime() - date2.getTime())); timediff = diff.getTime(); weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7)); timediff -= weeks * (1000 * 60 * 60 * 24 * 7); days = Math.floor(timediff / (1000 * 60 * 60 * 24)); timediff -= days * (1000 * 60 * 60 * 24); hours = Math.floor(timediff / (1000 * 60 * 60)); timediff -= hours * (1000 * 60 * 60); mins = Math.floor(timediff / (1000 * 60)); timediff -= mins * (1000 * 60); secs = Math.floor(timediff / 1000); timediff -= secs * 1000; var gResults = hours + "." + mins; return gResults; } function trim(inputstringTrim) { fixedTrim = ""; lastCh = " "; for (x = 0; x < inputstringTrim.length; x++) { ch = inputstringTrim.charAt(x); if ((ch != " ") || (lastCh != " ")) { fixedTrim += ch; } lastCh = ch; } if (fixedTrim.charAt(fixedTrim.length - 1) == " ") { fixedTrim = fixedTrim.substring(0, fixedTrim.length - 1); } return fixedTrim; } function selectedIndex(setValue) { if (setValue != null) this.obj.selectedIndex = setValue; else return this.obj.selectedIndex; } function dbLookup(server,path,view,key,column){ xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; var pos=0; currURL = (document.location.href).toLowerCase(); if (trim(server) == "") { pos = currURL.indexOf('://'); if (pos < 0 ) server = "http://emcapp1.electricmobility.com" // PUT YOUR SERVERNAME HERE else { pos += 3; pos = currURL.indexOf('/', pos); server = currURL.substring(0, pos) } } if( trim(path) == "" ) { if( pos > 0 ) { newPos = currURL.indexOf('.nsf',pos); if (newPos > 0) { path = currURL.substring(pos+1,newPos+4) } } } //Javascript index starts at 0, so need to decrement the column by -1 if( !isNaN(column) ) column -= 1; vurl = trim(server)+"/"+trim(path)+"/"+view+"?readviewentries&count=9999"; xmlDoc.load(vurl); nodes = xmlDoc.documentElement.childNodes; temp = new Array(nodes.length); var j = 0; for (var i = 0; i < nodes.length; i++) { if(nodes.item(i).childNodes.item(0).text==key) { temp[j] = nodes.item(i).childNodes.item(column).text; j++; } } var results = "" for (var i = 0; i < j; i++) { if (i==0) { results = temp[i]; } else { results = results + "," + temp[i]; } } return(results); } //End of dbLookup function dbColumn(server,path,view,column){ // server e path optional xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; var pos=0; currURL = (document.location.href).toLowerCase(); if (trim(server) == "") { pos = currURL.indexOf('://'); if (pos < 0 ) server = "http://emcapp1.electricmobility.com" // PUT YOUR SERVERNAME HERE else { pos += 3; pos = currURL.indexOf('/', pos); server = currURL.substring(0, pos) } } if( trim(path) == "" ) { if( pos > 0 ) { newPos = currURL.indexOf('.nsf',pos); if (newPos > 0) { path = currURL.substring(pos+1,newPos+4) } } } if( !isNaN(column) ) column -= 1; vurl = trim(server)+"/"+trim(path)+"/"+view+"?readviewentries&count=9999"; xmlDoc.load(vurl); nodes = xmlDoc.documentElement.childNodes; temp = new Array(nodes.length); var j = 0; for (var i = 0; i < nodes.length; i++) { temp[j] = nodes.item(column).childNodes.item(0).text; j++; } results = new Array(j); for (var i = 0; i < j; i++) { results[i] = temp[i]; } return(results); } //End of dbColumn function trim(sStr) { var iI = 0; var iJ = 0; var iTam = 0; var sAux = ""; iTam = sStr.length; if(iTam==0) return(sStr); for(iI=0; iI= iTam) return(""); for(iJ=iTam - 1; iJ>=0; iJ--) if(sStr.charAt(iJ)!=' ') break; return(sStr.substring(iI,iJ+1)); } //End of trim function explode(inputstring, separators, includeEmpties ) { inputstring = new String(inputstring); separators = new String(separators); if (separators == "undefined") { separators = " :;"; } fixedExplode = new Array(1); currentElement = ""; count = 0; for(x = 0; x < inputstring.length; x++) { echar = inputstring.charAt(x); if (separators.indexOf(echar) != -1) { if (((includeEmpties <= 0) || (includeEmpties == false)) && (currentElement == "")) {} else { fixedExplode[count] = currentElement; count++; currentElement = ""; } } else { currentElement += echar; } } if ((!(includeEmpties <= 0) && (includeEmpties != false)) || (currentElement != "")) { fixedExplode[count] = currentElement; } return fixedExplode; } function openBasicWindowURL (width, height, URL, scrollbars){ var strOpener = "width="+width+",height="+height+",resizable=yes,scrollbars="+scrollbars; var tempWindow = window.open("", "", strOpener); tempWindow.document.open(); tempWindow.location.href = URL; if (tempWindow != null && tempWindow.opener == null) tempWindow.opener=self; tempWindow.focus(); } function selectedIndex(setValue) { if (setValue != null) this.obj.selectedIndex = setValue; else return this.obj.selectedIndex; } function openCommentDialog() { dbh=window.location.host; temp1=window.location.pathname; temp2=temp1.toUpperCase(); dbp=temp2.slice(0,temp2.lastIndexOf('.NSF')); dbs=".nsf"; did=document.forms[0].DocID.value; w=500; h=250; var winl = (screen.width-w)/2; var wint = (screen.height-h)/2; url = 'http://' + dbh + dbp + dbs + '/DBoxComment?OpenForm&'+did; settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,resizable=yes,dependent=no' window.open(url, 'newWin', settings) } function openMailMessageDialog(ts) { if (doc.Title.eq("")) doc.Title.set("New Document"); if (ts != "SM") { doc.MailNotify.set("3"); doc.submit(); } dbh=window.location.host; temp1=window.location.pathname; temp2=temp1.toUpperCase(); dbp=temp2.slice(0,temp2.lastIndexOf('.NSF')); dbs=".nsf"; did=document.forms[0].DocID.value; w=600; h=360; var winl = (screen.width-w)/2; var wint = (screen.height-h)/2; url = 'http://' + dbh + dbp + dbs + '/DBoxMailMessage?OpenForm&'+ts+'&'+did; settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,resizable=yes,dependent=no' window.open(url, 'newWin', settings) } function refreshdoc() { //0 is MyTargetField //1 is SomeOtherField //2 is MyThirdField var f = document.forms[0]; //use nameCheck to know which field to update if ( f.nameCheck.value == "0" ) { f.Interviewer.value = f.NotesName.value; } else if ( f.nameCheck.value == "11" ) { f.rtManagera.value = f.NotesName.value; } else if ( f.nameCheck.value == "2" ) { f.L1_bo.value = f.NotesName.value; } else if ( f.nameCheck.value == "3" ) { f.Requestor.value = f.NotesName.value; } else if ( f.nameCheck.value == "4" ) { f.L1_keyEF.value = f.NotesName.value; } else if ( f.nameCheck.value == "5" ) { f.L1_cf.value = f.NotesName.value; } else if ( f.nameCheck.value == "6" ) { f.L1_key.value = f.NotesName.value; } else if ( f.nameCheck.value == "7" ) { f.L1_add1.value = f.NotesName.value; } else if ( f.nameCheck.value == "8" ) { f.L1_add2.value = f.NotesName.value; } else if ( f.nameCheck.value == "9" ) { f.L1_add3.value = f.NotesName.value; } else if ( f.nameCheck.value == "10" ) { f.L1_add4.value = f.NotesName.value; } else if ( f.nameCheck.value == "1" ) { f.Notifications.value = f.NotesName.value; } f.NotesName.value = ""; //clear out value f.nameCheck.value = ""; //clear out value } function NewWindow(mypage, myname, w, h, scroll) { var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable' win = window.open(mypage, myname, winprops) if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } } function emailCheck(emailStr) { var checkTLD=1; var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/; var emailPat=/^(.+)@(.+)$/; var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; var validChars="\[^\\s" + specialChars + "\]"; var quotedUser="(\"[^\"]*\")"; var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; var atom=validChars + '+'; var word="(" + atom + "|" + quotedUser + ")"; var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); var matchArray=emailStr.match(emailPat); if (matchArray==null) { alert("Email address seems incorrect (check @ and .'s)"); return false; } var user=matchArray[1]; var domain=matchArray[2]; for (i=0; i127) { alert("Ths username contains invalid characters."); return false; } } for (i=0; i127) { alert("Ths domain name contains invalid characters."); return false; } } if (user.match(userPat)==null) { alert("The username doesn't seem to be valid."); return false; } var IPArray=domain.match(ipDomainPat); if (IPArray!=null) { for (var i=1;i<=4;i++) { if (IPArray[i]>255) { alert("Destination IP address is invalid!"); return false; } } return true; } var atomPat=new RegExp("^" + atom + "$"); var domArr=domain.split("."); var len=domArr.length; for (i=0;i= 4) { win.window.focus(); } } function days_between(date1, date2) { var ONE_DAY = 1000 * 60 * 60 * 24 var date1_ms = date1.getTime() var date2_ms = date2.getTime() var difference_ms = Math.abs(date1_ms - date2_ms) return Math.round(difference_ms/ONE_DAY) } function launchCheck(date1, date2) { var today = new Date(date1); var date = new Date(date2); if (today.getTime() > date.getTime()) { alert("After"); } else { alert("Before"); } } function NewWindow(mypage, myname, w, h, scroll) { var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable' win = window.open(mypage, myname, winprops) if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } } function popup(the_link, win_name, w, h, top, left, rez, src) { window.open (the_link,win_name,"width="+w+",height="+h+" ,top="+top+" ,left="+left+" ,resizable="+rez+" ,scrollbars="+src); } function trim(inputString) { var interimString=''; var lastCharSpace=true; var i; for(i=0;i= 4) { win.window.focus(); } } function days_between(date1, date2) { var ONE_DAY = 1000 * 60 * 60 * 24 var date1_ms = date1.getTime() var date2_ms = date2.getTime() var difference_ms = Math.abs(date1_ms - date2_ms) return Math.round(difference_ms/ONE_DAY) } function launchCheck(date1, date2) { var today = new Date(date1); var date = new Date(date2); if (today.getTime() > date.getTime()) { alert("After"); } else { alert("Before"); } } function NewWindow(mypage, myname, w, h, scroll) { var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable' win = window.open(mypage, myname, winprops) if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } } function popup(the_link, win_name, w, h, top, left, rez, src) { window.open (the_link,win_name,"width="+w+",height="+h+" ,top="+top+" ,left="+left+" ,resizable="+rez+" ,scrollbars="+src); } function trim(inputString) { var interimString=''; var lastCharSpace=true; var i; for(i=0;i= 4) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) ); } else if (this.isKonqueror) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) ); } else if (this.isSafari) { this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) ); } else if (this.isOmniweb) { this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) ); } else if (this.isOpera) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) ); } else if (this.isIcab) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) ); } this.versionMajor = parseInt(this.versionMinor); // dom support this.isDOM1 = (document.getElementById); this.isDOM2Event = (document.addEventListener && document.removeEventListener); // css compatibility mode this.mode = document.compatMode ? document.compatMode : 'BackCompat'; // platform this.isWin = (ua.indexOf('win') != -1); this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) ); this.isMac = (ua.indexOf('mac') != -1); this.isUnix = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1) this.isLinux = (ua.indexOf('linux') != -1); // specific browser shortcuts this.isNS4x = (this.isNS && this.versionMajor == 4); this.isNS40x = (this.isNS4x && this.versionMinor < 4.5); this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7); this.isNS4up = (this.isNS && this.versionMinor >= 4); this.isNS6x = (this.isNS && this.versionMajor == 6); this.isNS6up = (this.isNS && this.versionMajor >= 6); this.isNS7x = (this.isNS && this.versionMajor == 7); this.isNS7up = (this.isNS && this.versionMajor >= 7); this.isIE4x = (this.isIE && this.versionMajor == 4); this.isIE4up = (this.isIE && this.versionMajor >= 4); this.isIE5x = (this.isIE && this.versionMajor == 5); this.isIE55 = (this.isIE && this.versionMinor == 5.5); this.isIE5up = (this.isIE && this.versionMajor >= 5); this.isIE6x = (this.isIE && this.versionMajor == 6); this.isIE6up = (this.isIE && this.versionMajor >= 6); this.isIE4xMac = (this.isIE4x && this.isMac); } var browser = new BrowserDetect();