/* =====================================================
Purpose: Define global variables for use in all functions
Designed: June 25, 2000
Developer: Kurt Saik
======================================================= */
var sLookfor = "NSF";
var host = location.hostname;
var gsPath = location.pathname.toUpperCase();
gsPath = gsPath.substring(0, gsPath.lastIndexOf(sLookfor));
gsPath = gsPath + sLookfor;
/* =====================================================
Purpose: To change the case value of a fields value
Designed: Jul 03, 2003
Developer: Kurt Saik
======================================================= */
function ChangeCase(sField,iType){
vField = eval("document.forms[0]."+ sField);
var sValue = vField.value;
var sCase = ""
if(iType=="1"){
// UpperCase
sCase = sValue.toUpperCase()
}else{
if(iType=="2"){
// LowerCase
sCase = sValue.toLowerCase()
}else{
// Retain same value
sCase = sValue
}
}
// Return update
vField.value = sCase
} // End of function
/* =====================================================
Purpose: To capture current delete request and overlay with a
confirmation alert to either continue or cancel delete request.
Designed: Jul 07, 2003
Developer: Kurt Saik
======================================================= */
function ConfirmationOfDelete(URL){
var form = document.forms[0];
//
// Define Message
sMsg = "You are about to delete this current record.\n\n"
sMsg = sMsg + "Click 'OK' to continue with delete, else\nclick 'Cancel' to return record."
//
// If user confirms OK, then continue with delete
if ( confirm(sMsg)){
document.location= URL
}
} // End of function
/* =====================================================
Purpose: To capture current delete request and overlay with a
confirmation alert to either continue or cancel delete request.
Designed: Jul 07, 2003
Developer: Linden Devine
======================================================= */
function PopConfirm(title, msg, URLE){
// 2011-08-11 pb, alert(URLE);
var blur = "onBlur='self.focus()'" + "onLoad='self.focus()'";
// var blur = "onLoad='self.focus()'";
var s1 = "
Please correct the error(s) above and re-save the form.";
var n1 = " Please consult the User Guide if you need assistance.";
var s1 = "Errors ............................................ " +
"" +
// "" +
""+
"";
var s2 = "ERROR! - cannot save " + table + " record. ";
var s3 = " | | | | "+
"| "+
" | ";
popuperr = window.open("","errDialog","height=500,width=500,top=0,left=0,scrollbars=yes");
popuperr.document.write(s1+s2+h1+msg+f1+s3);
popuperr.document.close();
}
function PopMsg(msg, title){
var DQUOTE = '\"';
var h1 = " ";
var s1 = "Message ............................................ " +
"" +
""+
"";
var s2 = "" + title + "! ";
var s3 = "
| | | | "+
"| "+
" | ";
popupmsg = window.open("","msgDialog","height=200,width=400,top=0,left=0,scrollbars=yes");
popupmsg.document.write(s1+s2+h1+msg+s3);
popupmsg.document.close();
}
function CloseErr(){
if(popuperr && popuperr.open && !popuperr.closed) popuperr .close();
}
function GoBack(){
if(popuperr && popuperr.open && !popuperr.closed) popuperr.close();
self.history.back();
}
function chk_submit(formobj) {
dataOK = dataOK + 1;
if (dataOK > 1)
{
alert("Warning Save button already clicked, please click on OK button below and wait for prior request to complete.");
return(false);
}
else
return(true);
}
function showhelp(newin) {
docurl = new String(window.location);
addr = docurl.toLowerCase();
winurl = docurl.slice(0, (addr.indexOf("nsf") + 3)) + "/CBTLookup/" + newin + "-000-000-000?opendocument";
helpwin=window.open(winurl,"helpwin","toolbar=no,resizable=yes,scrollbars=yes,width=1000,height=600,top=0,left=0");
}
function showtutor(newin) {
docurl = new String(window.location);
addr = docurl.toLowerCase();
//winurl = docurl.slice(0, (addr.lastIndexOf("nsf") + 3)) + "/CBTLookup/" + newin + "?opendocument";
winurl = docurl.slice(0, (addr.indexOf("nsf") + 3)) + "/HelpGuide/" + newin + "?opendocument";
self.location = winurl;
}
/* =====================================================
Purpose: Sort data columns of table (max 6 columns)
Designed: Mar 16, 2004
Developer: Linden Devinei
======================================================= */
function setDataType(cValue)
{
// THIS FUNCTION CONVERTS DATES AND NUMBERS FOR PROPER ARRAY
// SORTING WHEN IN THE SORT FUNCTION
var isDate = new Date(cValue);
if (isDate == "NaN")
{
if (isNaN(cValue))
{
// THE VALUE IS A STRING, MAKE ALL CHARACTERS IN
// STRING UPPER CASE TO ASSURE PROPER A-Z SORT
cValue = cValue.toUpperCase();
return cValue;
}
else
{
// VALUE IS A NUMBER, TO PREVENT STRING SORTING OF A NUMBER
// ADD AN ADDITIONAL DIGIT THAT IS THE + TO THE LENGTH OF
// THE NUMBER WHEN IT IS A STRING
var myNum;
myNum = String.fromCharCode(48 + cValue.length) + cValue;
// override this following code line due to fields not all being numeric in column
// return myNum;
cValue = cValue.toUpperCase();
return cValue;
// end of override code
}
}
else
{
// VALUE TO SORT IS A DATE, REMOVE ALL OF THE PUNCTUATION AND
// AND RETURN THE STRING NUMBER
//BUG - STRING AND NOT NUMERICAL SORT .....
// ( 1 - 10 - 11 - 2 - 3 - 4 - 41 - 5 etc.)
var myDate = new String();
myDate = isDate.getFullYear() + " " ;
myDate = myDate + isDate.getMonth() + " ";
myDate = myDate + isDate.getDate(); + " ";
myDate = myDate + isDate.getHours(); + " ";
myDate = myDate + isDate.getMinutes(); + " ";
myDate = myDate + isDate.getSeconds();
//myDate = String.fromCharCode(48 + myDate.length) + myDate;
return myDate ;
}
}
function sortTable(col, tableToSort)
{
var iCurCell = col + tableToSort.cols;
var totalRows = tableToSort.rows.length;
var bSort = 0;
var colArray = new Array();
var oldIndex = new Array();
var indexArray = new Array();
var bArray = new Array();
var newRow;
var newCell;
var i;
var c;
var j;
// ** POPULATE THE ARRAY colArray WITH CONTENTS OF THE COLUMN SELECTED
for (i=1; i < tableToSort.rows.length; i++)
{
colArray[i - 1] = setDataType(tableToSort.cells(iCurCell).innerText);
iCurCell = iCurCell + tableToSort.cols;
}
// ** COPY ARRAY FOR COMPARISON AFTER SORT
for (i=0; i < colArray.length; i++)
{
bArray[i] = colArray[i];
}
// ** SORT THE COLUMN ITEMS
//alert ( colArray );
colArray.sort();
//alert ( colArray );
for (i=0; i < colArray.length; i++)
{ // LOOP THROUGH THE NEW SORTED ARRAY
indexArray[i] = (i+1);
for(j=0; j < bArray.length; j++)
{ // LOOP THROUGH THE OLD ARRAY
if (colArray[i] == bArray[j])
{ // WHEN THE ITEM IN THE OLD AND NEW MATCH, PLACE THE
// CURRENT ROW NUMBER IN THE PROPER POSITION IN THE
// NEW ORDER ARRAY SO ROWS CAN BE MOVED ....
// MAKE SURE CURRENT ROW NUMBER IS NOT ALREADY IN THE
// NEW ORDER ARRAY
for (c=0; c 11)
{
yearsToAdd = Math.floor((month+1)/12);
month -= 12*yearsToAdd;
yearsToAdd += numYears;
}
returnDate.setMonth(month);
returnDate.setFullYear(returnDate.getFullYear() + yearsToAdd);
returnDate.setTime(returnDate.getTime()+60000*60*24*numDays);
return returnDate;
}
function YearAdd(startDate, numYears)
{
return DateAdd(startDate,0,0,numYears);
}
function MonthAdd(startDate, numMonths)
{
return DateAdd(startDate,0,numMonths,0);
}
function DayAdd(startDate, numDays)
{
return DateAdd(startDate,numDays,0,0);
}
// end of date math functions -----------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function LZ(x) {return(x<0||x>9?"":"0")+x}
// ------------------------------------------------------------------
function formatDate(date,format) {
// These functions use the same 'format' strings as the
// java.text.SimpleDateFormat class, with minor exceptions.
// The format string consists of the following abbreviations:
//
// Field | Full Form | Short Form
// -------------+--------------------+-----------------------
// Year | yyyy (4 digits) | yy (2 digits), y (2 or 4 digits)
// Month | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
// | NNN (abbr.) |
// Day of Month | dd (2 digits) | d (1 or 2 digits)
// Day of Week | EE (name) | E (abbr)
// Hour (1-12) | hh (2 digits) | h (1 or 2 digits)
// Hour (0-23) | HH (2 digits) | H (1 or 2 digits)
// Hour (0-11) | KK (2 digits) | K (1 or 2 digits)
// Hour (1-24) | kk (2 digits) | k (1 or 2 digits)
// Minute | mm (2 digits) | m (1 or 2 digits)
// Second | ss (2 digits) | s (1 or 2 digits)
// AM/PM | a |
//
// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
// Examples:
// "MMM d, y" matches: January 01, 2000
// Dec 1, 1900
// Nov 20, 00
// "M/d/yy" matches: 01/20/00
// 9/2/00
// "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
// ------------------------------------------------------------------
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
format=format+"";
var result="";
var i_format=0;
var c="";
var token="";
var y=date.getYear()+"";
var M=date.getMonth()+1;
var d=date.getDate();
var E=date.getDay();
var H=date.getHours();
var m=date.getMinutes();
var s=date.getSeconds();
var yyyy,yy,MMM,MM,NNN,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
// Convert real date parts into formatted versions
var value=new Object();
if (y.length < 4) {y=""+(y-0+1900);}
value["y"]=""+y;
value["yyyy"]=y;
value["yy"]=y.substring(2,4);
value["M"]=M;
value["MM"]=LZ(M);
value["MMM"]=MONTH_NAMES[M-1];
value["NNN"]=MONTH_NAMES[M+11];
value["d"]=d;
value["dd"]=LZ(d);
value["E"]=DAY_NAMES[E+7];
value["EE"]=DAY_NAMES[E];
value["H"]=H;
value["HH"]=LZ(H);
if (H==0){value["h"]=12;}
else if (H>12){value["h"]=H-12;}
else {value["h"]=H;}
value["hh"]=LZ(value["h"]);
if (H>11){value["K"]=H-12;} else {value["K"]=H;}
value["k"]=H+1;
value["KK"]=LZ(value["K"]);
value["kk"]=LZ(value["k"]);
if (H > 11) { value["a"]="PM"; }
else { value["a"]="AM"; }
value["m"]=m;
value["mm"]=LZ(m);
value["s"]=s;
value["ss"]=LZ(s);
while (i_format < format.length) {
c=format.charAt(i_format);
token="";
while ((format.charAt(i_format)==c) && (i_format < format.length)) {
token += format.charAt(i_format++);
}
if (value[token] != null) { result=result + value[token]; }
else { result=result + token; }
}
return result;
}
// end of date format functions ------------------------------------------------------------------
/* =====================================================
Purpose: To display a list of all fields and controls on a form.
Designed: Jun 17, 2004
Developer: Linden Devine
======================================================= */
function showFields(){
var form = document.forms[0];
var s2 = '';
var s3 = '';
var s4 = '';
var len = form.length;
// var blur = "onBlur='self.focus()'" + "onLoad='self.focus()'";
var blur = "onLoad='self.focus()'";
// create page header info
var s1 = "Debug Form Fields and Values" +
"" +
""
// create table header info
s2 = s2 + "| FORM NAME | " + form.name + " | " +
"| Object Name | Type | Value | "
// loop through all objects on a form
for(i=0; i" + form[i].name + " | " + form[i].type + " | " + form[i].value + " | "
}
// create debugging view links
s3 = s3 + '| *** Live Debugging Support *** | '
// create page footer info
var s4 = " "
popup = window.open("","popFormFields","height=800,width=1000,top=0,left=0,scrollbars=yes, resizable=yes")
popup.document.write(s1+s3+s2+s4)
popup.document.close();
} // End of function
|
|