function check_weight (ninput, errormsg) {
/* Checks input of a box and ONLY allows numbers to be inserted */
	var stringToMatch = '';

	//WebTV requires the string to be recreated to strip out 'undefined' characters
	var Length = String(ninput.value).length;
	for (i=0; i<=Length-1; i++) {
		//alert(String(ninput.value).charAt(i));
		if (String(ninput.value).charAt(i) != 'undefined')
		{
			stringToMatch = stringToMatch + String(ninput.value).charAt(i);
		}
	}

	if (stringToMatch != 'undefined')
	{
		var re = /^[0-9]+\.?[0-9]*$/	// Create a regular expression to match every numeric character
		var txtMatch = stringToMatch.match(re);

		if (String(txtMatch) == 'null')
		{ 
			alert(errormsg);
			ninput.focus(); 
			ninput.select();
			return false;
		}
	}
	
	return true;
}

function isPosNum( inValue ) { 
	if( !isNaN( inValue ) &&  parseFloat( inValue ) >= 0 ){ 
		return true;
	}
	return false;
}
/*
This function is being used by weight_chart pages as well as others.
Need to be careful changing this function.
*/
function CheckPage( numWeek, strTranslation, strWarningMsg,  theForm ) {

		// Confirm save 
		if( numWeek != '' ) {
			if ( !confirm(strTranslation) ) {
					return false;
			}
		}

		if( !isPosNum( theForm.weight_minor.value ) ||
			( typeof( theForm.weight_major )!= "undefined" &&
				!isPosNum( theForm.weight_major.value ) ) ) {
				alert( strWarningMsg );
				return false;
		}
			
		return true;
}
