// isNumeric(String s)
// Returns true if non-empty string s consists of numbers [0..9] only.
function isNumeric(s){ 
	var re=/[^0-9]/;
	return !re.test(s);	
}

// Check whether string s is empty.
function isEmpty(s){   
	return ((s == null) || (s.length == 0))
}

// isPositiveInteger(String s)
// Returns true if s is integer > 0.
function isPositiveInteger(s){
	return (!isEmpty(s) && isNumeric(s) && ('0'!=s.charAt(0)));
}

// isNonNegativeInteger(String s)
// Returns true if s is integer >= 0.
function isNonNegativeInteger(s){
	return (0==parseInt(s) || isPositiveInteger(s));
}

// isNegativeInteger(String s)
// Returns true if s is integer < 0.
function isNegativeInteger(s){
	return (s.indexOf('-')== 0 && isPositiveInteger(s.substr(1)));
}

// isInteger(String s)
// Returns true if s is an integer.
function isInteger(s){
	return (isNonNegativeInteger(s) || isNegativeInteger(s) );
}

// isReal(String s)
// Returns true if value is a real number , except for 
// real numbers in scientific notation and  real 
// numbers with thousands' separator.  
function isReal(s){
	// if it is empty return false
	if (isEmpty(s))
		return false;
	// if there are any chars other then digits, '-', '.'
	// return false	
	var re=/[^0123456789\-\.]/;
	if (re.test(s))
		return false;
	// if '-' appears more than once or once but not at the 
	// beggining, return false	
	if (s.lastIndexOf('-') > 0)
		return false;
	// if there is more than 1 decimal point	
	if (s.indexOf('.') != s.lastIndexOf('.'))
		return false;
	// check for the appropriate format
	// [-]?[digit]+[.]?[digit]?		
	var re=/-?\d+\.?\d?/;
	return re.test(s);
}		

// isReal(String s)
// Returns true if value is a real number >0, , except for 
// real numbers in scientific notation and real 
// numbers with thousands' separator.  
function isPositiveReal(s){
	return (parseFloat(s) > 0);
}	

function produceError(Object, Message){
	alert(Message);
	Object.focus();
}
			