function getElement(id)
{
        if (document.all)
                return document.all[id];
        else if (document.getElementById)
                return document.getElementById(id);
        else
                return false;
}

function zakladkiwysukiwarkiwlacz()
{
        var zakladki = document.getElementById("zakladki");
        var naszezakladki = zakladki.getElementsByTagName('a');
        for(var i = 0; i < naszezakladki.length; i++)
        {
                
                naszezakladki[i].onclick = wyszClick;
        }
}

        function PrzeniesWartosci1()
        {
                document.wyjazdy2.kraj.selectedIndex=document.wyjazdy1.kraj.selectedIndex;
                populateregion(document.wyjazdy2,document.wyjazdy2.kraj.options[document.wyjazdy2.kraj.selectedIndex].value);
                document.wyjazdy2.region.selectedIndex=document.wyjazdy1.region.selectedIndex;
                document.wyjazdy2.miesiac.selectedIndex=document.wyjazdy1.miesiac.selectedIndex;
                populatedni(document.wyjazdy2,document.wyjazdy2.miesiac.options[document.wyjazdy2.miesiac.selectedIndex].value);
                document.wyjazdy2.dzien.selectedIndex=document.wyjazdy1.dzien.selectedIndex;
                document.wyjazdy2.standard.selectedIndex=document.wyjazdy1.standard.selectedIndex;
                document.wyjazdy2.cena.selectedIndex=document.wyjazdy1.cena.selectedIndex;
                document.wyjazdy2.transport.selectedIndex=document.wyjazdy1.transport.selectedIndex;                
        }

        function PrzeniesWartosci2()
        {
                document.wyjazdy1.kraj.selectedIndex=document.wyjazdy2.kraj.selectedIndex;
                populateregion(document.wyjazdy1,document.wyjazdy1.kraj.options[document.wyjazdy1.kraj.selectedIndex].value);
                document.wyjazdy1.region.selectedIndex=document.wyjazdy2.region.selectedIndex;        
                document.wyjazdy1.miesiac.selectedIndex=document.wyjazdy2.miesiac.selectedIndex;
                populatedni(document.wyjazdy1,document.wyjazdy1.miesiac.options[document.wyjazdy1.miesiac.selectedIndex].value);
                document.wyjazdy1.dzien.selectedIndex=document.wyjazdy2.dzien.selectedIndex;
                document.wyjazdy1.standard.selectedIndex=document.wyjazdy2.standard.selectedIndex;
                document.wyjazdy1.cena.selectedIndex=document.wyjazdy2.cena.selectedIndex;
                document.wyjazdy1.transport.selectedIndex=document.wyjazdy2.transport.selectedIndex;                
        }


function zaawansowanaRozwin()
{
                document.getElementById('wycieczkiSzukaj').style.display = 'none';
                document.getElementById('ZaawansowanaSzukaj').style.display = 'block';
                PrzeniesWartosci1();
}

function zaawansowanaZwin()
{
                document.getElementById('wycieczkiSzukaj').style.display = 'block';
                document.getElementById('ZaawansowanaSzukaj').style.display = 'none';
                PrzeniesWartosci2();
}

function inicjalizacja()
{
        populateregion(document.wyjazdy1,document.wyjazdy1.kraj.options[document.wyjazdy1.kraj.selectedIndex].value);
        populateregion(document.wyjazdy2,document.wyjazdy2.kraj.options[document.wyjazdy2.kraj.selectedIndex].value);
        populatedni(document.wyjazdy1,document.wyjazdy1.miesiac.options[document.wyjazdy1.miesiac.selectedIndex].value); 
        populatedni(document.wyjazdy2,document.wyjazdy2.miesiac.options[document.wyjazdy2.miesiac.selectedIndex].value); 
        populatedni2(document.wyjazdy2,document.wyjazdy2.miesiac2.options[document.wyjazdy2.miesiac2.selectedIndex].value); 
        cookieForms('open', 'wyjazdy1');
        cookieForms('open', 'wyjazdy2');
        cookieForms('open', 'hotels_form0');
        cookieForms('open', 'MainForm');        
}

function zamkniecie()
{
        cookieForms('save', 'wyjazdy1');
        cookieForms('save', 'wyjazdy2');
        cookieForms('save', 'hotels_form0');
        cookieForms('save', 'MainForm');
}


function wyszClick(e)
{
        var Formularze = ["wycieczki","hotele","bilety"];
        var Zakladka = PobierzEventa(e);
        for (var i = 0; i < Formularze.length; i++)
        {                
                if (Zakladka.id == Formularze[i]+ 'Zakladka')
                {
                        document.getElementById(Formularze[i] + 'Szukaj').style.display = 'block';
                        document.getElementById(Formularze[i] + 'Zakladka').src = 'grafika/'+Formularze[i]+'2.png';
                } else {
                        document.getElementById(Formularze[i] + 'Szukaj').style.display = 'none';
                        document.getElementById(Formularze[i] + 'Zakladka').src = 'grafika/'+Formularze[i]+'1.png';
                }
        }
        document.getElementById('ZaawansowanaSzukaj').style.display = 'none';                
        return false;
}


function PobierzEventa(e)
{
        var targ;if(!e)
        var e=window.event;if(e.target)targ=e.target;else if(e.srcElement)targ=e.srcElement;{if(targ.nodeType==3)
        targ=targ.parentNode;}
        return targ;
}

function czyPoprawnyEmail(email_form)
{
        if ( (email_form.indexOf(' ')>-1)||(email_form.indexOf('@')==-1)||( (email_form.charAt(email_form.length-3)!='.')&&(email_form.charAt(email_form.length-4)!='.') ) )
        {
                      if (email_form!='') return false;
            }
            return true;
}

function wyslij()
{
        if (document.znajdz.email_form.value=='') {alert('Proszę podać adres e-mail lub numer telefonu kontaktowego'); return;}
            else if (document.znajdz.email_form.value!='' && !czyPoprawnyEmail(document.znajdz.email_form.value)) {alert('Twój adres e-mail jest niepoprawny !!!'); document.znajdz.email_form.focus(); return;}
            else if (document.znajdz.tresc_form.value=='' || document.znajdz.tresc_form.value=='np. Tunezja, 14 dni, termin: 15.06 do 30.06, 2 posiłki, wylot z Warszawy, cena do 1600 pln/os') {alert('Proszę podać treść zapytania o ofertę'); return;}
            else document.znajdz.submit();
}

function wyswietl(plik, szerokosc, wysokosc, tytul, opis)
{
var domyslna_szerokosc = 0; 
var domyslna_wysokosc = 0;
var domyslny_tytul = "";
var domyslny_opis = "";
var obramowanie = 1; 
var kolor_obramowania = "black";
var kolor_tla = "'/grafika/newdesign/tla/ogolne.jpg'"; 
var kolor_tekstu = "#002D44";  
var rozmiar_czcionki = 14;  
var czcionka = "Tahoma, Verdana, Arial, Helvetica, sans-serif";
        
        if (!szerokosc && domyslna_szerokosc) var szerokosc = domyslna_szerokosc;
         if (!wysokosc && domyslna_wysokosc) var wysokosc = domyslna_wysokosc;
          if (!tytul && domyslny_tytul) var tytul = domyslny_tytul;
          if (!tytul)
          {
            var start = plik.lastIndexOf('/');
           var stop = plik.lastIndexOf('.');
            if (stop < start) stop = plik.length;
            var tytul = plik.substring(start+1, stop);
          }
          if (!opis && domyslny_opis) var opis = domyslny_opis;

         szerokosc = Math.abs(isNaN(parseInt(szerokosc)) ? 0 : parseInt(szerokosc));
         szerokosc = szerokosc+8;
          wysokosc = Math.abs(isNaN(parseInt(wysokosc)) ? 0 : parseInt(wysokosc));
           obramowanie = Math.abs(isNaN(parseInt(obramowanie)) ? 0 : parseInt(obramowanie));
         rozmiar_czcionki = Math.abs(isNaN(parseInt(rozmiar_czcionki)) ? 0 : parseInt(rozmiar_czcionki));

        var okno = window.open("", "", "menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=yes,scrollbars=yes" + (szerokosc ? ",width=" + szerokosc : "") + (wysokosc ? ",height=" + wysokosc : ""));

  if (!okno) return true;

  okno.document.open();
  okno.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><HTML><HEAD><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=iso-8859-2"><TITLE>' + tytul + '</TITLE><link href="/css/cocostyle.css" rel="stylesheet" type="text/css"></HEAD><BODY style="background-image: url('+kolor_tla+');><TABLE BORDER="0" WIDTH="100%" HEIGHT="100%" CELLPADDING="0" CELLSPACING="0"><TR><TD ALIGN="center" VALIGN="middle"><table bgcolor="#FFFFFF" cellpadding="10" cellspacing="0"><tr><td><IMG SRC="' + plik + '" border="1"></td></tr><tr><td class="Th c2 s12 link2" align="right"><A HREF="javascript:window.close()" class="link2"><B>[ Zamknij ]</B></A></td></tr></table></TD></TR></TABLE></BODY></HTML>'); 

  okno.document.close();

  return false;
}


function open_photo_window(w, h, c)
{
        if (w > screen.availWidth) 
        {
                w = screen.availWidth - 50;
                scrollbars = 'yes';
        }
        else if (h > screen.availHeight)
        {
                h = screen.availHeight - 50;
                scrollbars = 'yes';
        }
        else
        {
                scrollbars = 'no';
        }
        parameters = 'top=' +  eval((screen.availHeight-h)/4) + ',left=' + eval((screen.availWidth-w)/4) + ',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes, width='+w+', height='+h;
        okno=window.open ('', '', parameters);
        okno.document.open();
        okno.document.write('<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><HTML><HEAD><META HTTP-EQUIV=\"Content-type\" CONTENT=\"text/html; charset=iso-8859-2\"><TITLE>Mapa tras narciarskich</TITLE></HEAD><BODY><IMG SRC=\"/grafika/narty/' + c + '.jpg\" onclick=\"window.close()\"></BODY></HTML>'); 
        okno.document.close();
                                        
}

        var expDays = 1;
        var exp = new Date(); 
        exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

        function getCookieVal (offset) 
        {  
                var endstr = document.cookie.indexOf (";", offset);  
                if (endstr == -1) { endstr = document.cookie.length; }
                return unescape(document.cookie.substring(offset, endstr));
        }


        function GetCookie (name) 
        {
                var arg = name + "=";  
                var alen = arg.length;  
                var clen = document.cookie.length;  
                var i = 0;  
                while (i < clen) 
                { 
                        var j = i + alen;    
                        if (document.cookie.substring(i, j) == arg) return getCookieVal (j);    
                        i = document.cookie.indexOf(" ", i) + 1;
                        if (i == 0) break;
                }
                return null;
        }

        function SetCookie (name, value) 
        {
                
                var argv = SetCookie.arguments;  
                var argc = SetCookie.arguments.length;
                var expires = (argc > 2) ? argv[2] : null;
                
                var path = (argc > 3) ? argv[3] : null;  
                var domain = (argc > 4) ? argv[4] : null;  
                var secure = (argc > 5) ? argv[5] : false;  
                var path = '/';
                document.cookie = name + "=" + escape (value) + 
                ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
                ((path == null) ? "" : ("; path=" + path)) +  
                ((domain == null) ? "" : ("; domain=" + domain)) +    
                ((secure == true) ? "; secure" : "");
        }

        function cookieForms() 
        {  
                var mode = cookieForms.arguments[0];

                for(f=1; f<cookieForms.arguments.length; f++) 
                {
                        formName = cookieForms.arguments[f];

                        if(mode == 'open') 
                        {        
                                cookieValue = GetCookie('saved_'+formName);
                                if(cookieValue != null) 
                                {
                                        var cookieArray = cookieValue.split('#cf#');
                                        if(cookieArray.length == document[formName].elements.length) 
                                        {
                                                
                                                var i=0;
                                                for(i=0; i<document[formName].elements.length; i++) 
                                                {                                
                                                        if(cookieArray[i].substring(0,6) == 'select') 
                                                        { 
                                                                document[formName].elements[i].options.selectedIndex = cookieArray[i].substring(7, cookieArray[i].length-1); 
                                                        }
                                                        else if((cookieArray[i] == 'cbtrue') || (cookieArray[i] == 'rbtrue')) { document[formName].elements[i].checked = true; }
                                                        else if((cookieArray[i] == 'cbfalse') || (cookieArray[i] == 'rbfalse')) { document[formName].elements[i].checked = false; }
                                                        else { document[formName].elements[i].value = (cookieArray[i]) ? cookieArray[i] : ''; }
                                                                                                                
                                                        if(formName=='wyjazdy1') 
                                                        {                                        
                                                                if (i==0) 
                                                                {                        
                                                                        populateregion(document.wyjazdy1,document.wyjazdy1.kraj.options[document.wyjazdy1.kraj.selectedIndex].value);
                                                                }
                                                                
                                                                if (i==2)
                                                                {
                                                                        populatedni(document.wyjazdy1,document.wyjazdy1.miesiac.options[document.wyjazdy1.miesiac.selectedIndex].value); 
                                                                }                                                        
                                                        }
                                                        if(formName=='wyjazdy2') 
                                                        {                                        
                                                                if (i==0) 
                                                                {                        
                                                                        populateregion(document.wyjazdy2,document.wyjazdy2.kraj.options[document.wyjazdy2.kraj.selectedIndex].value);
                                                                }
                                                                
                                                                if (i==2)
                                                                {
                                                                        populatedni(document.wyjazdy2,document.wyjazdy2.miesiac.options[document.wyjazdy2.miesiac.selectedIndex].value); 
                                                                }
                                                                if (i==4)
                                                                {
                                                                        populatedni2(document.wyjazdy2,document.wyjazdy2.miesiac2.options[document.wyjazdy2.miesiac2.selectedIndex].value); 
                                                                }                                                                
                                                                
                                                        }                                                        
                                                }
                                        }
                                }
                        }

                        if(mode == 'save') 
                        {        
                                cookieValue = '';

                                for(i=0; i<document[formName].elements.length; i++) 
                                {
                                        fieldType = document[formName].elements[i].type;
                                        if(fieldType == 'password') { passValue = ''; }
                                        else if(fieldType == 'checkbox') { passValue = 'cb'+document[formName].elements[i].checked; }
                                        else if(fieldType == 'radio') { passValue = 'rb'+document[formName].elements[i].checked; }
                                        else if(fieldType == 'select-one') { passValue = 'select'+document[formName].elements[i].options.selectedIndex; }
                                        else { passValue = document[formName].elements[i].value; }
                                        cookieValue = cookieValue + passValue + '#cf#';
                                }
                                cookieValue = cookieValue.substring(0, cookieValue.length-4); // Remove last delimiter
                                SetCookie('saved_'+formName, cookieValue, exp);                
                        }        
                }
        }
        
        
var DowolnyArray = new Array("('Dowolny')");
var styczenArray = new Array("('Dowolny')", "('1')", "('2')", "('3')", "('4')", "('5')", "('6')", "('7')", "('8')", "('9')", "('10')", "('11')", "('12')", "('13')", "('14')", "('15')", "('16')", "('17')", "('18')", "('19')", "('20')", "('21')", "('22')", "('23')", "('24')", "('25')", "('26')", "('27')", "('28')", "('29')", "('30')", "('31')");
var lutyArray = new Array("('Dowolny')", "('1')", "('2')", "('3')", "('4')", "('5')", "('6')", "('7')", "('8')", "('9')", "('10')", "('11')", "('12')", "('13')", "('14')", "('15')", "('16')", "('17')", "('18')", "('19')", "('20')", "('21')", "('22')", "('23')", "('24')", "('25')", "('26')", "('27')", "('28')");
var marzecArray = new Array("('Dowolny')", "('1')", "('2')", "('3')", "('4')", "('5')", "('6')", "('7')", "('8')", "('9')", "('10')", "('11')", "('12')", "('13')", "('14')", "('15')", "('16')", "('17')", "('18')", "('19')", "('20')", "('21')", "('22')", "('23')", "('24')", "('25')", "('26')", "('27')", "('28')", "('29')", "('30')", "('31')");
var kwiecienArray = new Array("('Dowolny')", "('1')", "('2')", "('3')", "('4')", "('5')", "('6')", "('7')", "('8')", "('9')", "('10')", "('11')", "('12')", "('13')", "('14')", "('15')", "('16')", "('17')", "('18')", "('19')", "('20')", "('21')", "('22')", "('23')", "('24')", "('25')", "('26')", "('27')", "('28')", "('29')", "('30')");
var majArray = new Array("('Dowolny')", "('1')", "('2')", "('3')", "('4')", "('5')", "('6')", "('7')", "('8')", "('9')", "('10')", "('11')", "('12')", "('13')", "('14')", "('15')", "('16')", "('17')", "('18')", "('19')", "('20')", "('21')", "('22')", "('23')", "('24')", "('25')", "('26')", "('27')", "('28')", "('29')", "('30')", "('31')");
var czerwiecArray = new Array("('Dowolny')", "('1')", "('2')", "('3')", "('4')", "('5')", "('6')", "('7')", "('8')", "('9')", "('10')", "('11')", "('12')", "('13')", "('14')", "('15')", "('16')", "('17')", "('18')", "('19')", "('20')", "('21')", "('22')", "('23')", "('24')", "('25')", "('26')", "('27')", "('28')", "('29')", "('30')");
var lipiecArray = new Array("('Dowolny')", "('1')", "('2')", "('3')", "('4')", "('5')", "('6')", "('7')", "('8')", "('9')", "('10')", "('11')", "('12')", "('13')", "('14')", "('15')", "('16')", "('17')", "('18')", "('19')", "('20')", "('21')", "('22')", "('23')", "('24')", "('25')", "('26')", "('27')", "('28')", "('29')", "('30')", "('31')");
var sierpienArray = new Array("('Dowolny')", "('1')", "('2')", "('3')", "('4')", "('5')", "('6')", "('7')", "('8')", "('9')", "('10')", "('11')", "('12')", "('13')", "('14')", "('15')", "('16')", "('17')", "('18')", "('19')", "('20')", "('21')", "('22')", "('23')", "('24')", "('25')", "('26')", "('27')", "('28')", "('29')", "('30')", "('31')");
var wrzesienArray = new Array("('Dowolny')", "('1')", "('2')", "('3')", "('4')", "('5')", "('6')", "('7')", "('8')", "('9')", "('10')", "('11')", "('12')", "('13')", "('14')", "('15')", "('16')", "('17')", "('18')", "('19')", "('20')", "('21')", "('22')", "('23')", "('24')", "('25')", "('26')", "('27')", "('28')", "('29')", "('30')");
var pazdziernikArray = new Array("('Dowolny')", "('1')", "('2')", "('3')", "('4')", "('5')", "('6')", "('7')", "('8')", "('9')", "('10')", "('11')", "('12')", "('13')", "('14')", "('15')", "('16')", "('17')", "('18')", "('19')", "('20')", "('21')", "('22')", "('23')", "('24')", "('25')", "('26')", "('27')", "('28')", "('29')", "('30')", "('31')");
var listopadArray = new Array("('Dowolny')", "('1')", "('2')", "('3')", "('4')", "('5')", "('6')", "('7')", "('8')", "('9')", "('10')", "('11')", "('12')", "('13')", "('14')", "('15')", "('16')", "('17')", "('18')", "('19')", "('20')", "('21')", "('22')", "('23')", "('24')", "('25')", "('26')", "('27')", "('28')", "('29')", "('30')");
var grudzienArray = new Array("('Dowolny')", "('1')", "('2')", "('3')", "('4')", "('5')", "('6')", "('7')", "('8')", "('9')", "('10')", "('11')", "('12')", "('13')", "('14')", "('15')", "('16')", "('17')", "('18')", "('19')", "('20')", "('21')", "('22')", "('23')", "('24')", "('25')", "('26')", "('27')", "('28')", "('29')", "('30')", "('31')");


	function populateregion(inForm,selected) 
	{
		var selectedArray = eval(selected + "Array");
		
		while (selectedArray.length < inForm.region.options.length) {inForm.region.options[(inForm.region.options.length - 1)] = null;}  
		for (var i=0; i < selectedArray.length; i++) {eval("inForm.region.options[i]=" + "new Option" + selectedArray[i]);}
		if (inForm.kraj.options[0].value == '') 
		{
			inForm.kraj.options[0]= null;
			if ( navigator.appName == 'Netscape') 
			{
				if (parseInt(navigator.appVersion) < 4) { window.history.go(0); }
				else { if (navigator.platform == 'Win32' || navigator.platform == 'Win16') { window.history.go(0); } }
	} 	} 	} 

	function populatedni(inForm,selected) 
	{
		if (selected == 'Dowolny') {var mies='Dowolny'}
		if (selected == '1') {var mies='styczen'}
		if (selected == '2') {var mies='luty'}
		if (selected == '3') {var mies='marzec'}
		if (selected == '4') {var mies='kwiecien'}
		if (selected == '5') {var mies='maj'}
		if (selected == '6') {var mies='czerwiec'}
		if (selected == '7') {var mies='lipiec'}
		if (selected == '8') {var mies='sierpien'}
		if (selected == '9') {var mies='wrzesien'}
		if (selected == '10') {var mies='pazdziernik'}
		if (selected == '11') {var mies='listopad'}
		if (selected == '12') {var mies='grudzien'}
	
		var selectedArray = eval(mies + "Array");
		while (selectedArray.length < inForm.dzien.options.length) {inForm.dzien.options[(inForm.dzien.options.length - 1)] = null;}
		for (var i=0; i < selectedArray.length; i++) {eval("inForm.dzien.options[i]=" + "new Option" + selectedArray[i]);}
		if (inForm.miesiac.options[0].value == '') 
		{
			inForm.miesiac.options[0]= null;
			if ( navigator.appName == 'Netscape') 
			{
				if (parseInt(navigator.appVersion) < 4) { window.history.go(0); }
				else { if (navigator.platform == 'Win32' || navigator.platform == 'Win16') { window.history.go(0); } } 
	} 	} 	}


	function populatedni2(inForm,selected) 
	{
		if (selected == 'Dowolny') {var mies='Dowolny'}
		if (selected == '1') {var mies='styczen'}
		if (selected == '2') {var mies='luty'}
		if (selected == '3') {var mies='marzec'}
		if (selected == '4') {var mies='kwiecien'}
		if (selected == '5') {var mies='maj'}
		if (selected == '6') {var mies='czerwiec'}
		if (selected == '7') {var mies='lipiec'}
		if (selected == '8') {var mies='sierpien'}
		if (selected == '9') {var mies='wrzesien'}
		if (selected == '10') {var mies='pazdziernik'}
		if (selected == '11') {var mies='listopad'}
		if (selected == '12') {var mies='grudzien'}
	
		var selectedArray = eval(mies + "Array");
		while (selectedArray.length < inForm.dzien2.options.length) {inForm.dzien2.options[(inForm.dzien2.options.length - 1)] = null;}
		for (var i=0; i < selectedArray.length; i++) {eval("inForm.dzien2.options[i]=" + "new Option" + selectedArray[i]);}
		if (inForm.miesiac2.options[0].value == '') 
		{
			inForm.miesiac2.options[0]= null;
			if ( navigator.appName == 'Netscape') 
			{
				if (parseInt(navigator.appVersion) < 4) { window.history.go(0); }
				else { if (navigator.platform == 'Win32' || navigator.platform == 'Win16') { window.history.go(0); } } 
	} 	} 	}

function rozwin(a)
{
	document.getElementById(a+'_koncow').style.height='600px';
	document.getElementById(a+'_koncow').style.backgroundColor='#FFFFFF';
	var b='last';
	document.getElementById(a+'_koncow').innerHTML=document.getElementById(b+'_minuteSzukaj').innerHTML;
}