$(document).ready(function() {
	$('#menulist li a').css({backgroundPosition: '0px 9px'});

	$('#menulist li a').hover(function() {
		$(this).animate({
			backgroundPosition: '(0 0)'
		}, 200);
	}, function() {
		$(this).animate({
			backgroundPosition: '(0 9px)'
		}, 300);
	});
	
    $("#accordion").accordion({
		alwaysOpen: false,
		active: false,
		autoHeight: false,
		selectedClass: "active"
	});
	$("div#trescaktualnosci hr, div#trescdzialu hr").wrap("<div class='hr'><div></div></div>");

});



function sprawdzForm() {
	var reg;
	document.getElementById("email").style.borderColor="#000000";
	document.getElementById("nazwisko").style.borderColor="#000000";
	document.getElementById("telefon").style.borderColor="#000000";
	document.getElementById("wiadomosc").style.borderColor="#000000";
	
	document.getElementById("email").style.backgroundColor="#ffffff";
	document.getElementById("nazwisko").style.backgroundColor="#ffffff";
	document.getElementById("telefon").style.backgroundColor="#ffffff";
	document.getElementById("wiadomosc").style.backgroundColor="#ffffff";
	
	var email=true;	
	reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if (!reg.test(document.getElementById("email").value) || document.getElementById("email").value.length<=7) {
		document.getElementById("email").style.borderColor="red";
		document.getElementById("email").style.backgroundColor="#ffe9e9";
		email=false;
	}
	
	var nazwisko=true;
	reg = /^[A-Za-zęóąśłżźćńĘÓĄŚŁŻŹĆŃ]+( ){1}[A-Za-zęóąśłżźćńĘÓĄŚŁŻŹĆŃ\-]+$/;
	if (!reg.test(document.getElementById("nazwisko").value) || document.getElementById("nazwisko").value.length<=5) {
		document.getElementById("nazwisko").style.borderColor="red";
		document.getElementById("nazwisko").style.backgroundColor="#ffe9e9";
		nazwisko=false;
	}

	var telefon=true;
	reg = /^\+?\d*$/;
	if (!reg.test(document.getElementById("telefon").value) || document.getElementById("telefon").value.length<7) {
		document.getElementById("telefon").style.borderColor="red";
		document.getElementById("telefon").style.backgroundColor="#ffe9e9";
		telefon=false;
	}
	
	var wiadomosc=true;
	if(document.getElementById("wiadomosc").value.length<=20) {
		document.getElementById("wiadomosc").style.borderColor="red";
		document.getElementById("wiadomosc").style.backgroundColor="#ffe9e9";
		wiadomosc=false;
	}
	
	if(email && telefon && nazwisko && wiadomosc) {
		return true;
	}	
	return false;
}



/**
 * @author Alexander Farkas
 * v. 1.02
 */
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
            
           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);
