
var ns6=document.getElementById&&!document.all?1:0

var head="display:''"
var folder=''

function bl_r_copy() {
	rf = document.blacklist_add_form.reason_full.value;
	r = document.blacklist_add_form.reason.value;
	rf = r;
}

function show(id) {
	document.getElementById(id + '_1').style.display = 'none';
	document.getElementById(id + '_2').style.display = 'block';
	}
	
function hide(id) {
	document.getElementById(id + '_2').style.display = 'none';
	document.getElementById(id + '_1').style.display = 'block';
	}

function HText() {
	to_show_t=prompt('Введите фразу, показывающую скртытый текст','показать');
	to_hide_t=prompt('Введите фразу скрываущую скрытый текст','скрыть')
	id="";
	for(i=0;i<10;i++) {
		n=Math.floor(10*Math.random()+1);
		id+=n;
	}
	main.mtext.value+="[htext,"+id+","+to_show_t+","+to_hide_t+"]ТУТ ВВЕДИТЕ СКРЫТЫЙ ТЕКСТ[/htext]";

}

function add_sm(smile) {

	document.main.mtext.value += smile;
	
}

function pname(name){
  if (name != '') document.main.mtext.value = document.main.mtext.value + "[b]" + name + "[/b]\n";

}
function answer(id){
	document.answer_f.ans_id.value=id;
}

function CheckAnswer() {
	if (answer_f.ans_id.value == "" || answer_f.ans_id.value == " ") {
		alert ("Комментарий не выбран!!!");
		return false;
		}
	else if(answer_f.answer.value == "" || answer_f.answer.value == " ") {
		alert ("Заполните поле ответа!!!");
		return false;
		}
	else {
		return true;
		}
	}
function CheckPub() {
	if (main.mtext.value == "" || main.mtext.value == " ") {
		alert ("Интересно, а что вы собрались публиковать!?!?!?");
		return false;
		}
	else {
		return true;
		}
	}
	
function CheckComm() {
	if (main.mtext.value == "" || main.mtext.value == " ") {
		alert ("Заполните поле комментария!!!");
		return false;
		}
	else {
		return true;
		}
	}

function CheckQuiz() {
	i=0;
	er=0;
	while(i<11) {
		ans="quiz.q_"+i;
		if(ans.value=="" || ans.value==" ") {
			er=1;
			}
		i++;
		}
	if(quiz.q_1.value=="1") {
		er=1;
		}
	if(er==1) {
		alert("Вы ответили не на все вопросы викторины!!!");
		return false;
		}
	else {
		return true;
		}
	}


function expandit(curobj){
	folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style
	if (folder.display=="none")
		folder.display=""
	else
		folder.display="none"
	}

////////
function vbcode(form,vbcode,prompttext) {
		inserttext = prompt(prompttext+"\n["+vbcode+"]Текст[/"+vbcode+"]","");
			document.com.comment.value += "["+vbcode+"]"+inserttext+"[/"+vbcode+"] ";
}
if (document.selection||document.getSelection) {Q=true} else {var Q=false}
var txt=''

function copyQ() {
txt=''
if (document.getSelection) {txt=document.getSelection()}
else if (document.selection) {txt=document.selection.createRange().text;}
txt='[q]'+txt+'[/q]\n'
}
function pasteQ() {
document.main.mtext.value+=txt;
}


/////////////////////////////////////////////////
// UNIVERSAL BULLETIN BOARD CODE INTERFACE v2.1
// By Mark Plachetta (astroboy@zip.com.au)
/////////////////////////////////////////////////

/////////////////////////////
// Basic browser detection
//
  var ie = (document.all) ? 1 : 0;
  var nn = (document.layers) ? 1 : 0;
  var n6 = (window.sidebar) ? 1 : 0;

  function ubbcInit() {
    form = document.forms["main"];
    if (window.RegExp) {
      var tempStr = "a";
      var tempReg = new RegExp(tempStr);
      if (tempReg.test(tempStr)) { reSupport = 1; }
    }
  }


/////////////////////////////
// Code inserter
//
  function ubbCode(code) {
    if (form["mtext"].createTextRange && form["mtext"].caretPos) {
      var caretPos = form["mtext"].caretPos;
      caretPos.text = code;
    } else { form["mtext"].value += code; }
    form["mtext"].focus();
  }

/////////////////////////////
// Misc utils
//
  function storeCaret(el) {
    if (el.createTextRange) {
      el.caretPos = document.selection.createRange().duplicate();
    }
  }

  function getText() {
      return ((form["mtext"].createTextRange && form["mtext"].caretPos) ? form["mtext"].caretPos.text : '');
  }

  function isUrl(text) {
    return ((text.indexOf('.') > 7) &&
            ((text.substring(0,7) == 'http://') ||
            (text.substring(0,6) == 'ftp://')));
  }

  function isEmail(str) {
    if (!reSupport) { return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); }
    var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
    var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
    return (!r1.test(str) && r2.test(str));
  }

    function returnFocus() {
    setTimeout('form["mtext"].focus()',10);
  }

  function resetList(list) {
    setTimeout('form["'+list+'"].options[0].selected = true',10);
  }



  function winStat(txt) {
    window.status = txt;
    return true;
  }

  function removeElement(array,value) {
    array = array.split(',');
    for (i = 0; i < array.length; i++) {
      if (array[i] == value) { var pos = i; break; }
    }
    for (i = pos; i < (array.length-1); i++) {
      array[i] = array[i + 1];
    }
    array.length = array.length - 1;
    return array.join(',');
  }


/////////////////////////////
// Indivdual code types
//
  var openTags = new Array('');
  var closedTags = new Array('dummy','b','i','u','s','code','q','me','list');
  function ubbBasic(code) {
    var text = getText();
    if (text) {
      code = '[' + code + ']' + text + '[/' + code + ']';
      ubbCode(code);
    } else {
      if (openTags.join(',').indexOf(','+code) != -1) {
        var tag = '[/' + code + ']';
        openTags = removeElement(openTags.join(','),code).split(',');
        closedTags[closedTags.length] = code;
      } else {
        var tag = '[' + code + ']';
        closedTags = removeElement(closedTags.join(','),code).split(',');
        openTags[openTags.length] = code;
      } ubbCode(tag);
    }
  }

  function ubbFont(list) {
    var attrib = list.name.substring(1,list.name.length);
    var value = list.options[list.selectedIndex].value;
    if (value && attrib) {
      var code = '[' + attrib + '=' + value + ']' + getText() + '[/' + attrib + ']';
      ubbCode(code);
    }
    resetList(list.name);
  }

  function ubbFont2(list) {
    var value = list.options[list.selectedIndex].value;
    if (value) {
      var code = '<' + value + '>' + getText() + '</' + value + '>';
      ubbCode(code);
    }
    resetList(list.name);
  }
  function ubbAlign(align) {
    if (!align) { return; }
    code = '[' + align + ']' + getText() + '[/'+align+']';
    ubbCode(code);
    resetList("talign");
  }


  function ubbList(size) {
    var text = getText();
    if (!size && !text) { ubbBasic('list'); }
    else if (!size && text && reSupport) {
      var regExp = /\n/g;
      text = text.replace(regExp,'\n[*]');
      var code = '[list]\n[*]' + text + '\n[/list]\n';
      ubbCode(code);
    } else {
      if (text) { text += '\n'; }
      var code = text + '[list]\n';
      for (i = 0; i < size; i++) { code += '[*]\n'; }
      code += '[/list]\n';
      ubbCode(code);
      resetList("quicklist");
    }
  }

  function ubbListItem() {
    var code = '[*]' + getText();
    ubbCode(code);
  }

  function ubbHref() {
    var url = 'http://'; var desc = '';
    var text = getText();
    if (text) {
      if (isUrl(text)) { url = text; }
      else { desc = text; }
    }
    url = prompt('Введите ссылку:',url) || '';
    desc = prompt('Описание ссылки:',desc) || url; 
	if (!isUrl(url)) { returnFocus(); return; }
    var code = '[url=' + url + ']' + desc + '[/url]';
    ubbCode(code);
  }

  function ubbEmail() {
    var email = ''; var desc = '';
    var text = getText();
    if (text) {
      if (isEmail(text)) { email = text; }
      else { desc = text; }
    }
    email = prompt('Введите E-mail адрес:',email) || '';
    desc = prompt('Введите описание:',desc) || email; 
	if (!isEmail(email)) { returnFocus(); return; }
    var code = '[email=' + email + ']' + desc + '[/email]';
    ubbCode(code);
  }

  function ubbImage() {
    var text = getText();
    var url = (text && isUrl) ? text : prompt("\nВведите URL картинки:","http://") || ""; 
	if (!url) { return; }
    var code = "[IMG]" + url + "[/IMG]";
    ubbCode(code);
  } 
