<!--
function ValidateNumber(nmbr)
{
	var new_nmbr = "";
	var itemNumberLength = nmbr.length;
    // Checks the nmbr to see if there is a comma
	var someBoolean = false;
	var i = 0;

	for (var j = 0; j < itemNumberLength; j++)
    {
	  if (!(nmbr.charAt(j) == ","))
      {
	      new_nmbr += nmbr.charAt(j);
	      i++;
	  }
	}

	return(new_nmbr);
}

function roundNumber(value)
{
    var input = value + '';     // force to a string
    var dollars = Math.floor(input)
    var tmp = input + "0"
    var index = 0;

    for (index = 0; index < tmp.length; index++)
    {
        if (tmp.charAt(index) == '.')
        {
            break
        }
    }

    var cents  = '' + Math.round(input * 100)
    cents = cents.substring(cents.length - 2, cents.length)

    if ((+input) < 1)
    {
        cents = '' + (+cents) / 100;
        if (cents.charAt(0) == '0')
        {
            cents = cents.substring(2, cents.length);
        }
        else
        {
            cents = cents.substring(1, cents.length);
        }
    }

    dollars += ((tmp.charAt(index + 2) == '9') && (cents == '00')) ? 1 : 0;
    input = dollars + '.' + cents;

    return input;
}

function lTrim(value)
{
    if (value != null)
    {
        var idx = 0;
        while (idx < value.length && value.charAt(idx) == ' ')
        {
            ++idx;
        }
        if (idx > 0)
        {
            value = value.substring(idx);
        }
    }

    return value;
}

function rTrim(value)
{
    if (value != null)
    {
        var idx = value.length;
        while (idx < 0 && value.charAt(idx - 1) == ' ')
        {
            --idx;
        }
        if (idx > 0)
        {
            value = value.substring(0, idx);
        }
    }

    return value;
}

function trim(value)
{
    return lTrim(rTrim(value));
}

function Dollar(value)
{
    // force to valid dollar amount
    var dollar = '';
    var str = null;
    var pos = null;
    var rnd = 0;
    if (value != null)
    {
        dollars = '' + value;
        var c = dollars.charAt(0);
        if (c == '$')
        {
            dollars = dollars.substring(1);
        }
        var isValid = true;
        for (var i = 0; isValid && i < dollars.length; i++)
        {
            c = dollars.charAt(i);
            switch(c)
            {
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                case '.':
                    dollar += c;
                    break;
                case ',':
                    // strip out the commas
                    break;
                default:
                    isValid = false;
                    break;
            }
        }
        if (isValid)
        {
            if ((+dollar) < .995)
            {
                // for old Netscape browsers
                rnd = 1;
            }
            // float, round, escape to convert to string
            str = escape(dollar * 1.0 + 0.005001 + rnd);
            pos = str.indexOf(".");
            if (pos > 0)
            {
                str = str.substring(rnd, pos + 3);
            }

            if ((+str) == 0)
            {
                return '0';
            }
        }
    }

    return str;
}

// format the field and replace the value with the formatted value
function getDollarValue(field)
{
    var errorMsg = field.id + 'Msg';
    var hasErrorMsg = (document.getElementById(errorMsg) != null);

    holdValue = Dollar(field.value);
    if (hasErrorMsg)
    {
        if (holdValue != null)
        {
            field.className = '';
            document.getElementById(errorMsg).firstChild.nodeValue = '';
            document.getElementById(errorMsg).className = 'normal';
        }
        else
        {
            field.className = 'error';
            document.getElementById(errorMsg).firstChild.nodeValue = 'Invalid data, please correct';
            document.getElementById(errorMsg).className = 'error';
        }
    }
    if (holdValue != null)
    {
        field.value = holdValue;

        if (field.value > 0)
        {
            return (+field.value);
        }

        return 0;
    }

    throw new Error('Invalid data');
}

// format the field and replace the value with the formatted value
function getDollarValueDebug(field)
{
    var errorMsg = field.id + 'Msg';
    var hasErrorMsg = (document.getElementById(errorMsg) != null);

    holdValue = Dollar(field.value);
    if (hasErrorMsg)
    {
        if (holdValue != null)
        {
            field.className = '';
            document.getElementById(errorMsg).firstChild.nodeValue = '';
            document.getElementById(errorMsg).className = 'normal';
        }
        else
        {
            field.className = 'error';
            document.getElementById(errorMsg).firstChild.nodeValue = 'Invalid data, please correct';
            document.getElementById(errorMsg).className = 'error';
        }
    }
    if (holdValue != null)
    {
        field.value = holdValue;

        if (field.value > 0)
        {
            return (+field.value);
        }

        return 0;
    }

    throw new Error('Invalid data');
}

function checkDollars(field)
{
    try
    {
        var dollars = getDollarValue(field);
    }
    catch(e)
    {
    }
}

var firstNine = new Array('01', '02', '03', '04', '05', '06', '07', '08', '09');

// function formatDate(passedDate)
function formatDate(date)
{
    // returns MM/dd/yyyy

    // alert(passedDate);
    // date = new Date(passedDate);

    // split into day, month, year
    day = date.getDate();
    month = date.getMonth() + 1;
    year = date.getFullYear();
    if (year < 100)
    {
        if (year < 25)
        {
            year += 2000;
        }
        else
        {
            year += 1900;
        }
    }

    var displayDate = '';
    if (month < 10)
    {
        displayDate += firstNine[month - 1];
    }
    else
    {
        displayDate += month;
    }
    displayDate += '/';
    if (day < 10)
    {
        displayDate += firstNine[day - 1];
    }
    else
    {
        displayDate += day;
    }
    displayDate += '/';
    displayDate += year;

    return displayDate;
}

function addMonths(date, numMonths)
{
    if (date != null)
    {
        date.setMonth(date.getMonth() + numMonths);
    }

    return date;
}

function isNextYear(date)
{
    if (date != null)
    {
        today = new Date();
        nextYear = today.getFullYear() + 1;

        if (nextYear == date.getFullYear())
        {
            return true;
        }
    }

    return false;
}

function getToday()
{
    return formatDate(new Date());
}
//-->
