 
function requiredChk(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = '#FF6633'; 
        error = "The required field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;  
}

function maxChk(fld,max){
	var error = "";

	if (fld.value.length > max )	{
		fld.style.background = '#FF6633';
		error = "The field contains value over the limit.\n";
	}else {
        fld.style.background = 'White';
    }
	return error;
}

function limitsChk(fld,min,max) {
//document.write(isNaN(min))
	var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = '#FF6633'; 
        error = "You didn't enter a value.\n";
    } else if ((fld.value.length < min) || (fld.value.length > max)) {
        fld.style.background = '#FF6633'; 
        error = "The field is the wrong length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#FF6633'; 
        error = "The field contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function typeChk(fld,datatype) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    

  /* if (fld.value == "") {
        error = "You didn't enter a valid value.\n";
        fld.style.background = '#FF6633';
    } else */if (isNaN(parseInt(stripped))) {
        error = "The field contains illegal characters.\n";
        fld.style.background = '#FF6633';
    } /*else if (!(stripped.length == 10)) {
        error = "The phone number is the wrong length. Make sure you included an area code.\n";
        fld.style.background = 'Yellow';
    }*/else {
        fld.style.background = 'White';
    }
    return error;
}

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

function test(param)
{
	document.write(param);
}
