'CONST LOADFROMSQL = "0"
'CONST LOADFROMIIS = "1"
'CONST ADDROW = "2"
'CONST SAVE = "3"
'CONST READYSTATE_COMPLETE = "complete"


''''
' isValidDate()
' Purpose: Determine if the entered by a user is a valid date.  
'          The SQL Server isDate and date conversion functions 
'          are not as forgiving as VBScript's isDate function.  
'          So, this function must be called in place of the VbScript
'          isDate function to provide better assurance that the date 
'          value will be accepted by SQL Server.
''''
FUNCTION isValidDate(strDateValue)

	isValidDate = true
	
	if not isDate(strDateValue) then
		isValidDate = false
	elseif getCharCount(strDateValue, "/") < 2 and getCharCount(strDateValue, "-") < 2 then
		isValidDate = false	
	elseif Year(strDateValue) > 9999 then
	    isValidDate = false
	elseif Year(strDateValue) > 99 and Year(strDateValue) < 1753 then
	    isValidDate = false
	end if

END FUNCTION

''''
' getCharCount(strValue)
' Purpose: Return a count of the specified character found in the specified string
''''
FUNCTION getCharCount(strValue, strChar)
DIM intDelimCount

	arrayDate = split(strValue, strChar)
	intDelimCount = uBound(arrayDate)
	getCharCount = intDelimCount

END FUNCTION

''''
' validDateRange(strStartDate, strEndDate)
' Purpose:  Validate that the end date is defined to occur after the start date
''''
FUNCTION validDateRange(strStartDate, strEndDate)
DIM dtmStartDate, dtmEndDate

	dtmStartDate = dateValue(strStartDate)
	dtmEndDate = dateValue(strEndDate)
	
	if (dtmStartDate > dtmEndDate) then
		validDateRange = false
	else
		validDateRange = true
	end if
	
END FUNCTION

''''
' getFormattedDate()
' Purpose:  Accept a date value and return the date 
'           value in a MM/DD/YYYY format.
FUNCTION getFormattedDate(strDateValue)
DIM strYear, strDay, strMonth

	strMonth = Month(strDateValue)
	if strMonth < 10 then
		strMonth = CSTR("0" & strMonth)
	end if
	strDay = Day(strDateValue)
	if strDay < 10 then
		strDay = CSTR("0" & strDay)
	end if
	strYear = Year(strDateValue)
	getFormattedDate = strMonth & "/" & strDay & "/" & strYear

END FUNCTION

function SubmitPage(frm, txt, page, action)
	'window.alert("tt")
	window.event.returnValue = false
	dim obj
	set obj = document.all(frm)
	obj.all(txt).value = action
	obj.action = page
	obj.submit()
end function
