
	
var det=navigator.userAgent.toUpperCase();
var Netscape4PC=(det.indexOf("WIN",0) != -1) && (det.indexOf("MOZILLA/4",0) != -1) && (navigator.appName == "Netscape");
var Netscape6PC=(det.indexOf("WIN",0) != -1) && (det.indexOf("NETSCAPE6",0) != -1) && (navigator.appName == "Netscape");
if (!Netscape6PC) {
	var MozillaPC=(det.indexOf("WIN",0) != -1) && (det.indexOf("GECKO",0) != -1);
} else {
	var MozillaPC=false;
}




var textAreaCountCheckFailed=false;
var textAreaCount_ErrorColor="#FFCC66";
var textAreaCount_RegColor="#FFFFFF";

	
function textAreaCountCheckBlur(inTAC) {
	if (arguments.length == 0) {
		alert("Textarea Error #02402: You must pass in the 'this' parameter to use the Textarea component\n(example: onBlur=\"textAreaCountCheckBlur('this');\" )\n\nPlease check the documentation at http://home.www.uprr.com/emp/it/hf/ricola/textarea/ for valid parameters and format.");
		return false;
	}
	if (textAreaCountCheckFailed) {
		inTAC.focus();
	}
	textAreaCountCheckFailed=false;
}
	
	

	
function textAreaCountCheck() {
	if (arguments[0]) { 
		inTA=arguments[0]; 
	} else {
		alert("Textarea Error #02399: You must pass in the 'this' parameter to use the Textarea component\n(example: onChange=\"textAreaCountCheck('this','MaxChars: 256');\" )\n\nPlease check the documentation at http://home.www.uprr.com/emp/it/hf/ricola/textarea/ for valid parameters and format.");
		return false;
	}

	var currBGColor=new String(arguments[0].style.backgroundColor);
	if (currBGColor.toUpperCase() != textAreaCount_ErrorColor.toUpperCase()) {
		if (arguments[0].style.backgroundColor != "") {
			textAreaCount_RegColor=arguments[0].style.backgroundColor;
		}
	} else {
		arguments[0].style.backgroundColor = textAreaCount_RegColor;
	}	
	
	var useMaxSoftRows=false;
	var useMaxHardRows=false;
	var useMaxRowChars=false;
	var useTotalChars=false;
	var currCols="1856";
	for (iargs=1; iargs<arguments.length; iargs++) {
		if (arguments[iargs].toString().indexOf(":") == -1) {
			alert("Textarea Error #02400: Argument #" + (iargs + 1) + " (" + arguments[iargs] + ") is not a valid parameter.\n\nPlease check the documentation at http://home.www.uprr.com/emp/it/hf/ricola/textarea/ for valid parameters and format.");
			return false;
		} else if (arguments[iargs].toString().toLowerCase().indexOf("maxchars:") != -1) { 
			var inTotalChars=parseInt(arguments[iargs].replace(/(\w+)\s*:\s*(\w+)/,"$2"));
			useTotalChars=true;
		} else if (arguments[iargs].toString().toLowerCase().indexOf("maxrowchars:") != -1) { 
			var inMaxRowChars=parseInt(arguments[iargs].replace(/(\w+)\s*:\s*(\w+)/,"$2"));
			useMaxRowChars=true;
		} else if (arguments[iargs].toString().toLowerCase().indexOf("maxhardrows:") != -1) {
			var inMaxHardRows=parseInt(arguments[iargs].replace(/(\w+)\s*:\s*(\w+)/,"$2"));
			useMaxHardRows=true;
		} else if (arguments[iargs].toString().toLowerCase().indexOf("maxsoftrows:") != -1) {
			var inMaxSoftRows=parseInt(arguments[iargs].replace(/(\w+)\s*:\s*(\w+)/,"$2"));
			useMaxSoftRows=true;
		} else if (arguments[iargs].toString().toLowerCase().indexOf("cols:") != -1) {
			currCols=parseInt(arguments[iargs].replace(/(\w+)\s*:\s*(\w+)/,"$2"));
		} else {
			alert("Textarea Error #02401: Argument #" + (iargs + 1) + " (" + arguments[iargs] + ") is not a valid parameter.\n\nPlease check the documentation at http://home.www.uprr.com/emp/it/hf/ricola/textarea/ for valid parameters and format.");
			return false;
		}		
	}	
		var currTextArea=new String(inTA.value);
		var textAreaAry=new Array();
		var i=0;
	
		if (Netscape6PC || MozillaPC) {
			textAreaAry=currTextArea.split("\n");
		} else {
			textAreaAry=currTextArea.split("\r\n");
		}
		if (useTotalChars) {
			if (currTextArea.length > inTotalChars) {
				alert("There are more than " + inTotalChars + " characters in this textarea (you have " + currTextArea.length + ").\nPlease reduce the amount of letters/numbers/spaces by " + (currTextArea.length - inTotalChars) + ".");
				textAreaCountCheckFailed=true;
				inTA.style.backgroundColor=textAreaCount_ErrorColor;
				return false;
			}
		}
		if (useMaxHardRows) {
			if (textAreaAry.length > inMaxHardRows) {
				alert("There are more than " + inMaxHardRows + " hard rows (lines seperated by hitting the \"Enter\" key) in this text box (you have " + textAreaAry.length + " hard rows).\nPlease reduce the amount of rows by " + (textAreaAry.length - inMaxHardRows) + " by removing where the \"Enter\" key was pressed.");
				textAreaCountCheckFailed=true;
				inTA.style.backgroundColor=textAreaCount_ErrorColor;
				return false;
			}
		}
		if (useMaxRowChars) {
			for (i=0; i<textAreaAry.length; i++) {
				if (textAreaAry[i].length > inMaxRowChars) {
					alert("There are more than " + inMaxRowChars + " characters (you have " + textAreaAry[i].length + ") on line #" + (i + 1) + ":\n\n\t" + textAreaAry[i] + "\n\nPlease reduce the amount of letters/numbers/spaces in that line by " + (textAreaAry[i].length - inMaxRowChars) + " or seperate the line with the \"Enter\" key.");
					textAreaCountCheckFailed=true;
					inTA.style.backgroundColor=textAreaCount_ErrorColor;
					return false;
				}
			}
		}
		
		if (useMaxSoftRows) {
			if (!Netscape4PC) {
				currCols=inTA.cols;
			}
			var totalSoftRows = Math.ceil(currTextArea.length/currCols);
			if (totalSoftRows > inMaxSoftRows) {
				alert("There are too many rows in this textarea.\nYou have " + totalSoftRows + " and it can only allow " + inMaxSoftRows + ".\nPlease remove " + (totalSoftRows - inMaxSoftRows) + " row(s).");
				textAreaCountCheckFailed=true;
				inTA.style.backgroundColor=CEFColor;
				return false;
			}
		}
		inTA.style.backgroundColor=textAreaCount_RegColor;
	}
	
function textAreaCountKeyUp(inTAC,inTotalChars) {
	var currTextArea=inTAC.value;
	if (arguments.length != 2) {
		alert("RICOLA Error #02402: Not enough parameters sent to the textAreaCountKeyUp function.  Please review documentation online at http://home.www.uprr.com/emp/it/hf/ricola/textarea/");
		return false;
	}
	inTotalChars=parseInt(inTotalChars.replace(/(\w+)\s*:\s*(\w+)/,"$2"));

	if (currTextArea.length > inTotalChars) {
		inTAC.style.backgroundColor=textAreaCount_ErrorColor;
	} else {
		var currBGColor=new String(arguments[0].style.backgroundColor);
		if (currBGColor.toUpperCase() != textAreaCount_ErrorColor.toUpperCase()) {
			if (arguments[0].style.backgroundColor != "") {
				textAreaCount_RegColor=arguments[0].style.backgroundColor;
			}
		} else {
			arguments[0].style.backgroundColor = textAreaCount_RegColor;
		}	
	}
}
	