//###############################################################
//##           The JavaScript Library of VBScript
//##                  by Randy McCleary
//##                r_mccleary@hotmai.com
//###############################################################


/**************************************************************
 Abs: Returns a value of the same type that is passed to it
      specifying the absolute value of a number.
 Parameters:
      dblNumber = Any Number, negative or postive.
 Returns: Absolute Number
***************************************************************/
function Abs(dblNumber) {
	return Math.abs(dblNumber);
}

/**************************************************************
 Asc: Returns an Integer representing the character code
      corresponding to the first letter in a string
 Parameters:
   String = The required string argument is any valid string expression.
   			If the string if not in the range 32-126, the function return ZERO
 Returns: Integer
***************************************************************/
function Asc(string) {
	var strSymbols = " !\"#$%&'()*+'-./0123456789:;<=>?@";
	var strLetters = "abcdefghijklmnopqrstuvwxyz";
	var intLocation;
	
	strSymbols += strLetters.toUpperCase();
	strSymbols += "[\\]^_`";
	strSymbols += strLetters;
	strSymbols += "{|}~";
	intLocation = strSymbols.indexOf(string);
	if (loc > -1) { 
		Ascii_Decimal = 32 + intLocation;
		return (32 + intLocation);
	}
	return (0);
}

/**************************************************************
 Atn: Tbis function returns the arctangent for a number. 
 Parameters:
      dblNumber = A numeric value between -PI/2 and PI/2 radians.
 Returns: Absolute Number
***************************************************************/
function Atn(dblNumber) {
	return Math.atan(dblNumber);
}

/**************************************************************
 Chr: Returns a String containing the character associated
      with the specified character code.
 Parameters:
     CharCode = Long that identifies a character.
 Returns: String
***************************************************************/
function Chr(CharCode) {
	return String.fromCharCode(CharCode);
}

/**************************************************************
 date: This function returns the current date of the computer.
 Parameters:
     none
 Returns: Returns the current date. (10/2/2003)
***************************************************************/
function date() {
	var dtmDate = new Date();
	dtmDate = dtmDate.getMonth()+1 + "/" + dtmDate.getDate() + "/" + dtmDate.getFullYear();
	return (dtmDate.toLocaleString());
}

/**************************************************************
 DateAdd: Returns a Date containing a date to which a specified
          time interval has been added.
 Parameters:
     Interval  = Defines the type of time interval you wish to 
                 add onto the date. 
     intNumber = A multiplier for the Interval argument 
                 (i.e., how many days, weeks, months, etc.). 
     dtmDate   = Argument is a date or time
 Returns: String
***************************************************************/
function DateAdd(Interval, intNumber, dtmDate) {
	var strInterval = Interval.toLowerCase();
	var intNumber = new Number(intNumber);
	var dtmDate = new Date(dtmDate);
	
	var strDate = "";
	var intYear = dtmDate.getFullYear();
	var intMons = dtmDate.getMonth();
	var intDays = dtmDate.getDate();
	var intHour = dtmDate.getHours();
	var intMins = dtmDate.getMinutes();
	var intSecs = dtmDate.getSeconds();
	
	
	if (strInterval == "yyyy") { // Year
		var dtmNewDate = new Date(intYear + intNumber, intMons, intDays, intHour, intMins, intSecs);
	}
	else if (strInterval == "q") { // Quarter
		var dtmNewDate = new Date(intYear, intMons + (intNumber * 3), intDays, intHour, intMins, intSecs);
	}
	else if (strInterval == "m") { // Month
		var dtmNewDate = new Date(intYear, intMons + intNumber, intDays, intHour, intMins, intSecs);
	}	
	else if (strInterval == "y" || strInterval == "d" || strInterval == "w") { // Day of Year, Day, Weekday
		var dtmNewDate = new Date(intYear, intMons, intDays + intNumber, intHour, intMins, intSecs);
	}	
	else if (strInterval == "ww") { // Week of Year
		var dtmNewDate = new Date(intYear, intMons, intDays + (intNumber * 7), intHour, intMins, intSecs);
	}
	else if (strInterval == "h") { // Hour
		var dtmNewDate = new Date(intYear, intMons, intDays, intHour + intNumber, intMins, intSecs);
	}	
	else if (strInterval == "n") { // Minute
		var dtmNewDate = new Date(intYear, intMons, intDays, intHour, intMins + intNumber, intSecs);
	}
	else if (strInterval == "s") { // Second
		var dtmNewDate = new Date(intYear, intMons, intDays, intHour, intMins, intSecs + intNumber);
	}
	
	if (intHour == 0 && intMins == 0 && intSecs == 0) {
		strDate = DateValue(dtmNewDate);
	}
	else {
		strDate = DateValue(dtmNewDate) + " " + TimeValue(dtmNewDate);
	}
	return strDate;
}

/**************************************************************
 DateDiff: Returns the Difference between two dates in weeks,
           days, hours, minutes & seconds
 Parameters:
    - Date1: First Date
    - Date2: Second Data
 Returns: String containing the weeks, days, hours, minutes &
          seconds between the two dates.
***************************************************************/
function DateDiff(strReturn, Date1, Date2) {
	var dtmDiff  = new Date();
	var dtmDate1 = new Date(Date1);
	var dtmDate2 = new Date(Date2);
	
	dtmDate1.setTime(dtmDate1.getTime());
	dtmDate2.setTime(dtmDate2.getTime());

	dtmDiff.setTime((dtmDate2.getTime() - dtmDate1.getTime()));
	var timediff = dtmDiff.getTime();
	
	var years  = (((dtmDate2.getMonth() - dtmDate1.getMonth()) + (dtmDate2.getYear() - dtmDate1.getYear()) * 12) / 12);
	var months = ((dtmDate2.getMonth() - dtmDate1.getMonth()) + (dtmDate2.getYear() - dtmDate1.getYear()) * 12);
	var weeks  = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7) + .5);
	var days   = Math.floor(timediff / (1000 * 60 * 60 * 24));
	var hours  = Math.floor(timediff / (1000 * 60 * 60));
	var mins   = Math.floor(timediff / (1000 * 60));
	var secs   = Math.floor(timediff / 1000);
	
	if (strReturn == "y") {
		return years;
	}
	else if (strReturn == "m") {
		return months;
	}
	else if (strReturn == "w") {
		return weeks;
	}
	else if (strReturn == "d") {
		return days;
	}
	else if (strReturn == "h") {
		return hours;
	}
	else if (strReturn == "n") {
		return mins;
	}
	else if (strReturn == "s") {
		return secs;
	}
}

/**************************************************************
 DateValue: This function returns the Date value for the 
            specific input date/time.
 Parameters:
     dtmDate = Any Valid date format
 Returns: DateValue in the format of (10/3/2003).
***************************************************************/
function DateValue(dtmDate) {
	//if (IsDate(dtmDate) == false ) {
	//	return null;
	//}
	var dtmDate = new Date(dtmDate);
	dtmDate = Month(dtmDate) + "/" + dtmDate.getDate() + "/" + dtmDate.getFullYear();
	return (dtmDate.toLocaleString());
}

/**************************************************************
 DateSerial: This function returns the current Date of the computer.
 Parameters:
     Year  : String, Integer, or Expression (100 To 9999)
     Month : String, Integer, or Expression (-9999999 To +9999999)
     Day   : String, Integer, or Expression (-9999999 To +9999999)
 Returns: Returns the Date. (6/22/2003)
***************************************************************/
function DateSerial(Year, Month, Day) {
	var Years   = new Number(Year);
	var Months  = new Number(Month);
	var Days    = new Number(Day);
	var arrDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
	//***************************************************
	// Years
	//***************************************************
	if ((Years >= 100) && (Years <= 9999)) {
		Years = Years;
	}
	else {
		return null;
	}

	//***************************************************
	// Months    
	//***************************************************
	if (Months >= 1 && Months <= 12) {
		Months = Months;
	}
	else if (Months > 12) {
		// While Months is greater than 12, then keep subtracting 12 
		// to Months and incrementing the year by one.
		while (Months > 12 ) { 
			Months -= 12;
			Years += 1;
		}
	}
	else if (Months < 1) {
		// While Months is less than - 12, then keep adding 12 to Months
		// and decrementing the year by one.
		while (Months <= -12 ) { 
			Months += 12;
			Years -= 1;
		}
		
		// If Months is greater than -12 and is Greater or Equal to 0
		// then subtract One from Years.
		if (Months > -12 && Months <= 0) {
			Years -= 1;
		}
		
		// Months = 12 plus what is left over in the variable Months
		Months = 12 + Months;
	}

	//***************************************************
	// Days
	//***************************************************
	if (Days > 0) {
		// Set DaysInMonth for Feburary
		arrDays[1] = DaysInMonth(2, Years);
	
		// While Days is greater than the total days in the month subtract
		// the total days from the Days, and increment the Months by 1.
		while (Days > arrDays[Months - 1]) {
			Days -= arrDays[Months -1];
			Months += 1;		
			
			if (Months > 12) {
				Months -= 12;
				Years  += 1;
			}
			
			// Set DaysInMonth for Feburary
			arrDays[1] = DaysInMonth(2, Years);
		}
	}
	else if (Days <= 0) {
		if (Days == 0) {
			Months -=1;
			if (Months == 0){
				Months = 12;
				Years -= 1;
			}
			
			// Set DaysInMonth for Feburary
			arrDays[1] = DaysInMonth(2, Years);
			Days = arrDays[Months-1];
		}
		else {
			arrDays[1] = DaysInMonth(2, Years);
			
			// While Days is less than or equal to the total days in the Month
			// then increment the days by the total days in the month and 
			// subtract one from the Months.
			while (Days <= - arrDays[Months - 1]) {
				// Set DaysInMonth for Feburary
				arrDays[1] = DaysInMonth(2, Years);
				Days += arrDays[Months -1];
				Months -= 1;
				
				if (Months == 0) {
					Months += 12;
					Years  -= 1;
				}		
				
				// Set DaysInMonth for Feburary
				arrDays[1] = DaysInMonth(2, Years);				
			}
			if (Days == 0 || Days > -arrDays[Months-1]) {
				Months -=1;
			}
			if (Months == 0) {
				Months += 12;
				Years  -= 1;
			}
			
			// Set DaysInMonth for Feburary
			arrDays[1] = DaysInMonth(2, Years);	
			
			if (Days == -arrDays[Months-1]) {
				Days = 0;
				Months -=1;
			}
			if (Months == 0) {
				Months += 12;
				Years  -= 1;
			}
			
			// Set DaysInMonth for Feburary
			arrDays[1] = DaysInMonth(2, Years);
			
			// Days is equal to the number of days in the month to 
			// the days left over not greater then the total days 
			// in the month. Ex: Jan 31 days - 15 = Jan 16th.
			Days = arrDays[Months-1] + Days;
		}
	}
	if ((Years >= 1) && (Years <= 9999)) {
		return Months + "/" + Days + "/" + Years;
	}
	else {
		return null;
	}
}

/**************************************************************
 DaysInMonth: This function returns the number of days in a
 	           a given month and year. This is used to find out
 	           when a year has a leap day or not.
 Parameters:
    Month = A month Number (1-12).
    Year  = A 4 Digit Year number.
 Returns: Integer - (28-31).
***************************************************************/
function DaysInMonth(Month, Year) {
	var arrDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
	if ((Month==2) && (Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0))) {
		arrDays[1] = 29;
	}
	return arrDays[Month-1];
}

/**************************************************************
 Day: This function returns the number of the current day of 
      the month using any valid date expression as an argument.  
 Parameters:
    Number = A valid date.
 Returns: Integer - Day's date 1-31
***************************************************************/
function Day(dtmDate) {
	var dtmDate = new Date(dtmDate);
	return dtmDate.getDate(dtmDate);
}

/**************************************************************
 Exp: This function returns the value of e to the power of a 
      number that is passed to it.  
 Parameters:
    Number = A number.
 Returns: The value of e to the power of a number(Floating point).
***************************************************************/
function Exp(Number) {
	return Math.exp(Number)
}
 
/**************************************************************
 Fix: This function converts a decimal number (floating-point)
      to an integer number (fix-point). 
 Parameters:
    Number = A floating point Number to fix.
 Returns: Integer 
***************************************************************/
function Fix(Number) {
	if (Number < 0 ) {
		return Math.ceil(Number) 
	}
	else {
		return Math.floor(Number)
	}
}
	
/**************************************************************
 FormatCurrency: Returns an expression formatted as a currency
                 value using the currency symbol $.
 Parameters:
    Expression = Expression to be formatted.
 Returns: String
***************************************************************/
function FormatCurrency(Expression) {
	var intDecimals = 2;
	var dbInVal = Expression;
	var bNegative = false;
	var iInVal = 0;
	var strInVal
	var strWhole = "", strDec = "";
	var strTemp = "", strOut = "";
	var iLen = 0;

	if (dbInVal < 0) {
		bNegative = true;
		dbInVal *= -1;
	}

	dbInVal = dbInVal * Math.pow(10, intDecimals)
	iInVal = parseInt(dbInVal);
	
	if ((dbInVal - iInVal) >= .5) {
		iInVal++;
	}
	
	strInVal = iInVal + "";
	strWhole = strInVal.substring(0, (strInVal.length - intDecimals));
	strDec = strInVal.substring((strInVal.length - intDecimals), strInVal.length);
	
	while (strDec.length < intDecimals) {
		strDec = "0" + strDec;
	}
	
	iLen = strWhole.length;
	if (iLen >= 3) {
		while (iLen > 0) {
			strTemp = strWhole.substring(iLen - 3, iLen);
			
			if (strTemp.length == 3) {
				strOut = "," + strTemp + strOut;
				iLen -= 3;
			}
			else {
				strOut = strTemp + strOut;
				iLen = 0;
			}
		}
		
		if (strOut.substring(0, 1) == ",") {
			strWhole = strOut.substring(1, strOut.length);
		}
		else {
			strWhole = strOut;
		}
	}
	
	if (bNegative) {
		return "-$" + strWhole + "." + strDec;
	}
	else {
		return "$" + strWhole + "." + strDec;
	}
}

/**************************************************************
 FormatDateTime: Returns an expression formatted as a date or
                 time. If DateTime is null then false is returned.
 Parameters:
   DateTime   = Date/Time expression to be formatted
   FormatType = Numeric value that indicates the date/time 
                format used. If omitted, GeneralDate is used
                0 = Very Long Date/Time Format (Mon Jul 10, 12:02:30 am EDT 2000)
                1 = Long Date/Time Format (Monday, July 10, 2000)
                2 = Short Date (1/10/00)
                3 = Long Time (4:20 PM)
                4 = Military Time (14:43)
 Returns: String
***************************************************************/
function FormatDateTime(DateTime, FormatType) {
	if (DateTime == null) {
		return false;
	}

	if ((FormatType < 0) || (FormatType > 4)) {
		FormatType = 1;
	}

	var dtmDate  = new Date(DateTime);
	var strDay   = WeekdayName(dtmDate.getDay());
	var intDay   = dtmDate.getDate();
	var intMonth = Month(dtmDate.getMonth());
	var strMonth = MonthName(intMonth);
	var intYear  = dtmDate.getFullYear();

	// Format Type decision time!
	if (FormatType == 0) { // Sat Oct 25 14:23:17 CDT 2003
		return (dtmDate);
	}
	else if (FormatType == 1) { // Saturday, June 26, 2003
		return (strDay + ", " + strMonth + " " + intDay + ", " + intYear);
	}
	else if (FormatType == 2) { // 6/26/2003
		return (DateValue(dtmDate));
	}
	else if (FormatType == 3) { // 3:48:01 PM
		return (TimeValue(dtmDate));
	}	
	else if (FormatType == 4) { // 15:48
		return (Hour(dtmDate) + ":" + Minute(dtmDate));
	}
}

/**************************************************************
 FormatNumber: Returns an expression formatted as a number.
 Parameters:
   Expression            = Expression to be formatted.
   NumDigitsAfterDecimal = Numeric value indicating how many places
   								to the right of the decimal are displayed.
 Returns: String
***************************************************************/
function FormatNumber(Expression, NumDigitsAfterDecimal) {
	var intDecimals = NumDigitsAfterDecimal;
	var dbInVal = Expression;
	var bNegative = false;
	var iInVal = 0;
	var strInVal;
	var strWhole = "", strDec = "";
	var strTemp = "", strOut = "";
	var iLen = 0;

	if (dbInVal < 0) {
		bNegative = true;
		dbInVal *= -1;
	}

	dbInVal = dbInVal * Math.pow(10, intDecimals);
	iInVal = parseInt(dbInVal);
	if ((dbInVal - iInVal) >= .5) {
		iInVal++;
	}
	strInVal = iInVal + "";
	strWhole = strInVal.substring(0, (strInVal.length - intDecimals));
	strDec = strInVal.substring((strInVal.length - intDecimals), strInVal.length);
	while (strDec.length < intDecimals) {
		strDec = "0" + strDec;
	}
	iLen = strWhole.length;
	if (iLen >= 3) {
		while (iLen > 0) {
			strTemp = strWhole.substring(iLen - 3, iLen);
			if (strTemp.length == 3) {
				strOut = "," + strTemp + strOut;
				iLen -= 3;
			}
			else {
				strOut = strTemp + strOut;
				iLen = 0;
			}
		}
		if (strOut.substring(0, 1) == ",") {
			strWhole = strOut.substring(1, strOut.length);
		}
		else {
			strWhole = strOut;
		}
	}
	if (bNegative) {
		return "-" + strWhole + "." + strDec;
	}
	else {
		return strWhole + "." + strDec;
	}
}

/**************************************************************
 FormatPercent: Returns an expression formatted as a percentage
                (multipled by 100) with a trailing % character
 Parameters:
    Expression = Expression to be formatted.
 Returns: String
***************************************************************/
function FormatPercent(Expression, NumDigitsAfterDecimal) {
	var intDecimals = NumDigitsAfterDecimal;
	var dbInVal = Expression * 100;
	var bNegative = false;
	var iInVal = 0;
	var strInVal;
	var strWhole = "", strDec = "";
	var strTemp = "", strOut = "";
	var iLen = 0;

	if (dbInVal < 0) {
		bNegative = true;
		dbInVal *= -1;
	}

	dbInVal = dbInVal * Math.pow(10, intDecimals)
	iInVal = parseInt(dbInVal);
	if ((dbInVal - iInVal) >= .5) {
		iInVal++;
	}
	strInVal = iInVal + "";
	strWhole = strInVal.substring(0, (strInVal.length - intDecimals));
	strDec = strInVal.substring((strInVal.length - intDecimals), strInVal.length);
	while (strDec.length < intDecimals) {
		strDec = "0" + strDec;
	}
	iLen = strWhole.length;
	if (iLen >= 3) {
		while (iLen > 0) {
			strTemp = strWhole.substring(iLen - 3, iLen);
			if (strTemp.length == 3) {
				strOut = "," + strTemp + strOut;
				iLen -= 3;
			}
			else {
				strOut = strTemp + strOut;
				iLen = 0;
			}
		}
		if (strOut.substring(0, 1) == ",") {
			strWhole = strOut.substring(1, strOut.length);
		}
		else {
			strWhole = strOut;
		}
	}
	if (bNegative) {
		return "-" + strWhole + "." + strDec + "%";
	}
	else {
		return strWhole + "." + strDec + "%";
	}
}

/**************************************************************
 Hex: Returns a value of the same type that is passed to it
      specifying the absolute value of a number.
 Parameters:
      Number = Any Number, negative or postive.
 Returns: Absolute Number
***************************************************************/
function Hex(Number) {
	var strHex;
	
	if (Number >= 2) {
		return Math.abs(Number);
	}
}

/**************************************************************
 Hour: This function returns the hour of the Date/Time passed 
      as the parameter using any valid Time expression as an argument.  
 Parameters:
    dtmTime = A valid Time Expression.
 Returns: Integer - base upon a 24 clock (military time, values 
          will run from 0 to 23). 
***************************************************************/
function Hour(dtmTime) {
	var dtmDate = new Date(dtmTime);
	var temp    = new Date();
	var theDate = dtmDate.setDate(dtmDate.getDate());
	
	if (theDate > 0 ) {
		//
	}
	else {
		var dtmDate = new Date(temp.getMonth(temp) + "/" + temp.getDate(temp) + "/" + temp.getFullYear(temp) + " " + dtmTime);
	}
	return dtmDate.getHours(dtmDate);
}

/**************************************************************
 Int: This function converts a decimal number (floating-point) 
      to an integer number (fix-point). 
      Positive numbers are not rounded up. The decimal point
      and all digits to the right are effectively chopped off 
      Negative numbers are rounded down (towards more negative). 
 Parameters:
    Number = A decimal Number.
 Returns: Integer 
***************************************************************/
function Int(Number) {
	return Math.floor(Number)
}

/**************************************************************
 InStr: Returns a Long specifying the position of the first
        occurrence of one string within another. Is String1
        or String2 are null, false is returned.
 Parameters:
      String1 = String expression being searched.
      String2 = String expression sought
 Returns: Integer
***************************************************************/
function InStr(String1, String2) {
	if (String1 == null || String2 == null) {
		return false;
	}

	String1 = String1.toLowerCase();
	String2 = String2.toLowerCase();

	var i = String1.indexOf(String2);
	if (i == -1) {
		return 0;
	}
	else {
		return i + 1;
	}
}

/**************************************************************
 InStrF: 
***************************************************************/
function InStrF(String1, String2) {

	String1 = String1.toLowerCase();
	String2 = String2.toLowerCase();

	var i = String1.indexOf(String2); 
	if (i == 0) {
		return true;
	}
	else {
		return false;
	}
}

/**************************************************************
 IsChar: Returns a Boolean value indicating whether an expression can
 			be evaluated as a character (this not only includes alpha chars
 			but all symbols such as @#$%^&|\_+-/*="!?,.:;'(){}<>[]
 Parameters:
     String = A numeric expression or string expression.
 Returns: Boolean
***************************************************************/
function IsChar(String) {
	var intNumber = new Number(String);
	var strNumbers  = "0123456789";
	
	if (intNumber.toString() != "NaN") {
		return false;
	}
	else {
		var strInput = String.toLowerCase();
	}
	
	if (Len(strInput) < 1) {
		return false;
	}

	for (var i = 0; i < strInput.length; i++) {
		var j = strInput.substr(i, 1)
		var x = strNumbers.indexOf(j, 0)
		if (x != -1) {
			return false;
		}
	}
	return true;
}

/**************************************************************
 IsDate: Returns a Boolean (true) if the date is true, false is not
 Parameters:
	- strDate: String date in format (MM/DD/YYYY) or (MM-DD-YYYY)
 Returns: Boolean
***************************************************************/
function IsDate(strDate) {
	var strPattern = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})+(\ |)/;
	var arrPattern = strDate.match(strPattern);
	if (arrPattern == null) {
		return false;
	}

	var intMonth = arrPattern[1];
	var intDay   = arrPattern[3];
	var intYear  = arrPattern[4];
	
	if (intMonth < 1 || intMonth > 12) {
		return false;
	}

	if (intDay < 1 || intDay > 31) {
		return false;
	}

	if ((intMonth==4 || intMonth==6 || intMonth==9 || intMonth==11) && intDay==31) {
		return false;
	}

	if (intMonth == 2) {
		if (intDay>29 || (intDay==29 && !(intYear % 4 == 0 && (intYear % 100 != 0 || intYear % 400 == 0)))) {
			return false;
		}
	}
	return true;
}

/**************************************************************
 IsEmail: Returns a Boolean if the specified Email is a valid
 	       e-mail address. If Expression is null, false is returned.
 Parameters:
    Expression = e-mail to validate.
 Returns: Boolean
***************************************************************/
function IsEmail(strEmail) {
	if (strEmail == null) {
		return false;
	}

	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) {
			supported = 1;
		}
	}
	if (!supported)  {
		return (strEmail.indexOf(".") > 2) && (strEmail.indexOf("@") > 0);
	}
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	//var r2 = new RegExp("^[a-zA-Z0-9\\.\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\}\\~]*[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\}\\~]\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(strEmail) && r2.test(strEmail));
}

/**************************************************************
 IsNumeric: Returns a Boolean value indicating whether an expression can
			   be evaluated as a number (this includes values like $15,656.00)
 Parameters:
    String = A numeric expression or string expression.
 Returns: Boolean
***************************************************************/
function IsNumeric(String) {
	var strInput = new Number(Replace(String, "$", ""));
	strInput = strInput.toString();
	var strNumbers = "0123456789.-";

	if (Len(strInput) < 1 || strInput == "NaN") {
		return false;
	}

	for (var i = 0; i < Len(strInput); i++) {
		var j = strInput.substr(i, 1)
		var x = strNumbers.indexOf(j, 0)
		if (x == -1) {
			return false;
		}
	}
	return true;
}

/**************************************************************
 IsTime: Returns a Boolean (true) if the Time is validated as a 
         Time Format, false is not
 Parameters:
   strTime: String Time in following formats:
		hh:mm:ss tt - 3:48:01 PM
		hh:mm tt    - 3:48 PM
		hh:mm       - 15:48
 Returns: Boolean
***************************************************************/
function IsTime(strTime) {
	var strTime1 = /^(\d{1,2})(\:)(\d{2})\2(\d{2})(\ )\w[am|pm]$/i;
	var strTime2 = /^(\d{1,2})(\:)(\d{2})(\ )\w[am|pm]$/i;
	var strTime3 = /^(\d{1,2})(\:)(\d{1,2})$/;
	
	var strFormat1 = strTime.match(strTime1);
	var strFormat2 = strTime.match(strTime2);
	var strFormat3 = strTime.match(strTime3);

   // Check to see if it matches one of the 3 Format Strings.
	if (strFormat1 == null && strFormat2 == null && strFormat3 == null) {
		return false;
	}
	else if (strFormat1 != null) {
		// Validate for this format: 3:48:01 PM
		if (strFormat1[1] > 12 || strFormat1[1] < 00) {
			return false;
		}
		if (strFormat1[3] > 59 || strFormat1[3] < 00) {
			return false;	
		}
		if (strFormat1[4] > 59 || strFormat1[4] < 00) {
			return false;	
		}
	}
	else if (strFormat2 != null) {
		// Validate for this format: 3:48 PM
		if (strFormat2[1] > 12 || strFormat2[1] < 00) {
			return false;
		}
		if (strFormat2[3] > 59 || strFormat2[3] < 00) {
			return false;	
		}
	}
	else if (strFormat3 != null) {
		// Validate for this format: 15:48
		if (strFormat3[1] > 23 || strFormat3[1] < 00) {
			return false;
		}
		if (strFormat3[3] > 59 || strFormat3[3] < 00) {
			return false;	
		}
	}
	return true;
}

/**************************************************************
 Join: Returns a string created by joining a number of
       substrings contained in an array.
 Parameters:
   array     = One-dimensional array containing substrings
               to be joined
   Delimiter = String character used to separate the substrings
               in the returned string.If delimiter is a zero-length
               string(""), all items in the list are concatenated
               with no delimiters.
 Returns: String
***************************************************************/
function Join(array, strDelimiter) {
	var strTemp = '';

	if (array.length == 0) {
		return '';
	}

	if (strDelimiter.length == 0) {
		strDelimiter = ' ';
	}

	for (var i = 0; i < array.length; i++) {
		strTemp += array[i]
		if (i < array.length - 1) {
			strTemp += strDelimiter;
		}
	}
	return strTemp;
}

/**************************************************************
 LBound: Returns a Long containing the smallest available
         subscript for the indicated dimension of an array
 Parameters:
      array = Array to verify
 Returns: Integer (-1 if Array does not contain any subscript)
***************************************************************/
function LBound(array) {
	var i = 0;
	var j = '';

	if (array.length == 0) {
		return -1;
	}

	for (i = 0; i < array.length; i++) {
		j = array[i]
		if (j != null) {
			j = i;
			return j;
		}
	}
	return -1;
}

/**************************************************************
 LCase: Returns a string to lower-case.
 Parameters:
      String = String to convert to lower-case
 Returns: String
***************************************************************/
function LCase(String) {
	return String.toLowerCase();
}

/**************************************************************
 Left: Returns a String containing a specified number of
       characters from the left side of a string.
 Parameters:
   String = String expression from which the leftmost characters
            are returned. If string contains null, false is returned.
   Length = Numeric expression indicating how many characters to
            return. If 0, a zero-length string("") is returned. If
            greater than or equal to the number of characters in
            string, the entire string is returned.
 Returns: String
***************************************************************/
function Left(String, Length) {
	if (String == null) {
		return (false);
	}
	return String.substr(0, Length);
}

/**************************************************************
 Len: Returns a the number of characters in a string or the
      number of bytes required to store a variable.
 Parameters:
	string = Any valid string expression. If string contains 
		null, false is returned.
 Returns: Length of String
***************************************************************/
function Len(String) {
	if (String == null) {
		return false;
	}
	return String.length;
}

/**************************************************************
 Log: Function returns the natural logarithm of a number
 Parameters:
      Number = Any Positive Number.
 Returns: Floating Point Number
***************************************************************/
function Log(Number) {
	return Math.log(Number);
}

/**************************************************************
 LTrim: Returns a String Trimming the leading spaces
 Parameters:
   String = The required string argument is any valid string 
   			expression. If string contains null, false is returned
 Returns: String
***************************************************************/
function LTrim(String) {
	if (String == null) {
		return (false);
	}
	return String.replace(/(^\s+)/g,"");
}

/**************************************************************
 Mid: Returns a String containing a specified number of
      characters from a string
 Parameters:
   String = String expression from which characters are returned.
            If string contains null, false is returned.
   Start  = Number. Character position in string at which the part to
				be taken begins. If Start is greater than the number of
				characters in string, Mid returns a zero-length string("").
   Length = Number of characters to return. If omitted false is returned.
 Returns: String
***************************************************************/
function Mid(String, Start, Length) {
	if (String == null && (Length == null || Length.length == 0)) {
		return false;
	}

	if (Start > String.length) {
		return '';
	}
	return String.substr((Start - 1), Length);
}

/**************************************************************
 Minute: This function returns the minutes of the Date/Time passed 
      as the parameter using any valid Time expression as an argument.  
 Parameters:
    dtmTime = A valid Time Expression.
 Returns: Integer - from 0 to 59). 
***************************************************************/
function Minute(dtmTime) {
	var dtmDate = new Date(dtmTime);
	var temp    = new Date();
	var theDate = dtmDate.setDate(dtmDate.getDate());
	
	if (theDate > 0 ) {
		//
	}
	else {
		var dtmDate = new Date(temp.getMonth(temp) + "/" + temp.getDate(temp) + "/" + temp.getFullYear(temp) + " " + dtmTime);
	}
	return dtmDate.getMinutes(dtmDate);
}

/**************************************************************
 Month: This function returns the month number from the passed
       argument, which has to be a valid date expression.  
 Parameters:
    dtmDate = A valid date.
 Returns: Integer - (1 To 12)
***************************************************************/
function Month(dtmDate) {
	var dtmDate = new Date(dtmDate);
	return dtmDate.getMonth(dtmDate) + 1;
}

/**************************************************************
 MonthName: Returns a String specifying the name of the day
            for a given day.
 Parameters:
      dtmDate = Day to evaluate. Between 1-7
 Returns: String
 Examples: MonthName(Month("3/23/2003"))
***************************************************************/
function MonthName(dtmDate) {
	var arrMonths = new Array("", "January", "February", "March", "April", "May", "June", 
									  "July", "August", "September", "October", "November", "December");
	return arrMonths[dtmDate];
}

/**************************************************************
 Now: This function returns the current Date/Time of the computer.
 Parameters:
     none
 Returns: Returns the current Date/Time in the following format.
          (Monday, June 09, 2003 7:33:56 PM)
***************************************************************/
function Now() {
	var dtmDate = new Date();
	return (dtmDate.toLocaleString());
}

/**************************************************************
 Oct: This function returns the Octal value of a number.
 Parameters: 
 		intNumber = Number, String, or Numeric Expression
 Returns: String representing the Octal Value of the input Number.
***************************************************************/
function Oct(intNumber) {
	var strNumber = "";
	var intCount = 0;
	var i = 11;
	
	if (IsNumeric(intNumber) && TypeName(intNumber) == "string") {
		intNumber = new Number(intNumber);
	}
	else if (!IsNumeric(intNumber)) {
		return null;
	}

	if (intNumber > 0) {
		while (i > 0) {
			intCount = 0;
			if (intNumber < Math.pow(8,i) && intNumber >= Math.pow(8,i)/8) {
				while(intNumber >= Math.pow(8,i)/8) {
					intNumber -= Math.pow(8,i)/8;
					intCount += 1;
				}
				strNumber += intCount;
			}	
			else {
				if (Len(strNumber) != 0) {
					strNumber += "0";
				}
			}	
			i -= 1;
		}
	}
	else if (intNumber < 0) {
		if (Abs(intNumber) < 32768) {
			i = 5;
			strNumber += "1";
		}
		else {
			i = 10;
			strNumber += "3";
		}
		while (i > 0) {
			intCount = 8;
			if (Abs(intNumber) < Math.pow(8,i) && Abs(intNumber) >= Math.pow(8,i)/8) {
				while(Abs(intNumber) >= Math.pow(8,i)/8) {
					intNumber += Math.pow(8,i)/8;
					intCount -= 1;
				}
				if (Abs(intNumber) > 0) {
					intCount -= 1;
				}
				strNumber += intCount;
			}	
			else {
				if (Abs(intNumber) == 0) {
					strNumber += "0";
				}
				else {
					strNumber += "7";
				}
			}	
			i -= 1;
		}
	}
	else {
		strNumber = 0;
	}	
	return strNumber;
		
		//************************************
		//** 8's
		//************************************
		intCount = 8;
		if (Abs(intNumber) < 64 && Abs(intNumber) >= 8) {
			while(Abs(intNumber) >= 8) {
				intNumber += 8;
				intCount -= 1;
			}
			if (Abs(intNumber) > 0) {
				intCount -= 1;
			}
			strNumber += intCount;
		}	
		else {
			if (Len(strNumber) != 0) {
				strNumber += "0";
			}
			else {
				strNumber += "7";
			}
		}	
		
		//************************************
		//** 1's
		//************************************
		intCount = 8;
		if (Abs(intNumber) < 8 && Abs(intNumber) >= 1) {
			while(Abs(intNumber) >= 1) {
				intNumber += 1;
				intCount -= 1;
			}
			strNumber += intCount;
			//intNumber = Abs(6 + intNumber);
			//strNumber += intNumber;
		}
		else {
			if (Len(strNumber) != 0) {
				strNumber += "0";
			}
		}	
	//}
	
	return strNumber;	
	
	//return Math.pow(8,4);

	//************************************
	//** 4096's
	//************************************
	intCount = 0;
	if (intNumber < 32768 && intNumber >= 4096) {
		while(intNumber >= 4096) {
			intNumber -= 4096;
			intCount += 1;
		}
		strNumber += intCount;
	}	
	else {
		if (Len(strNumber) != 0) {
			strNumber += "0";
		}
	}	

	//************************************
	//** 512's
	//************************************
	intCount = 0;
	if (intNumber < 4096 && intNumber >= 512) {
		while(intNumber >= 512) {
			intNumber -= 512;
			intCount += 1;
		}
		strNumber += intCount;
	}	
	else {
		if (Len(strNumber) != 0) {
			strNumber += "0";
		}
	}	
	
	//************************************
	//** 64's
	//************************************
	intCount = 0;
	if (intNumber < 512 && intNumber >= 64) {
		while(intNumber >= 64) {
			intNumber -= 64;
			intCount += 1;
		}
		strNumber += intCount;
	}
	else {
		if (Len(strNumber) != 0) {
			strNumber += "0";
		}
	}	
	
	//************************************
	//** 8's
	//************************************
	intCount = 0;
	if (intNumber < 64 && intNumber >= 8) {
		while(intNumber >= 8) {
			intNumber -= 8;
			intCount += 1;
		}
		strNumber += intCount;
	}	
	else {
		if (Len(strNumber) != 0) {
			strNumber += "0";
		}
	}	
	
	//************************************
	//** 1's
	//************************************
	if (intNumber < 8 && intNumber >= 1) {
		strNumber += intNumber;
	}
	else {
		if (Len(strNumber) != 0) {
			strNumber += "0";
		}
	}	
	return strNumber;
}

/**************************************************************
 Rand: Returns a random number between a lower and upper limit
 Parameters:
      intLower = Lower Limit
      intUpper = Upper Limit
 Returns: Random Number (integer)
***************************************************************/
function Rand(intLower, intUpper) {
	return Math.floor(Math.random() * (intUpper - intLower + 1) + intLower);	
}

/**************************************************************
 RGB: This function returns an integer that defines an RGB 
      color value  
 Parameters:
      Red   = The red component of the color must be a integer ranging from 0-255
      Green = The green component of the color must be a integer ranging from 0-255
      Blue  = The blue component of the color must be a integer ranging from 0-255
 Returns: Integer 
***************************************************************/
function RGB(Red, Green, Blue) {
	var intR = new Number(Red);
	var intG = new Number(Green);
	var intB = new Number(Blue);
	
	return ((intR) + (intG * 256) + (intB * 256 * 256));
}

/**************************************************************
 Replace: Returns a string in which a specified substring has
          been replaced with another substring a specified
          number of times.
 Parameters:
   String     = String expression containing substring to replace
   Find       = Substring being searched for.
   Replace    = Replacement substring.
 Returns: String
***************************************************************/
function Replace(String, Find, Replace) {
	var strTemp = String;
	var j = 0;

	for (var i = 0; i < String.length; i++) {
		j = strTemp.indexOf(Find);
		if (j == -1) {
			break;
		}
		else {
			strTemp = strTemp.substring(0, j) + Replace + strTemp.substring((j + Find.length));
		}
	}
	return strTemp;
}

/**************************************************************
 Right: Returns a String containing a specified number of
        characters from the right side of a string.
 Parameters:
   String = String expression from which the rightmost characters
   			are returned. If string contains null, false is returned.
   Length = Numeric expression indicating how many characters to
            return. If 0, a zero-length string ("") is returned. If
            greater than or equal to the number of characters in string,
            the entire string is returned.
 Returns: String
***************************************************************/
function Right(String, Length) {
	if (String == null) {
		return (false);
	}
	return String.substr((String.length - Length), Length);
}

/**************************************************************
 Round: Returns a String Trimming the trailing spaces
 Parameters:
   Number = The umber to be rounded.
 Returns: Number Rounded.
***************************************************************/
function Round(Number) {
	return Math.round(Number);
}

/**************************************************************
 RTrim: Returns a String Trimming the trailing spaces
 Parameters:
   String = The required string argument is any valid string
   			expression. If string contains null, false is returned
 Returns: String
***************************************************************/
function RTrim(String) {
	if (String == null) {
		return false;
	}
	return String.replace(/(\s+$)/g,"");
}

/**************************************************************
 Second: This function returns the seconds of the Date/Time passed 
      as the parameter using any valid Time expression as an argument.  
 Parameters:
    dtmTime = A valid Time Expression.
 Returns: Integer - from 0 to 59). 
***************************************************************/
function Second(dtmTime) {
	var temp  = new Date();
	var dtmDate = new Date(temp.getMonth(temp) + "/" + temp.getDate(temp) + "/" + temp.getFullYear(temp) + " " + dtmTime);
	return dtmDate.getSeconds(dtmDate);
}

/**************************************************************
 Sgn: Returns an Integer indicating the sign of a number. If
      Integer is not a number the functions return false.
 Parameters:
   Integer = The number argument can be any valid numeric expression.
 Returns: Integer -1 If Integer < 0
                   0 If Integer = 0
                   1 If Integer > 0
               false If Parameter IS NOT NUMERIC
***************************************************************/
function Sgn(intNumber) {
	var strNumbers = "0123456789-";

	if (intNumber.length < 1) {
		return false;
	}

	for (var i = 0; i < intNumber.length; i++) {
		var j = intNumber.substr(i, 1);
		var a = strNumbers.indexOf(j, 0);
		if (a == -1) {
			return false;
		}
	}
	if (intNumber < 0) {
		return -1;
	}
	else if (intNumber == 0) {
		return 0;
	}
	else {
		return 1;
	}
}

/**************************************************************
 Sin: This Function is used to return the sine of its argument,
      which will be a number between -1 and 1 
 Parameters:
      Number = A Number
 Returns: The returns the sine for a number (angle). 
***************************************************************/
function Sin(Number) {
	return Math.sin(Number);
}

/**************************************************************
 Space: Returns a String consisting of the specified number
        of spaces
 Parameters:
      Number = Number of spaces you want in the string.
 Returns: String
***************************************************************/
function Space(intNumber) {
	var strTemp = '';

	if (intNumber < 1) {
		return '';
	}

	for (var i = 0; i < intNumber; i++) {
		strTemp += ' ';
	}
	return strTemp;
}

/**************************************************************
 Split: Returns a zero-based, one-dimensional array containing
        a specified number of substrings
 Parameters:
   Expression = String expression containing substrings and
                delimiters. If expression is a zero-length
                string(""), Split returns an empty array,
                that is, an array with no elements and no data.
   Delimiter  = String character used to identify substring
                limits. If delimiter is a zero-length
                string(""), a single-element array containing
                the entire expression string is returned.
 Returns: String
***************************************************************/
function Split(Expression, strDelimiter) {
	var temp = Expression;
	var a, b = 0;
	var array = new Array();

	if (strDelimiter.length == 0) {
		array[0] = Expression;
		return array;
	}

	if (Expression.length == '') {
		array[0] = Expression;
		return array;
	}

	strDelimiter = strDelimiter.charAt(0);

	for (var i = 0; i < Expression.length; i++) {
		a = temp.indexOf(strDelimiter);
		if (a == -1) {
			array[i] = temp;
			break;
		}
		else {
			b = (b + a) + 1;
			var temp2 = temp.substring(0, a);
			array[i] = temp2;
			temp = Expression.substr(b, Expression.length - temp2.length);
		}
	}

	return array;
}

/**************************************************************
 Sqr: This Function returns the square root of a number. If 
      that number is negative, then the Netscape browser returns 
      the value of NaN, whereas the Internet Explorer browser 
      returns an Error message. 
 Parameters:
      Number = A Postive Number
 Returns: The square root of a positive number
***************************************************************/
function Sqr(Number) {
	return Math.sqrt(Number);
}

/**************************************************************
 StrConv: Returns a String converted as specified in the
          Parameters Section.
 Parameters:
   String     = String expression to be converted.
   Conversion = Number specifying the type of conversion 
                to perform.
                1 = TO UPPER CASE
                2 = to lower case
                3 = To Proper Case
                If Conversion is null or not specified 1
                is set as default.
 Returns: String
***************************************************************/
function StrConv(String, Conversion) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;

	if (Conversion == null || Conversion.length == 0) {
		Conversion = '1';
	}

	if (Conversion != '1' && Conversion != '2' && Conversion != '3') {
		Conversion = '1';
	}

	if (Conversion == '1') {
		return String.toUpperCase();
	}

	if (Conversion == '2') {
		return String.toLowerCase();
	}

	//Proper Case
	tmpStr = String.toLowerCase();
	strLen = tmpStr.length;
	if (strLen > 0) {
		for (index = 0; index < strLen; index++) {
			if (index == 0) {
				tmpChar = tmpStr.substring(0, 1).toUpperCase();
				postString = tmpStr.substring(1, strLen);
				tmpStr = tmpChar + postString;
			}
			else {
				tmpChar = tmpStr.substring(index, index + 1);
				if (tmpChar == " " && index < (strLen - 1)) {
					tmpChar = tmpStr.substring(index + 1, index + 2).toUpperCase();
					preString = tmpStr.substring(0, index + 1);
					postString = tmpStr.substring(index + 2,strLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}
	return tmpStr;
}

/**************************************************************
 StrReverse: Returns a string in which the character order
                of a specified string is reversed
 Parameters:
   Expression = The expression argument is the string whose characters
   				 are to be reversed. If expression is a zero-length
   				 string(""), a zero-length string is returned. If
   				 expression is null, false is returned.
 Returns: String
***************************************************************/
function StrReverse(Expression) {
	if (Expression == null) {
		return (false);
	}

   var strReturn = '';
   for (var i = (Expression.length - 1); i >= 0; i--) {
		strReturn += Expression.charAt(i);
	}
   return strReturn;
}

/**************************************************************
 Tan: This function returns a number representing the tangent 
      of an angle.  
 Parameters:
      Number = A Number
 Returns: The tangent for a number (angle). 
***************************************************************/
function Tan(Number) {
	return Math.tan(Number);
}
 
/**************************************************************
 Time: This function returns the current time of the computer.
 Parameters:
     none
 Returns: Returns the current Time. (12:03:03 PM)
***************************************************************/
function Time() {
	var dtmDate = new Date();
	var intHours = dtmDate.getHours();
	var intMins  = dtmDate.getMinutes();
	var intSecs  = dtmDate.getSeconds();
	
	if (intHours >=24 || intHours < 0) {
		return null;
	}
	
	if (intMins == 0) {
		intMins = "00";
	}
	else if (Len(String(intMins))==1) {
		intMins = "0" + intMins;
	}
		
	if (intSecs == 0) {
		intSecs = "00";
	}
	else if (Len(String(intSecs))==1) {
		intSecs = "0" + intSecs;
	}
	
	if (intHours >= 12 ) {
		if (intHours != 12) {
			intHours -= 12;
		}
		return (intHours + ":" + intMins + ":" + intSecs + " PM");
	}
	else {
		if (intHours == 0) {
			intHours = 12;
		}
		return (intHours + ":" + intMins + ":" + intSecs + " AM");
	}
}

/**************************************************************
 TimeSerial: This function returns the current time of the computer.
 Parameters:
     Hours  : String, Integer, or Expression (-9999999 To +9999999)
     Minutes: String, Integer, or Expression (-9999999 To +9999999)
     Seconds: String, Integer, or Expression (-9999999 To +9999999)
 Returns: Returns the Time. (12:03:03 PM)
***************************************************************/
function TimeSerial(Hours, Minutes, Seconds) {
	var Hours   = new Number(Hours);
	var Minutes = new Number(Minutes);
	var Seconds = new Number(Seconds);

	if (Seconds >= 60) {
		while (Seconds >= 60 ) {
			Seconds -= 60;
			Minutes += 1;
			
			if (Minutes == 60) {
				Minutes = 0;
				Hours += 1;
			}
			
			if (Hours == 24) {
				Hours = 0;
			}
		}
	}
	else if (Seconds < 0) {
		while (Seconds < 0 ) { 
			Seconds += 60;
			
			if (Hours == -1) {
				Hours = 23;
			}
			
			if (Minutes == -1) {
				Hours -= 1;
				Minutes += 59;
			}
			else {
				Minutes -= 1;
			}
		}
	}
	
	if (Minutes >= 60) {
		while (Minutes >= 60 ) {
			Minutes -= 60;
			Hours += 1;

			if (Hours == 24) {
				Hours = 0;
			}
		}
	}
	else if (Minutes < 0) {
		while (Minutes < 0 ) { 
			Minutes += 60;
			Hours -= 1;
			
			if (Hours == -1) {
				Hours = 23;
			}
		}
	}
	
	if (Hours >= 24) {
		while (Hours >= 24 ) {
			Hours -= 23;

			if (Hours == 24) {
				Hours = 0;
			}
		}
	}
	else if (Hours < 0) {
		while (Hours < 0 ) { 
			Hours += 24;
		}
	}
	
	var temp  = new Date();
	var dtmDate = new Date(temp.getMonth(temp) + "/" + temp.getDate(temp) + "/" + temp.getFullYear(temp) + " " + Hours + ":" + Minutes + ":" + Seconds);
	var intHours = dtmDate.getHours();
	var intMins  = dtmDate.getMinutes();
	var intSecs  = dtmDate.getSeconds();
	
	if (intMins == 0) {
		intMins = "00";
	}
	else if (Len(String(intMins))==1) {
		intMins = "0" + intMins;
	}
		
	if (intSecs == 0) {
		intSecs = "00";
	}
	else if (Len(String(intSecs))==1) {
		intSecs = "0" + intSecs;
	}
	
	if (intHours >= 12 ) {
		if (intHours != 12) {
			intHours -= 12;
		}
		return (intHours + ":" + intMins + ":" + intSecs + " PM");
	}
	else {
		if (intHours == 0) {
			intHours = 12;
		}
		return (intHours + ":" + intMins + ":" + intSecs + " AM");
	}
}

/**************************************************************
 TimeValue: This function returns the Time value for the 
            specific input date/time.
 Parameters:
     dtmDate = Any Valid date format
 Returns: TimeValue in the format of (12:03:03 PM).
***************************************************************/
function TimeValue(dtmDate) {
	var dtmTime = dtmDate;
	var dtmDate = new Date(dtmTime);
	var temp    = new Date();
	var theDate = dtmDate.setDate(dtmDate.getDate());
	
	if (theDate > 0 ) {
		//
	}
	else {
		var dtmDate = new Date(temp.getMonth(temp) + "/" + temp.getDate(temp) + "/" + temp.getFullYear(temp) + " " + dtmTime);
	}

	var intHours = dtmDate.getHours();
	var intMins  = dtmDate.getMinutes();
	var intSecs  = dtmDate.getSeconds();
	
	if (intHours == 0 && intMins == 0) {
		intHours = temp.getHours();
		intMins  = temp.getMinutes();
		intSecs  = temp.getSeconds();
	}

	if (intMins == 0) {
		intMins = "00";
	}
	else if (Len(String(intMins))==1) {
		intMins = "0" + intMins;
	}
		
	if (intSecs == 0) {
		intSecs = "00";
	}
	else if (Len(String(intSecs))==1) {
		intSecs = "0" + intSecs;
	}
	
	if (intHours >= 12 ) {
		if (intHours != 12) {
			intHours -= 12;
		}
		return (intHours + ":" + intMins + ":" + intSecs + " PM");
	}
	else {
		if (intHours == 0) {
			intHours = 12;
		}
		return (intHours + ":" + intMins + ":" + intSecs + " AM");
	}
}

/**************************************************************
 Trim: Returns a String Trimming Both Leading/Trailing Spaces
 Parameters:
   String = The required string argument is any valid string expression.
   			If string contains null, false is returned
 Returns: String
***************************************************************/
function Trim(String) {
	if (String == null) {
		return (false);
	}
	return String.replace(/(^\s+)|(\s+$)/g,"");
}

function Trim2(String) {
	if (String == null) {
		return (false);
	}
	return String.replace(/(\s+)/g,"");
}

/**************************************************************
 TypeName: Returns the type of an unevaluated operand which can be 
       a number, string, variable, object, or keyword
 Parameters:
   Type  = A number, string, variable, object, or keyword.
 Returns: String - Type Name
***************************************************************/
function TypeName(Type) {
	return typeof(Type);
} 

/**************************************************************
 UBound: Returns a Long containing the largest available
         subscript for the indicated dimension of an array
 Parameters:
     array = Array to verify
 Returns: Integer (-1 if Array does not contain any subscript)
***************************************************************/
function UBound(array) {
	return (array.length - 1);
}

/**************************************************************
 UCase: Returns a string to upper-case.
 Parameters:
      String = String to convert to upper-case
 Returns: String
***************************************************************/
function UCase(String) {
	return String.toUpperCase();
}

/**************************************************************
 Weekday: Returns a Integer
 Parameters:
      dtmDate = Date to evaluate in the following formats:
      		 '3/23/2003' or 'March 23, 2003'
 Returns: Integer
 Examples: Weekday(Weekday("3/23/2003"))
***************************************************************/
function Weekday(dtmDate) {
	var dtmDay = new Date(dtmDate);
	return dtmDay.getDay();
}

/**************************************************************
 WeekdayName: Returns a String specifying the name of the day
            for a given day.
 Parameters:
      dtmDate = Day to evaluate. Between 1-7
 Returns: String
 Examples: WeekdayName(Weekday("3/23/2003"))
***************************************************************/
function WeekdayName(dtmDate) {
	var arrDays = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
	return arrDays[dtmDate];
}

/**************************************************************
 Year: This function returns the full 4 digit year using any 
       valid date expression as an argument.  
 Parameters:
    dtmDate = A valid date.
 Returns: Integer - Full Year 4 digits
***************************************************************/
function Year(dtmDate) {
	var dtmDate = new Date(dtmDate);
	return dtmDate.getFullYear(dtmDate);
}


function percent(x) { 
	return Math.round((x-0)*100) + '%'; 
}