
$(
  function()
  {
    form();
    kalendarium();
    facebook();
  }
)

kalendarium = function()
{
  $('.kalendarz').find('a').click(
    function()
    {
      var dane    = {'id':$(this).attr('rel')};
      var adres = '/kalendarium'; 
      $('<div/>',{'id':'kalendarium_box'}).dialog(
        {
          title     :"Kalendarium, Senator Piotr Zientarski",
          width     : 600,
          height    : 390,
          modal     : true,
          resizable : false,
          open      : function()
            {
              
              $(this).load(adres,dane);
            }  
        }
      );
    }
  );   
}

facebook = function()
{
  var height = $('#facebook').height();
  height = Math.round(($(window).height()-height)/2);
  $('#facebook').css('margin-top',height);
  
  $('#facebook').mouseover(function()
      {
        $(this).stop();
        $(this).animate({'margin-left':'0px'});
      }).mouseout(function()
      {
        $(this).stop();
        $(this).animate({'margin-left':'-204px'});
      })
}

pokaz = function(obiekt)
  {
      $(obiekt).toggle(0);
  }

zawijaj = function(source,destination)
  {
     $(source).effect('pulsate');
     $(destination).toggle('blind');
  }
  
form = function()
  {
    $('#formularz input[name=ok]').val(1);
  }  



//------------------------------------------------------------------ 


function ajax_post(adres,typ_zwracany,argumenty,pole_wyswietlania)
{
    $.ajax(
      {
      type: "POST",
      url: adres,
      data: argumenty,
      success: function(msg)
              {
                //$(pole_wyswietlania).hide(400).show(400);
                $(pole_wyswietlania).effect('highlight');
                $(pole_wyswietlania).html(msg);
                $(pole_wyswietlania).show("slow");
                //console.log('Operacja zakonczona sukcesem');
              },
      complete: function(msg)
              {
                //console.log('zakonczono pobieranie: '+msg);
              },
      error: function(msg)
              {
                //console.log('blad podczas operacji: '+msg);
                alert( " blad podczas wykonywania operacji");
              },
      beforeSend: function(msg)
              {
                $(pole_wyswietlania).html('Ładowanie treści proszę czekać...');
                //console.log('Wyslano operacje na serwer: ' + msg );
              },
      start: function(msg)
              {
                //console.log('Zainicjowano ajax: ' + msg );
              },
      stop: function(msg)
              {
                //console.log('Zatrzymano ajax: ' + msg );
              },
      dataType: typ_zwracany,
      async: true
      }
    );
}
