//alert('OK');

function forma_platnosci(id){

	if(id==7 || id==8){
		aktywuj_prezent();
	}else{
		deaktywuj_prezent();
	}
}

function aktywuj_prezent(){
	//wyswietl_adresdowysylki();
	thisform = document.wysylka;
	rd_index = -1;
	for(i=thisform.w_tn_adres.length-1; i > -1; i--) {
		if (thisform.w_tn_adres[i].checked) {
			rd_index = i; i = -1;
		}
	}
	if(rd_index==1){ //wybieram drugi radiobutton
		//wyswietl_adresdowysylki(0);
		//alert(rd_index);
	}
	wyswietl_bilecik(1);
}

function deaktywuj_prezent(){
	wyswietl_bilecik(0);

}

function wyswietl_bilecik(pokaz){
	if(pokaz){
		document.getElementById('sh_w_bilecik').style.display = "";
	}else{
		document.getElementById('sh_w_bilecik').style.display = "none";
	}
}

function wyswietl_dane_kontaktowe(wartosc){
	//0 - osoba prywatna
	//1 - firma

	if(wartosc){
		document.getElementById('zamawiajacy').innerHTML = "Firma";
		document.getElementById('nip_ukryty').style.display = "";
	}else{
		document.getElementById('zamawiajacy').innerHTML = "Imię i nazwisko";
		document.getElementById('nip_ukryty').style.display = "none";
	}
}

function wyswietl_rodzaj_rachunku(pokaz){
	//1 - paragon
	//0 - faktura
	if(pokaz){
		//paragon
		document.getElementById('rachunek').style.display = "none";
		wyswietl_danenafakturze(1);
	}else{
		//faktura
		document.getElementById('rachunek').style.display = "";
		thisform = document.wysylka;
		rd_index = -1;
		for(i=thisform.r_tn_rachunek_dane.length-1; i > -1; i--) {if (thisform.r_tn_rachunek_dane[i].checked) {rd_index = i; i = -1;}}
		if(rd_index==1){ //wybieram drugi radiobutton
			wyswietl_danenafakturze(0);
		}



	}
}

function wyswietl_danenafakturze(pokaz){
	//0 - dane inne niz powyze
	if(pokaz){
		document.getElementById('f_rodzajrachunku').style.display = "none";
	}else{
		document.getElementById('f_rodzajrachunku').style.display = "";
	}
}

function wyswietl_adresdowysylki(pokaz){
	if(pokaz){
		document.getElementById('f_adresdowysylki').style.display = "none";
	}else{
		document.getElementById('f_adresdowysylki').style.display = "";
	}
}

function sprawdz_wartosci(){

		rd_index = -1;
		thisform = document.wysylka;

		
		for(i=thisform.k_tn_firma.length-1; i > -1; i--) {if (thisform.k_tn_firma[i].checked) {rd_index = i; i = -1;}}
		if(rd_index==1){ //wybieram drugi radiobutton
			wyswietl_dane_kontaktowe(1);
		}
		rd_index = -1;
		for(i=thisform.r_tn_rachunek.length-1; i > -1; i--) {if (thisform.r_tn_rachunek[i].checked) {rd_index = i; i = -1;}}
		if(rd_index==1){ //wybieram drugi radiobutton
			wyswietl_rodzaj_rachunku(0);
		}
		rd_index = -1;
		for(i=thisform.r_tn_rachunek_dane.length-1; i > -1; i--) {if (thisform.r_tn_rachunek_dane[i].checked) {rd_index = i; i = -1;}}
		if(rd_index==1){ //wybieram drugi radiobutton
			wyswietl_danenafakturze(0);
		}
		rd_index = -1;
		for(i=thisform.w_tn_adres.length-1; i > -1; i--) {if (thisform.w_tn_adres[i].checked) {rd_index = i; i = -1;}}
		if(rd_index==1){ //wybieram drugi radiobutton
			wyswietl_adresdowysylki(0);
		}
}


function test(){

alert('Test: TEST');

}