function ToolsCryptStr() {
 
}
//############################3
function setFocus(id) { document.first.text1.select(); } 
//############################3
function newWin(w,h,url) {
 var win=window.open(url,'w', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+w+',height='+h);
 win.focus();
 return false;
}
//############################3
// Открытие ссылки без реферера
function openEx(url) {
//  url = escape(url);
//  url = encodeURIComponent(url);
  url=url.replace('/\"/','');

//alert(url);

  w = window.open();
  w.document.write('<meta http-equiv="refresh" content="0;url='+url+'">');
  w.document.close();

//  w.location=url;

  return false;
}
//############################3
function Go(url) {
 window.location=url;
}
//############################3
function getSelectedText1() {
 if (window.getSelection) {selection = window.getSelection();}
    else {selection = document.selection.createRange().text;}
 var selection = new String(selection);
 return selection;
}

function do_quote(name) {
    if (window.getSelection) {selection = window.getSelection();}
    else {selection = document.selection.createRange().text;}
    var selection = new String(selection);
    if (selection.length>0) {
	var textarea=document.getElementById('msg_text');
	if (! textarea) { return null; }
        if (name) name='="'+name+'"';
	textarea.value += '[quote'+name+']\n'+selection+'[/quote]\n';
	textarea.focus();
    } else {
      alert("Для цитирования выделите мышкой требуемую часть текста и щелкните по кнопке \"Цитата\"");
    }
    return false;
}

function SetAllCheckBoxes(FormName, FieldName)
{
    if(!document.forms[FormName])
	return;
    var objCheckBoxes = document.forms[FormName].elements[FieldName];
    if(!objCheckBoxes)
	return;
    var CheckValue=document.forms[FormName].elements['all_'+FieldName].checked;
// alert(CheckValue);
    var countCheckBoxes = objCheckBoxes.length;
    if(!countCheckBoxes)
	objCheckBoxes.checked = CheckValue;
    else
	// set the check value for all check boxes
	for(var i = 0; i < countCheckBoxes; i++)
	    objCheckBoxes[i].checked = CheckValue;
//	    if (objCheckBoxes[i].checked) objCheckBoxes[i].checked = false;
//			    else objCheckBoxes[i].checked = true;
}

function areaReSize (id,num) {
// var elem=document.getElementById(id);
 var iframe = document.getElementById(XBB.iframe_id).contentWindow;
 var elem=iframe.document.forms.xbb.xbb_textarea;
 if (!elem) alert('Invalid textarea id ('+id+')');
 var rows = elem.rows;
 elem.rows = parseInt(rows) + parseInt(num);
 return false;
}

// **************************
var IE=0;
var MZ=0;
var OP=0;
 
function hasSelectedFeature()
{
    if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1
     && navigator.userAgent.indexOf("Windows") != -1) {
        IE = 1;
        return true;
    }
    if (navigator.userAgent.indexOf("Mozilla") != -1) {
        MZ = 1;
        return true;
    }
    if (navigator.userAgent.indexOf("Opera") != -1) {
        OP = 1;
        return true;
    }
    return false;
}
 
function getSelectedText()
{
    if (IE || OP){
        return document.selection.createRange().text;
    }
    if (MZ) {
        var s;
        if (typeof(window.getSelection) == "function") {
            s = window.getSelection().toString();
        } else {
           s = document.getSelection();
        }
        return s;
    }
    return "";
}
 
function Insert(name)
{
    var txt=getSelectedText1();
// alert(txt);
    var iframe = document.getElementById(XBB.iframe_id).contentWindow;
    var input = iframe.document.forms.xbb.xbb_textarea;
    if (name != "") {
	input.value += '[quote][b]'+name+':[/b]\n'+txt+'[/quote]\n\n';
//        input.value = input.value + "[quote]" + txt + "[/quote]\n";
        //alert(name);
    }
}

