function Validator(theForm) {
	if (theForm.fuser.value.replace(/(^\s*)|(\s*$)/g, "") == "") {
		alert("Поле \"Ваше имя\" пустое!");
		theForm.fuser.focus();
		return (false);
	}
	
	if (theForm.subject.value.replace(/(^\s*)|(\s*$)/g, "") == "") {
		alert("Поле \"Тема сообщения\" пустое!");
		theForm.subject.focus();
		return (false);
	}

	if (theForm.content.value.replace(/(^\s*)|(\s*$)/g, "") == "") {
		alert("Поле \"Сообщение\" пустое!");
		theForm.content.focus();
		return (false);
	}

//	document.frmMsg.action='<?=$root?>forum/postmsg';
	document.frmMsg.target='';

	return (true);
}

function AddSmile(code) {
	if (code != "") {
		if (document.selection) {
			document.frmMsg.content.focus();
			
			var txtContent = document.frmMsg.content.value;
			var str = document.selection.createRange();
			
			if (str.text == "") {
				str.text = code;
			} else if (txtContent.indexOf(str.text) != -1) {
				str.text = code + str.text;
			} else {
				document.frmMsg.content.value = txtContent + code;
			}
		} else {
			document.frmMsg.content.value = document.frmMsg.content.value + code;
		}
	}
}

function AddCode(code1, code2) {
	if (document.selection) {
		document.frmMsg.content.focus();

		var txtContent = document.frmMsg.content.value;
		var str = document.selection.createRange();

		if (str.text == "") {
			str.text = code1 + code2;
		} else if (txtContent.indexOf(str.text) != -1) {
			str.text = code1 + str.text + code2;
		} else {
			document.frmMsg.content.value = txtContent + code1 + code2;
		}
	} else {
		document.frmMsg.content.value = document.frmMsg.content.value + code1 + code2;
	}
}


function Validator2(theForm) {
/*
	if (theForm.fuser.value.replace(/(^\s*)|(\s*$)/g, "") == "") {
		alert("Поле \"Ваше имя\" пустое!");
		theForm.fuser.focus();
		return (false);
	}
*/
	
	if (theForm.subject.value.replace(/(^\s*)|(\s*$)/g, "") == "") {
		alert("Поле \"Тема сообщения\" пустое!");
		theForm.subject.focus();
		return (false);
	}
	
	if (theForm.content.value.replace(/(^\s*)|(\s*$)/g, "") == "") {
		alert("Поле \"Ответ\" пустое!");
		theForm.content.focus();
		return (false);
	}
	
//	document.frmMsg.action = '<?=$root?>forum/postrep';
	document.frmMsg.target = '';
	return (true);
}

function AddSmile2(code) {
	if (code != "") {
		if (document.selection) {
			document.frmMsg.content.focus();
			
			var txtContent = document.frmMsg.content.value;
			var str = document.selection.createRange();
			
			if (str.text == "") {
				str.text = code;
			} else if (txtContent.indexOf(str.text) != -1) {
				str.text = code + str.text;
			} else {
				document.frmMsg.content.value = txtContent + code;
			}
		} else {
			document.frmMsg.content.value = document.frmMsg.content.value + code;
		}
	}
}

function AddCode2(code1, code2) {
	if (document.selection) {
		document.frmMsg.content.focus();

		var txtContent = document.frmMsg.content.value;
		var str = document.selection.createRange();
		
		if (str.text == "") {
			str.text = code1 + code2;
		} else if (txtContent.indexOf(str.text) != -1) {
			str.text = code1 + str.text + code2;
		} else {
			document.frmMsg.content.value = txtContent + code1 + code2;
		}
	} else {
		document.frmMsg.content.value = document.frmMsg.content.value + code1 + code2;
	}
}

