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;
}


$(document).ready(function(){
  //$.preloadCssImages({ 'imgDir': '../pliki' });
  $(".lightbox").lightBox();
  $("html").css({"overflow-y":"scroll"});
  var margin_left = Math.round(($("#linki_bot").outerWidth()-$("#linki_bot ul").outerWidth())/2);
	//$("#linki_bot ul").css({"margin-left":margin_left});
	//$("#linki_bot ul").css({"margin-left":0});
	$("#linki_bot ul").css({"opacity":0});
	$("#linki_bot ul").animate({marginLeft: margin_left, opacity: 1}, 500,"linear",function()
		{
			$("#kolumna1 ul li").each(function (i) {
				if(i>=10)
				{
					$(this).hide();
					$(this).addClass("ukryte");
					$("#lista_tv_wiecej").css({"visibility":"visible"});
				}
				else
				{
					$(this).show(1000);
				}
			});
			
			$("#kolumna1 a img").each(function (i) {
				if(i>=10)
				{
					$(this).parent("a").hide();
					$(this).parent("a").addClass("ukryte");
					$("#lista_event_wiecej").css({"visibility":"visible"});
				}
				else
				{
					$(this).show(1000);
				}
			});			
		}
	);
	//animate({opacity: 0.8}, 300,"linear");
	//alert($("#srodek .tekst").outerHeight())
   

	$("#kolumna2 .galeria").each(function (i) {
					var licznik=0;
					$(this).children(".lightbox").each(function (j) {
						licznik++;
						if((licznik)%4==0){$(this).addClass('last');}
					});
	      }); 
		  
	$("#menu_top li a").each(function (i) {
		if ( !$(this).hasClass("but"+(i+1)+"o") && !$(this).hasClass("lng") )
		//if ( $(this).not(".but"+(i+1)+"o") )
		{	 
					 $(this).hover(
				      function () {
							//alert($(this).html())
							$(this).addClass("but"+(i+1)+"o");
							//alert($(this).parent().outerWidth());
							$(this).parent().prepend("<div class='flara' style='width:"+($(this).parent().outerWidth()-2)+"px;height:"+($(this).parent().outerHeight()-2)+"px;'></div>");
							$(this).parent().children("div").css({"opacity":0});
							$(this).parent().children("div").animate({opacity: 1}, 500,"linear")
				      }, 
				      function () {
							$(this).removeClass("but"+(i+1)+"o");
							$(this).parent().children("div").animate({opacity: 0}, 500,"linear",function()
							{
								$(this).parent().children("div").remove();
							})
														
				      }
				    ); 
		}
		else
		{
			if (!$(this).hasClass("lng"))
			{
			$(this).parent().prepend("<div class='flara' style='width:"+($(this).parent().outerWidth()-2)+"px;height:"+($(this).parent().outerHeight()-2)+"px;'></div>");
			$(this).parent().children("div").css({"opacity":0});
			$(this).parent().children("div").animate({opacity: 1}, 500,"linear")
			}
		}
	 }); 


	$("#lista_tv_wiecej").click(function(){
		//alert($(this).html())
		if($(this).html()=="więcej &gt;")
		{
			$("#kolumna1 ul li").show(1000);
			$(this).html("< zwiń");
		}
		else if($(this).html()=="&lt; zwiń")
		{
			$("#kolumna1 ul li.ukryte").hide(1000);
			$(this).html("więcej >");
		}

		if($(this).html()=="more &gt;")
		{
			$("#kolumna1 ul li").show(1000);
			$(this).html("< hide");
		}
		else if($(this).html()=="&lt; hide")
		{
			$("#kolumna1 ul li.ukryte").hide(1000);
			$(this).html("more >");
		}		
		return false;
	});
	
	$("#lista_event_wiecej").click(function(){
		//alert($(this).html())
		if($(this).html()=="więcej &gt;")
		{
			$("#kolumna1 a").show(1000);
			$(this).html("< zwiń");
		}
		else if($(this).html()=="&lt; zwiń")
		{
			$("#kolumna1 a.ukryte").hide(1000);
			$(this).html("więcej >");
		}
		
		if($(this).html()=="more &gt;")
		{
			$("#kolumna1 a").show(1000);
			$(this).html("< hide");
		}
		else if($(this).html()=="&lt; hide")
		{
			$("#kolumna1 a.ukryte").hide(1000);
			$(this).html("more >");
		}		
		return false;
	});	
		  
	  
   
   $("input.wyslij").hover(
      function () {
        $(this).attr("src","pliki/wyslij_over.gif");
      }, 
      function () {
        $(this).attr("src","pliki/wyslij.gif");
      }
    );

  for(ni=1;ni<=5;ni++)
  {
   $(".buttony a.but"+ni).hover(
      function () {
        nazwa_css=$(this).attr('class');
		id_but=nazwa_css.replace(" graf", "");
		id_but=id_but.replace("but", "");
		//alert(id_but)
		$("#linia"+id_but).css("visibility", "visible");//css({"visibility":"visible"});
      }, 
      function () {
        $("#linia"+id_but).css("visibility", "hidden");//css({"visibility":"hidden"});
      }
    );
  }

    $(".lightbox").hover(
      function () {
			$(this).children("img").animate({opacity: 0.8}, 300,"linear");
      }, 
      function () {
			$(this).children("img").animate({opacity: 1}, 300,"linear");        
      }
    ); 

/*	
	$('.lightbox').ahover({moveSpeed: 100, hoverEffect: function() {
        $(this)
            .css({opacity: 0.99})
            .animate({opacity: 0.5}, 750)
            .animate({opacity: 0.99}, 750)
            .dequeue();
        $(this).queue(arguments.callee);
    }});
*/
	
  /*
			css({opacity: 0.99})
            .animate({opacity: 0.5}, 750)
            .animate({opacity: 0.99}, 750)
			*/
  
  
      $(".menu_lewe .main li a.rozwin").each(function () {
		if($(this).next().css('display')=='block')
		{
          $(this).html("-");
		}
      });

  

	  $(".menu_lewe .main li a.rozwin").click(function(){

			if ($(this).next().is(":hidden")){$(this).next().show('slow');}
			else{$(this).next().hide('slow');}
			if($(this).html()=='+'){$(this).html('-');}
			else{$(this).html('+');}
			return false;

	  }); 

  
    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('zmiany zapisane\n'+responseText);
	//$("#form_kontaktowy textarea").text(responseText);
	//editable_kat(".kategorie p");
    alert(responseText);
	//$('td.but_radio').jForms();
	//$('td.but_radio .chosen').removeClass('chosen');	
	//$('td.but_radio .radioAreaChecked').removeClass('radioAreaChecked');
  }

$(".ajax").submit(function(){
	/*
	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.");
	$(this).ajaxSubmit(options_wyslij);
   }
   else
   {
	alert("Wiadomość nie została wysłana.\n Wypełnij pola z gwiazdką.");
   }
   */
   $(this).ajaxSubmit(options_wyslij);
   return false;
  }); 

$("#formz").submit(function(){
	var p2a=document.formz['2a'].value;
	var p2b=document.formz['2b'].value;
	var p2c=document.formz['2c'].value;
	var p3a=document.formz['3a'].value;
	var p3b=document.formz['3b'].value;
	var p3c=document.formz['3c'].value;
	var p3d=document.formz['3d'].value;
	var p3e=document.formz['3e'].value;
	var p4a=document.formz['4a'].value;
	var p4b=document.formz['4b'].value;
	var p4c=document.formz['4c'].value;
	
   if(p2a!='' && p2b!='' && p2c!='' && p3a!='' && p3b!='' && p3c!='' && p3d!='' && p3e!='' && p4a!='' && p4b!='' && p4c!='')
   {
	//alert("Wiadomość została wysłana.");
	$(this).ajaxSubmit(options_wyslij);
   }
   else
   {
	alert('Wypełnij pola z gwiazdką !!!');
   }
   return false;
  }); 
  
  
$("table.fotorelacje tr:odd").css("background-color", "#f1efdc");
$("table.fotorelacje tr:even").css("background-color", "#eee7c9");

	  name_pola = new Array();
	  value_pola = new Array();
	  $("form.ajax :text,form.ajax textarea").each(function (i) {
				name_pola[i]=$("form :text,form.ajax textarea").eq(i).attr('name');
				value_pola[i]=$("form :text,form.ajax textarea").eq(i).val();
				
				$("form :text,form.ajax 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+"']").
				$("form :text,form.ajax textarea").eq(i).blur(function () {
					if(this.value=='')this.value=value_pola[i];
				})
      });
  
});


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"); */

