﻿

$(document).ready(function(){

$("#cennik").each(function(){
  $("tr:odd", this).not(".even").addClass("odd");
  $("tr:even", this).not(".odd").addClass("even");
});


$("#login_form").submit(function()
{
        //remove all the class add the messagebox classes and start fading
		$("#login").animate({"height": "80px"}, "slow");
        $("#linfo").removeClass().addClass('messagebox').text('Proszę czekać....').fadeIn(1000);
        //check the username exists or not from ajax
        $.post("loginek.php",{ name:$('#username').val(),pass:$('#password').val(),test:$('#test').val(),rand:Math.random() } ,function(data)
        {
          if(data=='ok') //if correct login detail
          {
		  $("#login").animate({"height": "80px"}, "slow");
                $("#linfo").fadeTo(200,0.1,function()  //start fading the messagebox
                {
                  //add message and change the class of the box and start fading
                  $(this).html('Logowanie.....').addClass('messageboxok').fadeTo(900,1,
                  function()
                  {
                     //redirect to secure page
                     document.location='index.php?dzial=logon';
                  });
                });
          }
          else
          {
		  $("#login").animate({"height": "80px"}, "slow");
                $("#linfo").fadeTo(200,0.1,function() //start fading the messagebox
                {
                  //add message and change the class of the box and start fading
                  $(this).html('Błąd logowania...').addClass('messageboxerror').fadeTo(900,1);
                });
          }
       });
       return false;//not to post the  form physically
});



$('#slider').cycle({
    fx:     'fade',
    timeout: 6000,
    delay:  -2000,
    cleartypeNoBg: true
});

//$(document).pngFix(); 

//$("#fbox a").fancybox();

			$("#fbox a").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});



$("form#kontakt").submit(function(){

var str = $("form#kontakt").serialize();

   $.ajax({
   type: "POST",
   url: "contact.php",
   data: str,
   success: function(msg){
    
$("#note").ajaxComplete(function(event, request, settings){

if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
{
result = '<div class="notification_ok">Wiadomość wysłana. Dziękujemy!</div>';
$("#fields").hide();
}
else
{
result = msg;
}

$(this).html(result);

});

}

 });

return false;

});

});



