function alertBox (vField, vMessage, vType ) {
	if ( vMessage == "null" ) return;
		alert (vMessage )
	if ( vType == "radio" ) return;
	if ( vType == "checkbox" ) return;
	if ( vType == "text" ) {
		vField.focus();
		vField.select();
	} else {
		vField.focus();
	}
	return;
	}

function failNull ( vField, vMessage, vType) {
	theValue = getFieldValue (vField, vType);
	if ( theValue == "" ) {
		alertBox ( vField, vMessage, vType );
		return ( true );
	}
	trimField = trimBlanks( theValue, " " );
	if ( trimField =="" ) {
		alertBox ( vField, vMessage, vType );
		return ( true );
	}
	return ( false );
	}

function failContains( vField, vValue, vMessage, vType ) { 
                     theValue = getFieldValue (vField, vType); 
                     var count = ( failContains.arguments.length == 6 ) ? vValue.length-1 : 0; 
                     var value = ( failContains.arguments.length == 6 ) ? vValue.substring(0,1) : vValue; 

                     //fail the submit if the field contains the value(s)...
                     for ( i = 0; i <= count; i++) {
                     if ( theValue.indexOf(value) > -1) { 

                     alertBox ( vField, vMessage, vType ); 

                     return (true); 

                     }
                     value = ( count > 0 ) ? vValue.substring(i+1,i+2) : vValue;
                     } 

                     //otherwise continue...
                     return (false)
                     }

function getFieldValue ( theField, vType ) { 

//this function will return the field value (or value list) based on the element type 

theValue = ""; 
sep = ""; 
hits = 0; 

//text is the user-entered value as a string
if ( vType == "text" ) return ( theField.value ); 

//textarea is the user-entered value as a string array of one element
if ( vType == "textarea" ) return ( theField[0].value ); 

//select is an array of selection pointers to an array of strings representing the choices
if ( vType == "select" ) { 

for ( i = 0; i < theField.options.length; i++ ) {
if ( theField.options[i].selected ) theValue += theField.options[i].text 
} 
return ( theValue );
}


//checkboxes & radio buttons are not so simple
if ( vType == "checkbox" || vType == "radio" ) { 

if ( theField.value == null ) { 

//if we're here, we are validating a radio button or a nn multi-element checkbox 

for ( i = 0; i < theField.length; i++ ) { 
if ( theField[i].checked ) { 
hits++; 
if ( hits > 1 ) {
sep = "; ";
} 
theValue += sep + theField[i].value; 
} 
}
} 
return ( theValue );

} else { 

//if we are here, must be an ie checkbox, or nn with a one-element checkbox") 

if ( navigator.appName == "Microsoft Internet Explorer" ) { 

//ie. return some data so we can validate on the server; 
return ("can't validate on client")
} 

//nn one-element checkbox, see if its checked ...
if (theField.checked ) { 
return ( theField.value ); 

} else {
return ( "" ); 
} 
} 
}

function trimBlanks ( theLine, repChar ) {
trimString="";
	for ( i = 0; i < theLine.length; i++) {
	theChar=theLine.substring( i, i+1);
	if ( theChar == " ") {
		trimString += repChar
		} 
	else 
		{
		trimString+=theLine.substring ( i, i+1);
		}
	}
		return (trimString);	
	}