//Jumps directly to a specified page number
function jumpTo( page )
{
	document.forms[1].nextpage.value = page
	document.forms[1].clicktype.value = 'jump'
	document.forms[1].submit()
}

/***************************************************************/

//Executes the submission script and disables the buttons
function execute( obj, nextpage )
{
	document.forms[1].nextpage.value = parseInt(document.forms[1].savepage.value) + nextpage
	document.forms[1].clicktype.value = obj.value

	if ( document.forms[1].Save )
		document.forms[1].Save.disabled = true
	if ( document.forms[1].Proceed )
		document.forms[1].Proceed.disabled = true
		
	obj.value = 'Please Wait'
}

/***************************************************************/

//Checks to see if a string is a valid number, used by isDate
function isNum( string )
{
	if ( string == '' || string == null )
		return false

	for(i = 0; i < string.length; i++)
		if ( ! string.charAt(i).match(/[0-9]/) )
			return false
	return true
}

/***************************************************************/

//Checks for a valid date
function isDate( obj )
{
	if ( obj.value != '' )
	{	
		var dateArray
		
		if ( obj.value.indexOf('-') > 0 )
			dateArray = obj.value.split('-')
		else
			dateArray = obj.value.split('/')
		
		if ((( isNum(dateArray[0]) ) && ( isNum(dateArray[1]) ) && ( isNum(dateArray[2]) )))
		{
			var month = dateArray[0] - 1
			var day = dateArray[1]
			var year = dateArray[2]
			var date = new Date( year, month, day )

			if (( date.getMonth() == month ) && ( date.getDate() == day ) && ( date.getFullYear() == year ))
				return true	//Validation success
		}
	}
	
	alert( 'Date format should be MM/DD/YYYY' )
	obj.focus()
	return false //Invalid date
}

/***************************************************************/

//Checks for a valid date that is two weeks in the future
function isTwoWeekDate( obj )
{
	if ( obj.value != '' )
	{	
		var dateArray
		
		if ( obj.value.indexOf('-') > 0 )
			dateArray = obj.value.split('-')
		else
			dateArray = obj.value.split('/')
		
		if ((( isNum(dateArray[0]) ) && ( isNum(dateArray[1]) ) && ( isNum(dateArray[2]) )))
		{
			var month = dateArray[0] - 1
			var day = dateArray[1]
			var year = dateArray[2]
			var date = new Date( year, month, day )
			var today = new Date()
			var twoweeks = new Date(today.valueOf() + (13*24*60*60*1000))

			if (( date.getMonth() == month ) && ( date.getDate() == day ) && ( date.getFullYear() == year ))
			{
				if (date.valueOf() >= twoweeks.valueOf())
					return true	//Validation success
			}
		}
	}
	
	alert( 'Date format should be MM/DD/YYYY and must be at least two weeks in the future.' )
	obj.focus()

	return false //Invalid date
}

/***************************************************************/

//Checks for a valid date that is after the holiday
function isAfterHolidayDate( obj )
{
	if ( obj.value != '' )
	{	
		var dateArray
		
		if ( obj.value.indexOf('-') > 0 )
			dateArray = obj.value.split('-')
		else
			dateArray = obj.value.split('/')
		
		if ((( isNum(dateArray[0]) ) && ( isNum(dateArray[1]) ) && ( isNum(dateArray[2]) )))
		{
			var month = dateArray[0] - 1
			var day = dateArray[1]
			var year = dateArray[2]
			var date = new Date( year, month, day )
			var holiday = new Date( '2007', '00', '08')
			if (date.valueOf() >= holiday.valueOf())
			{
				return true	//Validation success
			}
		}
	}
	
	alert( 'Campus Visits are not available before January 8, 2007.' )
	obj.focus()

	return false //Invalid date
}

/***************************************************************/

//Checks for a valid date that is one week in the future
function isOneWeekDate( obj )
{
	if ( obj.value != '' )
	{	
		var dateArray
		
		if ( obj.value.indexOf('-') > 0 )
			dateArray = obj.value.split('-')
		else
			dateArray = obj.value.split('/')
		
		if ((( isNum(dateArray[0]) ) && ( isNum(dateArray[1]) ) && ( isNum(dateArray[2]) )))
		{
			var month = dateArray[0] - 1
			var day = dateArray[1]
			var year = dateArray[2]
			var date = new Date( year, month, day )
			var today = new Date()
			var oneweek = new Date(today.valueOf() + (6*24*60*60*1000))

			if (( date.getMonth() == month ) && ( date.getDate() == day ) && ( date.getFullYear() == year ))
			{
				if (date.valueOf() >= oneweek.valueOf())
					return true	//Validation success
			}
		}
	}
	
	alert( 'Date format should be MM/DD/YYYY and must be at least one week in the future.' )
	obj.focus()

	return false //Invalid date
}

/***************************************************************/

//Checks for a valid date that is ten days in the future
function isTenDaysDate( obj )
{
	if ( obj.value != '' )
	{	
		var dateArray
		
		if ( obj.value.indexOf('-') > 0 )
			dateArray = obj.value.split('-')
		else
			dateArray = obj.value.split('/')
		
		if ((( isNum(dateArray[0]) ) && ( isNum(dateArray[1]) ) && ( isNum(dateArray[2]) )))
		{
			var month = dateArray[0] - 1
			var day = dateArray[1]
			var year = dateArray[2]
			var date = new Date( year, month, day )
			var today = new Date()
			var oneweek = new Date(today.valueOf() + (10*24*60*60*1000))

			if (( date.getMonth() == month ) && ( date.getDate() == day ) && ( date.getFullYear() == year ))
			{
				if (date.valueOf() >= oneweek.valueOf())
					return true	//Validation success
			}
		}
	}
	
	alert( 'Date format should be MM/DD/YYYY and must be at least ten days in the future.' )
	obj.focus()

	return false //Invalid date
}

/***************************************************************/

//Checks to see if a textbox is empty
function isNotEmpty( obj )
{
	if ( obj.value == '' )
	{
		alert( 'A required input field must be filled in before proceeding!' )
		obj.focus()
		return false
	}
	return true	//Validation success
}

/***************************************************************/

//Checks to see if a selection was made for a drop-down list
function hasSelection( obj )
{
	if ( obj.selectedIndex == 0 )
	{
		alert( 'A required drop-down list selection must be made before proceeding!' )
		obj.focus()
		return false
	}
	return true	//Validation success
}

/***************************************************************/

//Checks to see if input is a valid number
function isNumber( obj )
{
	var number = obj.value
	var pass = true
	
	if ( number == '' || number == null )
		pass = false
	else
	{
		for(i = 0; i < number.length; i++)
			if ( ! number.charAt(i).match(/[0-9]/) )
				pass = false
	}
	
	if ( pass )
		return true	//Validation success
	else
	{
		alert('A required numeric input has not been filled in correctly!')
		obj.focus()
		return false
	}
}

/***************************************************************/

//Checks to see if input is a valid word
function isWord( obj )
{
	var string = obj.value
	var pass = true
	
	if ( string.value == '' || string.value == null )
		pass = false
	else
	{
		string = string.toUpperCase()
		for(i = 0; i < string.length; i++)
			if ( ! string.charAt(i).match(/[A-Z]/) )
				pass = false
	}
	
	if ( pass )
		return true	//Validation success
	else
	{
		alert('A required alphabetic input has not been filled in correctly!')
		obj.focus()
		return false
	}
}

/***************************************************************/

//Checks to see if radio button group has a selection
function hasRadioCheck( obj )
{
	var check = false
	
	for (i=0; i < obj.length; i++)
	{
		if (obj[i].checked)
		{
			check = true
			break
		}
	}
	
	if ( check )
		return true	//Validation success
	else
	{
		alert('A required radio-button selection must be made before proceeding!')
		obj[0].focus()
		return false
	}
}

/***************************************************************/

//Checks a textarea to see if it exceeds a maximum limit
function checkLength( obj, max )
{
	if ( obj.value.length > max )
	{
		alert('Entered text exceeds ' + max + ' characters. Please trim the text.')
		obj.focus()
		return false
	}
	return true	//Validation success
}

/***************************************************************/

//Checks a checkbox to see if it had been checked
function isChecked( obj )
{
	if ( obj.checked )
		return true	//Validation success
	else
	{
		alert('A required checkbox must be checked before proceeding!')
		obj.focus()
		return false
	}
}

