/*
*       $Header: /repos/termapneumatyka/site/page/menu.js,v 1.1 2005/11/21 11:29:28 mariuszw Exp $
*/
        //global object that contains popup image data
        var popupImageObj;

        /////////////////////////////////////////////////////////////////////////
        //
        //  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;
        }
        
        function selectTabbedPanel(position, state) {
                        
                var line = document.getElementById('lnTabbedPanel'+position);
                if(typeof(line) == 'object' && line != null) {
                        if(state) line.style.backgroundColor = 'rgb(0, 0, 0)';
                        else line.style.backgroundColor = 'rgb(204, 0, 0)';
                }
        }
        
        function showTabbedPanel( position )
        {
                for(var i = 1; i <= 6; i++)
                {
                        var panel = document.getElementById('tabbedPanel'+i);
                        
                        if(typeof(panel) == 'object' && panel != null) {
                                if(i == position) panel.style.display = 'block';
                                else panel.style.display = 'none';
                        }
                        
                        var cell = document.getElementById('tdTabbedPanel'+i);
                        if(typeof(cell) == 'object' && cell != null)
                        {
                                if(i == position) cell.style.backgroundColor = 'rgb(242, 242, 242)';
                                else cell.style.backgroundColor = 'rgb(255, 255, 255)';
                        }
                        
                        var anchor = document.getElementById('aTabbedPanel'+i);
                        if(typeof(anchor) == 'object' && anchor != null)
                        {
                                if(i == position) anchor.className = 'link6a';
                                else anchor.className = 'link6';
                        }
                }        
        }
        
        function updateOrderData(containerName, productCode, productPrice, vatTax)
        {
                /*
                var container = document.getElementById(containerName);
                if(typeof(container) != 'object' || container == null) return;
                */
                var radios = document.getElementsByTagName('input');
                
                for(var i=0; i<radios.length; i++)
                {
                        if(radios[i].type != 'radio') continue;
                        if(!radios[i].name.match(/^param_[0-9]*$/)) continue;
                        if(!radios[i].checked) continue;
                        
                        var suffix = radios[i].value;
                        
                        var priceEl = document.getElementById('price_'+suffix);
                        if(typeof(priceEl) == 'object' && priceEl != null) 
                        {
                                productPrice = productPrice + parseFloat(priceEl.value);
                        }
                
                        var codeEl = document.getElementById('code_'+suffix);
                        if(typeof(codeEl) == 'object' && codeEl != null) 
                        {
                                productCode += codeEl.value;
                        }
                }
                var productCodeEl = document.getElementById('productOrderCode');
                if(typeof(productCodeEl) == 'object' && productCodeEl != null)
                {
                        productCodeEl.value = productCode;
                }
        
                var productNettoPriceEl = document.getElementById('productOrderNettoPrice');
                if(typeof(productNettoPriceEl) == 'object' && productNettoPriceEl != null)
                {
                        productNettoPriceEl.value = roundValue(productPrice, 2);
                }
        
                var productBruttoPriceEl = document.getElementById('productOrderBruttoPrice');
                if(typeof(productBruttoPriceEl) == 'object' && productBruttoPriceEl != null)
                {
                        var bruttoPrice = productPrice * ( 1 + vatTax / 100);
                        productBruttoPriceEl.value = roundValue(bruttoPrice, 2);
                }
        }
        
        function roundValue(value, roundRatio)
        {
                var div = Math.pow(10,roundRatio);
                var result = Math.round(div * value) / div;
                var decimal = Math.round((parseFloat(result) - parseInt(result)) * div);
                var decimalStr = '';
                
                for(var i=0; i<roundRatio; i++)
                {
                        decimalStr = '' + (decimal % 10) + decimalStr;
                        decimal = Math.round(decimal / 10);
                }
                
                return Math.floor(result) + '.' + decimalStr;
        }
        
        function setCheckboxState(formName, state)
        {
                var form = document.getElementById(formName);
                var inputs = form.getElementsByTagName('input');
                
                for(var i=0; i<inputs.length; i++)
                {
                        if(inputs[i].type == 'checkbox') inputs[i].checked = state;
                }
        }
        
        function submitFilmForm(formName, resolution) {
                var form = document.getElementById(formName);
                if(typeof(form) != 'object' || form == null) return null;
                
                var resolutionEl = document.getElementById('filmResolution');
                if(typeof(resolutionEl) != 'object' || resolutionEl == null) return null;
                
                resolutionEl.value = resolution;
                form.submit();
        }
        
        function submitNewsletterForm(formName, errorMessage) {
                var form = document.getElementById(formName);
                if(typeof(form) != 'object' || form == null) return null;
                
                var recipient = document.getElementById('newsletterEmail');
                if(typeof(recipient) != 'object' || recipient == null) return null;
                
                if(recipient.value == '') {
                        alert(errorMessage);
                        return;
                }
                
                form.submit();
        }
        
        function submitSendToForm(formName, errorMessage) {
                var form = document.getElementById(formName);
                if(typeof(form) != 'object' || form == null) return null;
                
                var recipient = document.getElementById('sendToRecipient');
                if(typeof(recipient) != 'object' || recipient == null) return null;
                
                if(recipient.value == '') {
                        alert(errorMessage);
                        return;
                }
                
                var sender = document.getElementById('sendToSender');
                if(typeof(sender) != 'object' || sender == null) return null;
                
                if(sender.value == '') {
                        alert(errorMessage);
                        return;
                }
                
                form.submit();
        }
        
        function submitContactForm(formName, errorMessage) {
                var form = document.getElementById(formName);
                if(typeof(form) != 'object' || form == null) return null;
                
                var recipient = document.getElementById('contactCity');
                if(typeof(recipient) != 'object' || recipient == null) return null;
                if(recipient.value == '') {
                        alert(errorMessage);
                        return;
                }
                
                var recipient = document.getElementById('contactEmail');
                if(typeof(recipient) != 'object' || recipient == null) return null;
                if(recipient.value == '') {
                        alert(errorMessage);
                        return;
                }
                
                var recipient = document.getElementById('contactQuestion');
                if(typeof(recipient) != 'object' || recipient == null) return null;
                if(recipient.value == '') {
                        alert(errorMessage);
                        return;
                }

                form.submit();
        }
        
        function submitSelectForm(formName, errorMessage)
        {
                var form = document.getElementById(formName);
                var inputs = form.getElementsByTagName('input');
                
                for(var i=0; i<inputs.length; i++)
                {
                        if(inputs[i].type == 'checkbox' && inputs[i].checked == true)
                        {
                                form.submit();
                                return;
                        }
                }
                
                alert(errorMessage);
        }
        
        function submitRecruitmentForm(formName, errorMessage, items) {
                var form = document.getElementById(formName);
                if(typeof(form) != 'object' || form == null) return null;
                
                if(arguments.length > 3) {
                        for(var i = 2; i < arguments.length; i++) {
                                var element = document.getElementById(arguments[i]);
                        
                                if(typeof(element) == 'object' && element != null) {
                                        if(element.value == '') {
                                                alert(errorMessage);
                                                return;
                                        }
                                }
                        }
                }
                
                form.submit();
        }
        
        function submitSearchForm(formName, emptyErrorMessage, checkErrorMessage)
        {
                var form = document.getElementById(formName);

                var optionChosen = false;
                var inputs = form.getElementsByTagName('input');
                for(var i=0; i<inputs.length; i++)
                {
                        if(inputs[i].type == 'text')
                        {                        
                                if(inputs[i].value == '')
                                {
                                        alert(emptyErrorMessage);
                                        return
                                }
                        }
                        else if(inputs[i].type == 'checkbox')
                        {
                                if(inputs[i].checked) optionChosen = true;
                        }
                }
                
                if(!optionChosen) 
                {
                        alert(checkErrorMessage);
                        return;
                }
                
                form.submit();
        }
        
        function setElementValue( elementName, value )
        {
                var element = document.getElementById(elementName);
                if(typeof(element) == 'object' && element != null)
                {
                        element.value = value;
                }
        }
        
        function submitParamSearchForm( formName, groupInputName )
        {
                var form = document.getElementById(formName);
                
                var selectedGroup = document.getElementById(groupInputName)
                if(typeof(selectedGroup) == 'object' && selectedGroup != null && selectedGroup.value != '')
                {
                        form.submit();
                }
        }      
        
        function submitForm( formName )
        {
                var form = document.getElementById(formName);
                form.submit();
        }
        
        function setDefaultCountryState( state )
        {
                var provinceSelect = document.getElementById('extranetProvince');
                provinceSelect.disabled = !state;
                provinceSelect.selectedIndex = 0;
                
                var countryInput = document.getElementById('extranetCountry');
                if(state) countryInput.value = '';
                countryInput.disabled = state;
                
                var polandText = document.getElementById('defaultCountry');
                if(state) polandText.style.color = '#3E505D';
                else polandText.style.color = '#AAAAAA';
        }
        
        function clearRegisterForm( formName )
        {
                var form = document.getElementById(formName);
                
                var inputs = form.getElementsByTagName('input');
                for(var i = 0; i < inputs.length; i++)
                {
                        if(inputs[i].type == 'text')
                        {
                                inputs[i].value = '';
                        }
                }
                
                setDefaultCountryState(true);
                
                var checkbox = document.getElementById('useOtherCountry');
                checkbox.checked = false;
                
                var input = document.getElementById('extranetCountry');
                input.value = '';
        }
        
        function checkClientData(errorMessage)
        {
                var element = null;
                
                element = document.getElementById('extranetName');
                if(element.value == '')
                {
                        alert(errorMessage);
                        return false;
                }
        
                element = document.getElementById('extranetSurname');
                if(element.value == '')
                {
                        alert(errorMessage);
                        return false;
                }
        
                element = document.getElementById('extranetEmail');
                if(element.value == '')
                {
                        alert(errorMessage);
                        return false;
                }
                
                element = document.getElementById('extranetStreet');
                if(element.value == '')
                {
                        alert(errorMessage);
                        return false;
                }
                
                element = document.getElementById('extranetPostCode');
                if(element.value == '')
                {
                        alert(errorMessage);
                        return false;
                }
                
                element = document.getElementById('extranetCity');
                if(element.value == '')
                {
                        alert(errorMessage);
                        return false;
                }
                
                element = document.getElementById('extranetPhone');
                if(element.value == '')
                {
                        alert(errorMessage);
                        return false;
                }
                
                element = document.getElementById('useOtherCountry');
                if(element.checked)
                {
                        element = document.getElementById('extranetCountry');
                        if(element.value == '')
                        {
                                alert(errorMessage);
                                return false;
                        }
                }
                else
                {
                        element = document.getElementById('extranetProvince');
                        if(element.selectedIndex == 0)
                        {
                                alert(errorMessage);
                                return false;
                        }
                }
                
                return true;
        }
        
        function submitRegisterForm(formName, errorMessage, passwordErrorMessage)
        {
                if(!checkClientData(errorMessage)) return;
                
                var passwordEl = document.getElementById('extranetPassword');
                if(passwordEl.value == '')
                {
                        alert(errorMessage);
                        return;
                }
                
                var passwordEl2 = document.getElementById('extranetRetypedPassword');
                if(passwordEl2.value == '')
                {
                        alert(errorMessage);
                        return;
                }
                
                if(passwordEl.value != passwordEl2.value)
                {
                        alert(passwordErrorMessage);
                        return;
                }
                
                var form = document.getElementById(formName);
                form.submit();
        }
        
        function submitOrderForm(formName, action, param, errorMessage, errorMessage2)
        {
                var form = document.getElementById(formName);
                var actionElement = document.getElementById('extranetAction');
                
                switch(action)
                {
                        case 'sendPassword':
                                var emailElement = document.getElementById(param);
                
                                if(emailElement.value == '') 
                                {
                                        alert(errorMessage);
                                        return;
                                }
                
                                actionElement.value = action;
                                form.submit();
                                break;
                                
                        case 'changeToOrder':
                        case 'change':
                                
                                var inputs = form.getElementsByTagName('input');
                                for(var i = 0; i < inputs.length; i++)
                                {
                                        if(inputs[i].type == 'text' && inputs[i].name.match(/^extranetProductAmount_[0-9]+$/))
                                        {
                                                if(!inputs[i].value.match(/^[0-9]+$/)) 
                                                {
                                                        alert(errorMessage);
                                                        return;
                                                }
                                        }
                                }
                                
                                if(action == 'changeToOrder') form.action = param;
                                
                                actionElement.value = 'change'
                                form.submit();
                                break;
                                
                        case 'order':
                                
                                if(param != true)
                                {
                                        if(!checkClientData(errorMessage)) return;
                                }
                                
                                var inputs = form.getElementsByTagName('input');
                                for(var i = 0; i < inputs.length; i++)
                                {
                                        if(inputs[i].type == 'text' && inputs[i].name.match(/^extranetProductAmount_[0-9]+$/))
                                        {
                                                if(!inputs[i].value.match(/^[0-9]+$/)) 
                                                {
                                                        alert(errorMessage2);
                                                        return;
                                                }
                                        }
                                }
                                
                                actionElement.value = action;
                                form.submit();
                                break;
                        
                        case 'delete':
                        case 'decrease':
                        case 'increase':
                                actionElement.value = action;
                                document.getElementById('extranetProductId').value = param;
                                form.submit();
                                break;
                }
        }
        
        
        function setMainMenuSelect(elementName, state)
        {
                var element = document.getElementById(elementName);
                
                if(typeof(element) == 'object' && element != null)
                {
                        //alert(element.style.borderBottomColor);
                        if(element.style.borderBottomColor.match(/db0c10/)) return;
                        if(element.style.borderBottomColor.match(/219[^0-9]+12[^0-9]+16/)) return;
                        
                        if(state) element.style.borderBottomColor = '#BE7213';
                        else element.style.borderBottomColor = '#553E1C';
                }
        }
        
        /*
                Debug function used to view object properties and events
                
                @author MariuszW (23-03-2005)
        */
        
        function showObjectProperties( obj )
        {
                var text = new String();
            
                if( typeof( obj ) == 'object' )
                {
                        if( obj.className ) text = "Object className: " + obj.className;
                        text = "\n\nProperties of specified object:\n\n";
            
                        for(element in obj)
                        {
                            
                                name = new String(element);
                                
                                if(!name.match(/^on/)) text +=  name + ",  ";
                            
                        }
                
                        text += "\n\nEvents of specified object:\n\n";
                        for(element in obj)
                        {
                                name = new String(element);
                                
                                if(name.match(/^on/)) text +=  name + ",  ";
                        }
                }
                else 
                {
            
                text = "Object value: " + new String( obj );
            
                }
            
            alert( text );
        }
        
        function showHideDistributors(cityId) {
        
                showHide('distributors'+cityId);
                
                var cityObj = document.getElementById('city'+cityId);
                if(typeof(cityObj) == 'object' && cityObj != null) {
                
                        var distObj = document.getElementById('distributors'+cityId);
                        if(typeof(distObj) == 'object' && distObj != null) {
                                if(distObj.style.display == 'none') cityObj.style.backgroundColor = '#F9F9F9';
                                else cityObj.style.backgroundColor = '#E5E5E5';
                        }
                }
        }
        
        function showHide(elementId) 
        {
                var obj = document.getElementById(elementId);
                if(typeof(obj) == 'object' && obj != null) {
	                if(obj.style.display == 'none') obj.style.display = 'block';
                        else obj.style.display = 'none';
                }
        }


        /////////////////////////////////////////////////////////////////////////
        //
        //  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: 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: 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 ) 
        {
                imageObj = new Image();
                
                images = new Array();
                images[0] = a_host + "/images/bt_next_a.gif";
                images[1] = a_host + "/images/bt_prev_a.gif";
                images[2] = a_host + "/images/bt_kat1_01_a.gif";
                
                for( i = 0; i < images.length; i++ )
                {
                        imageObj.src = images[i];
                }
        } 

        /////////////////////////////////////////////////////////////////////////
        //
        //  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, formName, 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 );
                                var form = document.getElementById(formName);
                                form.action = a_host + "/wyszukiwanie/" + words2;
                                form.submit();
                        }
                        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();
                        }
                }
        }