function pokazPopup(ident)
		{
		
		window.open('pokazPopup.php?ident='+ident,'','toolbar=0,status=0,location=0, scrollbars=yes,resizable=no,width=600,height=630');
		}


function popup(id_strony,id_gal)
		{
		
		window.open('popup.php?id_strony='+id_strony+'&id_gal='+id_gal,'','toolbar=0,status=0,location=0, scrollbars=yes,resizable=no,width=600,height=560');	
		}



function popup_galeria(id_gal)
		{
		
		window.open('popup_galeria.php?id_gal='+id_gal,'','toolbar=0,status=0,location=0, scrollbars=yes,resizable=no,width=600,height=530');	
		}



					        function verify(form)
					        {
					           var passed = false;
					        var blnRetval, intAtSign, intDot, intComma, intSpace, intLastDot, intDomain, intStrLen;
					        if (form.Email){
					                       intAtSign=form.Email.value.indexOf("@");
					                        intDot=form.Email.value.indexOf(".",intAtSign);
					                        intComma=form.Email.value.indexOf(",");
					                        intSpace=form.Email.value.indexOf(" ");
					                        intLastDot=form.Email.value.lastIndexOf(".");
					                        intDomain=intDot-intAtSign;
					                        intStrLen=form.Email.value.length;
					                // *** CHECK FOR BLANK EMAIL VALUE
					                   if (form.Email.value == "" )
					                   {
					                alert("Please enter e-mail.");
					                form.Email.focus();
					                passed = false;
					                }
					                // **** CHECK FOR THE  @ SIGN?
					                else if (intAtSign == -1)
					                {
					
					                alert("Please enter valid e-mail : \"@\".");
					                        form.Email.focus();
					                passed = false;
					
					                }
					                // **** Check for commas ****
					
					                else if (intComma != -1)
					                {
					                alert("Please enter valid data...");
					                form.Email.focus();
					                passed = false;
					                }
					
					                // **** Check for a space ****
					
					                else if (intSpace != -1)
					                {
					                alert("Please enter valid data");
					                form.Email.focus();
					                passed = false;
					                }
					
					                // **** Check for char between the @ and dot, chars between dots, and at least 1 char after the last dot ****
					
					                else if ((intDot <= 2) || (intDomain <= 1)  || (intStrLen-(intLastDot+1) < 2))
					                {
					                alert("Please check this .\n" + form.Email.value + " is invalid.");
					                form.Email.focus();
					                passed = false;
					                }  else {
					                 passed = true;
					                }
					        	} else    {
					              passed = true;
					        }  return passed;
					  }










function check_form_optional(form_name) 
  {
  var form = form_name;

  var firstname = form.elements['firstname'].value;
  var lastname = form.elements['lastname'].value;
  var street_address = form.elements['street_address'].value;

  if (firstname == '' && lastname == '' && street_address == '') {
    return true;
  } else {
    return check_form(form_name);
  }
}







function walidacja(thisform)
{
with (thisform)
{
if (emptyvalidation(data_przyjazdu,"Wszystkie wymagane pola muszą być wypełnione : Data przyjazdu")==false) {data_przyjazdu.focus(); return false;};

if (emptyvalidation(imie,"Wszystkie wymagane pola muszą być wypełnione : Imię")==false) {imie.focus(); return false;};
if (emptyvalidation(nazwisko,"Wszystkie wymagane pola muszą być wypełnione : Nazwisko")==false) {nazwisko.focus(); return false;};
if (emptyvalidation(ulica,"Wszystkie wymagane pola muszą być wypełnione : Ulica")==false) {ulica.focus(); return false;};
if (emptyvalidation(nr_domu,"Wszystkie wymagane pola muszą być wypełnione : Numer domu")==false) {nr_domu.focus(); return false;};

if (emptyvalidation(miasto,"Wszystkie wymagane pola muszą być wypełnione : Miasto")==false) {miasto.focus(); return false;};
if (emptyvalidation(kod,"Wszystkie wymagane pola muszą być wypełnione : Kod")==false) {kod.focus(); return false;};


if (emptyvalidation(telefon,"Wszystkie wymagane pola muszą być wypełnione : Telefon")==false) {telefon.focus(); return false;};
if (emptyvalidation(email,"Wszystkie wymagane pola muszą być wypełnione : Adres E-mail")==false) {email.focus(); return false;};
if (emailvalidation(email,"Wprowadzono błędny adres e-mail")==false) {email.focus(); return false;};

}
}


function walidacja_kontaktu(thisform)
{
with (thisform)
{
if (emptyvalidation(imie_nazwisko,"Wszystkie wymagane pola muszą być wypełnione : Imię i Nazwisko")==false) {imie_nazwisko.focus(); return false;};
if (emptyvalidation(email,"Wszystkie wymagane pola muszą być wypełnione : Adres E-mail")==false) {email.focus(); return false;};
if (emailvalidation(email,"Wprowadzono błędny adres e-mail")==false) {email.focus(); return false;};
if (emptyvalidation(telefon,"Wszystkie wymagane pola muszą być wypełnione : Telefon")==false) {telefon.focus(); return false;};
}
}



function walidacja_newsletter(thisform)
{

with (thisform)
{

if (emptyvalidation(email,"Wprowadź adres E-mail")==false) {email.focus(); return false;};
if (emailvalidation(email,"Wprowadzono błędny adres e-mail")==false) {email.focus(); return false;};
}
}





function walidacja_rozszerzona(thisform)
{
with (thisform)
{
if (emptyvalidation(data_przyjazdu,"Wszystkie wymagane pola muszą być wypełnione : Data przyjazdu")==false) {data_przyjazdu.focus(); return false;};
if (emptyvalidation(data_wyjazdu,"Wszystkie wymagane pola muszą być wypełnione : Data wyjazdu")==false) {data_wyjazdu.focus(); return false;};

if (emptyvalidation(ilosc_pokoi,"Wszystkie wymagane pola muszą być wypełnione : Ilość pokoi")==false) {ilosc_pokoi.focus(); return false;};
if (digitvalidation(ilosc_pokoi,1,2,"Wprowadzono błędną ilość pokoi [poprawnie: od 1 do 2 cyfr]","I")==false) {ilosc_pokoi.focus(); return false;};
if (emptyvalidation(imie,"Wszystkie wymagane pola muszą być wypełnione : Imię")==false) {imie.focus(); return false;};
if (emptyvalidation(nazwisko,"Wszystkie wymagane pola muszą być wypełnione : Nazwisko")==false) {nazwisko.focus(); return false;};
if (emptyvalidation(ulica,"Wszystkie wymagane pola muszą być wypełnione : Ulica")==false) {ulica.focus(); return false;};
if (emptyvalidation(nr_domu,"Wszystkie wymagane pola muszą być wypełnione : Numer domu")==false) {nr_domu.focus(); return false;};

if (emptyvalidation(miasto,"Wszystkie wymagane pola muszą być wypełnione : Miasto")==false) {miasto.focus(); return false;};
if (emptyvalidation(kod,"Wszystkie wymagane pola muszą być wypełnione : Kod")==false) {kod.focus(); return false;};


if (emptyvalidation(telefon,"Wszystkie wymagane pola muszą być wypełnione : Telefon")==false) {telefon.focus(); return false;};
if (emptyvalidation(email,"Wszystkie wymagane pola muszą być wypełnione : Adres E-mail")==false) {email.focus(); return false;};
if (emailvalidation(email,"Wprowadzono błędny adres e-mail")==false) {email.focus(); return false;};


}
}



function walidacja_pakietowa(thisform)
{
with (thisform)
{
if (emptyvalidation(data_przyjazdu,"Wszystkie wymagane pola muszą być wypełnione : Data przyjazdu")==false) {return false;};

if (emptyvalidation(imie,"Wszystkie wymagane pola muszą być wypełnione : Imię")==false) {imie.focus(); return false;};
if (emptyvalidation(nazwisko,"Wszystkie wymagane pola muszą być wypełnione : Nazwisko")==false) {nazwisko.focus(); return false;};
if (emptyvalidation(ulica,"Wszystkie wymagane pola muszą być wypełnione : Ulica")==false) {ulica.focus(); return false;};
if (emptyvalidation(nr_domu,"Wszystkie wymagane pola muszą być wypełnione : Numer domu")==false) {nr_domu.focus(); return false;};

if (emptyvalidation(miasto,"Wszystkie wymagane pola muszą być wypełnione : Miasto")==false) {miasto.focus(); return false;};
if (emptyvalidation(kod,"Wszystkie wymagane pola muszą być wypełnione : Kod")==false) {kod.focus(); return false;};


if (emptyvalidation(telefon,"Wszystkie wymagane pola muszą być wypełnione : Telefon")==false) {telefon.focus(); return false;};
if (emptyvalidation(email,"Wszystkie wymagane pola muszą być wypełnione : Adres E-mail")==false) {email.focus(); return false;};
if (emailvalidation(email,"Wprowadzono błędny adres e-mail")==false) {email.focus(); return false;};


}
}

function emptyvalidation(entered, alertbox)
{

with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function digitvalidation(entered, min, max, alertbox, datatype)
{

with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") 
{checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
} 


function valuevalidation(entered, min, max, alertbox, datatype)
{

with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
}
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
} 


function emailvalidation(entered, alertbox)
{
with (entered)
{
apos=value.indexOf("@"); 
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
} 

