/*
*       $Header: /repos/kutno/site/page/menu.js,v 1.4 2005/09/26 10:22:45 mariuszw Exp $
*/
        //global object that contains popup image data
        var popupImageObj;

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja otwiera nowe okno z zawartoscia do wydruku
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function docPrinter( a_url )
        {
                a_text = ""+document.getElementById( "pagecontent" ).value+"";
                winObj = window.open( a_url, "_blank", "channelmode=no, toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, titlebar=yes, fullscreen=yes" );
                winObj.document.open();
                winObj.document.write( a_text );
                winObj.document.close();
        }
		
		function formSubmit( formName ) {
		        var formEl = document.getElementById(formName);	
		        if(typeof(formEl) == 'object' && formEl != null) {
		                formEl.submit();
		        }
		}
		
        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja przypisuje parametry do sortowania w cenniku i robi submita 
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function sortBy( a_field ,a_type )
        {
                oField = document.getElementById( "sort_by" );
                oField.value = a_field;
                oType = document.getElementById( "sort_type" );
                oType.value = a_type;
                document.forms.cennik_form.submit();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja wyswietla diva z tekstem 
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function showSearchDiv( a_type )
        {
                oDiv = document.getElementById( "searchwait" );
                oDiv.style.display = 'block';
                if( a_type != 1 )
                {
                        oDiv.scrollIntoView( true );
                }
                oDiv.style.top = 200;
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja chowa lub pokazuje to co ukryte/odkryte
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function showHide( a_docid ) 
        {
                obj = document.getElementById( a_docid );
                if( obj.style.display == 'none' )
                {
                        obj.style.display = 'block';
                }
                else
                {
                        obj.style.display = 'none';
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja podswietla tabbed panel
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function lightTabbed( a_name, on )
        {
                obj = document.getElementById( a_name );
                //if( ( obj.style.color == '#ff6600' ) || ( obj.style.color == 'rgb(255, 102, 0)' ) )
                //if( obj.style.fontWeight == 'normal' )
                //alert("->"+obj.style.borderTop+"<-");
                if( ( obj.style.borderTop == '1px solid #cccccc' ) || ( obj.style.borderTop == '#cccccc 1px solid' ) || ( obj.style.borderTop == '1px solid rgb(204, 204, 204)' ) )
                {
                        if( on == 1 )
                        {
                                //obj.style.backgroundColor = '#000000';
                                obj.style.color = '#ff6600';
                        }
                        else
                        {
                                //obj.style.backgroundColor = '#ff8000';
                                obj.style.color = '#cc0000';
                        }
                        
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja zarzadza przelaczaniem tabbed panel
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function showTabbed( a_name, a_num, a_id ) 
        {
                // a_name to nazwa wspolna dla grupy paneli
                // a_num to ilosc paneli w grupie [ 1..n ]
                // a_id to numer panelu w grupie [ 0..n-1 ]
                for( i = 0; i < a_num; i++ )
                {
                        l_tab = ''+a_name+''+i+'';
                        obj = document.getElementById( l_tab );
                        obj.style.display = 'none';
                        l_tabtop = ''+a_name+''+i+'top';
                        if( objtop = document.getElementById( l_tabtop ) )
                        {
                                //objtop.style.background = '#ff8000';
                                objtop.style.color = '#cc0000';
                                objtop.style.fontWeight = 'normal';
                                objtop.style.borderTop = '1px solid #cccccc';
                                objtop.style.borderLeft = '1px solid #cccccc';
                                objtop.style.borderRight = '1px solid #cccccc';
                        }
                }
                l_tab = ''+a_name+''+a_id+'';
                obj = document.getElementById( l_tab );
                obj.style.display = 'block';
                l_tabtop = ''+a_name+''+a_id+'top';
                objtop = document.getElementById( l_tabtop );
                //objtop.style.background = '#000000';
                objtop.style.color = '#ff6600';
                objtop.style.fontWeight = 'normal';
                objtop.style.borderTop = '1px solid #ffffff';
                objtop.style.borderLeft = '1px solid #ffffff';
                objtop.style.borderRight = '1px solid #ffffff';
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy podana data jest prawidłowa
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-26 10:57  piotrj     stworzenie
        //
        function CheckDate()
        {
                l_error = 0;
                l_year = document.getElementById( "year" );
                l_rok = l_year.value;
                l_month = document.getElementById( "month" );
                l_miesiac = l_month.value;
                l_day = document.getElementById( "day" );
                l_dzien = l_day.value;
                if( ( l_rok != "" ) || ( l_miesiac != "" ) || ( l_dzien != "" ) )
                {
                        l_error = 1;
                        l_d = new Date( l_rok, l_miesiac-1, l_dzien );
                        n_day = l_d.getDate();
                        n_month = l_d.getMonth()+1;
                        n_year = l_d.getFullYear();
                        if( ( n_year == l_rok ) && ( n_month == l_miesiac ) && ( n_day == l_dzien ) )
                        {
                                l_error = 0;
                        }
                }
                else
                {
                        l_error = 1;
                }
                return l_error;
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: kasuje wszystkie dane z formy aplikacja
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-26 10:57  piotrj     stworzenie
        //
        function KasujAplikacje( a_vis )
        {
                l_name = document.getElementById( "name" );
                l_name.value = "";
                l_surname = document.getElementById( "surname" );
                l_surname.value = "";
                l_phone = document.getElementById( "phone" );
                l_phone.value = "";
                l_e_mail = document.getElementById( "e_mail_work" );
                l_e_mail.value = "";
                //alert( a_vis );
                if( a_vis.charAt(0) == "1" )
                {
                        l_address = document.getElementById( "address" );
                        l_address.value = "";
                }
                if( a_vis.charAt(1) == "1" )
                {
                        l_year = document.getElementById( "year" );
                        l_year.value = "";
                        l_month = document.getElementById( "month" );
                        l_month.value = "";
                        l_day = document.getElementById( "day" );
                        l_day.value = "";
                }
                if( a_vis.charAt(2) == "1" )
                {
                        l_education = document.getElementById( "education" );
                        l_education.value = "";
                }
                if( a_vis.charAt(3) == "1" )
                {
                        l_motivation = document.getElementById( "motivation" );
                        l_motivation.value = "";
                }
                if( a_vis.charAt(4) == "1" )
                {
                        l_experience = document.getElementById( "experience" );
                        l_experience.value = "";
                }
                if( a_vis.charAt(5) == "1" )
                {
                        l_skills = document.getElementById( "skills" );
                        l_skills.value = "";
                }
                if( a_vis.charAt(6) == "1" )
                {
                        l_info = document.getElementById( "info" );
                        l_info.value = "";
                }
                if( a_vis.charAt(9) == "1" )
                {
                        l_wk_refer = document.getElementById( "wk_refer" );
                        l_wk_refer.value = "";
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy sa wypelnione wszystkie pola w aplikacji
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-26 10:57  piotrj     stworzenie
        //
        function CheckIsEmpty( a_req, a_vis )
        {
                txt = "Aby wysłać dane, musisz wypełnić poprawnie pola:"
                nazwypol = Array( "address", "birth", "education", "motivation", "experience", "skills", "info", "cv_file", "letter_file", "wk_refer" );
                nazwy = Array( " [Adres]", " [Data urodzenia]", " [Wykształcenie]", " [Motywacje]", " [Doświadczenie]", " [Umiejętności]", " [Informacje]", " [CV]", " [List motywacyjny]", " [Referencje]" );
                l_error = 0;
                l_name = document.getElementById( "name" );
                l_surname = document.getElementById( "surname" );
                l_phone = document.getElementById( "phone" );
                l_e_mail = document.getElementById( "e_mail_work" );
                if( l_name.value == "" )
                {
                        txt = txt+" [Imie]";
                        l_error = 1;
                }
                if( l_surname.value == "" )
                {
                        txt = txt+" [Nazwisko]";
                        l_error = 1;
                }
                if( l_phone.value == "" )
                {
                        txt = txt+" [Telefon]";
                        l_error = 1;
                }
                if( l_e_mail.value == "" )
                {
                        txt = txt+" [E-mail]";
                        l_error = 1;
                }
                for( i = 0; i <= 9; i++ )
                {
                        if( ( a_req.charAt(i) == "1" ) && ( a_vis.charAt(i) == "1" ) )
                        {
                                if( i != 1 )
                                {
                                        l_pole = document.getElementById( nazwypol[i] );
                                        if( l_pole.value == "" )
                                        {
                                                l_error = 1;
                                                txt = txt+nazwy[i];
                                        }
                                }
                                else
                                {
                                        l_error = CheckDate();
                                        if( l_error == 1 )
                                        {
                                                txt = txt+" [Rok] [Miesiąc] [Dzień]";
                                        }
                                }
                        }
                }
                if( l_error == 0 )
                {
                        document.forms.aplication_form.submit();
                }
                else
                {
                        txt = txt+".";
                        alert( txt );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: zmienia rozmiar okna
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function resizeImageWindow( imageObj, winObj )
        {
                if( imageObj.complete == true )
                {
                        l_width = imageObj.width+30;
                        l_height = imageObj.height+90;
                        winObj.resizeTo( l_width, l_height );
                }
                else
                {
                        setTimeout( "resizeImageWindow( imageObj, winObj )", 10 );
                }
        }

        /**
         * Function is used to show image popup window.
         * Window is created after complete image loading
         *
         * @param popupImageObj global variable - image to show object
         */
        function showImagePopupWindow()
        {
                if( popupImageObj.complete == true )
                {
                        windowWidth = popupImageObj.width + 20;
                        windowHeight = popupImageObj.height + 30;
                        
                        verticalPosition = (document.body.clientWidth - windowWidth) / 2;
                        if(verticalPosition < 0) verticalPosition = 0;
                        
                        horizontalPosition = (document.body.clientHeight - windowHeight) / 2;
                        if(horizontalPosition < 0) horizontalPosition = 0;
                        
                        popupWindowObj = window.open(   popupImageObj.src, 
                                                        "image_window", 
                                                        "channelmode=no, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, titlebar=no, \
                                                        width="+ windowWidth +", height="+ windowHeight +", \
                                                        left="+ verticalPosition +", top="+ horizontalPosition +"" );
                        popupWindowObj.focus();
                }
                else
                {
                        setTimeout( "showImagePopupWindow()", 10 );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: pokazuje obrazek w nowym dopasowanym oknie
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function showImage( pathToImage )
        {
                popupImageObj = new Image();
                popupImageObj.src = pathToImage;
                
                showImagePopupWindow( popupImageObj );
                
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy zaznaczony jest przynajmniej jeden produkt
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function isProductChecked( a_tekst )
        {
                jest = 0;
                numer = 0;
                chk = "chk" + numer;
                while( ( check = document.getElementById( chk ) ) && ( jest == 0 ) )
                {
                        if( check.checked == true )
                        {
                                jest = 1;
                        }
                        numer++;
                        chk = "chk" + numer;
                }
                if( jest == 1 )
                {
                        document.forms.check_prod.submit();
                }
                else
                {
                        alert( a_tekst );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy zaznaczony jest przynajmniej jeden parametr
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function isParamChecked( a_tekst )
        {
                jest = 0;
                numer = 0;
                chk = "chk" + numer;
                while( ( check = document.getElementById( chk ) ) && ( jest == 0 ) )
                {
                        if( check.checked == true )
                        {
                                jest = 1;
                        }
                        numer++;
                        chk = "chk" + numer;
                }
                if( jest == 1 )
                {
                        document.forms.check_param.submit();
                }
                else
                {
                        alert( a_tekst );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: zaznacza wszystkie checkboxy
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function check_all()
        {
                numer = 0;
                chk = "chk" + numer;
                while( ( check = document.getElementById( chk ) ) )
                {
                        check.checked = true;
                        numer++;
                        chk = "chk" + numer;
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: odznacza wszystkie checkboxy
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function check_none()
        {
                numer = 0;
                chk = "chk" + numer;
                while( ( check = document.getElementById( chk ) ) )
                {
                        check.checked = false;
                        numer++;
                        chk = "chk" + numer;
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: obsluguje kody produktow
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function zmien_kod()
        {
                vkod = document.getElementById( "kod" );
                vdkod = document.getElementById( "dkod" );
                vkod.value = vdkod.value;
                vcena = document.getElementById( "cena" );
                vdcena = document.getElementById( "dcena" );
                vcena.value = vdcena.value;
                vcenavat = document.getElementById( "cenavat" );
                vvat = document.getElementById( "dvat" );
                numer = 1;
                chks = "chks" + numer;
                chkc = "chkc" + numer;
                while( ( checks = document.getElementById( chks ) ) )
                {
                        if( checks.checked )
                        {
                                vkod.value = vkod.value + checks.value;
                                checkc = document.getElementById( chkc );
                                new_valuec = parseFloat( checkc.value );
                                old_value_plus = parseFloat( vcena.value );
                                vcena.value = old_value_plus + new_valuec;
                        }
                        numer++;
                        chks = "chks" + numer;
                        chkc = "chkc" + numer;
                }
                cena_float = vcena.value;
                pos_cena = cena_float.indexOf( "." );
                if( pos_cena < 0 )
                {
                        pos_cena = cena_float.indexOf( "," );
                        if( pos_cena < 0 )
                        {
                                cena_float = cena_float + ".00";
                        }
                        else
                        {
                                s1 = cena_float.substring( 0, pos_cena );
                                s1 = parseInt( s1 );
                                s2 = cena_float.substring( pos_cena+1, pos_cena+2 );
                                s2 = parseInt( s2 );
                                v1 = cena_float.substring( pos_cena+2, pos_cena+3 );
                                v1 = parseInt( v1 );
                                v2 = cena_float.substring( pos_cena+3, pos_cena+4 );
                                v2 = parseInt( v2 );
                                if( v2 > 5 )
                                {
                                        v1++;
                                        if( v1 > 9 )
                                        {
                                                v1 = 0;
                                                s2++;
                                                if( s2 > 9 )
                                                {
                                                        s2 = 0;
                                                        s1++;
                                                }
                                        }
                                }
                                cena_float = s1 + "." + s2 + v1;
                        }
                }
                vcena.value = cena_float;
                new_vat = parseFloat( vvat.value );
                vcenavat.value = vcena.value * new_vat;
                new_vcenavat = vcenavat.value;
                pos = new_vcenavat.indexOf( "." );
                if( pos >= 0  )
                {
                        ns1 = new_vcenavat.substring( 0, pos );
                        ns1 = parseInt( ns1 );
                        ns2 = new_vcenavat.substring( pos+1, pos+2 );
                        ns2 = parseInt( ns2 );
                        nv1 = new_vcenavat.substring( pos+2, pos+3 );
                        if( nv1 != "" )
                        {
                                nv1 = parseInt( nv1 );
                        }
                        else
                        {
                                nv1 = 0;
                        }
                        nv2 = new_vcenavat.substring( pos+3, pos+4 );
                        if( nv2 != "" )
                        {
                                nv2 = parseInt( nv2 );
                        }
                        else
                        {
                                nv2 = 0;
                        }
                        if( nv2 > 5 )
                        {
                                nv1++;
                                if( nv1 > 9 )
                                {
                                        nv1 = 0;
                                        ns2++;
                                        if( ns2 > 9 )
                                        {
                                                ns2 = 0;
                                                ns1++;
                                        }
                                }
                        }
                        vcenavat.value = ns1 + "." + ns2 + nv1;
                }
                else
                {
                        vcenavat.value = new_vcenavat + ".00";
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: zmienia lokacje na podany adres
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function go_to_location( a_location )
        {
                window.location = a_location;
        }

//--------------------------------------------------------------------------------------

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja wczytuje obrazki do pamieci przy ladowaniu strony
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function imgPreloader( a_host, a_modul ) 
        {
                imageObj = new Image();
                images = new Array();
                images[0] = a_host + "/images/main_page/button_szukaj.gif";
                images[1] = a_host + "/images/main_page/button_szukaj_a.gif";
                images[2] = a_host + "/images/main_page/button_down.gif";
                images[3] = a_host + "/images/main_page/button_down_a.gif";
                images[2] = a_host + "/images/main_page/button_up.gif";
                images[3] = a_host + "/images/main_page/button_up_a.gif";
                num = 6;
                for( i = 0; i < num; i++ )
                {
                        imageObj.src = images[i];
                }
        } 

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: przypisuje akcje do wykonania i robi submita
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-26 10:57  piotrj     stworzenie
        //
        function sendReferenceMail( a_text )
        {
                l_adresat = document.getElementById( "adresat" );
                l_nadawca = document.getElementById( "nadawca" );
                if( ( l_adresat.value == "" ) || ( l_nadawca.value == "" ) )
                {
                        alert( a_text );
                }
                else
                {
                        document.forms.polec_nas.submit();
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: przypisuje akcje do wykonania i robi submita
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-26 10:57  piotrj     stworzenie
        //
        function SubscriptAction( a_akcja )
        {
                l_hidden_action = document.getElementById( "akcja" );
                l_hidden_action.value = a_akcja;
                document.forms.subskrypt_form.submit();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja podmienia obrazki bez tekstu przy wywolaniu
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function changeImage2( a_name, on_off ) 
        {
                //alert( a_name );
                old_img = document.getElementById( a_name );
                old_src = old_img.src;
                len = old_src.length;
                roz = old_src.substr( len-4, len );
                if( on_off == 1 )
                {
                        new_src = old_src.substr( 0, len-4 ) + "_a" + roz;
                }
                else
                {
                        if( old_src.charAt(len-5) == "a" )
                        {
                                new_src = old_src.substr( 0, len-6 ) + roz;
                        }
                        else
                        {
                                new_src = old_src;
                        }
                }
                old_img.src = new_src
        } 

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: zmienia lokacje strony na podany adres
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function LocationFromMenu( adres )
        {
                window.location = adres;
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: usowa nadmiarowe spacje ze stringa
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function erase_space( str )
        {
                newstr = "";
                i = 0;
                strlen = str.length;
                znak = str.charAt(i);
                while( ( znak != "" ) && ( i < strlen ) )
                {
                        if( znak == " " )
                        {
                                i++;
                        }
                        else
                        {
                                while( ( znak != "" ) && ( znak != " " ) && ( i < strlen ) )
                                {
                                        newstr = newstr + znak;
                                        i++;
                                        znak = str.charAt(i);
                                }
                                newstr = newstr + "+";
                                i++;
                        }
                        znak = str.charAt(i);
                }
                len = newstr.length;
                znak = newstr.charAt( len-1 );
                if( znak == "+" )
                {
                        newstr = newstr.substr( 0, len-1 );
                }
                return newstr;
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza dlugosc wszystkich podanych slow
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function checkWordsLength( a_str )
        {
                l_ok = 1;
                l_str = "";
                l_index = 0;
                l_len = a_str.length;
                if( l_len > 1 )
                {
                        l_index = a_str.indexOf( "+" );
                        if( l_index > 0 )
                        {
                                l_str = a_str.substr( 0, l_index );
                                if( l_str.length > 1 )
                                {
                                        r_str = a_str.substr( l_index+1, l_len );
                                        l_ok = checkWordsLength( r_str );
                                }
                                else
                                {
                                        if( l_str.length > 0 )
                                        {
                                                l_ok = 0;
                                        }
                                }
                        }
                }
                else
                {
                        l_ok = 0;
                }
                return l_ok;
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: odsyla do wyszukiwania, jesli wpisano slowa
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function SendWords( a_host, a_id, text_to_alert )
        {
                //check_forbidden_chars( a_id, text_to_alert );
                word_container = document.getElementById( a_id );
                words = word_container.value;
                if( words != "" )
                {
                        words = words.toLocaleLowerCase();
                        re = /(\+)/g;
                        words = words.replace( re, "d7d18cfb3a0d8293e2f5d94ea30e04d2" );
                        words = erase_space( words );
                        is_ok = checkWordsLength( words );
                        if( is_ok == 1 )
                        {
                                words = encodeURI(words);
                                re = /(\%25+)/g;
                                words2 = words.replace( re, "e1e4faf650b9178c832fd6ce887e11d4" );
                                re = /(\/)/g;
                                words2 = words2.replace( re, "9fbbaa4cc515bc46e0c12e82a31df736" );
                                //alert( words+" --> "+words2 );
                                adres = a_host + "/wyszukiwanie/slowa/" + words2;
                                window.location = adres;
                        }
                        else
                        {
                                alert( text_to_alert );
                        }
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: inicjuje menu rozwijane
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        startList = function()
        {
                if ( document.all && document.getElementById )
                {
                        navRoot = document.getElementById( "nav" );
                        for ( i=0; i < navRoot.childNodes.length; i++ )
                        {
                                node = navRoot.childNodes[i];
                                if ( node.nodeName == "LI" )
                                {
                                        node.onmouseover = function()
                                        {
                                                this.className += "over";
                                        }
                                        node.onmouseout = function()
                                        {
                                                this.className = this.className.replace( "over", "" );
                                        }
                                }
                        }
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy w stringu nie ma zabronionych znakow
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function check_forbidden_chars( element_id, send, text_to_alert )
        {
                send_text_el = document.getElementById( element_id );
                send_text = send_text_el.value;
                pos = send_text.indexOf( "%" );
                pos2 = send_text.indexOf( "_" );
                if( ( pos >= 0 ) || ( pos2 >= 0 ) )
                {
                        send_text_el.value = "";
                        alert( text_to_alert );
                }
                if( send == 1 )
                {
                        if( send_text_el.value != "" )
                        {
                                document.forms.product_search.submit();
                        }
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy zaznaczona jest przynajmniej jedna opcja danego parametru
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function tryParamCheckbox( a_tekst, a_par_num, a_check_num )
        {
                l_selpar = "sel" + a_par_num + "par" + a_check_num;
                a_value = document.getElementById( l_selpar ).checked;
                jest = 1;
                if( a_check_num == 2 )
                {
                        numselpar = 3;
                }
                else
                {
                        numselpar = 2;
                }
                l_selpar = "sel" + a_par_num + "par" + numselpar;
                jestselpar = 0;
                while( selpar = document.getElementById( l_selpar ) )
                {
                        if( selpar.checked == true )
                        {
                                jestselpar = 1;
                        }
                        numselpar++;
                        if( numselpar == a_check_num )
                        {
                                numselpar++;
                        }
                        l_selpar = "sel" + a_par_num + "par" + numselpar;
                }
                if( jestselpar == 0 )
                {
                        jest = 0;
                }
                kontrol = document.getElementById( "kontrol" );
                kontrol.value = "0";
                if( jest == 1 )
                {
                        l_selpar = "sel" + a_par_num + "par" + a_check_num;
                        if( a_value == true )
                        {
                                document.getElementById( l_selpar ).checked = false;
                        }
                        else
                        {
                                document.getElementById( l_selpar ).checked = true;
                        }
                        l_src = document.forms.product_search_param.action;
                        document.forms.product_search_param.action = "" + l_src + "#dolstrony";
                        document.forms.product_search_param.submit();
                }
                else
                {
                        l_selpar = "sel" + a_par_num + "par" + a_check_num;
                        if( a_value == true )
                        {
                                oDiv = document.getElementById( "searchwait" );
                                oDiv.style.display = 'none';
                                alert( a_tekst );
                                document.getElementById( l_selpar ).checked = true;
                        }
                        else
                        {
                                document.getElementById( l_selpar ).checked = true;
                                l_src = document.forms.product_search_param.action;
                                document.forms.product_search_param.action = "" + l_src + "#dolstrony";
                                document.forms.product_search_param.submit();
                        }
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy zaznaczono parametry do wyszukiwania i robi submita
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function submit_param_search( text_to_alert, search_on, box_num )
        {
                jest = 1;
                for( numsel = 0; numsel <= box_num+1; numsel++ )
                {
                        l_sel = "sel" + numsel;
                        if( sel = document.getElementById( l_sel ) )
                        {
                                selval = sel.value;
                                if( selval != "" )
                                {
                                        numselpar = 2;
                                        l_selpar = "sel" + numsel + "par" + numselpar;
                                        jestselpar = 0;
                                        while( selpar = document.getElementById( l_selpar ) )
                                        {
                                                if( selpar.checked )
                                                {
                                                        jestselpar = 1;
                                                }
                                                numselpar++;
                                                l_selpar = "sel" + numsel + "par" + numselpar;
                                        }
                                        if( jestselpar == 0 )
                                        {
                                                jest = 0;
                                                numsel = box_num+1;
                                        }
                                }
                        }
                }
                kontrol = document.getElementById( "kontrol" );
                kontrol.value = "" + search_on + "";
                if( jest == 1 )
                {
                        if( search_on == 0 )
                        {
                                l_src = document.forms.product_search_param.action;
                                document.forms.product_search_param.action = "" + l_src + "#dolstrony";
                        }
                        document.forms.product_search_param.submit();
                }
                else
                {
                        oDiv = document.getElementById( "searchwait" );
                        oDiv.style.display = 'none';
                        alert( text_to_alert );
                        l_sel = "selopt";
                        if( select = document.getElementById( l_sel ) )
                        {
                                select.value = "";
                        }
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: usowa wybrany parametr ze strony
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function usun_wybrany_parametr( wiersz, kolejnosc )
        {
                selnum = "sel" + wiersz;
                l_param = document.getElementById( selnum );
                l_param.value = "";
                document.getElementById( "kontrol" ).value = 0;
                document.getElementById( "usun_kolejnosc" ).value = kolejnosc;
                l_src = document.forms.product_search_param.action;
                document.forms.product_search_param.action = "" + l_src + "#dolstrony";
                document.forms.product_search_param.submit();
        }
