
        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja sprawdza, czy podane w wirtualnym handlowcu parametry maja wlasciwy zakres
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function checkVirtual() 
        {
                noc = document.getElementById( "number_of_catalogs" ).value;
                cp = document.getElementById( "catalog_price" ).value;
                poc = document.getElementById( "percent_of_customers" ).value;
                nop = document.getElementById( "number_of_products" ).value;
                if( ( noc >= 1 ) && ( cp >= 1 ) && ( poc >= 1 ) && ( poc <= 100 ) && ( nop >= 1 ) )
                {
                        document.forms.virtual_trade_form.submit();
                }
                else
                {
                        alert( "Wprowadzono zle wartosci" );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  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/logo_mp.jpg";
                images[3] = a_host + "/images/main_page/banner.jpg";
                images[4] = a_host + "/images/main_page/button_FAQ.gif";
                images[5] = a_host + "/images/main_page/button_FAQ_a.gif";
                images[6] = a_host + "/images/main_page/button_wirtual.gif";
                images[7] = a_host + "/images/main_page/button_wirtual_a.gif";
                images[8] = a_host + "/images/main_page/button_send.gif";
                images[9] = a_host + "/images/main_page/button_send_a.gif";
                images[10] = a_host + "/images/main_page/button_wiecej.gif";
                images[11] = a_host + "/images/main_page/button_wiecej_a.gif";
                images[12] = a_host + "/images/button_wykrzyknik_m.gif";
                images[13] = a_host + "/images/button_wykrzyknik_m_a.gif";
                images[14] = a_host + "/images/foto_wirtual.gif";
                images[15] = a_host + "/images/button_wiecej_b.gif";
                images[16] = a_host + "/images/button_zadaj_maly.gif";
                images[17] = a_host + "/images/button_zadaj_maly_a.gif";
                images[18] = a_host + "/images/button_dot.gif";
                images[19] = a_host + "/images/button_dot_a.gif";
                images[20] = a_host + "/images/button_next.gif";
                images[21] = a_host + "/images/button_next_a.gif";
                images[22] = a_host + "/images/button_prev.gif";
                images[23] = a_host + "/images/button_prev_a.gif";
                images[24] = a_host + "/images/button_wykrzyknik.gif";
                images[25] = a_host + "/images/button_zadaj.gif";
                images[26] = a_host + "/images/button_ankieta.gif";
                images[27] = a_host + "/images/button_ankieta_a.gif";
                images[28] = a_host + "/images/mp_man.jpg";
                images[29] = a_host + "/images/button_wiecej_m_bg_1.gif";
                images[30] = a_host + "/images/button_wiecej_m.gif";
                images[31] = a_host + "/images/button_wiecej_m_a.gif";
                num = 32;
                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.toLowerCase();
                        words = erase_space( words );
                        is_ok = checkWordsLength( words );
                        if( is_ok == 1 )
                        {
                                words = encodeURI(words);
                                adres = a_host + "/wyszukiwanie/slowa/" + words;
                                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 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)
        {
                numsel = 0;
                l_sel = "sel" + numsel;
                jest = 1;
                while( sel = document.getElementById( l_sel ) )
                {
                        if( sel.value != "" )
                        {
                                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++;
                        l_sel = "sel" + numsel;
                }
                if( jest == 1 )
                {
                        kontrol = document.getElementById( "kontrol" );
                        kontrol.value = "1";
                        document.forms.product_search_param.submit();
                }
                else
                {
                        alert( text_to_alert );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: usowa wybrany parametr ze strony
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function usun_wybrany_parametr( wiersz )
        {
                selnum = "sel" + wiersz;
                l_param = document.getElementById( selnum );
                l_param.value = "";
                document.forms.product_search_param.submit();
        }

