function Inicjuj() {
Logowanie();
pokaz(1);
}

function pokaz(strona) {
    var
      tek = document.getElementById("szukaj_tekst").value;


    advAJAX.post({
            url : "szukaj.php",
            parameters: {
                tekst : tek,
                ktorastrona : strona
            },
            onInitialization : function() {
               document.getElementById("Przycisk").setAttribute('disabled','disabled');
               document.getElementById("szukaj_tekst").setAttribute('disabled','disabled');
            },
            onSuccess : function(obj) {

                document.getElementById("Przycisk").removeAttribute('disabled');
                document.getElementById("szukaj_tekst").removeAttribute('disabled');
                document.getElementById("komunikaty").innerHTML=obj.responseText;

            },
            onError:function(obj) {
              alert("Blad");
            }
   });
}

function checkKeycode(e) { //sprawdzenie czy wciśnięto eneter
  var keycode;
      if (window.event) keycode = window.event.keyCode;
      else if (e) keycode = e.which;
         if(keycode == 13){
          pokaz(1);
        if (window.event) window.event.keyCode=9;
          else if (e) e.which=9;
      }
}


function Logowanie() {

     forma=document.createElement('div');
     forma.setAttribute("id","Formularz");
     forma.setAttribute('align','center');
 //    f=document.createElement('form');
 //    f.setAttribute("id","Forma");
 //    f.setAttribute("method","post");


   //  f.appendChild(document.createTextNode("Szukaj:"));

     yourName=document.createElement('input');
     yourName.setAttribute('type','text');
     yourName.setAttribute('id','szukaj_tekst');
     yourName.setAttribute('name','szukaj_tekst');
     yourName.setAttribute('style',"border-width:2");
     yourName.onkeydown = checkKeycode;
     forma.appendChild(yourName);


    b=document.createElement('input');
    b.setAttribute('type','button');
    b.setAttribute('value','Szukaj');
    b.setAttribute('id','Przycisk');

    b.onclick = function(){pokaz(1);};


 //   f.appendChild(document.createElement('br'));
    forma.appendChild(b);

//    forma.appendChild(f);
    document.getElementById('szukaj').appendChild(forma);

}

