$("#chooseWoj").change(function() {
	val = $(this).val();
	window.location = "Szkolenia.html?s[wojewodztwo]="+val;
});


function validate_formmail(f)
 {				
	required = 0;
	wymagane = $(".required_field");
	$.each(wymagane, function () {
		title = $(this).attr('title');
		wartosc = $(this).val();
		if(wartosc.length < 3)
		 {
			alert('Wypelnij pole obowiązkowe: '+title);
			required++;
		 }				
	 });	 
	
	if(required > 0)
	 {
		return false;
	 }
 }

function MailIsValid(Email) 
{ 
	var Pattern = /^[a-z0-9-_]+(\.[a-z0-9-_]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/; 
	return (Pattern.test(Email)) ? true : false; 
} 

function testuj_email(f) {			
  if (!MailIsValid(f.newsletter_add.value)) { alert("Niepoprawny adres e-mail"); return false; }			 
}

function usun (link)
{
	komunikat = "Czy napewno chcesz to zrobić?"
	if (confirm(komunikat))	document.location.href = link;
}

function ask (link, komunikat)
{
	
	if (confirm(komunikat))	document.location.href = link;
}

function goToUrl(s) {
	var gourl = s.options[s.selectedIndex].value;	window.top.location.href = gourl;
}

$(".gThumb").click(function() {
	fileReplace = $(this).attr('rel');
	$("#gThumbBig").attr('src', 'public/foto/products/big_'+fileReplace);
	$("#gThumbLink").attr('href', 'public/foto/products/org_'+fileReplace);					
});


$("#ajaxLoginForm").submit(function() {
				
	loginValue = $("#ajaxLoginUser").val();
	passValue = $("#ajaxLoginPass").val();
	
	$.get("Login.html", { ajaxData: "login", login: loginValue, pass: passValue },
	  function(data){			
		
		if(data == 'USER_LOGGED')
		 {
			alert("Witamy w serwisie!");
			
			$.get("Login.html", { ajaxData: "user", userAccount: 'box' },
			function(userData){
				$("#ajaxLoginForm").remove();
				$("#userAccount").html(userData);
			});
			
			
		 }
		else
		 {
			alert("Błąd logowania! Użytkownik nieistnieje lub konto nie zostało aktywowane");
			$("#userAccount").empty();
		 }
		
		
	  });
	
	return false;		
 });
