// funkcje

function checkForm(form)
{
	
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	var filtertel = /^\d+$/;

	
	if (form.firma.value == '') { alert('Nie wypelniono pola Firma/Nazwisko!'); form.firma.focus(); return false; }
	if (form.firma.value.length < '3') { alert('Pole Firma/Nazwisko! powinno mieć przynajmniej 3 znaki!'); form.firma.focus(); form.firma.select(); return false; }				
	if (form.adres.value == '') { alert('Nie podano adresu!'); form.adres.focus(); return false; }
	if (form.telefon.value == '') { alert('Nie podano numeru telefonu!'); form.telefon.focus(); return false; } else {
		if (!filtertel.test(form.telefon.value)) { alert('Proszę podać poprawny numer telefonu.\n Akceptowane są tylko cyfry.\n Puste pola (przerwy) pomiędzy cyframi są niedozwolone.'); form.telefon.focus(); return false; }
	}
	if (form.adres_email.value != '') {
		if  (!filter.test(form.adres_email.value)) { alert('Proszę podać poprawny adres email'); form.adres_email.focus(); return false; }
	}
	if (form.tresc.value == '') { alert('Nie wpisano widomości!'); form.tresc.focus(); return false; }
	if (form.tresc.value.length > '2000') { alert('Tekst wiadomości jest zbyt dlugi! Max 2000 znaków.'); form.tresc.focus(); form.tresc.select(); return false; }
	
	if (form.code.value == '') { alert('Nie wypelniono pola KOD!'); form.code.focus(); return false; }
	if (form.code.value.length != '4') { alert('Pole KOD! powinno mieć 4 znaki!'); form.code.focus(); form.code.select(); return false; }				

	return true; 
}

function show(k)
{ 
   with(document){ 
      getElementById('k_1').style.display=k==1?'block':'none' 
      getElementById('k_2').style.display=k==2?'block':'none' 
      getElementById('k_3').style.display=k==1?'block':'none'
      window.document.location="#formularz"; 
   } 
}

function popup_scrolls(url, name, width, height)
{
	var x = (screen.availWidth - width)/2;
	var y = (screen.availHeight - height)/2;
	
	win = window.open(url, name, 'width='+width+',height='+height+',left='+x+',top='+y+',toolbar=0,menubar=0,scrollbars=1,resizable=0');
	win.focus();
}
