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(){

  $(".lightbox").lightbox();
  $("html").css({"overflow-y":"scroll"});
/**** splash ***/

	


	  name_pola = new Array();
	  value_pola = new Array();
	  $("#form_kontakt :text,#form_kontakt textarea").each(function (i) {
				name_pola[i]=$("#form_kontakt :text,#form_kontakt textarea").eq(i).attr('name');
				value_pola[i]=$("#form_kontakt :text,#form_kontakt textarea").eq(i).val();
				
				$("#form_kontakt :text,#form_kontakt 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_kontakt :text,#form_kontakt textarea").eq(i).blur(function () {
					if(this.value=='')this.value=value_pola[i];
				})
      });
/* 	  html_pola = new Array();
	  $("#form_kontakt textarea").each(function (i) {
				html_pola[i]=$("form :text").eq(i).val();
				
				$("#form_kontakt textarea").eq(i).focus(function () {
					if(this.value==value_pola[i])this.value='';
					alert($(this).html());
					alert(this.value);
					//alert('i '+(i-1))
					//alert('eq '+$(this).eq())
				})
				//$("input[name='"+name_pola+"']").
				$("#form_kontakt textarea").eq(i).blur(function () {
					if(this.value=='')this.value=value_pola[i];
				})
      }); */	  
	  
	  $("#poczta_form :text").each(function (i) {
				name_pola[i]=$("form :text").eq(i).attr('name');
				value_pola[i]=$("form :text").eq(i).val();
				//alert(i+','+name_pola[i]);
				//var i = i;
				
				$("#poczta_form :text").eq(i).focus(function () {
					if(this.value==value_pola[i])this.value='';
					if($(this).attr('name')=='haslo')
					{
						$(this).hide();
						$("#poczta_form :password").show();
						$("#poczta_form :password").focus();
						//$("#poczta_form :password").show(1,function () {$(this).focus()});
						//$(this).attr('type','password');
					}
					//alert('i '+(i-1))
					//alert('eq '+$(this).eq())
				})
				//$("input[name='"+name_pola+"']").
				$("form :text").eq(i).blur(function () {
					if(this.value=='')this.value=value_pola[i];
				})
				$("form :password").eq(i).blur(function () {
					//alert(this.value+', '+i);
					if(this.value=='')
					{
						//alert('dfd');
						$(this).hide();
						$("#poczta_form :text[name='haslo']").show();
						$("#poczta_form :text[name='haslo']").val(value_pola[1]);//trzeba by inaczej ta jedynke pobierac
						//$("#poczta_form :text[name='haslo']").focus();
					}
				})				
      });	  











function animuj_strzalke(co,ile,ile2) {
		$(co).animate({
		      "width":ile
		    }, 400, "easein",function(){animuj_strzalke_back(co,ile2,ile);});	
	return false;
}
function animuj_strzalke_back(co,ile,ile2) {
		$(co).animate({
		      "width":ile
		    },400, "easein",function(){/*animuj_strzalke(co,ile2,ile);*/});	
	return false;
}
function wroc_strzalke(co,ile) {
		$(co).animate({
		      "width":ile
		    }, 400, "easein");	
	return false;
}

$(".wersje a").hover(
      function () {
        animuj_strzalke("#strzalka_small",20,14)
      }, 
      function () {
        wroc_strzalke("#strzalka_small",14)
      }
    );
	
$("#wej_ent a").hover(
      function () {
        animuj_strzalke("#strz_big",54,44)
      }, 
      function () {
        wroc_strzalke("#strz_big",44)
      }
    );	

/*	
	$(".wersje a").mouseover(function(){
      //alert('frrgfdg')
	  animuj_strzalke("#strzalka_small",24,14)
    })
	
	
	$(".wersje a").mouseout(function(){
      wroc_strzalke("#strzalka_small",14)
    });
*/
	

/**** splash ***/  
  
  
  $(".rozwin_pyt").click(function(){
	//$("#pytania").slideToggle("slow");
	
	$("#pytania").animate({
      "height": "toggle", "opacity": "toggle"
    }, { duration: "slow" });
	
	
	//alert($(this).html())
	if($(this).html()=='rozwiń &gt;&gt;'){$(this).html('&lt;&lt; zwiń');}
	else if($(this).html()=='&lt;&lt; zwiń'){$(this).html('rozwiń &gt;&gt;');}	
	else if($(this).html()=='more &gt;&gt;'){$(this).html('&lt;&lt; less');}
	else if($(this).html()=='&lt;&lt; less'){$(this).html('more &gt;&gt;');}
	return false;
  })

	  $(".menu_lewe .main li a").click(function(){
	  //alert($(this).next().css("display"))
	  if ($(this).next().hasClass("aktywne"))
	  {
		//alert($(this).children("a").css("text-decoration"))
		//alert($(this).children("a").css("color"))
		//if($(this).children("a").css("color")=="rgb(0, 0, 0)")
		//{
		if ($(this).next().is(":hidden")){$(this).next().show('slow');}
		else{$(this).next().hide('slow');}
		return false;
		//}
	  }	
	  }); 

$(".pytanie").hover(
      function () {
        $(this).css({"text-decoration":"underline"});
      }, 
      function () {
        $(this).css({"text-decoration":"none"});
      }
    );  
  
 $(".pytanie").click(function(){
		//$(this).next().slideToggle(600);
		
		$(this).next().animate({
		      "height": "toggle", "opacity": "toggle"
		    }, 400, "easein");
			
		if ( $(this).hasClass("minus") ){$(this).removeClass("minus")}
		else{$(this).addClass("minus")}		
    }); 	  
  

  
  /*
  $(".menu_lewe .main li a").click(function(){ 
	$(this).parent().show('slow');
	return true;
  });  
  */
  /*
  $(".menu_lewe .main li").click(function(){
	if ($(this).children().next().is(":hidden")){$(this).children().next().show('slow');$(this).css({"cursor":"pointer"});}
	if ($(this).children().next().is(":visible")){$(this).children().next().hide('slow');$(this).css({"cursor":"pointer"});}
  });
  */
  //$("#pojazdy").tablesorter({sortList:[[0,0]], widgets: ['zebra']});
  //$("#karta_pojazdu tr:odd").css("background-color", "#f6f6f6");
  //$('form.jNice td.jnice').jNice();
  //$('form.jNice').jNice();
  //$(".numeric").numeric(",");
  //$(".rok").numeric(",");
  //$(".numeric").floatnumber(",",2);
  //$(function(){$('form.jNice').jNice();	});
  
    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);
	//$("#komunikat").html(responseText);
	pokaz_komunikat("#komunikat",responseText)
	//$('td.but_radio').jForms();
	//$('td.but_radio .chosen').removeClass('chosen');	
	//$('td.but_radio .radioAreaChecked').removeClass('radioAreaChecked');
  }


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

$("#komunikat").css({"opacity":0});
  
function pokaz_komunikat(komunikat,tresc)
{
 $(komunikat).html(tresc);
 $(komunikat).animate({opacity: 1},1000,function(){
	$(this).animate({opacity: 0},3500);
 });
}  
  
$("#form_kontaktowy").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ą.");
   }
   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");


ourDate = new Date();
/* var so = new SWFObject("pliki/onas.swf", "mymovie", "130", "130", "8", "#000000");
so.addParam("wmode", "transparent");
so.write("kolko"); */
});

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"); */
