var pamietaj = "";


function slowa() {
  var f = document.getElementsByTagName("*");
  var wyrazy = new Array;
  var wynik = "";
  var linia = "";
  re = ",";
   
  txt = f.nameField.value.replace(/^\s+/,"").replace(/\s+$/,"");
  txt2 = f.nameField.value.replace(/^\s+/,"").replace(/\s+$/,"");
  txt3 = f.nameField.value;
    
  if (txt.length<1) return 0;
  txt = txt.split(/\s*\n/); //dzieli na wiersze
  
  if (txt2.length<1) return 0;
  txt2 = txt2.split(/\s*/); //dzieli na litery
  
  ktore = f.boldField.value.replace(/^\s+/,"").replace(/\s+$/,"");
  
  ktore = ktore.split(/\s+/); 
  
  
  
  //txt3 = txt3.split(/\s+/); //dzieli na pojedyncze wyrazy
  
  // funkcja wpisujÄ_ca wyrazy wierszami do tablicy
  
  
  
  for (a=0; a<txt.length; a++) {
  txt4 = txt[a].split(/\s+/);
  wynik = "";
  
  for (kt=0; kt<ktore.length; kt++) { 
  if (a==ktore[kt]) {                                      //w tym miejscu wybieram który wiersz ma być pogrubiony
              for (k=0; k<txt4.length; k++) 
              {
              txt4[k] = "\<b>" + txt4[k] + "\</b>";				      
			        }
            }
          }
  
 
  for (k=0; k<txt4.length; k++) {
        txt4[k] = txt4[k].replace(re,"");
				wynik += "\<td>" + txt4[k] + "\</td>";
			}
	linia += "\<tr>" + wynik + "\</tr>" + "\n";
	
	}
	linia = "\<br /><br /><center><table border = 1>" + "\n" + linia;
  linia = linia + "\</table></center><br /><br />";
  
     	
  return linia;
  
}

function czysc() {
  var f = document.getElementsByTagName("*");
  var wyrazy = new Array;
  var wynik = "";
  var czyste = "";
  var re = /<td*?>/;
  
  txt = f.nameField.value.replace(/^\s+/,"").replace(/\s+$/,"");
  txt2 = f.nameField.value.replace(/^\s+/,"").replace(/\s+$/,"");
  txt3 = f.nameField.value;

  if (txt.length<1) return 0;
  txt = txt.split(/\s*\n/); //dzieli na wiersze

  if (txt2.length<1) return 0;
  txt2 = txt2.split(/\s*/); //dzieli na litery


  //txt3 = txt3.split(/\s+/); //dzieli na pojedyncze wyrazy

  // funkcja wpisujÄ_ca wyrazy wierszami do tablicy



  for (a=0; a<txt.length; a++) {
  txt4 = txt[a].split(/\s+/);
  wynik = "";
  
  for (k=0; k<txt4.length; k++) {
        txt4[k] = txt4[k].replace(re,"\>");
				wynik += txt4[k] + " ";
			}
	czyste += wynik + "\n";
	
	}
//  czyste = "\<br /><br /><center><table border = 1>" + "\n" + czyste;
//  czyste = czyste + "\</table></center><br /><br />";

     	
  return czyste;

}

function show(){
var warstwa = document.getElementById("tekst");
        warstwa.style.visibility = "visible";
}
function hide(){
var warstwa = document.getElementById("tekst");
        warstwa.style.visibility = "hidden";
}

function zapisz(){
  var f = document.getElementsByTagName("*");  
  
  pamietaj = f.nameField.value.replace(/^\s+/,"").replace(/\s+$/,"");
  
  return pamietaj;
        
}

function wklej(){
var wklejka = pamietaj;
    return wklejka;
}
