//********* Broken by WOYT ***********
function code(){
	var text='',il=0;
	var code=document.getElementById('kod1').value;
	for(var i=0;i<10;i++){
		il=0;
		il=parseInt(code[i])*(parseInt(code[9])+1);
		text+=il+'';
	}
	var code2=document.getElementById('kod2').value;
	if(code2==text.substring(0,4))
		return true
	document.getElementById('kod2').style.border = "dotted red 2px";
	alert('wprowadźono zły kod z obrazka');
	//window.location.reload();
	return false;
	
}
function sprawdzenie(){
	var ilosc=document.getElementById('form_ilosc').value;
	var walidacja=1;
	for(var i=1; i<=parseInt(ilosc);i++){
		var nazwa='form_'+i;
		if(document.getElementById(nazwa).value.length<2){
			walidacja=0;
			document.getElementById(nazwa).style.border = "dotted red 2px";
			//document.getElementById(nazwa).style.background='red';
		}else{
			document.getElementById(nazwa).style.border = "solid black 1px";
			//document.getElementById(nazwa).style.background='white';
		}	
	}
	if(!walidacja){
		alert('uzupełnij pola formularza');
		return false;
	}else{
		if(!code())
			return false;
		return true;
	}
}
function wyczysc(){
	if(!confirm('Czy jesteś pewien że chcesz wyczyścić formularz?')){return ;}
	var ilosc=document.getElementById('form_ilosc').value;
	for(var i=1; i<=parseInt(ilosc);i++){
		var nazwa='form_'+i;
		document.getElementById(nazwa).value='';	
	}
}

