function checkFormKontakt_custom() {
	var str = "", blad = "";
	var f = document.forms.cc;

	if(f.cc_user.value == "") str += " - nadawca\n";
	if( (f.cc_email.value == "") || (f.cc_email.value.indexOf("@",0) == "-1") || (f.cc_email.value.indexOf(".",0) == "-1") || (f.cc_email.value.indexOf("@",0) == (f.cc_email.value.length-1)) || (f.cc_email.value.indexOf(".",0) == (f.cc_email.value.length-1)) ) str += " - adres e-mail\n";
	if(f.cc_message.value == "") str += " - treść wiadomości\n";

	if(str != "") str = "Wypełnij wszystkie pola:\n"+str;
	if(blad != "") str = str+blad;

	if(str != "")
	{
		alert(str);
		return false;
	}
	else
	{
		str = "Wiadomość została wysłana.";
		alert(str);
		return true;
	}
}

function checkFormDodajProdukt() {
	var f = document.forms.nprod;

	if (f.f_nazwa.value == "") { alert("Wprowadź nazwę produktu..."); return false;}
	//else if (f.f_producent.selectedIndex == 0) { alert("Wybierz producenta produktu..."); return false;}
	else return true;
}

function checkFormSzukajProste() {
	var f = document.forms.mszukaj;
	if (f.sz_marka.selectedIndex == 0 && f.sz_fraza.value.length < 2) { alert("Wprowadź przynajmniej 2 znaki..."); return false;}
	else return true;
}

function checkFormLogowanie() {
	var str = "", blad = "";
	var f = document.forms.logowanie;

	if(f.f_email.value == "") str += " - nazwa użytkownika lub adres e-mail\n";
	if(f.f_haslo.value == "") str += " - hasło\n";

	if(str != "") str = "Wypełnij pola:\n"+str;
	if(blad != "") str = str+blad;

	if(str != "") {
		alert(str);
		return false;
	} else return true;
}

function checkFormKontakt() {
	var str = "", blad = "";
	var f = document.forms.kontakt;

	if(f.k_imie.value == "") str += " - nadawca\n";
	if(f.k_email.value == "") str += " - adres e-mail\n";
	if(f.k_temat.value == "") str += " - temat\n";
	if(f.k_tresc.value == "") str += " - treść wiadomości\n";

	if(str != "") str = "Wypełnij wszystkie pola:\n"+str;
	if(blad != "") str = str+blad;

	if(str != "") {
		alert(str);
		return false;
	} else return true;
}

function checkFormLogowanieMini() {
	var str = "", blad = "";
	var f = document.forms.logowaniemini;

	if(f.f_email.value == "") str += " - nazwa użytkownika lub adres e-mail\n";
	if(f.f_haslo.value == "") str += " - hasło\n";

	if(str != "") str = "Wypełnij pola:\n"+str;
	if(blad != "") str = str+blad;

	if(str != "") {
		alert(str);
		return false;
	} else {
		return true;
	}
}

function checkFormRejestracja() {
	var str = "", blad = "";
	var f = document.forms.rejestracja;

	if(f.f_email.value != "" && f.f_email.value.indexOf("@",0) == "-1" && f.f_email.value.indexOf(" ",0) == "-1") blad += "\nBłędny format adresu e-mail\n";
	if(f.f_haslo.value != "" && f.f_haslo.value != f.f_haslo1.value) { blad += "\nBłędnie powtórzone hasło...\n"; }

	if(f.f_user.value == "") str += " - użytkownik\n";
	if(f.f_email.value == "") str += " - e-mail\n";
	if(f.f_imie.value == "") str += " - imię\n";
	if(f.f_nazwisko.value == "") str += " - nazwisko\n";
	if(!f.f_plec[0].checked && !f.f_plec[1].checked) str += " - płeć\n";

	if(f.f_haslo.value == "") str += " - hasło\n";
	if(f.f_haslo1.value == "") str += " - powtórz hasło\n";

	if(f.f_telefon.value == "") str += " - telefon\n";
	if(f.f_ulica.value == "") str += " - ulica\n";
	if(f.f_nrdomu.value == "") str += " - numer domu\n";
	if(f.f_kod.value == "") str += " - kod pocztowy\n";
	if(f.f_miasto.value == "") str += " - miasto\n";
	if (f.f_wojewodztwo.selectedIndex == 0) str += " - województwo\n";
	if(f.f_imgveri.value == "") str += " - kod z obrazka\n";

	if(f.f_komunikator.selectedIndex != 0 && f.f_nrkomunikator.value == "") str += " - nr/login "+f.f_komunikator.options[f.f_komunikator.selectedIndex].value+"\n";

	if(str != "") str = "Wypełnij obowiązkowe pola:\n"+str;
	if(blad != "") str = str+blad;


	if(str != "") {
		alert(str);
		return false;
	}
	else {
		if (f.f_edycja.value == 0 && !f.f_regulamin.checked) { alert("Aby się zarejestrować musisz\nzaakceptować warunki regulaminu!"); return false;}
		return true;
	}
}

function checkFormZamowienie() {
	var str = "", blad = "";
	var f = document.forms.zamowienie;

	if(f.f_ad_email.value != "" && f.f_ad_email.value.indexOf("@",0) == "-1" && f.f_ad_email.value.indexOf(" ",0) == "-1") blad += "\nBłędny format adresu e-mail\n";

	if(f.f_ad_email.value == "") str += " - e-mail\n";
	if(f.f_ad_imie.value == "") str += " - imię\n";
	if(f.f_ad_nazwisko.value == "") str += " - nazwisko\n";
	if(f.f_ad_ulica.value == "") str += " - ulica\n";
	if(f.f_ad_nrdomu.value == "") str += " - numer domu\n";
	if(f.f_ad_kod.value == "") str += " - kod pocztowy\n";
	if(f.f_ad_miasto.value == "") str += " - miasto\n";

	if(str != "") str = "Wypełnij obowiązkowe pola:\n"+str;
	if(blad != "") str = str+blad;


	if(str != "") {
		alert(str);
		return false;
	}
	else {
		if(!f.f_regulamin.checked) { alert("Aby dokonać zakupu musisz\nzaakceptować warunki regulaminu!"); return false;}
		return true;
	}
}


function checkZmienHaslo() {
	var str = "", blad = "";
	var f = document.forms.zmienhaslo;

	if(f.f_shaslo.value == "") str += " - aktualne hasło\n";
	if(f.f_nhaslo.value == "") str += " - nowe hasło\n";
	if(f.f_nhaslo1.value == "") str += " - powtórz nowe hasło\n";
	if(f.f_nhaslo.value != "" && f.f_nhaslo.value != f.f_nhaslo1.value) { blad += "\nBłędnie powtórzone nowe hasło...\n"; }

	if(str != "") str = "Wypełnij pola:\n"+str;
	if(blad != "") str = str+blad;

	if(str != "") {
		alert(str);
		return false;
	} else return true;
}

function checkFormZamowienie2(sposob_dostawy,verify) {
	var f = document.forms.zamowienie;
	var str = "";

	//str += f.f_verify.value + "\n";
	//str += hex_md5(f.f_verify.value) + "\n";
	//str += verify + "\n";
	//alert( str );
	
	if( verify != "" )
	{
		if( f.f_verify.value == "" )
		{
			alert('Proszę wprowadzić 5 znakowy kod weryfikacyjny.');
			return false;
		}
		else if( hex_md5(f.f_verify.value) != verify )
		{
			//str += f.f_verify.value + "\n";
			//str += hex_md5(f.f_verify.value) + "\n";
			//str += verify + "\n";
			//alert( str );
			alert('Wprowadź poprawny kod weryfikacyjny.');
			return false;
		}
	}
	
	if (sposob_dostawy == "pobranie") return true;
	else if (sposob_dostawy == "osobisty") { // płatność: przelew || online || gotowka
		//if(f.f_sposobpl[0].checked || f.f_sposobpl[1].checked || f.f_krok.value==1) return true;
		if(f.f_sposobpl[0].checked || f.f_sposobpl[1].checked || f.f_sposobpl[2].checked || f.f_krok.value==1) return true;
		else {
			alert('Wybierz sposób płatności!');
			return false;
		}
	} else { // kurier, poczta, zam -> płatność: przelew || online
		if(f.f_sposobpl[0].checked || f.f_sposobpl[1].checked || f.f_krok.value==1) return true;
		else {
			alert('Wybierz sposób płatności!');
			return false;
		}
	}
}

function zoom(src, width, height, id) {
	var left = (screen.width/2)-(width/2);
	window.open('_zoom.php?src='+src,'galeria'+id,'top=100,left='+left+',scrolling=no,width='+width+',height='+height+',scrollbars=no,resizalbe=no');
}

function goscInfo() {
	alert("Aby dokonywać zakupów w sklepie musisz się zalogować!\nJeśli nie jeste¶ użytkownikiem tortownia.pl,\nzarejestruj się w dziale Moje konto.");
}

function openInfo(src, info, width, height) {
	var left = (screen.width/2)-(width/2);
	var top = (screen.height/2)-(height/2);
	wintitle = 'info'+Math.floor(Math.random()*10000);
	window.open('info.php?src='+src+'&width='+width+'&height='+height+'&info='+info, wintitle, 'top=100,left='+left+',top='+top+'scrolling=no,width='+width+',height='+height+',scrollbars=no,resizalbe=no,status=no');
}

function openInfoScroll(src, info, width, height) {
	var left = (screen.width/2)-(width/2);
	var top = (screen.height/2)-(height/2);
	wintitle = 'info'+Math.floor(Math.random()*10000);
	window.open('info.php?src='+src+'&width='+width+'&height='+height+'&info='+info, wintitle, 'top=100,left='+left+',top='+top+'scrolling=no,width='+width+',height='+height+',scrollbars=yes,resizalbe=no,status=no');
}

function swapImage(id, src) {
	var obj = document.getElementById(id);
	obj.src = src;
}

function errorNotice(path) {
	var width = 400;
	var height = 380;
	var left = (screen.width/2)-(width/2);
	var top = (screen.height/2)-(height/2);
	window.open('errornotice.php?path='+path+'&width='+width+'&height='+height, 'err'+Math.floor(Math.random()*10000), 'top=100,left='+left+',top='+top+'scrolling=no,width='+width+',height='+height+',scrollbars=no,resizalbe=no,status=no');
}

function checkFormErrorNotice() {
	var str = "", blad = "";
	var f = document.forms.error;

	if(f.opis.value == "") {
		alert('Opisz proszę błąd/uwagę w miarę dokładnie :-)');
		return false;
	} else if(f.osoba.value == "") {
		alert('Podaj nam proszę swój adres e-mail,\nabyśmy mogli skontaktować\nsię z Tobą w razie wątpliwości :-)');
		return false;
	} else return true;
}

function aktualnaDataGodzina() {
	// data w formacie Y-m-d H:i
	var output, teraz = new Date();
	
	output = teraz.getFullYear() + "-"
	if (teraz.getMonth() < 10)  output += "0";
	output += (teraz.getMonth()+1)+"-";
	if (teraz.getDate() < 10)  output += "0";
	output += teraz.getDate()+" ";
	if (teraz.getHours() < 10)  output += "0";
	output += teraz.getHours()+":";
	if (teraz.getMinutes() < 10)  output += "0";
	output += teraz.getMinutes();
		
	return output;
}

