function wiecej_zalacznikow(numer)
{
	nastepny=numer+1;
	poprzedni=numer-1;
	document.getElementById("zalacznik_"+nastepny).style.display='block';
	document.getElementById("zal_"+numer+"_wiecej").style.display='none';
	document.getElementById("zal_"+numer+"_mniej").style.display='block';
	if (numer!=4){
		document.getElementById("zal_"+nastepny+"_wiecej").style.display='block';
	}
	if (numer!=1){
		document.getElementById("zal_"+poprzedni+"_mniej").style.display='none';
	}
}

function mniej_zalacznikow(numer)
{
	nastepny=numer+1;
	poprzedni=numer-1;
	document.getElementById("zalacznik_"+nastepny).style.display='none';
	document.getElementById("zal_"+numer+"_wiecej").style.display='block';
	document.getElementById("zal_"+numer+"_mniej").style.display='none';
	if (numer!=4){
		document.getElementById("zal_"+nastepny+"_wiecej").style.display='none';
	}
	if (numer!=1){
		document.getElementById("zal_"+poprzedni+"_mniej").style.display='block';
	}
}

function menu_pokaz(pole)
{
	tablica=new Array();
	tablica[0]='regions';
	tablica[1]='decades';
	tablica[2]='civilizations';
	for (x in tablica)
	{
		div = document.getElementById(tablica[x]+"_list");
		if (tablica[x]==pole)
			div.style.display='block';
			else
			div.style.display='none';
	}
}

function pokaz_tom(tom,max)
{
	for (x=1; x<=max; x++)
	{
		div = document.getElementById("tom_"+x);
		if (div){
			if (x==tom)
				div.style.display='block';
				else
				div.style.display='none';
			
		}
	}
}

function Focus(control) {
  control.focus();
  control.select();
}

function IsEmailCorrect(email) {
  return email.match(/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})$/)!=null;
}

function IsEmpty(pole) {
  if (pole=='') 
  	return true
	else
	return false
}

function form_check(id)
{
	form=document.getElementById(id);
	if (IsEmpty(form.imie.value)) {
		alert ('Niewypełniono wymaganych pól: Imię');
		Focus(form.imie);
		return false;
	  }
	if (IsEmpty(form.nazwisko.value)) {
		alert ('Niewypełniono wymaganych pól: Nazwisko');
		Focus(form.nazwisko);
		return false;
	  }
	if (!IsEmailCorrect(form.mail.value)) {
		alert ('Niepoprawny adres e-mail');
		Focus(form.mail);
		return false;
	  }
	if (IsEmpty(form.temat.value)) {
		alert ('Niewypełniono wymaganych pól: Temat');
		Focus(form.temat);
		return false;
	  }
	if (IsEmpty(form.tresc.value)) {
		alert ('Niewypełniono wymaganych pól: Treść');
		Focus(form.tresc);
		return false;
	  }
	if (IsEmpty(form.token.value)) {
		alert ('Niewypełniono wymaganych pól: Treść obrazka');
		Focus(form.token);
		return false;
	  }
	return true;
}

function form_check2(id)
{
	form=document.getElementById(id);
	if (IsEmpty(form.autor.value)) {
		alert ('Niewypełniono wymaganych pól: Autor');
		Focus(form.autor);
		return false;
	  }
	if (IsEmpty(form.tresc.value)) {
		alert ('Niewypełniono wymaganych pól: Treść');
		Focus(form.tresc);
		return false;
	  }
	if (IsEmpty(form.token.value)) {
		alert ('Niewypełniono wymaganych pól: Treść obrazka');
		Focus(form.token);
		return false;
	  }
	return true;
}
