﻿
function isNull( obj ) {
	return ( typeof( obj ) == 'object' && !obj );
}



//Check a value to see if it's not empty... optionally focuses and selects
// pass null to toFocus to avoid said focusing (like if you're checking a
// hidden input element's value... hidden input elements can't receive focus
// and unfortunately, a javascript error in the middle of a form validation
// process kills the process and FORCES SUBMISSION OF THE FORM, when in fact
// it should PREVENT submission of the form

// returns true if the value is good to go, false if you should abandon form
// submission
function ValidateElement( value, errorMsg, toFocus ) {
	if( value == "" ) {
		alert( errorMsg );
		
		if( !isNull( toFocus ) ) {
			toFocus.focus();
			toFocus.select();
		}
		
		return false;
		
	}
	
	return true;
}