//menu

MaxGraf=50//liczba grafik
MaxStan=2
obrazki=new Array(MaxGraf*MaxStan)
nazwy=new Array(MaxGraf*MaxStan)
next=0

//dodaj_grafike("k1","img/kat/k1_")
//dodaj_grafike("k2","img/kat/k2_")

function dodaj_grafike(nazwa,plik){
	var a
	for (a=0;a<MaxStan;a++){
		nazwy[next]=new String()
		nazwy[next]=nazwa+a
		obrazki[next]=new Image()
		obrazki[next++].src=plik+a+".gif"
		}
}

function pstryk(nazwa,stan){
	var i
	for (i=0;nazwa+stan!=nazwy[i];i++);
        document.images[nazwa].src = obrazki[i].src
}

//data


var dn;

DayName = new Array(7);
DayName[0] = "niedziela";
DayName[1] = "poniedziałek";
DayName[2] = "wtorek";
DayName[3] = "środa";
DayName[4] = "czwartek";
DayName[5] = "piątek";
DayName[6] = "sobota";

MonthName = new Array(12);
MonthName[0] = "stycznia";
MonthName[1] = "lutego";
MonthName[2] = "marca";
MonthName[3] = "kwietnia";
MonthName[4] = "maja";
MonthName[5] = "czerwca";
MonthName[6] = "lipca";
MonthName[7] = "sierpnia";
MonthName[8] = "września";
MonthName[9] = "października";
MonthName[10] = "listopada";
MonthName[11] = "grudnia";

function getDateStr()
{
    var Today = new Date();
    var WeekDay = Today.getDay();
    var Month = Today.getMonth();
    var Day = Today.getDate();
    var Year = Today.getYear();

    if(Year <= 100) Year += 1900;

    return DayName[WeekDay] + "," + " " + Day + " " + MonthName[Month] + " " + Year;
}


//auto max okna

// Auto maximize window script - By Nick Lowe (nicklowe@ukonline.co.uk)
// Courtesy of SimplytheBest.net (http://simplythebest.net/info/dhtml_scripts.html)

//window.moveTo(0,0);
/*if(document.all){
	top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById){
	if(top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
		top.window.outerHeight = screen.availHeight;
		top.window.outerWidth = screen.availWidth;
	}
}*/


//podswietlenie tdSort

function changeTd(nr,over){
	if(document.all){
		if(over) tdSort[nr].className='tdSortCLASS2'
		else tdSort[nr].className='tdSortCLASS';
	}
}


//open window

// trzeba przeslac parametry
/*function openRezerwacjaC(id){
	link = "/html/rezerwacja.php?id_c=" + id
	autorWindow=window.open(link,parent.name,"toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=0,scrollbars=1,width=470,height=540,left=20,top=20");
}*/

function openCalendar(param,pole){
	//alert(pole);
	link = "/inc/kalendarz.php?pole=" + pole + param;

	calendarWindow=window.open(link,"kalendarz","toolbar=0,menubar=0,location=0,directories=0,status=0,resizable=0,scrollbars=0,titlebar=0,width=195,height=170,left=200,top=200");
}


function openInfo(id){
	link = "/html/info.php?id=" + id;
	autorWindow=window.open(link, "info","toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=0,scrollbars=1,width=466,height=540,left=20,top=20");
}

function openDodatkowe(id_ds, id_o, typ_dod){
	link = "/html/oferta_dodatki.php?id_ds=" + id_ds + "&id_o=" + id_o + "&typ=" + typ_dod
	autorWindow=window.open(link,"dodatkowe","toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=0,scrollbars=1,width=571,height=540,left=20,top=20");
}

function openPytania(id){
	link = "/html/mam_pytania.php?id_o=" + id;
	autorWindow=window.open(link, "info","toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=0,scrollbars=1,width=466,height=540,left=20,top=20");
}

function openWyslij(id){
	link = "/html/wyslij_znajomym.php?id_o=" + id;
	autorWindow=window.open(link, "info","toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=0,scrollbars=1,width=466,height=540,left=20,top=20");
}

function openWyszukiwarka(typ){
	link = "/html/wyszukiwarka.php?__pr=" + typ;
	autorWindow=window.open(link, "wyszukiwarka","toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=1,scrollbars=1,width=466,height=540,left=20,top=20");
}

function openWyszukiwarkaMapa(link){
	autorWindow=window.open(link, "wyszukiwarka","toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=1,scrollbars=1,width=466,height=540,left=20,top=20");
}

function openWyszukiwarkaMenu(link){
	autorWindow=window.open(link, "wyszukiwarka","toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=1,scrollbars=1,width=466,height=540,left=20,top=20");
}

function przekazData()
{
	var putdata="";
	for(i = 0;i < polaArr.length;i++)
		with(document.daneForm) {
			ind = "";
			f = elements[polaArr[i]].value;
			if (f == null)
			{
				ind = elements[polaArr[i]].selectedIndex;
				f = elements[polaArr[i]].options[ind].value
    	}
//				f = elements[polaArr[i]].selected;

			ff = elements[polaArr[i]].name;
			if ((f) && ( f != "0" ))
				putdata += "tab[" + ff + "]" + "=" + f + "%26";
		}
	//alert(putdata)
	//var putdata=document.daneForm.miesiac.selectedIndex + "#" + document.daneForm.rok.selectedIndex + "#" + document.daneForm.tekst.value;

	// wersja na dwa okna
	//opener.document.forms[0].przekaz.value=putdata;
	//opener.window.sendForm();
	//window.close();

	// wersja na 3 okna
	link = "/html/wyniki.php?przekaz=" + putdata;
	autorWindow=window.open(link, "bleble","toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=1,scrollbars=1,width=800,height=600,left=20,top=20");
}

//to jest nasz string wyjsciowy, w ktorym beda numery zaznaczonych checkbox'ow


//to jest funkcja wywolywana przy submicie
function openRezerwacjaC(form, id_c){
	var f;
	var bleStr="";
	for(i=0;i<CheckBoxArr.length;i++)
		with(document.questionForm) {
			f = elements[CheckBoxArr[i]].value;
			//jesli checkbox zaznaczony to jego numer sie doda do stringa poprzedzony pytajnikiem
			if(elements[CheckBoxArr[i]].checked==true) bleStr+="wyc[]="+f+"&";
			}

	//w to miejsce trzeba podpiac funkcje openwindow, czyli chyba tak...
	var link="/html/rezerwacja.php?"+bleStr+"id_c="+id_c;
	//alert(link);
	//teraz bedzie sie otwieral plik np. z wywolaniem rejestracja.php?1?2?4 w nowym oknie...
	//autorWindow=window.open(link,parent.name,"toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=0,scrollbars=1,width=466,height=540,left=20,top=20");
	autorWindow=window.open(link,"rezerwacja","toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=0,scrollbars=1,width=466,height=540,left=20,top=20");
}

function openRezerwacjaW(form, id){
	var f;
	var bleStr="";
	for(i=0;i<CheckBoxArr.length;i++)
		with(document.questionForm) {
			f = elements[CheckBoxArr[i]].value;
			//jesli checkbox zaznaczony to jego numer sie doda do stringa poprzedzony pytajnikiem
			if(elements[CheckBoxArr[i]].checked==true) bleStr+="wyc[]="+f+"&";
			}

	//w to miejsce trzeba podpiac funkcje openwindow, czyli chyba tak...
	var link="/html/rezerwacja.php?"+bleStr+"id_w="+id;
	//alert(link);
	//teraz bedzie sie otwieral plik np. z wywolaniem rejestracja.php?1?2?4 w nowym oknie...
	autorWindow=window.open(link,"rezerwacja","toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=0,scrollbars=1,width=466,height=540,left=20,top=20");
}

function openRezerwacjaO(form, id){
	var f;
	var bleStr="";
	for(i=0;i<CheckBoxArr.length;i++)
		with(document.questionForm) {
			f = elements[CheckBoxArr[i]].value;
			//jesli checkbox zaznaczony to jego numer sie doda do stringa poprzedzony pytajnikiem
			if(elements[CheckBoxArr[i]].checked==true) bleStr+="wyc[]="+f+"&";
			}

	//w to miejsce trzeba podpiac funkcje openwindow, czyli chyba tak...
	var link="/html/rezerwacja.php?"+bleStr+"id_o="+id;
	//alert(link);
	//teraz bedzie sie otwieral plik np. z wywolaniem rejestracja.php?1?2?4 w nowym oknie...
	autorWindow=window.open(link,"rezerwacja","toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=0,scrollbars=1,width=466,height=540,left=20,top=20");
}


function openMap(){
        autorWindow=window.open("/html/swiat.php",parent.name,"toolbar=0,menubar=0,location=0,directories=0,status=0,resizeable=0,scrollbars=0,width=600,height=690,left=20,top=20");
}

//sprawdza czy pole jest puste
function isEmpty(){
	for(i=0;i<emptyArr.length;i++)
		with(document.questionForm)
			if(elements[emptyArr[i]].value==""){
				alert("Pole " + namesArr[emptyArr[i]] + " musi być wypełnione!");
				elements[emptyArr[i]].focus();
				return true;
			}
	return false;
}

//sprawdza czy jesdno z pol jest wypelnione
function isEmpty2(){
	for(i=0;i<emptyorArr.length;i++)
		with(document.questionForm)
			if(elements[emptyorArr[i]].value!="") return false
			else j=i;
	alert("Przynajmniej jeden " + namesArr[emptyorArr[j-emptyorArr.length+1]] + " musi być podany!");
	document.questionForm.elements[emptyorArr[j-emptyorArr.length+1]].focus();
	return true;
}

/*function isEmptyOr2(){
	for(i=0;i<emptyor2Arr.length;i++)
		with(document.questionForm)
			if(elements[emptyor2Arr[i]].value!="") return false
			else j=i;
	//alert("Przynajmniej jeden " + namesArr[emptyor2Arr[j-emptyor2Arr.length+1]] + " musi być podany!");
	alert("Przynajmniej jedna osoba musi wykupic wycieczke");
	document.questionForm.elements[emptyor2Arr[j-emptyor2Arr.length+1]].focus();
	return true;
}*/

//sprawdza czy chcecboxy sa zaznaczone
function isCheckBoxEmpty(){
	for(i=0;i<emptyCheckBoxArr.length;i++)
		with(document.questionForm)
			if(elements[emptyCheckBoxArr[i]].checked==false){
				alert("Pole " + namesArr[emptyCheckBoxArr[i]] + " musi być zaznaczone!");
				elements[emptyCheckBoxArr[i]].focus();
				return true;
			}
	return false;
}

//sprawdza czy cyfra
function isDigit(){
   for(i=0;i<digitArr.length;i++){
   		with(document.questionForm){
			s=elements[digitArr[i]].value;
			for(j=0;j<s.length;j++)
				if(s.charAt(j)<'0' || s.charAt(j)>'9'){
					alert("Pole " + namesArr[digitArr[i]] + " musi być cyfrš!");
					elements[digitArr[i]].focus();
					return false;
				}
		}
	}
	return true;
}

//sprawdza czy kod pocztowy jest ok
function isKodOk(){
   for(i=0;i<kodArr.length;i++){
   		with(document.questionForm){
			s=elements[kodArr[i]].value;
			for(j=0;j<s.length;j++)
				if(j==2){
					if(s.charAt(j)!='-'){
						alert("le wpisany kod pocztowy. Poprawny format to xx-xxx! 1");
						elements[kodArr[i]].focus();
						return false;
					}
				}
				else if(s.charAt(j)<'0' || s.charAt(j)>'9'){
						alert("le wpisany kod pocztowy. Poprawny format to xx-xxx! 2");
						elements[kodArr[i]].focus();
						return false;
				}
		}
	}
	return true;
}

//sprawdza czy telefon Ok
function isTelOk(){
   for(i=0;i<telArr.length;i++){
   		with(document.questionForm){
			s=elements[telArr[i]].value;
			for(j=0;j<s.length;j++)
				if (s.charAt(j)<'0' || s.charAt(j)>'9')
					if (s.charAt(j)!='-'){
						alert("le wpisany numer telefonu.\nNumer telefonu musi być cyfrš. Może być oddzielony znakami '-'!");
						elements[telArr[i]].focus();
						return false;
					}
		}
	}
	return true;
}

//sprawdza czy data jest ok (rrrr-mm-dd)
function isDataOk(){
   for(i=0;i<dataArr.length;i++){
   		with(document.questionForm){
			s=elements[dataArr[i]].value;

			//dzien
			str = s.slice(0,2);
			for(j=0;j<str.length;j++)
				if(str.charAt(j)<'0' || str.charAt(j)>'9'){
					alert("Niepoprawnie wypełnione pole " + namesArr[dataArr[i]] + ".\nPrawidłowy format daty to dd-mm-rrrr!");
					elements[dataArr[i]].focus();
					return false;
				}
			if((str<1)||(str>31)){
				alert("Niepoprawnie wypełnione pole " + namesArr[dataArr[i]] + ".\nPrawidłowy format daty to dd-mm-rrrr!");
				elements[dataArr[i]].focus();
				return false;
			}


			//kreska
			str = s.slice(2,3);
			if(str!='-'){
				alert("Niepoprawnie wypełnione pole " + namesArr[dataArr[i]] + ".\nPrawidłowy format daty to dd-mm-rrrr!");
				elements[dataArr[i]].focus();
				return false;
			}

			//miesiac
			str = s.slice(3,5);
			for(j=0;j<str.length;j++)
				if(str.charAt(j)<'0' || str.charAt(j)>'9'){
					alert("Niepoprawnie wypełnione pole " + namesArr[dataArr[i]] + ".\nPrawidłowy format daty to dd-mm-rrrr!");
					elements[dataArr[i]].focus();
					return false;
				}
			if((str<1)||(str>12)){
				alert("Niepoprawnie wypełnione pole " + namesArr[dataArr[i]] + ".\nPrawidłowy format daty to dd-mm-rrrr!");
				elements[dataArr[i]].focus();
				return false;
			}

			//kreska
			str = s.slice(5,6);
			if(str!='-'){
				alert("Niepoprawnie wypełnione pole " + namesArr[dataArr[i]] + ".\nPrawidłowy format daty to dd-mm-rrrr!");
				elements[dataArr[i]].focus();
				return false;
			}

			//rok
			//czy jest digit
			str = s.slice(7,10);
			for(j=0;j<str.length;j++)
				if(str.charAt(j)<'0' || str.charAt(j)>'9'){
					alert("Niepoprawnie wypełnione pole " + namesArr[dataArr[i]] + ".\nPrawidłowy format daty to dd-mm-rrrr!");
					elements[dataArr[i]].focus();
					return false;
				}
			//czy rok<2001
			if(str<2001){
				alert("Niepoprawnie wypełnione pole " + namesArr[dataArr[i]] + ".\nPrawidłowy format daty to dd-mm-rrrr!");
				elements[dataArr[i]].focus();
				return false;
			}

		}
	}
	return true;
}


//czy nie za duzo znakow w tekscie
function isToLong(){
	for(i=0;i<longArr.length;i++)
   		with(document.questionForm)
			if(elements[longArr[i]].value.length > 2000) return true;
	return false;
}


//funkcja wywolywana przy submicie, wywoluje wszystkie powyzsze
//dobrze by bylo, zeby funkcje byly wywolywane w takiej kolejnosci chyba...:)
function checkform(form){
	if(isEmpty()) return false;
	if(isEmpty2()) return false;
	if(isCheckBoxEmpty()) return false;
	if(!isDataOk()) return false;
	if(!isDigit()) return false;
	if(!isKodOk()) return false;
	if(!isTelOk()) return false;
	if(isToLong()) return false;
}

function checkkatalog(form){
	if(isEmpty()) return false;
	if(!isKodOk()) return false;
	if(isToLong()) return false;
}


function checkwyslij(form){
	if(isEmpty()) return false;
}
//sprawdza czy pole jest puste
/*
function isEmpty(){
	for(i=0;i<emptyArr.length;i++)
		with(document.questionForm)
			if(elements[emptyArr[i]].value=="")	return true;

	return false;
}

//sprawdza czy chcecboxy sa zaznaczone
function isCheckBoxEmpty(){
	for(i=0;i<emptyCheckBoxArr.length;i++)
		with(document.questionForm)
			if(elements[emptyCheckBoxArr[i]].checked==false) return true;
	return false;
}

//sprawdza czy cyfra
function isDigit(){
   for(i=0;i<digitArr.length;i++){
   		with(document.questionForm){
			s=elements[digitArr[i]].value;
			for(j=0;j<s.length;j++)
				if (s.charAt(j)<'0' || s.charAt(j)>'9') return false;
		}
	}
	return true;
}

//sprawdza czy data
function isData(){
   for(i=0;i<dataArr.length;i++){
   		with(document.questionForm){
			s=elements[dataArr[i]].value;
			for(j=0;j<s.length;j++)
				if (s.charAt(j)<'0' || s.charAt(j)>'9')
					if (s.charAt(j)!='-') return false;
		}
	}
	return true;
}

//czy nie za duzo znakow w tekscie
function isToLong(){
	for(i=0;i<longArr.length;i++)
   		with(document.questionForm)
			if(elements[longArr[i]].value.length > 2000) return true;
	return false;
}

//funkcja wywolywana przy submicie, wywoluje wszystkie powyzsze
function checkform(form){
	var empty=false;
	var empty2=false;
	var alertStr="";

	if(isEmpty()) empty = true;
	if(isCheckBoxEmpty()) empty2 = true;
	if(empty) alertStr = "Pola oznaczone * musza byc wypelnione.\n";
	if(empty2) alertStr += "Checkboxy musza byz zaznaczone.\n";
	if(!isDigit()) alertStr += "Pola numerycze musza zawierac tylko cyfry.\n";
	if(!isData()) alertStr += "Pola mogš zawierać tylko cyfry przedzielone znakiem -.\n";
	//if(isToLong()) alertStr += "Maksymalna ilosc danych zawarta w polu edycyjnym wynosi 2000 znakow.\n";
	if(alertStr=="") return true;
	else alert(alertStr);

	return false;
}*/

