function openW(strona,width_,height_,sc){
         new_window = window.open(strona,'strona','width='+width_+',height='+height_+',toolbars=no,resizeble="no",scrollbars='+sc);
}

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,3})$/)!=null;
}

function IsEmpty(pole) {
  if (pole=='') 
  	return true
	else
	return false
}

function sprawdz_formularz()
{
if (IsEmpty(document.getElementById('imie').value)) {
    alert('Proszę podać imię');
    Focus(document.getElementById('imie'));
    return false;
  }
if (IsEmpty(document.getElementById('nazwisko').value)) {
    alert('Proszę podać nazwisko');
    Focus(document.getElementById('nazwisko'));
    return false;
  }
if (!IsEmailCorrect(document.getElementById('mail').value)) {
    alert('Proszę podać poprawny adres e-mail');
    Focus(document.getElementById('mail'));
    return false;
  }
if (IsEmpty(document.getElementById('zapytanie').value)) {
    alert('Proszę podać zapytanie');
    Focus(document.getElementById('zapytanie'));
    return false;
  }
return true;
}

function sprawdz_formularz1()
{
if (document.getElementById('zgoda_umieszczenie').checked == false) {
    alert('Proszę potwierdzić zgodę na umieszczenie informacji w bazie danych');
    Focus(document.getElementById('zgoda_umieszczenie'));
    return false;
  }
if (document.getElementById('zgoda_wykorzystanie').checked == false) {
    alert('Proszę potwierdzić zgodę na wykorzystanie adresu e-mail');
    Focus(document.getElementById('zgoda_wykorzystanie'));
    return false;
  }
	
if (IsEmpty(document.getElementById('ulica_nr').value)) {
    alert('Proszę podać ulicę');
    Focus(document.getElementById('ulica_nr'));
    return false;
  }
if (IsEmpty(document.getElementById('kod_pocztowy').value)) {
    alert('Proszę podać kod pocztowy');
    Focus(document.getElementById('kod_pocztowy'));
    return false;
  }
if (IsEmpty(document.getElementById('miejscowosc').value)) {
    alert('Proszę podać miejscowość');
    Focus(document.getElementById('miejscowosc'));
    return false;
  }
if (IsEmpty(document.getElementById('imie').value)) {
    alert('Proszę podać imię');
    Focus(document.getElementById('imie'));
    return false;
  }
if (IsEmpty(document.getElementById('nazwisko').value)) {
    alert('Proszę podać nazwisko');
    Focus(document.getElementById('nazwisko'));
    return false;
  }
if (IsEmpty(document.getElementById('telefon').value)) {
    alert('Proszę podać telefon');
    Focus(document.getElementById('telefon'));
    return false;
  }
if (!IsEmailCorrect(document.getElementById('email').value)) {
    alert('Proszę podać poprawny adres e-mail');
    Focus(document.getElementById('email'));
    return false;
  }
if (document.getElementById('dzialanosc').options[document.getElementById('dzialanosc').selectedIndex].value==0) {
	alert('Proszę podać działalność');
    Focus(document.getElementById('dzialanosc'));
    return false;	
  }
return true;
}

function spr_dzialalnosc(){
	var dzialanosc = document.getElementById('dzialanosc');
	if (dzialanosc.options[dzialanosc.length-1].selected==true) {
		document.getElementById('dzialanosc_inne').disabled=false;
	} else {document.getElementById('dzialanosc_inne').disabled=true;}
}

function spr_zaintresowania(){
	var dzialanosc = document.getElementById('zainteresowania');
	if (dzialanosc.options[dzialanosc.length-1].selected==true) {
		document.getElementById('zainteresowania_inne').disabled=false;
	} else {document.getElementById('zainteresowania_inne').disabled=true;}
}

function sprawdz_rezerwacja()
{
if (IsEmpty(document.getElementById('godnosc').value)) {
    alert('Proszę podać imię i nazwisko');
    Focus(document.getElementById('godnosc'));
    return false;
  }  
if (!IsEmailCorrect(document.getElementById('email').value)) {
    alert('Proszę podać poprawny adres e-mail');
    Focus(document.getElementById('email'));
    return false;
  }
if (IsEmpty(document.getElementById('telefon').value)) {
    alert('Proszę podać nr telefonu');
    Focus(document.getElementById('telefon'));
    return false;
  }  
if (IsEmpty(document.getElementById('kontakt').value)) {
    alert('Proszę podać osobę kontaktową');
    Focus(document.getElementById('kontakt'));
    return false;
  }  
if (document.getElementById('impreza').options[0].selected) {
    alert('Proszę wybrać imprezę');
    return false;
  }   
if (IsEmpty(document.getElementById('token').value)) {
    alert('Proszę przepisać token');
    Focus(document.getElementById('token'));
    return false;
  }   
}

function sprawdz_rezerwacja_ang()
{
if (IsEmpty(document.getElementById('godnosc').value)) {
    alert('Please type name');
    Focus(document.getElementById('godnosc'));
    return false;
  }  
if (!IsEmailCorrect(document.getElementById('email').value)) {
    alert('Please type email');
    Focus(document.getElementById('email'));
    return false;
  }
if (IsEmpty(document.getElementById('telefon').value)) {
    alert('Please type phone number');
    Focus(document.getElementById('telefon'));
    return false;
  }  
if (IsEmpty(document.getElementById('kontakt').value)) {
    alert('Please type contact person');
    Focus(document.getElementById('kontakt'));
    return false;
  }  
if (document.getElementById('impreza').options[0].selected) {
    alert('Please select event');
    return false;
  }  
if (IsEmpty(document.getElementById('token').value)) {
    alert('Please rewrite the token');
    Focus(document.getElementById('token'));
    return false;
  }   
}

function sprawdz_newsletter()
{
if (!IsEmailCorrect(document.getElementById('mail').value)) {
    alert('Proszę podać poprawny adres e-mail');
    Focus(document.getElementById('mail'));
    return false;
  }
return true;
}
