/*
	function:	encodes / decodes text string (passed from <textarea>) so it
						displays correctly - Inserts the new lines and breaks.
						This is used in conjunction with form / database entry for textfields
						to ensure correct entry and display of data entered.
	required:	string
	returns:	string
	code in holding page:
								strText = encode(strText);
						or	strText = decode(strText);
*/
//--------------------------
//-- encode message for querystring
//-- this then adds the string to a session variable
function encode(msgText){
	t="";
	for(i=0;i<msgText.length;i++){
		ch=msgText.charAt(i);
		if(ch=="/") t += "//"
		//if(ch == " ") t += "/b"
		else if(ch == "\n") t += "/n"
		else if(ch == "\r") t += "/r"
		else t += ch;
	}
	return t
}
//--------------------------
//-- decode message for desplay in textarea
function decode(msgText){
	t="";
	for(i=0;i<msgText.length;i++){
		ch=msgText.charAt(i);
		if(ch=="/"){
			++i;
			if(i<msgText.length){
				ch=msgText.charAt(i);
				if(ch == "/") t += ch
				else if(ch == "n") t += "\n"
				else if(ch == "r") t += "\r"
			}
		}else	t += ch;
	}
	return t
}
//--------------------------