// Define global Variables newWindow = ''; popupCalendar = ''; if (!opener) { userInfo = Get_Cookie('userinfo'); if (userInfo) { userInfo = userInfo.split('&'); userName = userInfo[0]; userType = userInfo[1]; } } var today = new Date(); var day = today.getDate(); var month = today.getMonth(); var year = y2k(today.getYear()); var monthNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December'); var monthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); var dow = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); useMonth = month; useYear = year; var serverParts = location.href.split('/'); //alert(serverParts); var thisServer = serverParts[0] + '\/\/' + serverParts[2] + '/'; if (serverParts[3]=='vapahcs') { thisServer = thisServer + 'vapahcs/'; } //thisServer = thisServer; document.write('\n'); // Browser/OS Detect var detect = navigator.userAgent.toLowerCase(); var mac = (detect.indexOf("mac") !=-1); var xplore = (detect.indexOf("msie") !=-1); var num = navigator.appVersion.charAt(0); // Check for DHTML support //if (document.all || document.layers) // document.dhtml = true; //else // location.href = "index_3.html"; // Use Correct Stylesheet based on OS/Browser if (xplore && (!mac)) stylesheet = "stylesheet_ie.css"; else if (mac) stylesheet = "stylesheet_mac.css"; else stylesheet = "stylesheet_nn.css"; // Only one style sheet, so hard-code file name here stylesheet = "stylesheet_all.css"; // Write Style Sheet and other JavaScript references document.write(''); //document.write(''); document.write(''); document.write(''); document.write(''); // Check for popup window if (document.all || document.layers || document.dhtml) { if (document.layers) document.captureEvents(Event.MOUSEUP) document.onmouseup = checkPopup; } else { event = null; } // Set IE and Netscape specific DHTML variables if (document.layers) doc = 'document.layers[', vis = '].visibility', top = '].top', left = '].left', height = '].document.height', trueTop = '].pageY'; if (document.all) var doc = 'document.all[', vis = '].style.visibility', top = '].style.posTop', left = '].style.posLeft', height = '].offsetHeight', trueTop = '].offsetTop'; if (document.getElementById) var doc = 'document.getElementById(', vis = ').style.visibility', top = ').style.top', left = ').style.left', height = ').offsetHeight'; /* if (document.layers) doc = 'document.layers.', vis = '.visibility', top = '.top', height = '.document.height', trueTop = '.pageY'; if (document.all) var doc = 'document.all.', vis = '.style.visibility', top = '.style.posTop', height = '.offsetHeight', trueTop = '.offsetTop'; if (document.getElementById) var doc = 'document.getElementById(', vis = ').style.visibility', top = ').style.top', left = ').style.left', height = ').offsetHeight'; */ // FUNCTIONS // // Common graphic mouse-over routines function imageOver(imageItem,subdir) { fileformat = ".gif"; document[imageItem].src = thisServer + subdir + imageItem + '_2' + fileformat; document.swapImage = imageItem; saveSubdir = subdir; } function imageOut() { if(document.swapImage) { fileformat = ".gif"; imageItem = document.swapImage; document[imageItem].src = thisServer + saveSubdir + imageItem + fileformat; } } // Open Popup Window, where URL is file to open, x is width and y is height function openWindow(url,x,y) { if (url.indexOf("http://")==-1 && url.indexOf("https://")==-1) url = thisServer + url; var rnd = Math.random()*1000000 + '=1'; if (String(url).indexOf('?') != -1) url+='&' + rnd; else url+='?' + rnd; //alert("Opening " + url); newWindow=open(url,'newWindow','menubar=no,scrollbars=yes,status=yes,resizable=yes,location=no,width=' + x + ',height=' + y); if (newWindow.opener == null) newWindow.opener = self; newWindow.focus(); } function openMenuWindow(url,x,y) { if (url.indexOf("http://")==-1 && url.indexOf("https://")==-1) url = thisServer + url; var rnd = Math.random()*1000000 + '=1'; if (String(url).indexOf('?') != -1) url+='&' + rnd; else url+='?' + rnd; newWindow=open(url,'newWindow','toolbar=yes,menubar=yes,scrollbars=yes,status=yes,resizable=yes,location=no,width=' + x + ',height=' + y); if (newWindow.opener == null) newWindow.opener = self; newWindow.focus(); } // Open Popup Window, special Funding Source listing, where URL is file to open, x is width and y is height, field is field to fill in, fieldnum is number in list function selectWindow(url,x,y,field,fieldnum,formname) { if (url.indexOf("http://")==-1 && url.indexOf("https://")==-1) url = thisServer + url + '?' + field + '&' + fieldnum + '&' + formname; var rnd = Math.random()*1000000 + '=1'; if (String(url).indexOf('?') != -1) url+='&' + rnd; else url+='?' + rnd; newWindow=open(url,'newWindow','menubar=no,scrollbars=yes,status=yes,resizable=no,location=no,width=' + x + ',height=' + y); newWindow.focus(); } // Open Information Popup Window function openInfoWindow(infoNum) { url = thisServer + 'templates/popup_info.html?' + infoNum; // alert ("URL: "+url); newWindow=open(url,'newWindow','menubar=no,scrollbars=yes,status=yes,resizable=no,location=no,width=450,height=250'); if (newWindow.opener == null) newWindow.opener = self; newWindow.focus(); } // Checks to see if a popup window is open, forces focus on popup function checkPopup() { if (newWindow && !newWindow.closed) { alert('Please close popup window before continuing'); newWindow.focus(); } if (popupCalendar && !popupCalendar.closed) { alert('Please close calendar window before continuing'); popupCalendar.focus(); } } // Returns current date function printDate() { var time = new Date(); timezoneoffset = time.getTimezoneOffset(); if ((navigator.appVersion.indexOf('MSIE 3') != -1)) timezoneoffset = timezoneoffset * (-1); time.setTime(time.getTime() + timezoneoffset*60*1000); time.setTime(time.getTime() + -8*60*60*1000); time.setHours(time.getHours() + 1); var monthNum = time.getMonth(); var hours = time.getHours(), minutes = padout(time.getMinutes()); var year = time.getYear(), month = monthNames[monthNum], day = time.getDate(), dowName = dow[time.getDay()]; // Long Date //document.write(dowName + ', ' + month + ' ' + day + ', ' + year + ', ' + hours + ':' + minutes); formattedDate = padout(monthNum+1) + '/' + padout(day) + '/' + year; return formattedDate; } // Redirects to URL function changeURL(thisURL) { confirmation = confirm('The page you are about to go to is not part of the VA Palo Alto Health Care System,\nand is thus not responsible for its contents.\n\nContinue?'); if (confirmation) location.href = thisServer + thisURL; } // Unhides a layer specified by thisLayer. IE only. function showSingleLayer(thisLayer) { if (document.dhtml) { // Show Popup Layer if (document.layers) {//document.layers[thisLayer].visibility = 'visible'; } else if (document.all) document.all[thisLayer].style.visibility = 'visible'; } } // Hides a layer specified by thisLayer. IE only. function hideSingleLayer(thisLayer) { if (document.dhtml) { // Hide Popup Layer if (document.layers) {//document.layers[thisLayer].visibility = 'hidden'; } else if (document.all) document.all[thisLayer].style.visibility = 'hidden'; } } function padout(number) { return (number < 10) ? '0' + number : number; } function padout100(number) { return (number < 10) ? '00' + number : (number < 100) ? '0' + number : number; } // Pop-up Calendar Functions function y2k(number) { return (number < 1000) ? number + 1900 : number; } function newCalendar(thisField,thisForm) { useThisField = thisField; useThisForm = thisForm; calendarURL = thisServer + 'calendar.html'; //alert(calendarURL); popupCalendar=open(calendarURL,'popupCalendar','status=no,resizable=no,width=235,height=250'); popupCalendar.focus(); // popupCalendar.location.href = calendarURL; // popupCalendar.location.reload(); if (popupCalendar.opener == null) popupCalendar.opener = self; } // Cookie Functions function Get_Cookie(vName) { if (document.cookie.length > 0) { var start = document.cookie.indexOf(vName+"="); var len = start+vName.length+1; if ((!start) && (vName != document.cookie.substring(0,vName.length))) return null; if (start == -1) return null; var end = document.cookie.indexOf(";",len); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(len,end)); } return null; } function Set_Cookie(vName,vValue,expires,path,domain,secure) { document.cookie = vName + "=" +escape(vValue) + ( (expires) ? ";expires=" + expires.toGMTString() : "") + ( (path) ? ";path=" + path : "") + ( (domain) ? ";domain=" + domain : "") + ( (secure) ? ";secure" : ""); } function Delete_Cookie(vName,path,domain) { if (Get_Cookie(vName)) document.cookie = vName + "=" + ( (path) ? ";path=" + path : "") + ( (domain) ? ";domain=" + domain : "") + ";expires=Thu, 01-Jan-70 00:00:01 GMT"; } function addYears(form,formField1,formField2,amount) { dateString = eval('document.' + form + '.' + formField1 + '.value'); year = dateString.substring(6,10); month = dateString.substring(0,2); day = dateString.substring(3,5); nextYear = new Date(((year - 0)+(amount-0)),month-1,day); var d = nextYear.getDate(); var day = (d < 10) ? '0' + d : d; var m = nextYear.getMonth() + 1; var month = (m < 10) ? '0' + m : m; var yy = nextYear.getYear(); var year = (yy < 1000) ? yy + 1900 : yy; expireDate = month + '/' + day + '/' + year; if (dateString) eval('document.' + form + '.' + formField2 + '.value = expireDate'); } function addMonths(form,formField1,formField2,amount) { dateString = eval('document.' + form + '.' + formField1 + '.value'); year = dateString.substring(6,10); month = dateString.substring(0,2); day = dateString.substring(3,5); newMonth = ((month - 1)+(amount-0)) nextMonth = new Date(year,newMonth,day); var d = nextMonth.getDate(); var day = (d < 10) ? '0' + d : d; var m = nextMonth.getMonth() + 1; var month = (m < 10) ? '0' + m : m; var yy = nextMonth.getYear(); var year = (yy < 1000) ? yy + 1900 : yy; expireDate = month + '/' + day + '/' + year; if (dateString) eval('document.' + form + '.' + formField2 + '.value = expireDate'); } // Sets price strings to .00 format function setDecimals(cost) { cost = (Math.round(cost*100))/100; return (cost == Math.floor(cost)) ? cost + '.00' : ( (cost*10 == Math.floor(cost*10)) ? cost + '0' : cost); } // Check valid field formats. Works with FormChek.js function checkField(thisField,formName,labelString) { valueGood = 1; fieldObject = eval('document.' + formName + '[thisField]'); if (thisField.indexOf('PHONE') > -1 || thisField.indexOf('FAX') > -1) { digits = eval('document.' + formName + '["' + thisField + '"].value'); if (digits.length == 5) { // Using 5 digit extension, check for just numbers valueGood = isInteger(digits, fieldObject); } else { valueGood = checkUSPhone(fieldObject); } } if (thisField.indexOf('EMAIL') > -1) { valueGood = checkEmail(fieldObject); } if (thisField.indexOf('SSN') > -1) { valueGood = checkSSN(fieldObject); } if (thisField.indexOf('SOC_SEC_NUMBER') > -1) { valueGood = checkSSN(fieldObject); } if (thisField.indexOf('ZIP') > -1) { valueGood = checkZIPCode(fieldObject); } // checks for valid date and format mm/dd/yyyy if (thisField.indexOf('DATE') > -1) { date = eval('document.' + formName + '.' + thisField + '.value'); if (date.length == 10) { year = date.substring(6,10); month = date.substring(0,2); day = date.substring(3,5); valueGood = isValidDate(year,month,day,labelString); } else { alert('Dates must be in MM/DD/YYYY format (ie, 03/12/2006). Please re-enter or use calendar pop-up.'); return false; } } return valueGood; } function isValidDate (yearField, monthField, dayField, labelString) { valueGood = 1; alertString = "The date for " + labelString + " is not valid. Please re-enter or use calendar pop-up."; // Next line is needed on NN3 to avoid "undefined is not a number" error // in equality comparison below. if (!isYear(yearField) || !isMonth(monthField) || !isDay(dayField)) { valueGood = 0; } if (!isDate(yearField, monthField, dayField)) { valueGood = 0; } if ((+yearField) < 1900) { valueGood = 0; } if (valueGood) { return true; } else { alert (alertString); return false; } } //Shows difference of days between date1 and date2 function compareDays(date1,date2) { year1 = date1.substring(6,10); month1 = date1.substring(0,2); day1 = date1.substring(3,5); year2 = date2.substring(6,10); month2 = date2.substring(0,2); day2 = date2.substring(3,5); date1 = new Date(year1,(month1-1),day1); date2 = new Date(year2,(month2-1),day2); var difference = Date.UTC(y2k(date1.getYear()),date1.getMonth(),date1.getDate(),0,0,0) - Date.UTC(y2k(date2.getYear()),date2.getMonth(),date2.getDate(),0,0,0); return difference/1000/60/60/24; } // checks for valid date and format mm/dd/yyyy // Added by Naresh function setUpSelect(fld,vl){ if ((eval("document."+fld))&&(vl != "")) { var ln = eval("document."+fld+".options.length"); for(var i=0;i