<!--
//REMEMBER://
/*
  Javascript uses 'var' instead of 'dim' to declare variables.
  Javascript like ASP declares all variables as VARIANT (No Type) except in constructors
  Javascript calls to the functions must be in lowercase!
  Javascript has to assign therefore instead of just saying 'trim(mystring)' it should be 'yourstring = trim(mystring)'
  Javascript requires lines to end with a semicolon (;) EXCEPT if the line ends with {, ), or is a variable declaration.
  Javascript uses "\" as an escape character, "=" to ASSIGN values ONLY, "==" to CHECK EQUALITY ONLY.
  Javascript returns certain values as an array 0 for January or start of string where VB returns a 1. In ALL these cases, the Javascript result is used to maintain integrity throughout the function calls.
  Javascript comparative functions (if, for, while, etc.) have ALL their evaluations in parentheses [i.e. if (x = 1) {, while (x > 1) {, etc.]
  Javascript can evaluate a string number as a number or a number string as a string, no messy conversions needed. Just do a 'isnumeric' check OR use 'cstr' to make it a bonafide string.
  Javascript is NOT server side and therefore only dynamic functions can be included in this wrapper.
*/

//Supported Commands://
/*
  Abs(num)
  Asc(str)
  CBool(str)
  CDbl(str)
  CDec(str)
  Chr(num)
  CInt(str)
  CLng(str)
  CSng(str)
- CStr(num)
  Date()
  Day(date)
  Exp(num)
  Fix(num)
  Hex(num)
  Hour(str)
  InputBox(str, strDEFAULT)
  InStr(strWHOLE, strPART)
  InStrRev(strWHOLE, strPART)
- Int(num)
  IsArray(array)
  IsDate(str)
  IsNull(str)
  IsNumeric(str OR num)
  LBound(array)
  LCase(str)
  Left(str, num)
  Len(str)
  LTrim(str)
- Mid(str, numSTART, numEND)
  Minute(str)
  Month(date)
  MonthName(date)
  MsgBox(str, 0 OR 1 ONLY)
  Now()
  Oct(num)
  Replace(str, strOLD, strNEW)
  Right(str, num)
  Round(num, numDECIMALPLACES)
- RTrim(str)
  Second(str)
  Space(num)
  Split(str)
  Sqr(num)
  StrReverse(str)
  Time()
  Trim(str)
  UBound(array)
  UCase(str)
- Weekday(date)
  WeekdayName(date)
  Year(date)
*/

//Begin VB Function Wrapper for JavaScript//
var tempString
var currentDate
function abs(numberData) {
  if (isNaN(numberData)) {
    alert("Number required for 'Abs' function.");
  } else {
    return Math.abs(numberData);
  }
}
function asc(stringData) {
  tempString = stringData.substring(0, 1).toString();
  return tempString.charCodeAt(0);
}
function cbool(stringData) {
  //Javascript uses '==' for determining a test for equality.//
  if (stringData.indexOf("==") > -1) {
    return eval(stringData);
  } else {
    alert("There must be an expression to evaluate for 'CBool' function (ex. A == B).");
  }
}
function cdbl(stringData) {
  if (isNaN(stringData)) {
    alert("Cannot convert '" + stringData + "'to a DOUBLE.");
  } else {
    return parseFloat(stringData);
  }
}
function cdec(stringData) {
  if (isNaN(stringData)) {
    alert("Cannot convert '" + stringData + "'to a DECIMAL.");
  } else {
    return parseFloat(stringData);
  }
}
function chr(numberData) {
  if (isNaN(numberData)) {
    if (numberData.indexOf(",") > -1) {
      return String.fromCharCode(eval(numberData));
    } else {
      alert("Number between 0 - 65535 required for 'Chr' function.");
    }
  } else if (numberData > 65535 || numberData < 0) {
    alert("Number between 0 - 65535 required for 'Chr' function.");
  } else {
    return String.fromCharCode(numberData);
  }
}
function cint(stringData) {
  if (isNaN(stringData)) {
    alert("Cannot convert '" + stringData + "' to an INTEGER.");
  } else {
    return parseInt(Math.round(stringData));
  }
}
function clng(stringData) {
  if (isNaN(stringData)) {
    alert("Cannot convert '" + stringData + "'to a LONG INTEGER.");
  } else {
    return parseInt(Math.round(stringData));
  }
}
function csng(stringData) {
  if (isNaN(stringData)) {
    alert("Cannot convert '" + stringData + "'to a SINGLE.");
  } else {
    return parseFloat(stringData);
  }
}
function cstr(stringData) {
  if (isNaN(stringData)) {
    return stringData;
  } else {
    tempString = stringData.toString();
    return tempString;
  }
}
function date() {
  currentdate = new Date();
  tempString = (currentdate.getMonth() + 1) + "/" + currentdate.getDate() + "/" + currentdate.getFullYear();
  return tempString;
}
function day(stringData) {
  tempString = stringData;
  if (isNaN(Date.parse(tempString))) {
    alert("Valid date required for the 'Day' function.")
  } else {
    currentdate = new Date(tempString);
    return currentdate.getDate();
  }
}
function exp(numberData) {
  if (isNaN(numberData)) {
    alert("Number required for 'Exp' function.");
  } else {
    return Math.exp(numberData);
  }
}
function fix(numberData) {
  if (isNaN(numberData)) {
    alert("Number required for 'Fix' function.");
  } else {
    tempString = numberData.toString();
    if (tempString.indexOf(".", 0) > -1) {
      return parseInt(tempString.substring(0, (tempString.indexOf(".", 0))));
    } else {
      return parseInt(tempString);
    }
  }
}
function hex(numberData) {
  //THIS FUNCTION MUST INCLUDE WITH THE 'hexletter' FUNCTION!!//
  var hexString = ""
  var holdString = ""
  if (isNaN(numberData)) {
    alert("Number required for 'Hex' function.");
  } else {
    tempString = Math.round(numberData);
    while (tempString > 15) {
      holdString = hexString;
      hexString = (hexletter(eval(tempString % 16))).toString() + holdString.toString();
      tempString = parseInt(tempString / 16);
    }
    holdString = hexString;
    hexString = (hexletter(tempString)).toString() + holdString.toString();
    return hexString;
  }
}
function hexletter(numberDataH) {
  //THIS FUNCTION MUST BE INCLUDED WITH THE 'hex' FUNCTION!!//
  switch (numberDataH) {
    case 10:
      return "A";
      break;
    case 11:
      return "B";
      break;
    case 12:
      return "C";
      break;
    case 13:
      return "D";
      break;
    case 14:
      return "E";
      break;
    case 15:
      return "F";
      break;
    default:
      return numberDataH;
      break;
  }
}
function hour(stringData) {
  if (timecheck(stringData) == true) {
    tempString = stringData.split(":");
    if (parseInt(tempString[0]) > 12) {
      return parseInt(tempString[0]);
    } else if (tempString[2].indexOf("P") > -1 || tempString[2].indexOf("p") > -1) {
      return (parseInt(tempString[0]) + 12);
    } else {
      return parseInt(tempString[0]);
    }
  } else {
    alert("Valid Time required for the 'Hour', 'Minute', or 'Second' functions.");
  }
}
function inputbox(stringData, defaultString) {
  //Due to the limited nature of Javascript, this function can only support the REQUIRED PROMPT and OPTIONAL DEFAULT strings.//
  if (stringData == null) {
    alert("A Prompt String is required for the 'InputBox' function.");
  } else {
    if (defaultString == null) {
      tempString = "";
    } else {
      tempString = defaultString;
    }
    return prompt(stringData, tempString);
  }
}
function instr(charStart, stringData, Searched) {
  //All comparisons are Text based.//
  var splitString, startChar
  tempString = stringData;
  splitString = Searched;
  if (isNaN(charStart)) {
    startChar = 0;
    if ((!(charStart == null)) && (!(stringData == null))) {
      tempString = charStart;
      splitString = stringData;
    }
  } else if (charStart < 0) {
    startChar = 0;
  } else if (charStart > tempString.length - 1) {
    startChar = tempString.length;
  } else {
    startChar = charStart;
  }
  if (startChar > 0 && startChar <= tempString.length) { startChar--; }
  /*
    VB/ASP returns a number starting with 1, 0 if not found.
    Javascript returns a number starting with 0, -1 if not found.
  */
  return tempString.indexOf(splitString, startChar);
}
function instrrev(stringData, Searched, charStart) {
  //All comparisons are Text based.//
  tempString = stringData;
  var startChar
  if (isNaN(charStart)) {
    startChar = 0;
  } else if (charStart < 0) {
    startChar = 0;
  } else if (charStart > tempString.length) {
    startChar = tempString.length;
  } else {
    startChar = charStart;
  }
  if (startChar > 0 && startChar <= tempString.length) { startChar--; }
  /*
    VB/ASP returns a number starting with 1, 0 if not found.
    Javascript returns a number starting with 0, -1 if not found.
  */
  return tempString.lastIndexOf(Searched, startChar);
}
function Int(numberData) {
  if (isNaN(numberData)) {
    alert("Number required for 'Int' function.");
  } else {
    if (numberData < 0) { numberData--; }
    tempString = numberData.toString();
    if (tempString.indexOf(".", 0) > -1) {
      return parseInt(tempString.substring(0, (tempString.indexOf(".", 0))));
    } else {
      return parseInt(tempString);
    }
  }
}
function isarray(xdata) {
  if (typeof xdata == "object" && xdata.constructor == Array) {
    return true;
  } else {
    return false;
  }
}
function isdate(stringData) {
  tempString = stringData;
  if (isNaN(Date.parse(tempString))) {
    return false;
  } else {
    var splitString, splitStringSub, intDateMonth, intDateDate, lngDateYear
    //first round of splits...//
    if (tempString.indexOf("/") > -1) {
      splitString = tempString.split("/");
    } else if (tempString.indexOf("-") > -1) {
      splitString = tempString.split("-");
    }
    //check for valid 3-splits, or perform second round of splits...//
    if (splitString.length >= 3) {
      intDateMonth = parseInt(splitString[0]);
      intDateDate = parseInt(splitString[1]);
      lngDateYear = splitString[2];
    } else if (splitString.length >= 2) {
      if (splitString[0].indexOf("/") > -1 || splitString[0].indexOf("-") > -1) {
        lngDateYear = splitString[1];
        if (splitString[0].indexOf("/") > -1) {
          splitStringSub = splitString[0].split("/");
          intDateMonth = parseInt(splitStringSub[0]);
          intDateDate = parseInt(splitStringSub[1]);
        }
        if (splitString[0].indexOf("-") > -1) {
          splitStringSub = splitString[0].split("-");
          intDateMonth = parseInt(splitStringSub[0]);
          intDateDate = parseInt(splitStringSub[1]);
        }
      } else if (splitString[1].indexOf("/") > -1 || splitString[1].indexOf("-") > -1) {
        intDateMonth = parseInt(splitString[0]);
        if (splitString[1].indexOf("/") > -1) {
          splitStringSub = splitString[1].split("/");
          intDateDate = parseInt(splitStringSub[0]);
          lngDateYear = splitStringSub[1];
        }
        if (splitString[1].indexOf("-") > -1) {
          splitStringSub = splitString[1].split("-");
          intDateDate = parseInt(splitStringSub[0]);
          lngDateYear = splitStringSub[1];
        }
      } else {
        return false;
      }
    }
    //finally, check date validity!!//
    if ((intDateMonth > 0 && intDateMonth < 13) && (intDateDate > 0 && intDateDate < 32)) {
      if ((intDateMonth == 1 || intDateMonth == 3 || intDateMonth == 5 || intDateMonth == 7 || intDateMonth == 8 || intDateMonth == 10 || intDateMonth == 12) && intDateDate <= 31) {
        return true;
      } else if ((intDateMonth == 4 || intDateMonth == 6 || intDateMonth == 9 || intDateMonth == 11) && intDateDate <= 30) {
        return true;
      } else if (intDateMonth == 2 && intDateDate <= 29 && ((lngDateYear % 4) == 0)) {
        return true;
      } else if (intDateDate <= 28) {
        return true;
      } else {
        return false;
      }
    } else {
      return false;
    }
    return(intDateMonth + "\\" + intDateDate + "\\" + lngDateYear);
  }
}
function isnull(stringData) {
  tempString = stringData;
  if (tempString == null) {
    return true;
  } else {
    return false;
  }
}
function isnumeric(stringData) {
  tempString = stringData;
  tempString = (!(isNaN(tempString)));
  return tempString;
}
function lbound(xdata) {
  //Javascript Arrays All start with and contain element 0.//
  if (typeof xdata == "object" && xdata.constructor == Array) {
    return 0;
  } else {
    alert("Valid Array required for 'LBound' function.");
  }
}
function lcase(stringData) {
  tempString = stringData;
  tempString = tempString.toLowerCase();
  return tempString;
}
function left(stringData, charLen) {
  if (isNaN(charLen)) {
    alert("Number of characters required for 'Right' function.");
  } else {
    if (charLen > stringData.length) {
      return stringData;
    } else if (charLen < 1) {
      return "";
    } else {
      return stringData.substring(0, charLen);
    }
  }
}
function len(stringData) {
  tempString = stringData;
  tempString = tempString.length;
  return tempString;
}
function ltrim(stringData) {
  tempString = stringData;
  while (tempString.indexOf(" ") == 0 && tempString.length > 0) {
    tempString = tempString.substr(1);
  }
  return tempString;
}
function mid(stringData, charStart, charEnd) {
  tempString = stringData;
  var startChar, endChar
  if (isNaN(charStart)) {
    startChar = 0;
  } else if (charStart < 0) {
    startChar = 0;
  } else if (charStart > tempString.length) {
    startChar = tempString.length;
  } else {
    startChar = charStart;
  }
  if (startChar > 0 && startChar <= tempString.length) { startChar--; }
  if (isNaN(charEnd)) {
    endChar = tempString.length - 1;
  } else if (charEnd < 0 || charEnd > tempString.length) {
    endChar = tempString.length - 1;
  } else {
    endChar = charEnd;
  }
  /*
    VB/ASP returns a number starting with 1, 0 if not found.
    Javascript returns a number starting with 0, -1 if not found.
  */
  tempString = tempString.substr(startChar, endChar);
  return tempString;
}
function minute(stringData) {
  if (timecheck(stringData) == true) {
    tempString = stringData.split(":");
    return tempString[1];
  } else {
    alert("Valid Time required for the 'Hour', 'Minute', or 'Second' functions.");
  }
}
function month(stringData) {
  tempString = stringData;
  if (isNaN(Date.parse(tempString))) {
    alert("Valid date required for 'Month' function.")
  } else {
    currentdate = new Date(tempString);
    /*
      VB/ASP returns a number between 1 - 12.
      Javascript returns a number between 0 - 11.
      January is FIRST in both.
    */
    return currentdate.getMonth();
  }
}
function monthname(stringData) {
  tempString = stringData;
  if (isNaN(Date.parse(tempString))) {
    alert("Valid date required for 'MonthName' function.")
  } else {
    currentdate = new Date(tempString);
    /*
      VB/ASP returns a number between 1 - 12.
      Javascript returns a number between 0 - 11.
      January is FIRST in both.
    */
    switch (currentdate.getMonth()) {
      case 0:
        return "January";
        break;
      case 1:
        return "February";
        break;
      case 2:
        return "March";
        break;
      case 3:
        return "April";
        break;
      case 4:
        return "May";
        break;
      case 5:
        return "June";
        break;
      case 6:
        return "July";
        break;
      case 7:
        return "August";
        break;
      case 8:
        return "September";
        break;
      case 9:
        return "October";
        break;
      case 10:
        return "November";
        break;
      case 11:
        return "December";
        break;
    }
  }
}
function msgbox(stringData, alertType) {
  //Due to the limited nature of Javascript, this function can only support OK or OK/CANCEL (0 Or 1) as button choices.//
  tempString = stringData;
  if (!(isNaN(alertType))) {
    if (alertType == 1) {
      if (confirm(stringData)) {
        return 1;
      } else {
        return 2;
      }
    } else {
      alert(stringData);
      return 1;
    }
  } else {
    alert(stringData);
    return 1;
  }
}
function now() {
  currentdate = new Date();
  var ToD
  tempString = (currentdate.getMonth() + 1) + "/" + currentdate.getDate() + "/" + currentdate.getFullYear() + " ";
  if (currentdate.getHours() > 12) {
    tempString = tempString + (currentdate.getHours() - 12) + ":"
    ToD = " PM";
  } else if (currentdate.getHours() == 0) {
    tempString = tempString + "12:";
    ToD = " AM";
  } else {
    tempString = tempString + currentdate.getHours() + ":"
    ToD = " AM";
  }
  if (currentdate.getMinutes() < 10) { tempString = tempString + "0"; }
  tempString = tempString + currentdate.getMinutes() + ":";
  if (currentdate.getSeconds() < 10) { tempString = tempString + "0"; }
  tempString = tempString + currentdate.getSeconds() + ToD;
  return tempString;
}
function oct(numberData) {
  var octString = ""
  var holdString = ""
  if (isNaN(numberData)) {
    alert("Number required for 'Oct' function.");
  } else {
    tempString = Math.round(numberData);
    while (tempString > 7) {
      holdString = octString;
      octString = (eval(tempString % 8)).toString() + holdString.toString();
      tempString = parseInt(tempString / 8);
    }
    holdString = octString;
    octString = tempString.toString() + holdString.toString();
    return octString;
  }
}
function replace(stringData, Replaced, Replacement) {
  //This function currently only support the REQUIRED expression, find, and replace strings.//
  if (Replaced == null || Replacement == null) {
    alert("A Search String and Replacement String are BOTH required.");
    return stringData;
  } else {
    tempString = stringData;
    var pattern = new RegExp(Replaced, "ig");
    tempString = stringData.replace(pattern, Replacement);
    return tempString;
  }
}
function right(stringData, charLen) {
  if (isNaN(charLen)) {
    alert("Number of characters required for 'Right' function.");
  } else {
    if (charLen > stringData.length) {
      return stringData;
    } else if (charLen < 1) {
      return "";
    } else {
      return stringData.substring(stringData.length - charLen, stringData.length);
    }
  }
}
function round(numberData, decimalPlaces) {
  var placesAfterDecimal, numberAfterDecimalPlaces, addString
  if (isNaN(numberData)) {
    alert("Number required for 'Round' function.");
  } else {
    tempString = numberData.toString();
    if (decimalPlaces > 0) {
      if (tempString.indexOf(".", 0) > -1) {
        tempString = numberData;
        placesAfterDecimal = tempString.length - tempString.indexOf(".", 0) - 1;
        if (placesAfterDecimal > decimalPlaces) {
          numberAfterDecimalPlaces = tempString.substr((tempString.indexOf(".", 0) + decimalPlaces + 1), 1);
          tempString = tempString.substring(0, tempString.length - (placesAfterDecimal - decimalPlaces));
          if (parseInt(numberAfterDecimalPlaces) > 4) {
            addString = "0.";
            for (var repeatchar = 1; repeatchar < decimalPlaces; repeatchar++) {
              addString = addString + "0";
            }
            addString = addString + "1";
            tempString = parseFloat(tempString) + parseFloat(addString);
          }
        }
        return tempString;
      }
      return parseFloat(tempString);
    } else {
      return Math.round(numberData);
    }
  }
}
function rtrim(stringData) {
  tempString = stringData;
  while (tempString.lastIndexOf(" ") == tempString.length - 1 && tempString.length > 0) {
    tempString = tempString.substr(0, tempString.length - 1);
  }
  return tempString;
}
function second(stringData) {
  if (timecheck(stringData) == true) {
    tempString = stringData.split(":");
    return parseInt(tempString[2]);
  } else {
    alert("Valid Time required for the 'Hour', 'Minute', or 'Second' functions.");
  }
}
function space(charLen) {
  if (isNaN(charLen)) {
    alert("Number > 0 required for 'Space' function.");
  } else if (charLen <=0) {
    alert("Number > 0 required for 'Space' function.");
  } else {
    tempString = ""
    for (var repeatchar = 0; repeatchar < charLen; repeatchar++) {
      tempString = tempString + " "
    }
    return tempString;
  }
}
function split(stringData, Searched) {
  tempString = "";
  if (Searched == null) {
    tempString = " ";
  } else {
    tempString = Searched;
  }
  return stringData.split(tempString);
}
function sqr(numberData) {
  if (isNaN(numberData)) {
    alert("Number required for 'Sqr' function.");
  } else {
    return Math.sqrt(numberData);
  }
}
function strreverse(stringData) {
  tempString = ""
  var holdString
  for (var reversechar = 0; reversechar < stringData.length; reversechar++) {
    holdString = tempString
    tempString = stringData.substring(reversechar, (reversechar + 1)) + holdString
  }
  return tempString;
}
function time() {
  currentdate = new Date();
  var ToD
  tempString = "";
  if (currentdate.getHours() > 12) {
    tempString = (currentdate.getHours() - 12) + ":"
    ToD = " PM";
  } else if (currentdate.getHours() == 0) {
    tempString = "12:";
    ToD = " AM";
  } else {
    tempString = currentdate.getHours() + ":"
    ToD = " AM";
  }
  if (currentdate.getMinutes() < 10) { tempString = tempString + "0"; }
  tempString = tempString + currentdate.getMinutes() + ":";
  if (currentdate.getSeconds() < 10) { tempString = tempString + "0"; }
  tempString = tempString + currentdate.getSeconds() + ToD;
  return tempString;
}
function timecheck(stringData) {
  //THIS FUNCTION IS NECESSARY TO THE 'hour','minute', and 'second' FUNCTIONS!!//
  if ((stringData.indexOf(":") > -1) && (stringData.indexOf(":") != stringData.lastIndexOf(":"))) {
    return true;
  } else {
    return false;
  }
}
function trim(stringData) {
  tempString = stringData;
  tempString = tempString.replace(/^\s*|\s*$/g,"");
  return tempString;
}
function trimold(stringData) {
  tempString = stringData;
  while (tempString.indexOf(" ") == 0 && tempString.length > 0) {
    tempString = tempString.substr(1);
  }
  while (tempString.lastIndexOf(" ") == tempString.length - 1 && tempString.length > 0) {
    tempString = tempString.substr(0, tempString.length - 1);
  }
  return tempString;
}
function ubound(xdata) {
  if (typeof xdata == "object" && xdata.constructor == Array) {
    return xdata.length;
  } else {
    alert("Valid Array required for 'UBound' function.");
  }
}
function ucase(stringData) {
  tempString = stringData;
  tempString = tempString.toUpperCase();
  return tempString;
}
function weekday(stringData) {
  tempString = stringData;
  if (isNaN(Date.parse(tempString))) {
    alert("Valid date required for 'Weekday' function.")
  } else {
    currentdate = new Date(tempString);
    /*
      VB/ASP returns a number between 1 - 7.
      Javascript returns a number between 0 - 6.
      Sunday is FIRST in both.
    */
    return currentdate.getDay();
  }
}
function weekdayname(stringData) {
  tempString = stringData;
  if (isNaN(Date.parse(tempString))) {
    alert("Valid date required for 'WeekdayName' function.")
  } else {
    currentdate = new Date(tempString);
    /*
      VB/ASP returns a number between 1 - 7.
      Javascript returns a number between 0 - 6.
      Sunday is FIRST in both.
    */
    switch (currentdate.getDay()) {
      case 0:
        return "Sunday";
        break;
      case 1:
        return "Monday";
        break;
      case 2:
        return "Tuesday";
        break;
      case 3:
        return "Wednesday";
        break;
      case 4:
        return "Thursday";
        break;
      case 5:
        return "Friday";
        break;
      case 6:
        return "Saturday";
        break;
    }
  }
}
function year(stringData) {
  tempString = stringData;
  if (isNaN(Date.parse(tempString))) {
    alert("Valid date required for 'Year' function.")
  } else {
    currentdate = new Date(tempString);
    return currentdate.getFullYear();
  }
}
//End VB Wrapper for JavaScript//
//-->