function okienko(sciezka, w, h) 
{
  //if ((w.valueOf()>800) && (screen.width<=800)) w='750'; 
  okno = window.open('' , '', "toolbar=0,location='',directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width="+w+",height="+h);
  okno.document.location = sciezka; 
}

function insertValue(txt) {

  var myQuery=document.postMsg.elements["tekst"];
	
  //IE support
  if (document.selection) {
     myQuery.focus();
     sel = document.selection.createRange();
     sel.text = txt;
     myQuery.focus();
  }
  
  //MOZILLA/NETSCAPE support
  else if (myQuery.selectionStart || myQuery.selectionStart == "0") {
    var startPos = myQuery.selectionStart;
    var endPos = myQuery.selectionEnd;
    var tekst= myQuery.value;

    myQuery.value = tekst.substring(0, startPos) + txt + tekst.substring(endPos, tekst.length);
    
  } else {
    myQuery.value += txt;
  }

}



function checkBrowser()
{
this.ver=navigator.appVersion;
this.dom=document.getElementById?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ns6=(this.dom && parseInt(this.ver)>= 5)?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.opr=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1)?1:0;
return this
}

function paste_strinL(strinL,isQuote){ 
if(strinL=='') alert('Zaznacz tekst, który chcesz cytować!');
else{
if (isQuote == 1) {
strinL = '[i]' + strinL + '[/i]' + '\n';
}
if (isQuote == 2) {
strinL = '[b]' + strinL + '[/b]' + '\n';
}
var isForm=document.forms["postMsg"];
if (isForm) {
//var input=document.forms["postMsg"].elements["tekst"];
//input.value=input.value+strinL; 
insertValue(strinL);
}
else alert('Dostęp zabroniony');
}
}

function pasteSel() {
if(document.getSelection) selection=document.getSelection();
else if(document.selection) selection=document.selection.createRange().text;
else if(window.getSelection) selection=window.getSelection;
else selection='';
}

function getQuotation() {
var bw=new checkBrowser();
if ((bw.ns6 || bw.ie5 || bw.ie6 || bw.ns4) && !bw.opr) {
document.writeln('&nbsp;&nbsp;&nbsp;<a href="javascript:paste_strinL(selection,1)" onMouseDown="pasteSel()" class="forum"> * Cytuj *</a>');
}
}



function limituj(limit, div, pole) {
	
     var gdzie = document.getElementById(div);
     var ile = parseInt(pole.length);
     rest=limit-ile;
     
     if (rest< 0) {
       pole = pole.substring(0, limit);
     }
     else
     {
        gdzie.innerHTML = "Zostało: " +rest.toString()+ " znaków";
     }
     
 }
 

 
