function DateDiff(sInctement, dSDate, dEDate)
{
    try
    {
        var iInt = Date.parse(dSDate) - Date.parse(dEDate);

        switch (sInctement)
        {
            case 'y':
                iInt = iInt / 52;
            case 'w':
                iInt = iInt / 7;
            case 'd':
                iInt = iInt / 24;
            case 'h':
                iInt = iInt / 60;
            case 'n':
                iInt = iInt / 60;
            case 's':
                iInt = iInt / 1000;
                break;
        }
        return iInt;
    }
    catch (oErr)
    {
        JSError('DateDiff', oErr);
    }
}
/********************************************************************************************
* DateAdd: is a function in JavaScript that works like the VB DateAdd
********************************************************************************************/
function DateAdd(sInctement, iInt, dDate)
{
    try
    {
        switch (sInctement)
        {
            case "y":
                dDate.setFullYear(dDate.getFullYear() + iInt);
                break;
            case "m":
                dDate.setMonth(dDate.getMonth() + iInt);
                break;
            case 'w':
                iInt = iInt * 7;
            case 'd':
                iInt = iInt * 24;
            case 'h':
                iInt = iInt * 60;
            case 'n':
                iInt = iInt * 60;
            case 's':
                iInt = iInt * 1000;
                break;
        }

        var NewIntDate = (Date.parse(dDate) - 0) + (iInt - 0);
        var NewDate = new Date((Date.parse(dDate) - 0) + (iInt - 0));

        return NewDate;
    }
    catch (oErr)
    {
        JSError('DateAdd', oErr);
    }
}
/********************************************************************************************
* cVBDate: converts a JavaScript Date to a Visual Basic date down to the second
********************************************************************************************/
function cVBDate(dDate, bRemoveTime)
{
    var ReturnDate = parseInt(dDate.getMonth() + 1) + '/' + parseInt(dDate.getDate()) + '/';
    if (dDate.getYear() < 1900)
    {
        ReturnDate = ReturnDate + (dDate.getYear() + 1900)
    }
    else
    {
        ReturnDate = ReturnDate + dDate.getYear()
    }

    if (!bRemoveTime)
    {
        ReturnDate = ReturnDate + ' ' + dDate.getHours() + ':';
        if (dDate.getMinutes() < 10)
        {
            ReturnDate += "0";
        }
        ReturnDate += dDate.getMinutes() + ':';
        if (dDate.getSeconds() < 10)
        {
            ReturnDate += "0";
        }
        ReturnDate += dDate.getSeconds();
    }

    return ReturnDate;
}
/********************************************************************************************
* cJDate: converts a Visual Basic Date to a JavaScript date down to the day
********************************************************************************************/
function cJDate(sDate)
{
    try
    {
        sDate = sDate + ' ';
        var aDateTime = sDate.split(' ');
        var aDate = aDateTime[0].split('/');

        var sDate = new Date(aDate[2], aDate[0] - 1, aDate[1]);
        return sDate;
    }
    catch (oErr)
    {
        JSError('cJDate', oErr);
    }
}

function cJDateTime(sDate)
{
    try
    {
        //alert(sDate);

        sDate = sDate + ' ';
        var aDateTime = sDate.split(' ');
        var aDate = aDateTime[0].split('/');
        var sTime;
        var aTime;
        var iHourModifier;
        var dDate;

        //alert(aDateTime[2]);

        if (aDateTime[2])
        {
            if (aDateTime[2] == 'PM')
            {
                iHourModifier = 0;
            }
            else
            {
                iHourModifier = 0;
            }
        }
        else
        {
            iHourModifier = 0;
        }

        //alert(aDateTime[1]);
        if (aDateTime[1])
        {
            aTime = aDateTime[1].split(':');

            aTime[0] = parseInt(aTime[0]) + iHourModifier;

            dDate = new Date(aDate[2], aDate[0] - 1, aDate[1], aTime[0], aTime[1], 0);
            //alert(aDate[2] + ' / ' + (aDate[0] - 1) + ' / ' + aDate[1] + '   ' + aTime[0] + ' : ' + aTime[1] + '\n\n' + dDate);
        }
        else
        {
            dDate = new Date(aDate[2], aDate[0] - 1, aDate[1]);
        }


        return dDate;
    }
    catch (oErr)
    {
        JSError('cJDate', oErr);
    }
}
