function paste(name){ 
var input=document.ANSWER_FORM.body
input.value+="[b]"+name+"[/b]\n";
}

function paste2(name){ 
var input=document.ANSWER_FORM.body
if (name!="") input.value+="[i]"+name+"[/i]\n"
}

function SetReplyForm(enablefocus){
/*
// NOT IMPLEMENTED YET
if (enablefocus) {document.ANSWER_FORM.Name.focus()}
var testUserName = getCookie("Login")
var testPassword = getCookie("Password")
if ((document.cookie)&&(testUserName != null)) {
	document.ANSWER_FORM.UserName.value = testUserName
	if (testPassword!=null) {document.REPLIER.Password.value = testPassword}
	if (enablefocus) {document.ANSWER_FORM.ReplyMessage.focus()}
	}
if (getCookie("DisableSmilies") == "yes") {document.ANSWER_FORM.DisableSmilies.checked = true}

if ((!enablefocus)&&(navigator.appVersion.indexOf("MSIE")!= -1)){ 

var i=1;
while (document.all("tbl"+i) != null) {document.all("tbl"+i).style.tableLayout="fixed"; i++}

var testform_cookie = getCookie('ReplyForm')
if (testform_cookie!=null){
form_cookie=testform_cookie.split("&");
if ((form_cookie[0] != null)&&(form_cookie[0] >=20)&&(form_cookie[0]<=250)) {document.REPLIER.ReplyMessage.cols=form_cookie[0]} else {document.REPLIER.ReplyMessage.style.width="100%"};
if (form_cookie[1] != null) {document.REPLIER.ReplyMessage.rows=form_cookie[1]}
if (form_cookie[2] != null) {document.REPLIER.ReplyMessage.style.fontSize=form_cookie[2]}
if (form_cookie[3] != null) {document.REPLIER.ReplyMessage.accessKey=form_cookie[3]}
} else {document.REPLIER.ReplyMessage.style.width="100%"}
}
*/

switch(navigator.appName) {
   case "Microsoft Internet Explorer":
      Key = "event.ctrlKey && event.keyCode == 13";
      document.onkeydown = GetKey;
      break;
   case "Netscape":
      Key = "(e.modifiers == 2 && e.which == 10) || (e.ctrlKey && e.which == 13)";
      document.captureEvents(Event.KEYDOWN);
      document.onkeydown = GetKey;
      break;
}
}

function GetKey(e) {
if (eval(Key)) {
	document.ANSWER_FORM.submit();
	SubmitOnce(document.ANSWER_FORM);
}
}


function SetLoginForm(){
/*var testUserName = getCookie("UserName")
var testPassword = getCookie("Password")
if ((document.cookie)&&(testUserName != null)) {
	document.LoginForm.UserName.value = testUserName
	if (testPassword!=null) {document.LoginForm.Password.value = testPassword}
	}
*/
}

function ReplyFormValidator(){
var max = 42000;
if (document.ANSWER_FORM.body.value.length == 0){
  alert('Напишите, пожалуйста, что-нибудь!');
  return false;
}
if (document.ANSWER_FORM.body.value.length > max){
  alert("Размер Вашего сообщения превышает максимум на "+(document.ANSWER_FORM.body.value.length-max)+" символов! Пожалуйста, уменьшите его, разбив на несколько частей!");
  return false;
}
if (document.ANSWER_FORM.name.value.length == 0){
  alert('Вы забыли указать своё имя!');
  return false;
}
document.ANSWER_FORM.Submit();
document.ANSWER_FORM.Submit.disabled=true;
return true;
}


function LoginFormValidator(){
if ((document.LoginForm.UserName.value.length == 0)||(document.LoginForm.Password.value.length == 0)){
  alert('Вы заполнили не все поля! Укажите своё имя и пароль!')
  return false;
 }
return true;
}

function SubmitOnce(theform){
if (theform.target=="preview") {return}
if (document.all||document.getElementById){
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") {tempobj.disabled=true}
}
}
}

function getCookie(name) {
var prefix = name + "="
var StartIndex = document.cookie.indexOf(prefix)
if (StartIndex == -1)
return null
var EndIndex = document.cookie.indexOf(";", StartIndex + prefix.length)
if (EndIndex == -1)
EndIndex = document.cookie.length
return unescape(document.cookie.substring(StartIndex + prefix.length, EndIndex))
}

