function adulto(x){
	return '<table width="100%"><tr><td colspan=2 align=center><b>Dane uczestnika wyjazdu</b></td></tr><tr><th width="50">Imię:</th><td width="500"><input id="imie'+x+'" name="adult_imie[]" value="" class="edit" type="text"></td></tr><tr><th>Nazwisko:</th><td><input id="nazwisko'+x+'" name="adult_nazwisko[]" value="" class="edit" type="text"></td></tr><tr><th>Data urodzenia DD-MM-YYYY:</th><td><input id="urodziny'+x+'" name="adult_birth[]" value="" class="edit" type="text"></td></tr><tr><th>Adres zameldowania:</th><td><input id="adres'+x+'" name="adult_live[]" value="" class="edit" type="text"></td></tr><tr><th>Kod pocztowy:</th><td><input id="kodpp'+x+'" name="adult_kod[]" value="" class="edit" type="text"></td></tr><tr><th>Miasto:</th><td><input id="miasto'+x+'" name="adult_miasto[]" value="" class="edit" type="text"></td></tr></table>';
}
function childo(){
	return '<table width="100%"><tr><td colspan=2 align=center><b>Dziecko</b></td></tr><tr><th width="50">Imię:</th><td width="500"><input name="child_imie[]" value="" class="edit" type="text"></td></tr><tr><th>Nazwisko:</th><td><input name="child_nazwisko[]" id="rezerwacja_nazwisko" value="" class="edit" type="text"></td></tr><tr><th>Data urodzenia DD-MM-YYYY:</th><td><input name="child_birth[]" id="rezerwacja_nazwisko" value="" class="edit" type="text"></td></tr></table>';
}
function infanto(){
	return '<table width="100%"><tr><td colspan=2 align=center><b>Niemowle</b></td></tr><tr><th width="50">Imię:</th><td width="500"><input name="infant_imie[]" value="" class="edit" type="text"></td></tr><tr><th>Nazwisko:</th><td><input name="infant_nazwisko[]" id="rezerwacja_nazwisko" value="" class="edit" type="text"></td></tr><tr><th>Data urodzenia DD-MM-YYYY:</th><td><input name="infant_birth[]" id="rezerwacja_nazwisko" value="" class="edit" type="text"></td></tr></table>';
}

function dopisz(adult,child,infant,checktrue){
//	alert(checktrue); true or false
	var zwroc='';
	for(var x=0;x<adult;x++)
		zwroc=zwroc+adulto(x);
	for(var x=0;x<child;x++)
		zwroc=zwroc+childo();
	for(var x=0;x<infant;x++)
		zwroc=zwroc+infanto();
	return zwroc;
}

function tez_jedzie(){
	if (document.getElementById('wpisz1').checked){
		if (document.getElementById('imie0')==null){} else {
			document.getElementById('imie0').value=document.getElementById('rezerwacja_imie').value;
			document.getElementById('nazwisko0').value=document.getElementById('rezerwacja_nazwisko').value;
			document.getElementById('adres0').value=document.getElementById('rezerwacja_adres').value;
			document.getElementById('kodpp0').value=document.getElementById('rezerwacja_kodp').value;
			document.getElementById('miasto0').value=document.getElementById('rezerwacja_miasto').value;
		}
	}
}

function pokaz_inne_terminy(){
		for(var x=0;x<10;x++){
			if (document.getElementById('tabelka_global_'+x+'')==null){} else 
				document.getElementById('tabelka_global_'+x+'').style.display='';
		}
} 

function sprawdz_pola(){
		var komunikat='';
		if (document.getElementById('rezerwacja_imie').value.length==0) komunikat=komunikat+"Proszę podać imię osoby zgłaszającej\n";
		if (document.getElementById('rezerwacja_nazwisko').value.length==0) komunikat=komunikat+"Proszę podać nazwisko osoby zgłaszającej\n";
		if (document.getElementById('rezerwacja_telefon').value.length==0) komunikat=komunikat+"Proszę podać telefon osoby zgłaszającej\n";
		if (document.getElementById('rezerwacja_email').value.length==0) komunikat=komunikat+"Proszę podać e-mail osoby zgłaszającej\n";
		if (document.getElementById('rezerwacja_adres').value.length==0) komunikat=komunikat+"Proszę podać adres osoby zgłaszającej\n";
		if (document.getElementById('rezerwacja_kodp').value.length==0) komunikat=komunikat+"Proszę podać kod pocztowy osoby zgłaszającej\n";
		if (document.getElementById('rezerwacja_miasto').value.length==0) komunikat=komunikat+"Proszę podać miejscowość osoby zgłaszającej\n";
		if (document.getElementById('rezerwacja_dorosli').value<=0) komunikat=komunikat+"Proszę podać ilość osób uczestniczących w imprezie\n";
		if (document.getElementById('regulamin').checked==false) komunikat=komunikat+"Proszę zaakceptować regulamin\n";
		if (document.getElementById('zgoda').checked==false) komunikat=komunikat+"Proszę wyrazie zgodę na przetwarzanie danych osobowych\n";

		for(var x=0; x<document.getElementById('rezerwacja_dorosli').value; x++){
				if (document.getElementById('imie'+x).value.length==0) komunikat=komunikat+"Proszę podać imię osoby "+(x+1)+" uczestniczącej w imprezie\n";
				if (document.getElementById('nazwisko'+x).value.length==0) komunikat=komunikat+"Proszę podać nazwisko osoby "+(x+1)+" uczestniczącej w imprezie\n";
				if (document.getElementById('adres'+x).value.length==0) komunikat=komunikat+"Proszę podać adres osoby "+(x+1)+" uczestniczącej w imprezie\n";
				if (document.getElementById('urodziny'+x).value.length==0) komunikat=komunikat+"Proszę podać datę urodzenia osoby "+(x+1)+" uczestniczącej w imprezie\n";
				if (document.getElementById('kodpp'+x).value.length==0) komunikat=komunikat+"Proszę podać kod pocztowy osoby "+(x+1)+" uczestniczącej w imprezie\n";
				if (document.getElementById('miasto'+x).value.length==0) komunikat=komunikat+"Proszę podać miejscowość osoby "+(x+1)+" uczestniczącej w imprezie\n";
		}
		
		if (komunikat.length==0)
			 return true;
		else {
				 alert(komunikat);
				 return false;
		}
}	