

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 load(arg,txt)
{

if (document.getElementById("ramka")!=undefined)
	{
	document.getElementById("ramka").src=arg; 
//document.getElementById("info").innerHTML = '<a href="javascript:load(\'top.php\',\'\');">strona główna</a> <font class="info"> &raquo; '+txt+'</font>'; 
	}
	else
	{
	parent.document.getElementById("ramka").src=arg; 
//parent.document.getElementById("info").innerHTML = '<a href="javascript:load(\'top.php\',\'\');">strona główna</a> <font class="info"> &raquo; '+txt+'</font>'; 
	}



}

function walidacja(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(adres,"Wszystkie wymagane pola muszą być wypełnione : Adres")==false) {adres.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 (oferty.checked==false && aktualnosci.checked==false)
	{
	alert('Proszę zaznaczyć przynajmniej\n jedną z opcji : oferty, aktualności');	
	return false;
	}

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_osob,"Wszystkie wymagane pola muszą być wypełnione : Ilość osób")==false) {ilosc_osob.focus(); return false;};
if (digitvalidation(ilosc_osob,1,2,"Wprowadzono błędną ilość osób [poprawnie: od 1 do 2 cyfr]","I")==false) {ilosc_osob.focus(); return false;};


if (emptyvalidation(imie_nazwisko,"Wszystkie wymagane pola muszą być wypełnione : Imię i Nazwisko")==false) {imie_nazwisko.focus(); return false;};
if (emptyvalidation(adres,"Wszystkie wymagane pola muszą być wypełnione : Adres")==false) {adres.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;};
if (digitvalidation(telefon,6,9,"Wprowadzono błędny telefon\n [poprawnie: od 6 do 9 cyfr (bez separatorów)]","I")==false) {telefon.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;}
}
} 
