function Sprawdz() {
	
	var regname = /^[A-Za-z ęĘóÓąĄśŚłŁżŻĄŹćĆńŃ]{3,100}$/;
	var regphone = /^[0-9 -+]{7,30}$/;
	var regemail = /^[a-z0-9][\w\.-]*\w@([\w-]+\.)*[a-z]{2,4}$/;
	var regtxt = /^[A-Za-z ęĘóÓąĄśŚłŁżŻĄŹćĆńŃ 0-9 -=.,+]{1,1000}$/;
	
	var name = document.getElementById("name").value;
	var phone = document.getElementById("phone").value;
	var mail = document.getElementById("mail").value;
	var txt = document.getElementById("txt").value;

	if(!regname.test(name)||name=='Imię i Nazwisko') return ShowMessage("Podaj swoje imię");
	//if(!regphone.test(phone)) return ShowMessage("Podaj numer telefonu");
	if(!regemail.test(mail)) return ShowMessage("Podaj prawidłowy adres email");
	//if(!regtxt.test(txt)||txt=='Wiadomo¶ć') return ShowMessage("Wpisz tre¶ć wiadomo¶ci");
	return true;
}

function Sprawdz_zamow_kat() {
	
	var regname = /^[A-Za-z ęĘóÓąĄśŚłŁżŻĄŹćĆńŃ]{3,100}$/;
	var regphone = /^[0-9 -+]{7,30}$/;
	var regemail = /^[a-z0-9][\w\.-]*\w@([\w-]+\.)*[a-z]{2,4}$/;
	var regtxt = /^[A-Za-z ęĘóÓąĄśŚłŁżŻĄŹćĆńŃ 0-9 -=.,+]{1,1000}$/;
	
	var imie = document.getElementById("imie").value;
	var nazwisko = document.getElementById("nazwisko").value;
	var ulica = document.getElementById("ulica").value;
	var miasto = document.getElementById("miasto").value;
	var kod = document.getElementById("kod").value;

	if(imie!='' && nazwisko!='' && ulica!='' && miasto!='' && kod!='')
	{
		alert("Wiadomość została wysłana");
		return true;
	}
	else
	{
		alert("Wiadomość nie została wysłana.\n Wypełnij pola z gwiazdką.");
		return false;
	}
}

function ShowMessage(txt) {
	document.getElementById("Message").innerHTML = '<b><font color="#800000">'+txt+'</font></b>';
	return false;
}

			function pageselectCallback(page_index, jq){
                // Get number of elements per pagionation page from form
                //var items_per_page = opts.items_per_page;
				var items_per_page = 5;
                //var max_elem = Math.min((page_index+1) * items_per_page, members.length);
				var max_elem = page_index*items_per_page+items_per_page
                var newcontent = '';
                $('#Searchresult').empty();
                // Iterate through a selection of the content and build an HTML string
                for(var i=page_index*items_per_page;i<max_elem;i++)
                {
                    var new_content = $('#hiddenresult div.news_box:eq('+i+')').clone();
					$('#Searchresult').append(new_content);
					//$('#Searchresult').empty().append(new_content); 
					//newcontent += $('#hiddenresult div.news_box:eq('+i+')').html();
                }
                //$('#Searchresult').empty().append(new_content); 
                // Replace old content with new content
                //$('#Searchresult').html(newcontent);
                
                // Prevent click eventpropagation
                return false;
            }


	/*
			function pageselectCallback(page_index, jq){
                var new_content = $('#hiddenresult div.news_box:eq('+page_index+')').clone();
                $('#Searchresult').empty().append(new_content);
                return false;
            }
	*/
           
            /** 
             * Callback function for the AJAX content loader.
             */
            function initPagination() {
                var num_entries = $('#hiddenresult div.news_box').length;
                // Create pagination element
                $("#Pagination").pagination(num_entries, {
                    num_edge_entries: 2,
                    num_display_entries: 8,
                    callback: pageselectCallback,
                    items_per_page:5,
					prev_text: "wstecz",
					next_text: "dalej"
                });
             }


$(document).ready(function(){

	$(".skoki_tab tr:odd").css("background-color", "#fff");
	
	//initPagination();      
	flowplayer("a.myPlayer", "flowplayer-3.1.1.swf", { 
        plugins: { 
		  controls: {time:false} 
		} 
    });  
	$("a.myPlayer").append("<div class='play'></div>");
	  
	  
	  if ( $.browser.msie && (!$.browser.version || parseInt($.browser.version) <= 6) )
      {
       $("#buttony ul li ul").append('<iframe style="/* border:#000 1px solid; */display:block;position:absolute;top:-1px;left:-1px;z-index:-1;filter:mask();'+'width:expression(this.parentNode.offsetWidth+1);height:expression(this.parentNode.offsetHeight+1)"></iframe>');
      }

/*  
$("#buttony ul li").hover(
    function () {
      if ($(this).children().next().is(":hidden")){$(this).children().next().show();}//animate({"height": "show","width": "show","opacity": "show"},"fast")
      if ( $(this).hasClass("sub_hor") ){$(this).addClass("sub_akt");}else{$(this).addClass("akt");}
      //$(this).children().next().css({position:"absolute",left:$(this).parent().outerWidth()-12}); //$(this).parent().outerWidth()
      if ( $.browser.msie && (!$.browser.version || parseInt($.browser.version) <= 6) )
      {
      $(this).css({"z-index":($(this).css("z-index")+1)});
      //$(this).children().next().css({position:"absolute",left:$(this).parent().outerWidth()-43,top:0});
      }
      else
      {
      $(this).css({"z-index":($(this).parent().parent().css("z-index")+1)});
      $(this).children().next().css({top:$(this).parent().css("top")-1});
      }
	  $(this).addClass("akt");
	  //alert($(this).children("a").className);
	  //$(this).children("a:first").css({"background":"red"});

    },
    function () {
      if ($(this).children().next().is(":visible")){$(this).children().next().hide();}
      if ( $(this).hasClass("sub_hor") ){$(this).removeClass("sub_akt");}else{$(this).removeClass("akt");}
      if ( $.browser.msie && (!$.browser.version || parseInt($.browser.version) <= 6) )
      {
      if ( !$(this).hasClass("sub_hor") ){$(this).css({"z-index":($(this).css("z-index")-1)});}
      }
      else
      {
      $(this).css({"z-index":($(this).css("z-index")-1)});
      }
	  $(this).removeClass("akt");
    }
  );
  */

  //$(".lightbox").lightbox();
  $(".lightbox2").lightBox();
  $(".lightbox").lightBox_old();
  $("html").css({"overflow-y":"scroll"});

    var options_wyslij = {
          //target:        '#myList',   // target element(s) to be updated with server response
          //beforeSubmit:  showRequest,  // pre-submit callback
          url: 'ajax.php',
		  resetForm: true,
          success:       showResponse_tekst
      };
  function showResponse_tekst(responseText, statusText)  {
    alert(responseText);
  }

	$(".ajax").submit(function(){
	   $(this).ajaxSubmit(options_wyslij);
	   return false;
	  }); 


	var options_guest = {
          //target:        '#myList',   // target element(s) to be updated with server response
          //beforeSubmit:  showRequest,  // pre-submit callback
          url: 'ajax.php',
		  resetForm: true,
          success:       showResponse_tekst_guest
      };
  function showResponse_tekst_guest(responseText, statusText)  {
   alert('Dziękujemy za wpisanie się do księgi gości.');
  }
  $('.guest').submit(function() {
	if(SprawdzGuestMail())
	{
		$(this).ajaxSubmit(options_guest);
	}
	else
	{
		alert('wpisz prawidłowy adres e-mail');
	}	
    return false;
  });


	  name_pola = new Array();
	  value_pola = new Array();
	  $("body :text,body textarea").each(function (i) {
				name_pola[i]=$("body :text,body textarea").eq(i).attr('name');
				value_pola[i]=$("body :text,body textarea").eq(i).val();
				
				$("body :text,body textarea").eq(i).focus(function () {
					if(this.value==value_pola[i])this.value='';
					//alert('i '+(i-1))
					//alert('eq '+$(this).eq())
				})
				//$("input[name='"+name_pola+"']").
				$("body :text,body textarea").eq(i).blur(function () {
					if(this.value=='')this.value=value_pola[i];
				})
      });


//****************************** kalendarz ************************************** 
	$("#MiniCal .dzien a").click(function() { 
		var t = this;
		var dat = $(this).attr("name");
		//otworz('kalendarz_edit.php?date='+dat,400,400);
		
		$("#opisCal").slideUp("slow", function () {
			 $(this).load("ajax.php", {opis_kal: dat}, function(){
					$(this).slideDown("slow");
			 });
		});
		
		$(".nagls a").click(function() { 
		var n = $(this).attr("name").split("_");
		var d = n[1].split("-");
		$("#dzi").val( d[2] );
		$("#mie").val( d[1] );
		$("#rok").val( d[0] );
		$("#MainForm").submit();
	});

		//$("#opisCal").load("ajax.php", {opis_kal: dat});
		/*
		$.ajax({
			url: "index.php?GoDo=SetDate&d="+dat,
			cache: false,
			success: function(p){
				if(p=="SET") $(t).addClass("zaz");
				else if(p=="UNSET") $(t).removeClass("zaz");
			}
		});
		*/
	});
	
	$(".nagls a").click(function() { 
		var n = $(this).attr("name").split("_");
		var d = n[1].split("-");
		$("#dzi").val( d[2] );
		$("#mie").val( d[1] );
		$("#rok").val( d[0] );
		$("#MainForm").submit();
	});	 
	 
//****************************** kalendarz end ********************************** 	 
//****************************** newsletter ************************************** 	
	$("#zapisz_nws").click(function(){
		 if(SprawdzMail())
		 {
			 $.ajax({
			 type: "POST",
			 url: "ajax.php",
			 data: "zapisz_newsl=true&mail="+document.getElementById("nws_mail").value,
			 success: function(msg){
			   alert(msg);
			 }
		   });
		 }
		 else
		 {
		   alert("Podaj prawidłowy adres email");
		 }
		 //return false;
	  });
	$("#wypisz_nws").click(function(){
		 if(SprawdzMail())
		 {
			 $.ajax({
			 type: "POST",
			 url: "ajax.php",
			 data: "wypisz_newsl=true&mail="+document.getElementById("nws_mail").value,
			 success: function(msg){
			   alert(msg);
			 }
		   });
		 }
		 else
		 {
		   alert("Podaj prawidłowy adres email");
		 }
		 //return false;
	  });

	$("#nws_form").submit(function(){
	   //alert('Użyj przycisku zapisz, albo wypisz');
	   alert('Użyj przycisku zapisz');
	   return false;
	  });	
//****************************** newsletter end ********************************** 	  
});
//************************* end jquery *********************************

String.prototype.trim = function()
{
  return this.replace(/^\s+|\s+$/g,"");
};
function Sprawdz_szukaj() {
var txt = document.getElementById("szuk").value;
if(txt.trim() == '' || txt=='fraza do wyszukania...') {alert('wpisz szukan± frazę');return false;}
else{return true;}
}
function SprawdzMail() {
	var regemail = /^[a-z0-9][\w\.-]*\w@([\w-]+\.)*[a-z]{2,4}$/;
	var mail = document.getElementById("nws_mail").value;
	if(!regemail.test(mail)){ /* alert("Podaj prawidłowy adres email"); */ return false;}
	else{return true;}
}
function SprawdzGuestMail() {
	var regemail = /^[a-z0-9][\w\.-]*\w@([\w-]+\.)*[a-z]{2,4}$/;
	var mail = document.getElementById("guest_mail").value;
	//alert(mail);
	if(!regemail.test(mail)){ /* alert("Podaj prawidłowy adres email"); */ return false;}
	else{return true;}
}


function otworz(adres,szer,wys,tytul,wj,hj) {
//wj jednostka szerokosci
//hj jednostka wysokosci
//1 => px, 2 => %	
  /* szer=690;
  wys=390; */
  if(wj==2)
  {
  szer=(screen.width*szer)/100;
  lewa=(screen.width-szer)/2;  
  }
  else
  {
  lewa=(screen.width-szer)/2;
  }
  
  if(hj==2)
  {
  wys=(screen.height*wys)/100;
  prawa=(screen.height-wys)/2;   
  }  
  else
  {
  prawa=(screen.height-wys)/2;
  }
noweOkno = window.open(adres, tytul, 'menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=no, status=no, width='+szer+', height='+wys+', left='+lewa+', top='+prawa)
noweOkno.focus();
}
/* var so = new SWFObject("pliki/flash.swf", "mymovie", "910", "268", "8", "#000000");
so.addParam("wmode", "transparent");
so.write("baner"); */

