function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function isPrice(str) { 
	isprice = /^\d+\.\d{2}/; 
	return isprice.test( str ); 
}

function ValNum(val)
{
	  var strPass = val.value;
	  var strLength = strPass.length;
	  var lchar = val.value.charAt((strLength) - 1);
	  var cCode = CalcKeyCode(lchar);

	  if (cCode < 48 || cCode > 57 ) {
	    var myNumber = val.value.substring(0, (strLength) - 1);
	    val.value = myNumber;
	  }
	  return false;
}

//msg - error message to show
//fld - field in which the error message will be shown
function ValMaxAge(age, max, msg, fld) {
	if (age.value>max) {
		age.value=max;
		fld.value=msg;
		age.focus();
		return false;
	}
	return true;
}

function ValReq(val, msg, fld) {
	if (val.value==null || val.value=='') {
		fld.value = msg
		return false;
	}
	return true;
}

function checkEmpty(fld) {
	if (fld.length) return true;
	else return false;
	
}

function SupplPrice(id) {
	if (document.getElementById(id).checked) return document.getElementById(id).value;
	else return 0;
}
