function isNumber(inputVal) {
	var checkOK = "0123456789-";
	var checkStr = "" + inputVal;
  var allValid = true;
  var allNum = "";
  
	for (var i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
	}		
		
	return allValid;
}
function checkfield(chkvalue, chktype, chkmsg) {
	if ((chkvalue.value == "") && (chktype != "select"))
	{
    if (chktype != "")
	  {			 
	    alert ("Please enter a value for the " + chkmsg + " field.");
	    chkvalue.focus();
	    return false;
    }
	}
	else
	{
		// Validate Number Fields
		if (chktype == "number")
		{
      if (!isNumber(chkvalue.value))
      {
        alert("Please enter only digit and \"-\" characters in the " + chkmsg + " field.");
        chkvalue.focus();
        return false;
      }
		} else if (chktype == "decimal") {
      if (!isDecimalNumber(chkvalue.value))
      {
        alert("Please enter only digit and \"-\" characters and only one \".\" character in the " + chkmsg + " field.");
        chkvalue.focus();
        return false;
      }			
		} else if (chktype == "radio") {
      // Radio buttons are tricky... so separate checks are done here
	    gotAvalue = false;
      for (x = 0; x < chkvalue.length; x++) {
        if (chkvalue[x].checked) {
          gotAvalue = true;
        }
      }
      if (!gotAvalue) {
			  alert ("Please enter a value for the " + chkmsg + " field.");
			  chkvalue[0].focus();
			  return false;
      }			
		} else if (chktype == "select") {
      if (chkvalue.selectedIndex == 0 ) {
	      alert ("Please enter a value for the " + chkmsg + " field.");
		    chkvalue.focus();
		    return false;
      }		
		}
	}
	return true;
}
function checkfieldnew(chkvalue, chktype, imgname, getfocusobject) {
	document.getElementById(imgname).className='hidden';
	if ((chkvalue.value == "") && (chktype != "select"))
	{
		if (chktype != "")
			{			 
				document.getElementById(imgname).className='visible';
				if(getfocusobject==0)
				{chkvalue.focus();}
				{return false;}
			}
	}
	else
	{
	// Validate Number Fields
	if (chktype == "number")
	{
      if (!isNumber(chkvalue.value))
      {
        document.getElementById(imgname).className='visible';
        if(getfocusobject==0){chkvalue.focus();}
        return false;
      }
		} else if (chktype == "decimal") {
      if (!isDecimalNumber(chkvalue.value))
      {
        document.getElementById(imgname).className='visible';
        if(getfocusobject==0){chkvalue.focus();}
        return false;
      }			
		} else if (chktype == "radio") {
      // Radio buttons are tricky... so separate checks are done here
	    gotAvalue = false;
		for (x = 0; x < chkvalue.length; x++) {
        if (chkvalue[x].checked) {
          gotAvalue = true;
        }
      }
      if (!gotAvalue) {
			  document.getElementById(imgname).className='visible';
			  if(getfocusobject==0){chkvalue[0].focus();}
			  return false;
      }			
		} else if (chktype == "select") {
      if (chkvalue.selectedIndex == 0 ) {
	        document.getElementById(imgname).className='visible';
		    if(getfocusobject==0){chkvalue.focus();}
		    return false;
		}		
		}
	}
	return true;
}

