<!--
//  Panel Formatowania 2003 by Xeon i Romek(część dla Mozilli)

var aktywnePole = 0;
var wybranyKolor = '000000';
var wybranyRozmiar = '11';

funkcja_br = 'Nowa linia: tekst<br>';
funkcja_b = 'Tekst pogrubiony: <b>tekst</b>';
funkcja_i = 'Tekst kursywa: <i>tekst</i>';
funkcja_u = 'Tekst podkreślony: <u>tekst</u>';
funkcja_em = 'Wstaw email: <a mailto=adres_email>adres_email</a>';
funkcja_a = 'Wstaw adres: <a href=http://adres_url>nazwa_linka</a>';
funkcja_c = 'Centruj tekst: <center>tekst</center>';
funkcja_n1 = 'Nagłówek 1: <span class=panel_naglowek1>tekst</span>';
funkcja_n2 = 'Nagłówek 2: <span class=panel_naglowek2>tekst</span>';
funkcja_ro = 'Rozmiar tekstu wstawianego przyciskiem Czcionka';
funkcja_ko = 'Kolor tekstu wstawianego przyciskiem Czcionka';
funkcja_cz = 'Tekst o wybranym rozmiarze i kolorze: <span >tekst</span>';
funkcja_s = 'Niełamliwa spacja: &nbsp;';
funkcja_ap = 'Apostrof: &acute;';
funkcja_k = 'Kropka: &#8226;';
funkcja_kw = 'Kwadrat: <sup>2</sup>';
funkcja_sz = 'Sześcian: <sup>3</sup>';
funkcja_st = 'Stopień: &deg;';
funkcja_co = 'Copyright: &copy;';
funkcja_r = 'Reserved: <sup>&reg;</sup>';

tekst_br = '<br>'
tekstPrzed_b = '<b>';
tekstPo_b = '</b>';
tekstPrzed_i = '<i>';
tekstPo_i = '</i>';
tekstPrzed_u = '<u>';
tekstPo_u = '</u>';
// tekstPrzed_em = '<a href=Adres_email>';
tekstPrzed_em = '<a href="mailto:';
tekstPo_em = '</a>';
// tekstPrzed_a = '<a href=http://Adres_url>';
tekstPrzed_a = '<a href="http://';
tekstPo_a = '</a>';
tekstPrzed_c = '<center>';
tekstPo_c = '</center>';
tekstPrzed_n1 = '<span class=panel_naglowek1>';
tekstPo_n1 = '</span>';
tekstPrzed_n2 = '<span class=panel_naglowek2>';
tekstPo_n2 = '</span>';
tekstPrzed_cz = '<span style="font-size:' + wybranyRozmiar + 'px; color:#' + wybranyKolor + '">';
tekstPo_cz = '</span>';
tekst_s = '&nbsp;'
tekst_ap = '&acute;'
tekst_k = '&#8226;'
tekst_kw = '<sup>2</sup>'
tekst_sz = '<sup>3</sup>'
tekst_st = '&deg;'
tekst_co = '&copy;'
tekst_r = '<sup>&reg;</sup>'

function ustawKursor(wybranePole) {
  aktywnePole = wybranePole;
  // alert('akt'+aktywnePole);
  if (wybranePole.createTextRange)
    wybranePole.caretPos = document.selection.createRange().duplicate();
}

function ustawKursor_test(wybranePole) {
  aktywnePole = wybranePole;
  if (wybranePole.createTextRange)
    alert('akt'+aktywnePole);
    // wybranePole.caretPos = document.selection.createRange().duplicate();
    wybranePole.caretPos = document.cursor;
}

function opisFunkcji(funkcja,pole) {
  pole.form.poleOpisFunkcji.value = eval("funkcja_" + funkcja);
}

function wstawPrzyKursorze(wstawianyTekst) {
  wybranePole = aktywnePole;
  if (wybranePole != 0 && wybranePole.createTextRange && wybranePole.caretPos) {
    var pozycjaKursora = wybranePole.caretPos;
    wstawianyTekst = eval("tekst_" + wstawianyTekst);
    pozycjaKursora.text = pozycjaKursora.text.charAt(pozycjaKursora.text.length - 1) == ' ' ? wstawianyTekst + ' ' : wstawianyTekst;
  }else
    wstawPrzyKursorzeMoz(wstawianyTekst); //  funkcja dla mozilli
  wybranePole.focus();
}

function wstawPrzyKursorzeMoz(wstawianyTekst) {
  wybranePole = aktywnePole;
  if (typeof wybranePole.setSelectionRange!="undefined") {
    var wartosc=wybranePole.value;
    var staryPoczatek=wybranePole.selectionStart;
    var staryKoniec=wybranePole.selectionEnd;
    var poczatek=0;
    var koniec=wartosc.length;
    podlancuch_przed = wartosc.substring(poczatek, staryPoczatek);
    podlancuch_zaznaczony = wartosc.substring(staryPoczatek, staryKoniec);
    podlancuch_za = wartosc.substring(staryKoniec, koniec);
    wstawianyTekst = eval("tekst_" + wstawianyTekst);
    wybranePole.value= podlancuch_przed+podlancuch_zaznaczony+wstawianyTekst+podlancuch_za;
    staryKoniec = staryKoniec + wstawianyTekst.length;
    wybranePole.selectionStart = staryKoniec;
    wybranePole.selectionEnd = staryKoniec;
  }
}

function wstawWokolKursora(wstawianyTekst) {
  wybranePole = aktywnePole;
  if (wybranePole != 0 && wybranePole.createTextRange && wybranePole.caretPos) {
    var pozycjaKursora = wybranePole.caretPos;
    var zaznaczonyTekst = pozycjaKursora.text;
    var zaznaczonyTekstObciety = zaznaczonyTekst;
    wstawianyTekstPrzed = eval("tekstPrzed_" + wstawianyTekst);
    if ((wstawianyTekst=='em') || (wstawianyTekst=='a')) // e-mail lub url
      wstawianyTekstPrzed = wstawianyTekstPrzed + zaznaczonyTekstObciety + '">';
    wstawianyTekstPo = eval("tekstPo_" + wstawianyTekst);
    zaznaczonyTekstObciety.length = zaznaczonyTekstObciety.length - 1;
    pozycjaKursora.text = pozycjaKursora.text.charAt(pozycjaKursora.text.length - 1) == ' ' ? wstawianyTekstPrzed + zaznaczonyTekstObciety + wstawianyTekstPo + ' ' : wstawianyTekstPrzed + zaznaczonyTekst + wstawianyTekstPo;
  }else
    wstawWokolKursoraMoz(wstawianyTekst);
  wybranePole.focus();
}

function wstawWokolKursoraMoz(wstawianyTekst) {
  wybranePole = aktywnePole;
  if (typeof wybranePole.setSelectionRange!="undefined") {
    var wartosc=wybranePole.value;
    var staryPoczatek=wybranePole.selectionStart;
    var staryKoniec=wybranePole.selectionEnd;
    var poczatek=0;
    var koniec=wartosc.length;
    podlancuch_przed = wartosc.substring(poczatek, staryPoczatek);
    podlancuch_zaznaczony = wartosc.substring(staryPoczatek, staryKoniec);
    podlancuch_za = wartosc.substring(staryKoniec, koniec);
    wstawianyTekstPrzed = eval("tekstPrzed_" + wstawianyTekst);
    if ((wstawianyTekst=='em') || (wstawianyTekst=='a')) // e-mail lub url
      wstawianyTekstPrzed = wstawianyTekstPrzed + podlancuch_zaznaczony + '">';
    wstawianyTekstPo = eval("tekstPo_" + wstawianyTekst);
    wybranePole.value= podlancuch_przed+wstawianyTekstPrzed+podlancuch_zaznaczony+wstawianyTekstPo+podlancuch_za;
    staryKoniec = staryKoniec + wstawianyTekstPrzed.length + wstawianyTekstPo.length;
    wybranePole.selectionStart = staryKoniec;
    wybranePole.selectionEnd = staryKoniec;
  }
}

function zmienRozmiar(wybranePole) {
  wybranyRozmiar = wybranePole.value;
  tekstPrzed_cz = '<span style="font-size:' + wybranyRozmiar + 'px; color:#' + wybranyKolor + '">';
}

function zmienKolor(wybranePole) {
  wybranyKolor = wybranePole.value;
  tekstPrzed_cz = '<span style="font-size:' + wybranyRozmiar + 'px; color:#' + wybranyKolor + '">';
}
// -->
