$(document).ready(function(){

	$("#addDialog form input[type=submit]").click(function(){
		if($("#addDialog form input[name=name]").attr("value") == "") {
			$("#addDialog form input[name=name]").addClass("inp-form-error");
			//alert($("#addDialog form input[name=name]").parent("tr").find(".error-td").html());
			$("#addDialog form tr#input-name td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			return false;
		} else {
			$("#addDialog form input[name=name]").removeClass("inp-form-error");
			$("#addDialog form tr#input-name td.error-td").html('');
		}
		return true;
	});
	
	$("#editDialog form input[type=submit]").click(function(){
		if($("#editDialog form input[name=name]").attr("value") == "") {
			$("#editDialog form input[name=name]").addClass("inp-form-error");
			$("#editDialog form tr#input-name td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			return false;
		} else {
			$("#editDialog form input[name=name]").removeClass("inp-form-error");
			$("#editDialog form tr#input-name td.error-td").html('');
		}
		return true;
	});
	
	$("#addModule form input[type=submit]").click(function(){
		if($("#addModule form input[name=name]").attr("value") == "") {
			$("#addModule form input[name=name]").addClass("inp-form-error");
			$("#addModule form tr#input-name td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			return false;
		} else {
			$("#addModule form input[name=name]").removeClass("inp-form-error");
			$("#addModule form tr#input-name td.error-td").html('');
		}
		return true;
	});
	
	/*$("form#uploadform").submit(function(){
		var errors = 0;
		if($("form#uploadform input[name=header]").attr("value") == "") {
			$("form#uploadform input[name=header]").addClass("inp-form-error");
			$("form#uploadform tr#input-header td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
			//return false;
		} else {
			$("form#uploadform input[name=header]").removeClass("inp-form-error");
			$("form#uploadform tr#input-header td.error-td").html('');
		}
		if($("tr.zewnetrzny").is(":visible") && ($("form#uploadform input[name=name]").attr("value") == "")){
			$("form#uploadform input[name=name]").addClass("inp-form-error");
			$("form#uploadform tr#input-name td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
			//return false;
		} else {
			$("form#uploadform input[name=name]").removeClass("inp-form-error");
			$("form#uploadform tr#input-name td.error-td").html('');
		}
		if(errors>0) return false;
	});*/
	
	$("#edytujArtykulForm form").submit(function(){
		if($("#edytujArtykulForm form input[name=name]").attr("value") == "") {
			$("#edytujArtykulForm form input[name=name]").addClass("inp-form-error");
			$("#edytujArtykulForm form tr#input-name td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			return false;
		} else {
			$("#edytujArtykulForm form input[name=name]").removeClass("inp-form-error");
			$("#edytujArtykulForm form tr#input-name td.error-td").html('');
		}
		return true;
	});
	
	$("form#galeria_form").submit(function(){
		var errors = 0;
		/*if($("form#galeria_form input[name=header]").attr("value") == "") {
			$("form#galeria_form input[name=header]").addClass("inp-form-error");
			$("form#galeria_form tr#input-header td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
			//return false;
		} else {
			$("form#galeria_form input[name=header]").removeClass("inp-form-error");
			$("form#galeria_form tr#input-header td.error-td").html('');
		}*/
		if($("form#galeria_form input[name=y]").attr("value") == "") {
			$("form#galeria_form input[name=y]").addClass("inp-form-error");
			$("form#galeria_form tr#input-y td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
			//return false;
		} else {
			$("form#galeria_form input[name=y]").removeClass("inp-form-error");
			$("form#galeria_form tr#input-y td.error-td").html('');
		}
		if($("form#galeria_form input[name=x]").attr("value") == "") {
			$("form#galeria_form input[name=x]").addClass("inp-form-error");
			$("form#galeria_form tr#input-x td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
			//return false;
		} else {
			$("form#galeria_form input[name=x]").removeClass("inp-form-error");
			$("form#galeria_form tr#input-x td.error-td").html('');
		}
		
		if($("form#galeria_form input[name=foto_y]").attr("value") == "") {
			$("form#galeria_form input[name=foto_y]").addClass("inp-form-error");
			$("form#galeria_form tr#input-foto_y td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
			//return false;
		} else {
			$("form#galeria_form input[name=foto_y]").removeClass("inp-form-error");
			$("form#galeria_form tr#input-foto_y td.error-td").html('');
		}
		if($("form#galeria_form input[name=foto_x]").attr("value") == "") {
			$("form#galeria_form input[name=foto_x]").addClass("inp-form-error");
			$("form#galeria_form tr#input-foto_x td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
			//return false;
		} else {
			$("form#galeria_form input[name=foto_x]").removeClass("inp-form-error");
			$("form#galeria_form tr#input-foto_x td.error-td").html('');
		}
		if(errors>0) return false;
	});
	
	
	$("form#ustawienia_form").submit(function(){
		var errors = 0;
		if($("form#ustawienia_form input[name=name]").attr("value") == "") {
			$("form#ustawienia_form input[name=name]").addClass("inp-form-error");
			$("form#ustawienia_form tr#input-name td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#ustawienia_form input[name=name]").removeClass("inp-form-error");
			$("form#ustawienia_form tr#input-name td.error-td").html('');
		}
		if($("form#ustawienia_form input[name=mail]").attr("value") == "") {
			$("form#ustawienia_form input[name=mail]").addClass("inp-form-error");
			$("form#ustawienia_form tr#input-mail td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#ustawienia_form input[name=mail]").removeClass("inp-form-error");
			$("form#ustawienia_form tr#input-mail td.error-td").html('');
		}
		if($("form#ustawienia_form input[name=pagename]").attr("value") == "") {
			$("form#ustawienia_form input[name=pagename]").addClass("inp-form-error");
			$("form#ustawienia_form tr#input-pagename td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#ustawienia_form input[name=pagename]").removeClass("inp-form-error");
			$("form#ustawienia_form tr#input-pagename td.error-td").html('');
		}
		if(errors>0) return false;
	});
	
	$("form#zmiana_hasla_form").submit(function(){
		var errors = 0;
		if($("form#zmiana_hasla_form input[name=old_pass]").attr("value") == "") {
			$("form#zmiana_hasla_form input[name=old_pass]").addClass("inp-form-error");
			$("form#zmiana_hasla_form tr#input-old_pass td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#zmiana_hasla_form input[name=old_pass]").removeClass("inp-form-error");
			$("form#zmiana_hasla_form tr#input-old_pass td.error-td").html('');
		}
		if($("form#zmiana_hasla_form input[name=new_pass1]").attr("value") == "") {
			$("form#zmiana_hasla_form input[name=new_pass1]").addClass("inp-form-error");
			$("form#zmiana_hasla_form tr#input-new_pass1 td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#zmiana_hasla_form input[name=new_pass1]").removeClass("inp-form-error");
			$("form#zmiana_hasla_form tr#input-new_pass1 td.error-td").html('');
		}
		if($("form#zmiana_hasla_form input[name=new_pass2]").attr("value") == "") {
			$("form#zmiana_hasla_form input[name=new_pass2]").addClass("inp-form-error");
			$("form#zmiana_hasla_form tr#input-new_pass2 td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#zmiana_hasla_form input[name=new_pass2]").removeClass("inp-form-error");
			$("form#zmiana_hasla_form tr#input-new_pass2 td.error-td").html('');
		}
		if(errors>0) return false;
	});
	
	$("form#modul_ustawienia_form").submit(function(){
	var errors = 0;
		if($("form#modul_ustawienia_form input[name=name]").attr("value") == "") {
			$("form#modul_ustawienia_form input[name=name]").addClass("inp-form-error");
			$("form#modul_ustawienia_form tr#input-name td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#modul_ustawienia_form input[name=name]").removeClass("inp-form-error");
			$("form#modul_ustawienia_form tr#input-name td.error-td").html('');
		}
		if(errors>0) return false;
	});
	
	$("form#photosize_form").submit(function(){
	var errors = 0;
		if($("form#photosize_form input[name=y]").attr("value") == "") {
			$("form#photosize_form input[name=y]").addClass("inp-form-error");
			$("form#photosize_form tr#input-y td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#photosize_form input[name=y]").removeClass("inp-form-error");
			$("form#photosize_form tr#input-y td.error-td").html('');
		}
		if($("form#photosize_form input[name=x]").attr("value") == "") {
			$("form#photosize_form input[name=x]").addClass("inp-form-error");
			$("form#photosize_form tr#input-x td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#photosize_form input[name=x]").removeClass("inp-form-error");
			$("form#photosize_form tr#input-x td.error-td").html('');
		}
		if(errors>0) return false;
	});
	
	$("form#videosize_form").submit(function(){
	var errors = 0;
		if($("form#videosize_form input[name=y]").attr("value") == "") {
			$("form#videosize_form input[name=y]").addClass("inp-form-error");
			$("form#videosize_form tr#input-y td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#videosize_form input[name=y]").removeClass("inp-form-error");
			$("form#videosize_form tr#input-y td.error-td").html('');
		}
		if($("form#videosize_form input[name=x]").attr("value") == "") {
			$("form#videosize_form input[name=x]").addClass("inp-form-error");
			$("form#videosize_form tr#input-x td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#videosize_form input[name=x]").removeClass("inp-form-error");
			$("form#videosize_form tr#input-x td.error-td").html('');
		}
		if(errors>0) return false;
	});
	
	$("form#newFaqForm").submit(function(){
	var errors = 0;
		if($("form#newFaqForm input[name=name]").attr("value") == ""){
			$("form#newFaqForm input[name=name]").addClass("inp-form-error");
			$("form#newFaqForm tr#input-name td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#newFaqForm input[name=name]").removeClass("inp-form-error");
			$("form#newFaqForm tr#input-name td.error-td").html('');
		}
		if(errors>0) return false;
	});
	
	$("form#newFaqQAForm").submit(function(){
	var errors = 0;
		if($("form#newFaqQAForm input[name=q]").attr("value") == ""){
			$("form#newFaqQAForm input[name=q]").addClass("inp-form-error");
			$("form#newFaqQAForm tr#input-q td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#newFaqQAForm input[name=q]").removeClass("inp-form-error");
			$("form#newFaqQAForm tr#input-q td.error-td").html('');
		}
		if($("form#newFaqQAForm input[name=a]").attr("value") == ""){
			$("form#newFaqQAForm input[name=a]").addClass("inp-form-error");
			$("form#newFaqQAForm tr#input-a td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#newFaqQAForm input[name=a]").removeClass("inp-form-error");
			$("form#newFaqQAForm tr#input-a td.error-td").html('');
		}
		if(errors>0) return false;
	});
	
	$("form#newNewsForm").submit(function(){
	var errors = 0;
		if($("form#newNewsForm input[name=title]").attr("value") == ""){
			$("form#newNewsForm input[name=title]").addClass("inp-form-error");
			$("form#newNewsForm tr#input-title td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#newNewsForm input[name=title]").removeClass("inp-form-error");
			$("form#newNewsForm tr#input-title td.error-td").html('');
		}
		if(errors>0) return false;
	});
	$("form#editNewsForm").submit(function(){
	var errors = 0;
		if($("form#editNewsForm input[name=title]").attr("value") == ""){
			$("form#editNewsForm input[name=title]").addClass("inp-form-error");
			$("form#editNewsForm tr#input-title td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#editNewsForm input[name=title]").removeClass("inp-form-error");
			$("form#editNewsForm tr#input-title td.error-td").html('');
		}
		if(errors>0) return false;
	});
	
	$("form#baner_form").submit(function(){
		var errors = 0;

		if($("form#baner_form input[name=foto_y]").attr("value") == "") {
			$("form#baner_form input[name=foto_y]").addClass("inp-form-error");
			$("form#baner_form tr#input-foto_y td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
			//return false;
		} else {
			$("form#baner_form input[name=foto_y]").removeClass("inp-form-error");
			$("form#baner_form tr#input-foto_y td.error-td").html('');
		}
		if($("form#baner_form input[name=foto_x]").attr("value") == "") {
			$("form#baner_form input[name=foto_x]").addClass("inp-form-error");
			$("form#baner_form tr#input-foto_x td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
			//return false;
		} else {
			$("form#baner_form input[name=foto_x]").removeClass("inp-form-error");
			$("form#baner_form tr#input-foto_x td.error-td").html('');
		}
		if(errors>0) return false;
	});
	
	$("form#slider_form").submit(function(){
		var errors = 0;

		if($("form#slider_form input[name=foto_y]").attr("value") == "") {
			$("form#slider_form input[name=foto_y]").addClass("inp-form-error");
			$("form#slider_form tr#input-foto_y td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
			//return false;
		} else {
			$("form#slider_form input[name=foto_y]").removeClass("inp-form-error");
			$("form#slider_form tr#input-foto_y td.error-td").html('');
		}
		if($("form#slider_form input[name=foto_x]").attr("value") == "") {
			$("form#slider_form input[name=foto_x]").addClass("inp-form-error");
			$("form#slider_form tr#input-foto_x td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
			//return false;
		} else {
			$("form#slider_form input[name=foto_x]").removeClass("inp-form-error");
			$("form#slider_form tr#input-foto_x td.error-td").html('');
		}
		if(errors>0) return false;
	});
	
	
	
	$("form#nowyOpiekunForm").submit(function(){
	var errors = 0;
		if($("form#nowyOpiekunForm input[name=imie]").attr("value") == ""){
			$("form#nowyOpiekunForm input[name=imie]").addClass("inp-form-error");
			$("form#nowyOpiekunForm tr#input-imie td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#nowyOpiekunForm input[name=imie]").removeClass("inp-form-error");
			$("form#nowyOpiekunForm tr#input-imie td.error-td").html('');
		}
		if($("form#nowyOpiekunForm input[name=nazwisko]").attr("value") == ""){
			$("form#nowyOpiekunForm input[name=nazwisko]").addClass("inp-form-error");
			$("form#nowyOpiekunForm tr#input-nazwisko td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#nowyOpiekunForm input[name=nazwisko]").removeClass("inp-form-error");
			$("form#nowyOpiekunForm tr#input-nazwisko td.error-td").html('');
		}
		if($("form#nowyOpiekunForm input[name=mail]").attr('value') == ""){
			$("form#nowyOpiekunForm input[name=mail]").addClass("inp-form-error");
			$("form#nowyOpiekunForm tr#input-mail td.error-td").html('<div class="error-left"></div><div class="error-inner">Pole wymagane</div>');
			errors++;
		} else {
			$("form#nowyOpiekunForm input[name=mail]").removeClass("inp-form-error");
			$("form#nowyOpiekunForm tr#input-mail td.error-td").html('');
		}
		if(errors>0) return false;
	});
	
	$("form#newsletter_config").submit(function(){
		var errors = 0;
		if($("form#newsletter_config input[name=title]").attr("value") == ""){
			$("form#newsletter_config input[name=title]").addClass("inp-form-error");
			$("form#newsletter_config input[name=title]").parents("p").find("span").html('<span class="error-left"></span><span class="error-inner">Pole wymagane</span>');
			errors++;
		} else {
			$("form#newsletter_config input[name=title]").removeClass("inp-form-error");
			$("form#newsletter_config input[name=title]").parents("p").find("span").html('');
		}
		
		if(errors > 0) return false;
	});
	
});





