function previewPicture(url,x,y) {
   wwpicpop=window.open(url,'picpopup','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,width='+(x)+',height='+(y)+',resizable=no');
   top.window.wwpicpop.document.write ('<html><head><title></title></head>'+'<body leftmargin=1 topmargin=1 rightmargin=1 bottommargin=1 marginwidth=1 marginheight=1 onLoad="focus();">'+'<a title="close this window" href="javascript:window.close();"><img src="'+url+'" alt="" hspace=0 vspace=0 width="'+x+'" height="'+y+'" align="middle" border=0></a></body></html>')
};
function selProduction() {
   document.forms["myf"].submit();
}
function Validator(theForm)
{

  if (theForm.user.value.replace(/(^\s*)|(\s*$)/g, "") == "")
  {
    alert("Поле \"Ваше имя\" пустое!");
    theForm.user.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='post_msg.php';
  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 Validator1(theForm)
{

  if ((!theForm.is_content.checked) && (!theForm.is_title.checked) && (!theForm.is_user.checked) && (!theForm.is_email.checked))
  {
    alert("Необходимо уточнить критерии поиска !");
    return (false);
  }

  return (true);
}