/*
*       $Header: /repos/rohmann/site/page/menu.js,v 1.1.1.1 2005/11/16 13:52:19 piotrj Exp $
*/

        //global object that contains popup image data
        var popupImageObj;
        
        /**
         * Global array PARAM_ARRAY that contains all param data MUST be provided!
         * Global variable EMPTY_OPTION_VALUE that contains first element name in param select MUST be provided!
         */

        //global array that contains product data
        var products = new Array();

        /**
         * Class used for managing parameter data
         * 
         * @param paramId       parameter id 
         * @param name          parameter name
         */
        function ParameterObj( paramId, name )
        {
                this.id = paramId;              //parameter id
                this.valueCount = 0;            //number of parameter values
                this.valueId = new Array();     //array that contains specified parameter value ids
                this.valueIdIndex = new Array();
                this.useValues = 'undefined';   //determines using all values in parameter or any value in product search
                this.name = name;
                this.isParamVisible = true;
        }

        /**
         * Function used to add parameter value id
         * 
         * @param valueId       id of parameter value
         */
        function ParameterObj_addValueId( valueId )
        {
                this.valueId[this.valueCount] = valueId;
                this.valueIdIndex[valueId] = valueId;
                this.valueCount++;
        }

        /**
         * Function used to get parameter name
         * 
         * @return string that contains parameter name
         */
        function ParameterObj_getName( name )
        {
                return this.name;
        }

        /**
         * Function used to get parameter id
         * 
         * @return string that contains parameter id
         */
        function ParameterObj_getId()
        {
                return this.id;
        }

        /**
         * Function used to check if parameter is visible
         * 
         * @return boolean true - if parameter is visible, false - otherwise
         */
        function ParameterObj_isVisible()
        {
                return this.isParamVisible;
        }

        /**
         * Function sets parameter visible state
         * 
         * @param state         boolean that is true if parameter is visible, false - otherwise
         */
        function ParameterObj_setVisible( state )
        {
                this.isParamVisible = state;
        }

        /**
         * Function checks if specified parameter fullfill search conditions specified by input parameter
         * Checks if parameters have same id, and compares parameters values.
         * If specified parameter must have all values provided by input parameter function checks if parameters have same values
         * If specified parameter must have any of inputed parameter values even only one value is enought to fullfill search conditions
         *
         * @param parameter     ParameterObj that contains search conditions
         *
         * @return boolean      true - specified parameter fullfills search conditions
         *                      false - specified parameter does not fullfill search conditions
         */
        function ParameterObj_fullfill( parameter )
        {
                if( this.id != parameter.id ) return false;
                if( parameter.useValues == 'all' )
                {
                        var id = null;
                        for( var i=0; i < parameter.valueId.length; i++ )
                        {
                                id = parameter.valueId[i];
                                
                                if( this.valueIdIndex.length <= id ) return false;
                                
                                if( this.valueIdIndex[id] != id ) return false;
                        }
                
                        return true;
                }
                
                if( parameter.useValues == 'any' )
                {
                        for( var i=0; i < parameter.valueId.length; i++ )
                        {
                                id = parameter.valueId[i];
                                
                                if( this.valueIdIndex.length <= id ) continue;
                                
                                if( this.valueIdIndex[id] == id ) return true;
                        }
                        
                        return false;
                }
        }

        /**
         * Function used for debug purposes.
         * Function shows parameter data in alert window
         *
         * @param title         string that contains popup window title
         */
        function ParameterObj_showData( title )
        {
                var text = 'Param id = ' + this.id + '\nValues:\n';
                
                for( var i = 0; i < this.valueId.length; i++ )
                {
                        text += this.valueId[i] + ', ';
                
                }
                
                text += '\nUse values: ' + this.useValues;
                if( ( title != '' ) && ( title != 'undefined' ) && ( title != null ) ) text += '\nTitle: ' + title;
                
                alert(text);
        }

        //adding functions to prototype
        ParameterObj.prototype.addValueId = ParameterObj_addValueId;
        ParameterObj.prototype.isVisible = ParameterObj_isVisible;
        ParameterObj.prototype.setVisible = ParameterObj_setVisible;
        ParameterObj.prototype.getId = ParameterObj_getId;
        ParameterObj.prototype.getName = ParameterObj_getName;
        ParameterObj.prototype.fullfill = ParameterObj_fullfill;
        ParameterObj.prototype.showData = ParameterObj_showData;

        /**
         * Class used for managing product data
         * 
         * @param prodId       product id
         */
        function ProductObj( prodId )
        {
                this.id = prodId;               //product id
                this.params = new Array();      //contains product parameters object
                this.paramCount = 0;            //parameters number
                this.found = true;              //determines if product fullfills search conditions
        }

        /**
         * Function used to add ParameterObj object to product
         * 
         * @param param instance of ParameterObj class
         */
        function ProductObj_addParam( param )
        {
                this.params[param.id] = param;
                this.paramCount++;
        }

        /**
         * Function used to check if product fullfills search conditions defined by parameter paramToCheck
         * 
         * @param paramToCheck  instance of ParameterObj that contains search conditions
         */
        function ProductObj_checkParam( paramToCheck )
        {
                var position = paramToCheck.id
                if( this.params.length >= position )
                {
                        var param = this.params[position];
                        if( typeof( param ) == 'object' )
                        {
                                if( param.fullfill( paramToCheck ) ) return;
                        }
                }
                
                this.found = false;
        }

        /**
         * Function checks if product fullfills search conditions.
         * Function checks only actual product state. State can change after parameters check
         * 
         * @return boolean      true - if product fullfills search conditions
         *                      false - if product does not fullfill search conditions
         */
        function ProductObj_isFound()
        {
                return this.found;
        }

        /**
         * Function reset product state to start state
         */
        function ProductObj_resetFound()
        {
                this.found = true;
        }

        //adding functions to prototype
        ProductObj.prototype.addParam = ProductObj_addParam;
        ProductObj.prototype.checkParam = ProductObj_checkParam;
        ProductObj.prototype.isFound = ProductObj_isFound;
        ProductObj.prototype.resetFound = ProductObj_resetFound;

        /**
         * Function used to copy search parameter div defined by id like 'paramSearchDiv_PARAMID_prototype' prototypes MUST be provided.
         * Function manages parameter select html object data
         *
         * @param paramId       contains parameter id
         */
        function showSearchParam( paramId )
        {
                var paramDiv = document.getElementById( 'paramSearchDiv_' + paramId + '_prototype' ).cloneNode(true);
                paramDiv.id = 'paramSearchDiv_' + paramId;
                paramDiv.name = 'paramSearchDiv_' + paramId;
                paramDiv.style.display = 'block';
                
                document.getElementById( 'paramSearchPanelDiv' ).appendChild( paramDiv );
                
                manageParamSelect( paramId, true );
                countProducts();
        }

        /**
         * Function hides search parameter div defined by id like 'paramSearchDiv_PARAM_ID'.
         * Function manages parameter select html object data
         *
         * @param paramId       contains parameter id
         */
        function hideSearchParam( paramId )
        {
                var paramDiv = document.getElementById( 'paramSearchDiv_' + paramId );
                paramDiv.parentNode.removeChild( paramDiv );
                
                manageParamSelect( paramId, false );
                
                countProducts();
        }

        /**
         * Function manages html select object state that contains parameter data.
         * Id and name attribute of this object MUST be 'paramSearchSelect'
         * Document MUST contain summary div html object 'paramSearchSummaryDiv1' and 'paramSearchSummaryDiv2'
         *
         * @param paramId       string id of parameter in select
         * @param isReduced     boolean determines action on parameter describbed by id
         *                      true - parameter must be added to select object
         *                      false - parameter must be removed from select object
         */
        function manageParamSelect( paramId, isReduced )
        {
                var paramSelect = document.getElementById( 'paramSearchSelect' );
                
                //updating global parameters visibility
                for( var i = 0; i < PARAM_ARRAY.length; i++ )
                {
                        if( PARAM_ARRAY[i].getId() == paramId )
                        {
                                PARAM_ARRAY[i].setVisible( !isReduced );
                                break;
                        }
                }
                
                //cleaning paramSelect
                for( var i = 0; i < paramSelect.options.length; i++ )
                {
                        paramSelect.options[i] = null;
                }
                
                //generating paramSelect parameter options
                var optionEl = null;
                paramSelect.options[0] = new Option( EMPTY_OPTION_VALUE, '' );
                var optionCounter = 1;
                for( var i = 0; i < PARAM_ARRAY.length; i++ )
                {
                        if( PARAM_ARRAY[i].isVisible() )
                        {
                                paramSelect.options[optionCounter] = new Option( PARAM_ARRAY[i].getName(), PARAM_ARRAY[i].getId() );
                                optionCounter++;
                        }
                        
                }
                
                paramSelect.selectedIndex = 0;
                
                var hiddenOptionCount = 0;
                
                if( isReduced )
                {
                        if( paramSelect.options.length == 1 ) paramSelect.style.display = 'none';
                        document.getElementById( 'paramSearchSummaryDiv1' ).style.display = 'block';
                        document.getElementById( 'paramSearchSummaryDiv2' ).style.display = 'block';
                }
                else
                {
                        paramSelect.style.display = 'block';
                        if( paramSelect.options.length == PARAM_ARRAY.length + 1 ) 
                        {
                                document.getElementById( 'paramSearchSummaryDiv1' ).style.display = 'none';
                                document.getElementById( 'paramSearchSummaryDiv2' ).style.display = 'none';
                        }
                }
        }

        /**
         * Function counts products that fullfill search conditions
         * Search conditions must be defined in 'paramSearchForm' html form
         *
         * Search conditions MUST be defined as elements with name and id as:
         *
         * checkboxes - 'paramSearchParameter_PARAMETERID_VALUEID' where PARAMETERID - is parameter id and VALUEID is id of specified parameter value
         *
         * radios - 'paramSearchAllowedValues_PARAMETERID' determines if product must contain all checked values (element value 'all') or only one of them (element value 'any')
         *
         * Function sets html object values:
         * 'productNumber1' - number of products that fullfill search criteria
         * 'productNumber2' - number of products that fullfill search criteria
         * 'selectedProduct' - id of products that fillfill search criteria separated by comma
         * Those elements MUST be provided.
         */
        function countProducts()
        {
                var form = document.getElementById( 'paramSearchForm' );
                
                var params = new Array();
                
                var inputs = form.getElementsByTagName( 'input' );
                for( var i = 0; i < inputs.length; i++ )
                {
                        //searching checked values
                        if( ( inputs[i].type == 'checkbox' ) && ( inputs[i].name.match( /^paramSearchParameter_[0-9]+_[0-9]+$/ ) != null ) )
                        {
                                if( inputs[i].checked )
                                {
                                        var paramString = new String( inputs[i].name ).replace( /^paramSearchParameter_/, '' );
                                        var paramId = paramString.replace( /_[0-9]+$/, '' );
                                        var valueId = paramString.replace( /^[0-9]+_/, '' );
                                
                                        if( params[paramId] == null )
                                        {
                                                params[paramId] = new ParameterObj( paramId );
                                        }
                                        params[paramId].addValueId( valueId );
                                }
                        }
                        
                        //searching all or any param criteria
                        if( ( inputs[i].type == 'radio' ) && ( inputs[i].name.match( /^paramSearchAllowedValues_[0-9]+$/ ) != null ) )
                        {
                                if( inputs[i].checked )
                                {
                                        inputs[i].focus();
                                        
                                        var paramId = new String( inputs[i].name ).replace( /^paramSearchAllowedValues_/, '' );
                                
                                        if( params[paramId] == null )
                                        {
                                                params[paramId] = new ParameterObj( paramId );
                                        }
                                        
                                        params[paramId].useValues = inputs[i].value;
                                        
                                }
                        }
                }
                
                var i,j;
                var searchInProducts = true;
                
                //reseting product found status
                for( i = 0; i < products.length; i++ )
                {
                        products[i].resetFound();
                }
                
                //checking if products fillfill search criteria
                for( i = 0; i < params.length; i++ )
                {
                        if( ( typeof( params[i] ) == 'object' ) && ( params[i] != null ) )
                        {
                                if( params[i].valueCount == 0 )
                                {
                                        searchInProducts = false;
                                        break;
                                }
                                
                                for( j = 0; j < products.length; j++ )
                                {
                                        if( products[j].isFound() )
                                        {
                                                products[j].checkParam( params[i] )
                                        }
                                }
                        }
                
                }
                
                //generating selectedProduct value
                var searchCount = 0;
                var searchProductId = '';
                for( i = 0; i < products.length && searchInProducts; i++ )
                {
                        if( products[i].isFound() )
                        {
                                searchCount++;
                                searchProductId += products[i].id + ';';
                        }
                }
                
                document.getElementById( 'productNumber1' ).innerHTML = searchCount;
                document.getElementById( 'productNumber2' ).innerHTML = searchCount;
                //document.getElementById( 'selectedProduct' ).value = searchProductId;
                document.getElementById( 'checked_product' ).value = searchProductId;
        }

        function submitParamSearchForm( formName, inputName, errorMessage )
        {
                var element = document.getElementById( inputName );
                if( ( typeof( element ) == 'object' ) && ( element != null ) )
                {
                        if( element.value != '' ) 
                        {
                                var form = document.getElementById( formName );
                                if( ( typeof( form ) == 'object' ) && ( form != null ) )
                                {
                                        form.submit();
                                        return;
                                }
                        }
                        alert( errorMessage );
                }
        }
        
//------------------------------------------------------------------------------------------------------------

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy w wyszukiwarce dla katalogu 
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function checkCatalogWords( a_txt, a_txt2, a_loc )
        {
                if( ( document.getElementById( "katname" ).checked != true ) && ( document.getElementById( "katdesc" ).checked != true ) && ( document.getElementById( "katcode" ).checked != true ) )
                {
                        alert( a_txt2 );
                }
                else
                {
                        words_container = document.getElementById( "catalog_words2" );
                        send_text = words_container.value;
                        newstr = "";
                        len = send_text.length;
                        i = 0;
                        while( ( send_text.charAt(i) != "" ) && ( i < len ) )
                        {
                                if( send_text.charAt(i) == " " )
                                {
                                        i++;
                                }
                                else
                                {
                                        while( ( send_text.charAt(i) != "" ) && ( send_text.charAt(i) != " " ) && ( i < len ) )
                                        {
                                                newstr = newstr + send_text.charAt(i);
                                                i++;
                                        }
                                        newstr = newstr + " ";
                                        i++;
                                }
                        }
                        len = newstr.length;
                        if( newstr.charAt(len-1) == " " )
                        {
                                newstr = newstr.substr( 0, len-1 );
                        }
                        if( newstr != "" )
                        {
                                document.getElementById( "catalog_words" ).value = newstr;
                                document.forms.catalog_words_search.action = a_loc;
                                document.forms.catalog_words_search.submit();
                        }
                        else
                        {
                                words_container.value = "";
                                document.getElementById( "catalog_words" ).value = "";
                                alert( a_txt );
                        }
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: wysyla zamowienie
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function sendOrder( a_text, a_type )
        {
                if( ( a_type == 1 ) || ( ( document.getElementById( "exname" ).value != "" ) && ( document.getElementById( "exsurname" ).value != "" ) && ( document.getElementById( "exmail" ).value != "" ) && ( document.getElementById( "exphone" ).value != "" ) ) )
                {
                        document.getElementById( "ordzamow" ).value = 1;
                        setOrder( 0, 0 );
                }
                else
                {
                        alert( a_text );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: dodaje produkt do koszyka
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function setOrder( a_id, a_del )
        {
                if( a_del == 1 )
                {
                        todel = a_id;
                }
                else
                {
                        todel = -1;
                }
                num = 0;
                name = "ordcode"+num;
                fullcode = "";
                while( l_code = document.getElementById( name ) )
                {
                        if( num != todel )
                        {
                                ilosc = document.getElementById( "kpr"+num ).value;
                                fullcode += l_code.value+"+"+ilosc+"|";
                        }
                        num++;
                        name = "ordcode"+num;
                }
                document.getElementById( "setfull" ).value = 1;
                document.getElementById( "fullorder" ).value = fullcode;
                document.forms.orderform.submit();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: dodaje produkt do koszyka
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function addToBasket( a_id, a_txt )
        {
                numer = 1;
                chks = "chks" + numer;
                ok = 1;
                oktmp = 0;
                oldname = "";
                while( ( checks = document.getElementById( chks ) ) )
                {
                        name = checks.name;
                        if( oldname != name )
                        {
                                if( ( oktmp == 0 ) && ( oldname != "" ) )
                                {
                                        ok = 0;
                                }
                                oldname = name;
                                oktmp = 0;
                        }
                        if( checks.checked )
                        {
                                oktmp = 1;
                        }
                        numer++;
                        chks = "chks" + numer;
                }
                if( ( oktmp == 0 ) && ( oldname != "" ) )
                {
                        ok = 0;
                }
                if( ok == 1 )
                {
                        l_cena = document.getElementById( "cena" ).value;
                        l_kod = document.getElementById( "kod" ).value;
                        l_zam = a_id+"+"+l_kod+"+"+l_cena+"+1|";
                        document.getElementById( "koszykadd" ).value = l_zam;
                        document.forms.koszykmem.submit();
                }
                else
                {
                        alert( a_txt );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function sendPassword( a_txt, a_adr )
        {
                if( document.getElementById( "exemail" ).value != "" )
                {
                        document.forms.exlogin.action = a_adr;
                        document.forms.exlogin.submit();
                }
                else
                {
                        alert( a_txt );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: przelacza pomiedzy wyborem polskich wojewodztw, a zmiana kraju
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function changeCountry( a_id )
        {
                adiv = document.getElementById( a_id );
                ainp = document.getElementById( "exkraj" );
                asel = document.getElementById( "exprovince" );
                if( document.getElementById( "exinny" ).checked == true )
                {
                        adiv.style.color = "#cccccc";
                        ainp.style.borderColor = "#7c94a5";
                        ainp.disabled = false;
                        asel.disabled = true;
                        asel.value = 0;
                }
                else
                {
                        adiv.style.color = "#666666";
                        ainp.value = "";
                        ainp.style.borderColor = "#cccccc";
                        ainp.disabled = true;
                        asel.disabled = false;
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function checkRegistrationForm( a_text, a_pass_text, a_type, a_adr )
        {
                if( ( document.getElementById( "exname" ).value != "" ) && ( document.getElementById( "exsurname" ).value != "" ) && ( document.getElementById( "exmail" ).value != "" ) && ( document.getElementById( "exstreet" ).value != "" ) && ( document.getElementById( "expostcode" ).value != "" ) && ( document.getElementById( "excity" ).value != "" ) && ( document.getElementById( "exphone" ).value != "" ) && ( ( ( document.getElementById( "expass" ).value != "" ) && ( document.getElementById( "expass2" ).value != "" ) ) || ( a_type == 2 ) ) )
                {
                        if( document.getElementById( "expass" ).value == document.getElementById( "expass2" ).value )
                        {
                                if( a_type == 2 )
                                {
                                        document.forms.exlogin.action = a_adr;
                                }
                                document.forms.exlogin.submit();
                        }
                        else
                        {
                                alert( a_pass_text );
                        }
                }
                else
                {
                        alert( a_text );
                }
        }



        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function checkLogin( a_text )
        {
                if( ( document.getElementById( "exemail" ).value != "" ) && ( document.getElementById( "exhaslo" ).value != "" ) )
                {
                        document.forms.exlogin.submit();
                }
                else
                {
                        alert( a_text );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy zaznaczony jest przynajmniej jeden produkt
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function unCheck( a_id, a_mem_id )
        {
                a_num = "chks"+a_id
                check = document.getElementById( a_num );
                memory = "mem"+a_mem_id;
                chk = document.getElementById( memory );
                if( chk.value == a_id )
                {
                        check.checked = false;
                        chk.value = 0;
                }
                else
                {
                        chk.value = a_id;
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  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;
                vcenaval = cena_float;
                somelen = vcenaval.length;
                dotpos = vcenaval.indexOf( "." ) + 3;
                if( dotpos < somelen )
                {
                        vcenaval = vcenaval.substring( 0, dotpos )
                }
                vcena.value = vcenaval;
                new_vat = parseFloat( vvat.value );
                vcenavatval = vcena.value * new_vat;
                vcenavat.value = vcenavatval;
                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++;
                                        }
                                }
                        }
                        someval = ns1 + "." + ns2 + nv1
                        somelen = someval.length;
                        dotpos = someval.indexOf( "." ) + 3;
                        if( dotpos < somelen )
                        {
                                someval = someval.substring( 0, dotpos )
                        }
                        vcenavat.value = someval;
                }
                else
                {
                        vcenavat.value = new_vcenavat + ".00";
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  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 );
                iname = a_name+"div";
                //if( ( obj.style.fontWeight == 'normal' ) || ( obj.style.fontWeight == '400' ) )
                if( ( obj.style.color == '#ffffff' ) || ( obj.style.color == 'rgb(255, 255, 255)' ) || ( obj.style.color == '#2859a6' ) || ( obj.style.color == 'rgb(40, 89, 166)' ) )
                {
                        if( on == 1 )
                        {
                                obj.style.color = '#ffffff';
                                obj.style.backgroundColor = '#2958a6';
                                idiva = iname+"a";
                                document.getElementById( idiva ).style.display = "none"
                                idivb = iname+"b";
                                document.getElementById( idivb ).style.display = "block"
                        }
                        else
                        {
                                obj.style.color = '#2859a6';
                                obj.style.backgroundColor = '#d5e2eb';
                                idiva = iname+"a";
                                document.getElementById( idiva ).style.display = "block"
                                idivb = iname+"b";
                                document.getElementById( idivb ).style.display = "none"
                        }
                        
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  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.color = '#2859a6';
                                objtop.style.backgroundColor = '#d5e2eb';
                                //objtop.style.fontWeight = 'normal';
                                idiva = l_tabtop+"diva";
                                document.getElementById( idiva ).style.display = "block"
                                idivb = l_tabtop+"divb";
                                document.getElementById( idivb ).style.display = "none"
                        }
                }
                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.color = '#fffffe';
                objtop.style.backgroundColor = '#2958a6';
                //objtop.style.fontWeight = 'bold';
                idiva = l_tabtop+"diva";
                document.getElementById( idiva ).style.display = "none"
                idivb = l_tabtop+"divb";
                document.getElementById( idivb ).style.display = "block"
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  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: sprawdza, czy sa wypelnione wszystkie pola w formularzu aplikacyjnym
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-26 10:57  piotrj     stworzenie
        //
        function checkIsEmpty( a_req, a_vis, a_text )
        {
                nazwypol = Array( "address", "birth", "education", "motivation", "experience", "skills", "info", "cv_file", "letter_file", "wk_refer" );
                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 == "" )
                {
                        l_error = 1;
                }
                if( l_surname.value == "" )
                {
                        l_error = 1;
                }
                if( l_phone.value == "" )
                {
                        l_error = 1;
                }
                if( l_e_mail.value == "" )
                {
                        l_error = 1;
                }
                for( i = 0; i <= 9; i++ )
                {
                        if( ( a_req.charAt(i) == "1" ) && ( a_vis.charAt(i) == "1" ) )
                        {
                                if( ( i != 1 ) && ( i != 0 ) )
                                {
                                        l_pole = document.getElementById( nazwypol[i] );
                                        if( l_pole.value == "" )
                                        {
                                                l_error = 1;
                                        }
                                }
                                else if( i == 0 )
                                {
                                        l_street = document.getElementById( "street" );
                                        l_postcode = document.getElementById( "postcode" );
                                        l_city = document.getElementById( "city" );
                                        if( ( l_street.value == "" ) || (  l_postcode.value == ""  ) || (  l_city.value == ""  ) )
                                        {
                                                l_error = 1;
                                        }
                                }
                        }
                }
                if( l_error == 0 )
                {
                        document.forms.aplication_form.submit();
                }
                else
                {
                        alert( a_text );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja zmienia odpowiednio ilosc dni w kalendarzu ze wzgledu na wybrany rok i miesiac
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function checkCallendar( aday, amonth, ayear )
        {
                var newopt;
                selyear = document.getElementById( "year" );
                year = selyear.value;
                selmonth = document.getElementById( "month" );
                month = selmonth.value;
                selday = document.getElementById( "day" );
                day = selday.value;
                numdays = selday.length;
                if( ( year >= ayear ) && ( month >= amonth ) )
                {
                        month = amonth;
                        selmonth.value = month;
                        if( day >= aday )
                        {
                                day = aday;
                                selday.value = day;
                        }
                }
                if( month == 2 )
                {
                        przestepny = ( year % 4 );
                        if( przestepny == 0 )
                        {
                                maxday = 29;
                        }
                        else
                        {
                                maxday = 28;
                        }
                }
                else
                {
                        if( ( month == 1 ) || ( month == 3 ) || ( month == 5 ) || ( month == 7 ) || ( month == 8 ) || ( month == 10 ) || ( month == 12 ) )
                        {
                                maxday = 31;
                        }
                        else
                        {
                                maxday = 30;
                        }
                }
                if( day > maxday )
                {
                        selday.value = maxday;
                        
                }
                if( maxday <= numdays )
                {
                        num = maxday;
                        for( i = maxday+1; i <= numdays; i++ )
                        {
                                selday.remove( maxday );
                        }
                }
                else
                {
                        for( i = numdays+1; i <= maxday; i++ )
                        {
                                newopt = document.createElement( "option" );
                                newopt.value = i;
                                //to dla IE
                                newopt.innerText = ""+i+"";
                                //to dla mozilli
                                newopt.text = ""+i+"";
                                selday.appendChild( newopt );
                        }
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja otwiera nowe okno z zawartoscia do wydruku
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function checkTourForm( a_text )
        {
                if( ( document.getElementById( "imnaz" ).value != "" ) && ( document.getElementById( "email" ).value != "" ) && ( document.getElementById( "okres" ).value != "" ) && ( document.getElementById( "jezyk" ).value != "" ) && ( document.getElementById( "kraj" ).value != "" ) && ( document.getElementById( "rodzaj" ).value != "" ) && ( document.getElementById( "kwatera" ).value != "" ) )
                {
                        document.forms.tourform.submit();
                }
                else
                {
                        alert( a_text );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja otwiera nowe okno z zawartoscia do wydruku
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function checkContactForm( a_text )
        {
                if( ( document.getElementById( "imnaz" ).value != "" ) && ( document.getElementById( "email" ).value != "" ) )
                {
                        document.forms.kontaktform.submit();
                }
                else
                {
                        alert( a_text );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  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();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja chowa lub pokazuje to co ukryte/odkryte
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function showHideAll( a_name, a_nr, a_ilosc )
        {
                for( i = 0; i < a_ilosc; i++ )
                {
                        if( i != a_nr )
                        {
                                docid = a_name+""+i+"";
                                document.getElementById( docid ).style.display = 'none';
                        }
                }
                docid = a_name+""+a_nr+"";
                obj = document.getElementById( docid );
                if( obj.style.display == 'none' )
                {
                        obj.style.display = 'block';
                }
                else
                {
                        obj.style.display = 'none';
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  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: 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: 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, a_type )
        {
                //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;
                                if( a_type != 0 )
                                {
                                        document.forms.searchmod.action = adres;
                                        document.forms.searchmod.submit();
                                }
                                else
                                {
                                        window.location = adres;
                                }
                        }
                        else
                        {
                                alert( text_to_alert );
                        }
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  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();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: odsyla do wyszukiwania ze stronicowania
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function sendPaging( a_adres )
        {
                document.forms.searchmod.action = a_adres;
                document.forms.searchmod.submit();
        }

//-------------------------------------------------------------------------------
//
//      ponizej kod dla czatu
//
//-------------------------------------------------------------------------------

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja otwiera nowe okno z zawartoscia do wydruku
        //
        //  Historia zmian:
        //  data              Kto        Opis
        //  ---------------------------------------------------------------------
        //  2004-08-20 13:19  piotrj     stworzenie
        //
        function openChat( a_url )
        {
                //a_text = ""+document.getElementById( "pagecontent" ).value+"";
                winObj = window.open( a_url, "_blank", "channelmode=no, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, titlebar=yes, fullscreen=no, width=420, height=423, left=200, top=100" );
                //winObj.document.open();
                //winObj.document.write( a_text );
                //winObj.document.close();
        }

