/* v1.0.4 */
function fvMaxLength(stop,obj,orEmpty,value,exclude,passFailID)
{
	if (fvStop) {
		return false;
	}
	var i;
	var notValid=false;
	var objType;
	objType=fvObjType(obj);
	if (objType=='text-array' || objType=='password-array' || objType=='textarea-array' || objType=='select-one-array' || objType=='select-multiple-array') {
		for (i=0; i<obj.length; i++) {
			if (objType=='select-multiple-array') {
				for (j=0; j<obj[i].length; j++) {
					if (obj[i][j].selected && fvCheckMaxLength(obj[i][j].value,value,exclude,orEmpty)) notValid=true;
				}
			}
			if (objType=='select-one-array') {
				if (fvCheckMaxLength(fvObjValue(obj[i]),value,exclude,orEmpty)) notValid=true;
			}
			else {
				if (fvCheckMaxLength(obj[i].value,value,exclude,orEmpty)) notValid=true;
			}
		}
	}
	else if (objType=='var') {
		if (fvCheckMaxLength(obj,value,exclude,orEmpty)) notValid=true
	}
	else if (objType=='var-array') {
		for (i=0; i<obj.length; i++) {
			if (fvCheckMaxLength(obj[i],value,exclude,orEmpty)) notValid=true
		}
	}
	else if (objType=='radio' || objType=='checkbox') {
		for (i=0; i<obj.length; i++) {
			if (obj[i].checked && fvCheckMaxLength(obj[i].value,value,exclude,orEmpty)) notValid=true;
		}
	}
	else if (objType=='select-multiple') {
		for (j=0; j<obj.length; j++) {
			if (obj[j].selected && fvCheckMaxLength(obj[j].value,value,exclude,orEmpty)) notValid=true;
		}
	}
	else if (objType=='select-one') {
		if (obj.length>0) {
			if (fvCheckMaxLength(fvObjValue(obj),value,exclude,orEmpty)) notValid=true;
		}
		else {
			if (fvCheckMaxLength('',value,exclude,orEmpty)) notValid=true;
		}
	}
	else  {
		if (fvCheckMaxLength(obj.value,value,exclude,orEmpty)) notValid=true;
	}
	if (stop) fvStop=notValid;
	if (passFailID!='') fvSetPassFail(passFailID,notValid);
	return notValid;
}

function fvCheckMaxLength(objValue,maxValue,exclude,orEmpty)
{
//Note: returns true if invalid
	if (typeof objValue=='undefined') {
		return orEmpty;
	}
	else if (orEmpty && objValue=='') {
		return false;
	}
	else if (isNaN(maxValue) || maxValue=='') {
		return false;
	}
	else if (exclude) {
		if (objValue.length-maxValue>=0) return true
	}
	else {
		if (objValue.length-maxValue>0) return true
	}
}
