  window.addEvent('domready', function(){
  	$('listaSzkoly').addEvents({
  		'mouseenter': function(){
  			// Always sets the duration of the tween to 1000 ms and a bouncing transition
  			// And then tweens the height of the element
  			$('menuSzkoly').set('tween', {
  				duration: 100
  			}).tween('height', '130px');
  		},
  		'mouseleave': function(){
  			// Resets the tween and changes the element back to its original size
  			$('menuSzkoly').set('tween', {}).tween('height', '0px');
  		}
  	});
  	
  	$('menuSzkoly').addEvents({
  		'mouseenter': function(){
  			// Always sets the duration of the tween to 1000 ms and a bouncing transition
  			// And then tweens the height of the element
  			this.set('tween', {
  				duration: 100
  				//,transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
  			}).tween('height', '130px');
  		},
  		'mouseleave': function(){
  			// Resets the tween and changes the element back to its original size
  			this.set('tween', {}).tween('height', '0px');
  		}
  	});
  });

  function sprawdzFormularz(AForm){
    if (!AForm.forma_prawna.value){
      document.getElementById('forma_prawna').className = 'errorSelect';
      return false;
    } else {
      document.getElementById('forma_prawna').className = 'formSzkoly'
      return true;
    }
  }

  function sprawdzForlumarzSzukania1(Aform){
    if(!Aform.searchbox1.value){
      document.getElementById('searchbox1').className = 'error';
      return false;
    } else {
      document.getElementById('searchbox1').className = '';
      return true;
    }
  }

  function sprawdzForlumarzSzukania(Aform){
    if(!Aform.searchbox.value){
      document.getElementById('searchbox').className = 'error';
      return false;
    } else {
      document.getElementById('searchbox').className = '';
      return true;
    }
  }

  var i = 0;
  function logowanie(){
    if( i%2 == 0){
      document.getElementById('dataUpdateWindow').className = 'dataUpdateWindowVisible';
      document.getElementById('maska').className = 'maskaOn';
    } else {
      document.getElementById('dataUpdateWindow').className = 'dataUpdateWindowHidden';
      document.getElementById('maska').className = 'maskaOff';
    }
    i++;
  }
  
  function sprawdzForlumarzLogowania(Aform){
    var pass;
    var id;
    id = document.logowanie.id_szkoly.value;
    pass = document.logowanie.haslo.value;
    alert(id +' - '+pass);
    return false;
  }
  
  function SendRequest1() { 
    $('loader').style.display = 'block';
    var req = mint.Request();
    req.OnSuccess = function () {
      $('loader').style.display = 'none';
    }
    req.AddParam("id", $("id_szkoly").value);
    req.AddParam("haslo", $("haslo").value);
    req.Send("/logowanie.php"+status, "response");
  }
    
  function zaloguj() {
    $('loader').style.display = 'block';
    var req = mint.Request();
    var haslo = document.getElementById('haslo');
    req.getJSON = true;
    req.OnSuccess = function() {
        if(this.responseJSON.success){
//          document.location.href="/kat/5/aktualizacja/"+$("id_szkoly").value;
          document.location.href="/kat/5/aktualizacja";
        } else {
          haslo.value = '';
          $("response").innerHTML = this.responseJSON.msg;
        }
        $('loader').style.display = 'none';
    }
    req.SendForm("form");
  }

  function zaktualizujPrezentacje(){
    $('aktualizowanie').style.display = 'block';
    var req = mint.Request();
    var id_szkoly = document.getElementById('id_szkoly');
    req.getJSON = true;
    req.OnSuccess = function() {
        if(this.responseJSON.success){
//          document.location.href="/kat/5/aktualizacja/"+$("id_szkoly").value;
          document.location.href="/prezentacja/"+this.responseJSON.id;
        } else {
          $("response1").innerHTML = this.responseJSON.msg;
        }
        $('aktualizowanie').style.display = 'none';
    }
    req.Send("/aktualizacje/aktualizacja_przeniesienie_danych.php", "response");
  }

  function SendRequestMiastaKursy() { 
    var req = mint.Request();
    req.getJSON = true;
    var select = document.getElementById('miasto');
    select.disabled = true;
    req.OnSuccess = function () {
      select.innerHTML = '';
      select.options[0] = new Option('wszystkie miasta','');
      select.options[0].className = 'selectTop';
      for(var i = 0; i < this.responseJSON.length; ++i) {
        select.options[i+1] = new Option(this.responseJSON[i],this.responseJSON[i]);
        select.options[i+1].className = 'select';
      }
      select.disabled = false;
    }
    req.AddParam("wojewodztwo", $("wojewodztwo").value);
    req.AddParam("kat", $("kat").value);
    req.Send("/pobierz_miasta.php");
  }

  function SendRequestMiasta() { 
    var req = mint.Request();
    req.getJSON = true;
    var select = document.getElementById('miasto');
    select.disabled = true;
    req.OnSuccess = function () {
      select.innerHTML = '';
      select.options[0] = new Option('wszystkie miasta','');
      select.options[0].className = 'selectTop';
      for(var i = 0; i < this.responseJSON.length; ++i) {
        select.options[i+1] = new Option(this.responseJSON[i],this.responseJSON[i]);
        select.options[i+1].className = 'select';
      }
      select.disabled = false;
    }
    req.AddParam("wojewodztwo", $("wojewodztwo").value);
    req.AddParam("forma_prawna", $("forma_prawna").value);
    req.AddParam("kat", $("kat").value);
    req.Send("/pobierz_miasta.php");
  }

  function SendRequestKierunki(){
    var req = mint.Request();
    req.getJSON = true;
    var select = document.getElementById('kierunki');
    select.disabled = true;
    req.OnSuccess = function () {
      select.innerHTML = '';
      select.options[0] = new Option('wszystkie kierunki','');
      select.options[0].className = 'selectTop';
      for(var i = 0; i < this.responseJSON.length; ++i) {
        select.options[i+1] = new Option(this.responseJSON[i],this.responseJSON[i]);
        select.options[i+1].className = 'select';
      }
      select.disabled = false;
    }
    req.AddParam("wojewodztwo", $("wojewodztwo").value);
    req.AddParam("forma_prawna", $("forma_prawna").value);
    req.AddParam("miasto", $("miasto").value);
    req.Send("/pobierz_kierunki.php");
  }

  function SendRequestAktualizacja() { 
    miastaAktualizacja();
    powiatyAktualizacja();
  }
  
  function miastaAktualizacja(){
    var req = mint.Request();
    req.getJSON = true;
    var select = document.getElementById('miasto');
    select.disabled = true;
    req.OnSuccess = function () {
      select.innerHTML = '';
      for(var i = 0; i < this.responseJSON.length; ++i) {
        select.options[i] = new Option(this.responseJSON[i],this.responseJSON[i]);
        select.options[i].className = 'select';
      }
      select.disabled = false;
    }
    req.AddParam("wojewodztwo", $("wojewodztwo").value);
    req.Send("/pobierz_miasta_aktualizacja.php");
  }
  
  function powiatyAktualizacja(){
    var req = mint.Request();
    req.getJSON = true;
    req.OnSuccess = function () {
      select.innerHTML = '';
      for(var i = 0; i < this.responseJSON.length; ++i) {
        select.options[i] = new Option(this.responseJSON[i],this.responseJSON[i]);
        select.options[i].className = 'select';
      }
      select.disabled = false;
    }
    req.AddParam("wojewodztwo", $("wojewodztwo").value);
    req.Send("/pobierz_powiaty_aktualizacja.php");
  }
  
  function odswiez_captche(){
    document.getElementById('captcha_img').src = '/captcha/captchaDodajSzkole.png';
    return false;
  }

  function pokaz_artykul(){
    $('artykul').style.display = 'block';
    $('zamknij_artykul').style.display = 'block';
  }
  
  function zamknij_artykul(){
    $('artykul').style.display = 'none';
    $('zamknij_artykul').style.display = 'none';
  }
