function ValidateEmailAddress( field, sLabel )
{
	if ( ! IsEmpty( field.value ) )
		if ( String(field.value).indexOf("@") == -1 )
			return '- The ' + sLabel + ' must be a valid E-mail-Address\r\n';
	return '';

}
function ValidateNotEmpty( field, sLabel )
{
    if ( IsEmpty( field.value ) )
		return '- ' + sLabel + ' is required\r\n';
	else
		return '';
}
function ValidateNotEmpty_Radio(field, sLabel)
{
	//if there's only one radio button in the set, length doesn't work properly
	if ( IsEmpty(field.length) )
	{
		if ( field.checked == false )
			return '- [' + sLabel + '] is required\r\n';
		else
			return '';
	}
	//else loop through set of radio buttons and verify that one is checked
	else
	{
		for(var i=0; i < field.length; i++)
		{
			if ( field[i].checked == true )
				return '';
		}
		return '- [' + sLabel + '] is required\r\n';
	}
}
function ValidateNotEmpty_Checkbox( field, sLabel )
{
    if ( ! field.checked )
		return '- [' + sLabel + '] must be checked\r\n';
	else
		return '';
}
function ValidateNotEmptyOneOfTwo( field1, field2, sText1, sText2 )
{
    if ( ( field1 == '' ) && ( field2 == '' ) )
		return '- ' + sText1 + ' or ' + sText2 + ' is required\r\n';
	else
		return '';
}
//
// both empty is valid, one not empty then the other needs to be not empty
function ValidateBothNotEmpty( field1, field2, sText1, sText2 )
{
    if ( ( ( field1 == '' ) && ( field2 == '' ) ) || ( ( field1 != '' ) && ( field2 != '' ) ) )
		return '';
	else
		return '- Both ' + sText1 + ' and ' + sText2 + ' are required\r\n';
}
function ValidateNotEmpty_Radio_Other(field_radio, sOther, field_other, sLabel)
{
	for(var i=0; i < field_radio.length; i++)
	{
		if ( ( field_radio[i].checked == true ) && ( field_radio[i].value == sOther ) )
			return ValidateNotEmpty( field_other, sLabel );
	}
	return '';
}
function IsEmpty( field )
{
	var oRegExp = /^(\s*)$/;
    if ( ( field == '' ) || 
		 ( String(field) == 'undefined' ) || 
		 ( oRegExp.test(field) ) ) 
		return true;
	else
		return false;
}
function GetFieldValue(sFieldName)
{
	var sText = '';
	for(var i=0; i < document.form1.elements.length; i++)
	{
		if (document.form1.elements[i].name == sFieldName)
		{
			 sText = document.form1.elements[i].value;
		}
	}
	return sText;
}
function GetRadioVal(field)
{
	var sText = '';
	for(var i=0; i < field.length; i++)
	{
		if ( field[i].checked == true )
		{
			sText = field[i].value;
		}
	}
	return sText;
}
function ValidateInteger( field, sLabel ) 
{
	var objRegExp = /(^-?\d\d*$)/;
	var sText = '';
    if ( ! IsEmpty( field.value ) )
		if ( ! objRegExp.test(field.value))
			sText = '- [' + sLabel + '] must be numeric\r\n';
	return sText;
}