var maxNavHideElements = 20; var allForms = new Array(); var i = 0; allForms[i++] = "summary_date"; allForms[i++] = "summary_company"; allForms[i++] = "detailed_detailed"; allForms[i++] = "detailed_compliance"; allForms[i++] = "detailed_prospect"; function sweepMenusClosed() { for (x=0;x 0) { return true; } else { return false; } } /*========================================================\ | validateDateField | requires [Input Object] [String:Tabid] |---------------------------------------------------------: | true = [Input Object].value matches format and rules | false = See AlertFocus(field,message,tab) `========================================================*/ function validateDateField(field,tab) { if (fieldHasValue(field)) { if (RegExDate.test(field.value)) { var dateParts = field.value.split('/'); var theMonth = convertFloat(dateParts[0]); var theDay = convertFloat(dateParts[1]); var theYear = convertFloat(dateParts[2]); //-- clean parts and put back together var newDateString = theMonth + "/" + theDay + "/" + theYear; //-- This logic makes sure impossible dates like Feb. 31 do not slip through. //-- formatProperDate evaluates the date, so it would be a different value //-- if not a regular date if (formatProperDate(trim(field.value)) == formatProperDate(trim(newDateString)) ) { return true; } else { return AlertFocus(field,"Please enter a date in the format MM/DD/YYYY.",tab); } } else { return AlertFocus(field,"Please enter a date in the format MM/DD/YYYY.",tab); } } return true; } /*========================================================\ | validateDateString | requires [String:Date] |---------------------------------------------------------: | true = [String:Date] matches format and rules | false = returns false `========================================================*/ function validateDateString(DateString) { if (RegExDate.test(DateString)) { //--- take date appart var dateParts = trim(DateString).split('/'); var theMonth = parseFloat(dateParts[0]); var theDay = parseFloat(dateParts[1]); var theYear = parseFloat(dateParts[2]); //-- clean parts and put back together var newDateString = theMonth + "/" + theDay + "/" + theYear; //-- This logic makes sure impossible dates like Feb. 31 do not slip through. //-- formatProperDate evaluates the date, so it would be a different value //-- if not a regular date if (formatProperDate(trim(DateString)) == formatProperDate(trim(newDateString)) ) { return true; } else { return false; } } else { return false; } } /*========================================================\ | formatProperDate | requires [String] |---------------------------------------------------------: | returns [String] properly formatted mm/dd/yyyy | NOTE: does NOT validate, WILL return value `========================================================*/ function formatProperDate(dateString) { var tempDate = new Date(dateString); var theMonth = tempDate.getMonth() + 1; var theDay = tempDate.getDate(); var theYear = tempDate.getYear(); if (theYear < 1000) { theYear += 1900; } var newDateVal = theMonth + "/" + theDay + "/" + theYear; return newDateVal; } /*========================================================\ | dateCompare | requires [String:date1] [String:date2] |---------------------------------------------------------: | returns number of days after date2 - date1 | assumes dates are in correct format `========================================================*/ function dateCompare(olderDate, newerDate) { var tempolderDate = new Date(olderDate); var tempnewerDate = new Date(newerDate); var olderDateValue = tempolderDate.getTime(); var newerDateValue = tempnewerDate.getTime(); var DateDifference = newerDateValue - olderDateValue; var OneDay = 1000*60*60*24; return Math.ceil(DateDifference / OneDay); } /*========================================================\ | DateAdd | requires [String:date1] [Integer days, months, years] |---------------------------------------------------------: | returns date with additional timespan `========================================================*/ function DateAdd(theDate, addDays, addMonths, addYears) { var MonthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); var theDate = new Date(theDate); var currentDayOfMonth = theDate.getDate(); // get current day of month var OneDay = 1000*60*60*(24.05); theDate.setDate(1); // set day of month to 1 for month operation if (parseFloat(addMonths)>0) { for (i=0;i0) { theDate = new Date(theDate.getTime() + (parseFloat(addDays) * OneDay)); } if (parseFloat(addYears)>0) { theDate.setYear(theDate.getFullYear() + addYears); } return formatProperDate(theDate); } /*========================================================\ | DateAddCheckLeapYear | requires Array | helper function for DateAdd |---------------------------------------------------------: | returns array with adjustments for leap year `========================================================*/ function DateAddCheckLeapYear(theYear,MonthDays) { if ( theYear % 4 == 0 ) { if ( theYear % 100 == 0 && theYear % 400 == 0 ) MonthDays[1] = 29; if ( theYear % 100 != 0 ) MonthDays[1] = 29; } else { MonthDays[1] = 28; } return MonthDays; } /*========================================================\ | AlertFocus | requires [Input Object] [String:message] [String:Tabid] |---------------------------------------------------------: | 1.opens alert with [String:message] | 2.TRY switches to Tab Panel [String:Tabid] | 3.brings focus to [Input Object] | 4.returns false `========================================================*/ function AlertFocus(field,message,tab) { if (message != undefined) { window.alert(message); } if (tab != undefined) { TabPanel(tab); } try { field.focus(); } catch (e) { // do nothing return false; } return false; } //======================================================== // String.format gives you C# style string formatting //======================================================== String.format = function() { if (arguments.length==0) { throw("String.format requires arguments"); } var str = " " + arguments[0]; for(var i=1;i