/*
*       $Header: /repos/cmsdemo/site/page/menu.js,v 1.9 2005/09/27 08:10:21 piotrj Exp $
*/
        /*

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja zalatwia nam obsluge PNG w IE // correctly handle PNG transparency in Win IE 5.5 & 6.
        //
        function correctPNG()
        {
                var arVersion = navigator.appVersion.split( "MSIE" );
                var version = parseFloat( arVersion[1] );
                if( ( version >= 5.5 ) && ( document.body.filters ) ) 
                {
                        for( var i = 0 ; i < document.images.length; i++ )
                        {
                                var img = document.images[i];
                                var imgName = img.src.toUpperCase();
                                if( imgName.substring( imgName.length-3, imgName.length ) == "PNG" )
                                {
                                        var imgID = ( img.id ) ? "id='" + img.id + "' " : ""
                                        var imgClass = ( img.className ) ? "class='" + img.className + "' " : "";
                                        var imgTitle = ( img.title ) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
                                        var imgStyle = "display: inline-block;" + img.style.cssText;
                                        if( img.align == "left" )
                                        {
                                                imgStyle = "float: left;" + imgStyle;
                                        }
                                        if( img.align == "right" )
                                        {
                                                imgStyle = "float: right;" + imgStyle;
                                        }
                                        if( img.parentElement.href )
                                        {
                                                imgStyle = "cursor: hand;" + imgStyle;
                                        }
                                        var strNewHTML = "<span " + imgID + imgClass + imgTitle
                                                + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
                                                + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                                                + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
                                        img.outerHTML = strNewHTML;
                                        i = i-1;
                                }
                        }
                }    
        }
        window.attachEvent( "onload", correctPNG );
        */

        /**
         * SWFObject v1.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
         *
         * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
         * http://www.opensource.org/licenses/mit-license.php
         *
         * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
         *   legal reasons.
         */
        if( typeof deconcept == "undefined" )
        {
                var deconcept = new Object();
        }
        if( typeof deconcept.util == "undefined" )
        {
                deconcept.util = new Object();
        }
        if( typeof deconcept.SWFObjectUtil == "undefined" )
        {
                deconcept.SWFObjectUtil = new Object();
        }
        deconcept.SWFObject = function( _1, id, w, h, _5, c, _7, _8, _9, _a, _b )
        {
                if( !document.createElement || !document.getElementById )
                {
                        return;
                }
                this.DETECT_KEY = _b ? _b : "detectflash";
                this.skipDetect = deconcept.util.getRequestParameter( this.DETECT_KEY );
                this.params = new Object();
                this.variables = new Object();
                this.attributes = new Array();
                if( _1 )
                {
                        this.setAttribute( "swf", _1 );
                }
                if( id )
                {
                        this.setAttribute( "id", id );
                }
                if( w )
                {
                        this.setAttribute( "width", w );
                }
                if( h )
                {
                        this.setAttribute( "height", h);
                }
                if( _5 )
                {
                        this.setAttribute( "version", new deconcept.PlayerVersion( _5.toString().split( "." ) ) );
                }
                this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion( this.getAttribute( "version" ), _7 );
                if( c )
                {
                        this.addParam( "bgcolor", c );
                }
                var q = _8 ? _8 : "high";
                this.addParam( "quality", q );
                this.setAttribute( "useExpressInstall", _7 );
                this.setAttribute( "doExpressInstall", false );
                var _d = ( _9 ) ? _9 : window.location;
                this.setAttribute( "xiRedirectUrl", _d );
                this.setAttribute( "redirectUrl", "" );
                if( _a )
                {
                        this.setAttribute( "redirectUrl", _a );
                }
        };
        deconcept.SWFObject.prototype = { 
                setAttribute:function( _e, _f )
                {
                        this.attributes[_e] = _f;
                }
                , getAttribute:function( _10 )
                {
                        return this.attributes[_10];
                }
                , addParam:function( _11, _12)
                {
                        this.params[_11]=_12;
                }
                , getParams:function()
                {
                        return this.params;
                }
                , addVariable:function( _13, _14 )
                {
                        this.variables[_13] = _14;
                }
                , getVariable:function( _15 )
                {
                        return this.variables[_15];
                }
                , getVariables:function()
                {
                        return this.variables;
                }
                , getVariablePairs:function()
                {
                        var _16 = new Array();
                        var key;
                        var _18 = this.getVariables();
                        for( key in _18 )
                        {
                                _16.push( key + "=" + _18[key] );
                        }
                        return _16;
                }
                , getSWFHTML:function()
                {
                        var _19 = "";
                        if( navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length )
                        {
                                if( this.getAttribute( "doExpressInstall" ) )
                                {
                                        this.addVariable( "MMplayerType", "PlugIn" );
                                }
                                _19 = "<embed type=\"application/x-shockwave-flash\" src=\"" + this.getAttribute( "swf" ) + "\" width=\"" + this.getAttribute( "width" ) + "\" height=\"" + this.getAttribute( "height" ) + "\"";
                                _19 += " id=\"" + this.getAttribute( "id" ) + "\" name=\"" + this.getAttribute( "id" ) + "\" ";
                                var _1a = this.getParams();
                                for( var key in _1a )
                                {
                                        _19 += [key] + "=\"" + _1a[key] + "\" ";
                                }
                                var _1c = this.getVariablePairs().join( "&" );
                                if( _1c.length > 0 )
                                {
                                        _19 += "flashvars=\"" + _1c + "\"";
                                }
                                _19 += "/>";
                        }
                        else
                        {
                                if( this.getAttribute( "doExpressInstall" ) )
                                {
                                        this.addVariable( "MMplayerType", "ActiveX" );
                                }
                                _19 = "<object id=\"" + this.getAttribute( "id" ) + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + this.getAttribute( "width" ) + "\" height=\"" + this.getAttribute( "height" ) + "\">";
                                _19 += "<param name=\"movie\" value=\"" + this.getAttribute( "swf" ) + "\" />";
                                var _1d = this.getParams();
                                for( var key in _1d )
                                {
                                        _19 += "<param name=\"" + key + "\" value=\"" + _1d[key] + "\" />";
                                }
                                var _1f = this.getVariablePairs().join( "&" );
                                if( _1f.length > 0 )
                                {
                                        _19 += "<param name=\"flashvars\" value=\"" + _1f + "\" />";
                                }
                                _19 += "</object>";
                        }
                        return _19;
                }
                , write:function( _20 )
                {
                        if( this.getAttribute( "useExpressInstall" ) )
                        {
                                var _21 = new deconcept.PlayerVersion( [6, 0, 65] );
                                if( this.installedVer.versionIsValid( _21 ) && !this.installedVer.versionIsValid( this.getAttribute( "version" ) ) )
                                {
                                        this.setAttribute( "doExpressInstall", true );
                                        this.addVariable( "MMredirectURL", escape( this.getAttribute( "xiRedirectUrl" ) ) );
                                        document.title = document.title.slice( 0, 47 ) + " - Flash Player Installation";
                                        this.addVariable( "MMdoctitle", document.title );
                                }
                        }
                        if( this.skipDetect || this.getAttribute( "doExpressInstall" ) || this.installedVer.versionIsValid( this.getAttribute( "version" ) ) )
                        {
                                var n = ( typeof _20 == "string" ) ? document.getElementById( _20 ) : _20;
                                n.innerHTML = this.getSWFHTML();
                                return true;
                        }
                        else
                        {
                                if( this.getAttribute( "redirectUrl" ) != "" )
                                {
                                        document.location.replace( this.getAttribute( "redirectUrl" ) );
                                }
                        }
                        return false;
                }
        };
        deconcept.SWFObjectUtil.getPlayerVersion = function( _23, _24 )
        {
                var _25 = new deconcept.PlayerVersion( [0, 0, 0] );
                if( navigator.plugins && navigator.mimeTypes.length )
                {
                        var x = navigator.plugins[ "Shockwave Flash" ];
                        if( x && x.description )
                        {
                                _25 = new deconcept.PlayerVersion( x.description.replace( /([a-z]|[A-Z]|\s)+/, "" ).replace( /(\s+r|\s+b[0-9]+)/, "." ).split( "." ) );
                        }
                }
                else
                {
                        try
                        {
                                var axo = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash" );
                                for( var i = 3; axo != null; i++ )
                                {
                                        axo = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash." + i );
                                        _25 = new deconcept.PlayerVersion( [i, 0, 0] );
                                }
                        }
                        catch( e ){}
                        if( _23 && _25.major > _23.major )
                        {
                                return _25;
                        }
                        if( !_23 || ( ( _23.minor != 0 || _23.rev != 0 ) && _25.major == _23.major ) || _25.major != 6 || _24 )
                        {
                                try
                                {
                                        _25 = new deconcept.PlayerVersion( axo.GetVariable( "$version" ).split( " " )[1].split( "," ) );
                                }
                                catch( e ){}
                        }
                }
                return _25;
        };
        deconcept.PlayerVersion = function( _29 )
        {
                this.major = parseInt( _29[0] ) != null ? parseInt( _29[0] ) : 0;
                this.minor = parseInt( _29[1] ) || 0;
                this.rev = parseInt( _29[2] ) || 0;
        };
        deconcept.PlayerVersion.prototype.versionIsValid = function( fv )
        {
                if( this.major < fv.major )
                {
                        return false;
                }
                if( this.major > fv.major )
                {
                        return true;
                }
                if( this.minor < fv.minor )
                {
                        return false;
                }
                if( this.minor > fv.minor )
                {
                        return true;
                }
                if( this.rev < fv.rev )
                {
                        return false;
                }
                return true;
        };
        deconcept.util = {
                getRequestParameter:function( _2b )
                {
                        var q = document.location.search || document.location.hash;
                        if( q )
                        {
                                var _2d = q.indexOf( _2b + "=" );
                                var _2e = ( q.indexOf( "&", _2d ) >- 1 ) ? q.indexOf( "&", _2d ) : q.length;
                                if( q.length > 1 && _2d >- 1 )
                                {
                                        return q.substring( q.indexOf( "=", _2d ) + 1, _2e );
                                }
                        }
                        return "";
                }
        };
        if( Array.prototype.push == null )
        {
                Array.prototype.push = function( _2f )
                {
                        this[this.length] = _2f;
                        return this.length;
                };
        }
        var getQueryParamValue = deconcept.util.getRequestParameter;
        var FlashObject = deconcept.SWFObject; // for backwards compatibility
        var SWFObject = deconcept.SWFObject;

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja zalatwia problem z wstawianiem flashy do IE
        //
        function drawFlash( path, param, quality, bgcolor, width, height, name, flashDiv )
        {
		var so = new SWFObject( path, name, width, height, "8", bgcolor );
		so.addParam( "quality", quality );
                var par = param.split( "&" );
                for( var i = 0; i < par.length; i++ )
                {
                        var p = par[i].split( "=" );
                        so.addVariable( p[0], p[1] );
                }
                so.addParam( "wmode", "transparent" );
		so.write( flashDiv );
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja zalatwia problem z wstawianiem flashy do IE
        //
        function drawFlashOld( path, param, quality, bgcolor, width, height, name )
        {
                document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="mainElem" align="middle">' );
                document.write( '<param name="allowScriptAccess" value="sameDomain" />' );
                document.write( '<param name="movie" value="'+path+'" />' );
                document.write( '<param name="quality" value="'+quality+'" />' );
                document.write( '<param name="bgcolor" value="'+bgcolor+'" />' );
                document.write( '<param name="wmode" value="transparent" >' );
                document.write( '<param name="FlashVars" value="'+param+'" >' );
                document.write( '<embed src="'+path+'?'+param+'" quality="'+quality+'" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" name="'+name+'" wmode="transparent" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' );
                document.write( '</object>' );
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: resetuje konfiguracje
        //
        function resetConfig()
        {
                document.getElementById( "reset" ).value = "1";
                document.forms.configuratorForm.submit();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: przycina tekst do wskazanej dlugosci
        //
        function configuratorSubmit( paramNumber, txt, type )
        {
                iVal = 0;
                iName = "";
                if( type == 1 )
                {
                        i = 1;
                        id = "value"+i+"";
                        found = 0;
                        while( ( found == 0 ) && ( oObj = document.getElementById( id ) ) )
                        {
                                if( oObj.checked )
                                {
                                        iVal = document.getElementById( "confval"+i+"" ).value;
                                        iName = document.getElementById( "confvalname"+i+"" ).value;
                                        found = 1;
                                }
                                i++;
                                id = "value"+i+"";
                        }
                }
                else
                {
                        found = 1;
                }
                if( found == 1 )
                {
                        document.getElementById( "currentPar" ).value = paramNumber;
                        document.getElementById( "chosenVal" ).value = iVal;
                        document.getElementById( "chosenValName" ).value = iName;
                        document.forms.configuratorForm.submit();
                }
                else
                {
                        alert( txt );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: przycina tekst do wskazanej dlugosci
        //
        function checkNumChars( id, num )
        {
                oTxt = document.getElementById( id );
                vTxt = oTxt.value;
                if( vTxt.length > num )
                {
                        vTxt = vTxt.substr( 0, num );
                        oTxt.value = vTxt;
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: odsyla do wyszukiwania ze stronicowania
        //
        function submitContactForm( a_txt )
        {
                oName = document.getElementById( "name" ).value;
                oSurName = document.getElementById( "surname" ).value;
                oEmail = document.getElementById( "conemail" ).value;
                oSubject = document.getElementById( "subject" ).value;
                getWysiwyg( 0 );
                oContent = document.getElementById( "wText0" ).value;
                if( ( oName != "" ) && ( oSurName != "" ) && ( oEmail != "" ) && ( oSubject != "" ) && ( oContent != "" ) )
                {
                        document.forms.contactForm.submit();
                }
                else
                {
                        alert( a_txt );
                }
        }

        //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' );
                var paramMem = '';
                var parCount = 0;
                var parOrder = new Array();
                for( var i = 0; i < inputs.length; i++ )
                {
                        var paramId = '';
                        var valueId = '';
                        //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_/, '' );
                                        paramId = paramString.replace( /_[0-9]+$/, '' );
                                        valueId = paramString.replace( /^[0-9]+_/, '' );
                                        if( params[paramId] == null )
                                        {
                                                params[paramId] = new ParameterObj( paramId );
                                        }
                                        params[paramId].addValueId( valueId );
                                        //
                                        if( ( parCount == 0 ) || ( ( parCount > 0 ) && ( parOrder[parCount-1] != paramId ) ) )
                                        {
                                                parOrder[parCount] = paramId;
                                                parCount++;
                                        }
                                        //
                                }
                        }
                        
                        //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 was = 0;
                for( i = 0; i < parCount; i++ )
                {
                        if( ( typeof( params[parOrder[i]] ) == 'object' ) && ( params[parOrder[i]] != null ) )
                        {
                                if( was != 0 )
                                {
                                        paramMem += ';';
                                }
                                paramMem += '' + params[parOrder[i]].id + '';
                                for( j = 0; j < params[parOrder[i]].valueCount; j++ )
                                {
                                        paramMem += ',' + params[parOrder[i]].valueId[j] + '';
                                }
                                paramMem += ',' + params[parOrder[i]].useValues + '';
                                was = 1;
                        }
                }
                //paramMem = '' + document.getElementById( "paramSearchGroup" ).value + '.' + paramMem + '';
                document.getElementById( "paramSearchMemory" ).value = paramMem;
                //alert(paramMem);
                
                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 != '' ) && ( element.value != '0' ) )
                        {
                                var form = document.getElementById( formName );
                                if( ( typeof( form ) == 'object' ) && ( form != null ) )
                                {
                                        form.submit();
                                        return;
                                }
                        }
                        alert( errorMessage );
                }
        }
        
//------------------------------------------------------------------------------------------------------------

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy w wyszukiwarce dla katalogu 
        //
        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
        //
        function sendOrder( a_text, a_type, a_text2, a_logged, a_order )
        {
                if( a_logged == 1 )
                {
                        if( document.getElementById( "regulamin" ).checked == true )
                        {
                                ok = 1;
                        }
                        else
                        {
                                ok = 0;
                        }
                }
                else
                {
                        ok = 1;
                }
                if( ok == 1 )
                {
                        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;
                                if( a_order == 1 )
                                {
                                        document.getElementById( "ordertype" ).value = 1;
                                }
                                else
                                {
                                        document.getElementById( "ordertype" ).value = 0;
                                }
                                setOrder( 0, 0 );
                        }
                        else
                        {
                                alert( a_text );
                        }
                }
                else
                {
                        alert( a_text2 );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: dodaje produkt do koszyka
        //
        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
        //
        function addToBasket2( a_id, a_price, a_code )
        {
                l_zam = a_id+"+"+a_code+"+"+a_price+"+1|";
                document.getElementById( "koszykadd" ).value = l_zam;
                document.forms.koszykmem.submit();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: dodaje produkt do koszyka
        //
        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 );
                        showTabbed( "tab", 5, 2 );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
        //
        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
        //
        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
        //
        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
        //
        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
        //
        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
        //
        function isProductChecked( a_tekst, a_type )
        {
                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 ) || ( a_type == 0 ) )
                {
                        document.forms.check_prod.submit();
                }
                else
                {
                        alert( a_tekst );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy zaznaczony jest przynajmniej jeden parametr
        //
        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
        //
        function check_all()
        {
                numer = 0;
                chk = "chk" + numer;
                while( ( check = document.getElementById( chk ) ) )
                {
                        check.checked = true;
                        numer++;
                        chk = "chk" + numer;
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: odznacza wszystkie checkboxy
        //
        function check_none()
        {
                numer = 0;
                chk = "chk" + numer;
                while( ( check = document.getElementById( chk ) ) )
                {
                        check.checked = false;
                        numer++;
                        chk = "chk" + numer;
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: obsluguje kody produktow
        //
        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
        //
        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 == '#e10a16' ) || ( obj.style.color == 'rgb(225, 10, 22)' ) || ( obj.style.color == '#616161' ) || ( obj.style.color == 'rgb(97, 97, 97)' ) )
                {
                        if( on == 1 )
                        {
                                obj.style.color = '#e10a16';
                                /*idiva = iname+"a";
                                document.getElementById( idiva ).style.display = "none"
                                idivb = iname+"b";
                                document.getElementById( idivb ).style.display = "block"*/
                        }
                        else
                        {
                                obj.style.color = '#616161';
                                /*idiva = iname+"a";
                                document.getElementById( idiva ).style.display = "block"
                                idivb = iname+"b";
                                document.getElementById( idivb ).style.display = "none"*/
                        }
                        
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja zarzadza przelaczaniem tabbed panel
        //
        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 = '#616161';
                                objtop.style.background = 'none';
                                //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 = '#e20a16';
                objtop.style.backgroundColor = '#fcfafb';
                //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 
        //
        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
        //
        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
        //
        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
        //
        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
        //
        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
        //
        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 odkrywa jeden element ukrywajac pozostale
        //
        function showChosen( a_name, a_nr )
        {
                docid = a_name+"0";
                i = 0;
                while( oObj = document.getElementById( docid ) )
                {
                        if( i != a_nr )
                        {
                                oObj.style.display = 'none';
                        }
                        i++;
                        docid = a_name+""+i+"";
                }
                docid = a_name+""+a_nr+"";
                oObj = document.getElementById( docid );
                oObj.style.display = 'block';
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja chowa lub pokazuje to co ukryte/odkryte
        //
        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
        //
        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
        //
        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
        //
        function showImage( pathToImage )
        {
                popupImageObj = new Image();
                popupImageObj.src = pathToImage;
                
                showImagePopupWindow( popupImageObj );
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: zmienia lokacje na podany adres
        //
        function go_to_location( a_location )
        {
                window.location = a_location;
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: przypisuje akcje do wykonania i robi submita
        //
        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
                {
                        getWysiwyg( 0 );
                        document.forms.polec_nas.submit();
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: przypisuje akcje do wykonania i robi submita
        //
        function SubscriptAction( a_akcja )
        {
                l_hidden_action = document.getElementById( "akcja" );
                l_hidden_action.value = a_akcja;
                document.forms.subskrypt_form.submit();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja sprawdza, czy grafika jest aktywna, czy nie
        //
        function checkIsOn( a_id )
        {
                oButton = document.getElementById( a_id );
                sSrc = oButton.src;
                iLen = sSrc.length;
                sRoz = sSrc.substr( iLen-6, 2 );
                if( sRoz == "_a" )
                {
                        return 1;
                }
                else
                {
                        return 0;
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja podmienia obrazki bez tekstu przy wywolaniu
        //
        function changeImage2( a_name, on_off ) 
        {
                old_img = document.getElementById( a_name );
                old_src = old_img.src;
                len = old_src.length;
                roz = old_src.substr( len-4, len );
                new_src = old_src;
                if( on_off == 1 )
                {
                        if( checkIsOn( a_name ) == 0 )
                        {
                                new_src = old_src.substr( 0, len-4 ) + "_a" + roz;
                        }
                }
                else
                {
                        if( checkIsOn( a_name ) == 1 )
                        {
                                new_src = old_src.substr( 0, len-6 ) + roz;
                        }
                }
                old_img.src = new_src
        } 

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: zmienia lokacje strony na podany adres
        //
        function LocationFromMenu( adres )
        {
                window.location = adres;
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: usowa nadmiarowe spacje ze stringa
        //
        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
        //
        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
        //
        function SendWords( a_host, a_id, text_to_alert1, text_to_alert2, a_type, a_default )
        {
                //check_forbidden_chars( a_id, text_to_alert );
                word_container = document.getElementById( a_id );
                words = word_container.value;
                if( ( words != "" ) && ( words != a_default ) )
                {
                        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" );
                                adres = a_host + "/wyszukiwanie/slowa/" + words2;
                                if( a_type == 1 )
                                {
                                        document.forms.searchmod.action = adres;
                                        document.forms.searchmod.submit();
                                }
                                else if( a_type == 2 )
                                {
                                        document.forms.searchtop.action = adres;
                                        document.forms.searchtop.submit();
                                }
                                else
                                {
                                        window.location = adres;
                                }
                        }
                        else
                        {
                                alert( text_to_alert1 );
                        }
                }
                else
                {
                        alert( text_to_alert2 );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sprawdza, czy w stringu nie ma zabronionych znakow
        //
        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
        //
        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
        //
        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
        //
        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
        //
        function sendPaging( a_adres )
        {
                document.forms.searchmod.action = a_adres;
                document.forms.searchmod.submit();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: odsyla do wyszukiwania ze stronicowania
        //
        function sendModuleSearch( a_adres )
        {
                document.getElementById( "moduleSearch1" ).value = 0;
                document.forms.searchmod.action = a_adres;
                document.forms.searchmod.submit();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: odsyla do wyszukiwania ze stronicowania
        //
        function dropFilters()
        {
                document.getElementById( "dropFilters" ).value = 1;
                document.forms.paramFilterForm.submit();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: odsyla do wyszukiwania ze stronicowania
        //
        function dropGroupFilters()
        {
                document.getElementById( "dropGroupFilters" ).value = 1;
                document.forms.paramGroupFilterForm.submit();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja otwiera nowe okno z zawartoscia do wydruku
        //
        function openMinimized( a_url )
        {
                winObj = window.open( a_url, "_blank", "channelmode=no, toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=no, resizable=yes, titlebar=yes, fullscreen=no, modal=no" );
                //winObj.moveTo( 0, 0 );
        }

//-------------------------------------------------------------------------------
//
//      ponizej kod dla menu rozwijanego
//
//-------------------------------------------------------------------------------

        var lastMenu = "";
        var lastOff = "";
        var currentMenu = "";
        var timeOutMenu = 0;
        //var menuOn = Array( "", "", "", "", "", "", "", "", "", "", "" );
        //var menuOff = Array( "", "", "", "", "", "", "", "", "", "", "" );
        
        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja pokazuje menu rozwijane
        //
        function showMenu2( a_id, a_zind )
        {
                if( ( a_id == lastMenu ) || ( a_id == currentMenu ) )
                {
                        clearTimeout( timeOutMenu );
                }
                else
                {
                        currentMenu = a_id;
                        hideMenu( lastMenu, 0 );
                }
                /*minLeft = document.getElementById( "dropdowndiv" ).offsetLeft;
                maxLeft = minLeft + 720;
                uA = window.navigator.userAgent;
                if( ( uA.indexOf( "Gecko" ) == -1 ) && ( uA.indexOf( "Opera" ) == -1 ) )
                {
                        agent = 0;
                        minLeft += 15;
                        maxLeft += 15;
                }
                else
                {
                        agent = 1;
                }*/
                minLeft = 0;
                maxLeft = 720;
                sTab = a_id.split( "_" );
                num = sTab.length-1;
                i = 0;
                sId = "" + sTab[i] + "";
                firstMenu = document.getElementById( "" + sTab[0] + "" );
                przesuniecie = firstMenu.offsetLeft;
                if( ( przesuniecie + 292 ) > maxLeft )
                {
                        nextEl = 140;
                }
                else
                {
                        nextEl = 0;
                }
                back = 0;
                while( i <= num )
                {
                        k = 0;
                        subM = "" + sId + "_m" + k + "";
                        while( oMenu = document.getElementById( subM ) )
                        {
                                oMenu.style.display = "block";
                                k++;
                                subM = "" + sId + "_m" + k + "";
                        }
                        mMenu = document.getElementById( "" + sId + "" );
                        posLeft = mMenu.offsetLeft;
                        hMenu = document.getElementById( "" + sId + "h" );
                        hMenu.style.top = "" + ( mMenu.offsetTop + 10 ) + "px";
                        przesun = przesuniecie;
                        if( i == 1 )
                        {
                                nextElem = nextEl;
                        }
                        else
                        {
                                nextElem = 0;
                        }
                        if( ( przesuniecie + nextElem + 152 ) > maxLeft )
                        {
                                if( i == 0 )
                                {
                                        //back = maxLeft - przesuniecie;
                                        back = przesuniecie + 150 - maxLeft;
                                        przesuniecie -= back;
                                }
                                else
                                {
                                        przesuniecie -= 140;
                                }
                        }
                        else// if( i > 0 )
                        {
                                przesuniecie += 140;
                        }
                        if( i > 0 )
                        {
                                if( ( przesun + nextElem + 152 ) > maxLeft )
                                {
                                        hMenu.style.left = "" + ( posLeft - 140 ) + "px";
                                }
                                else
                                {
                                        hMenu.style.left = "" + ( posLeft + 140 ) + "px";
                                }
                        }
                        else
                        {
                                if( ( przesun + 152 ) > maxLeft )
                                {
                                        hMenu.style.left = "" + ( posLeft - back ) + "px";
                                }
                                else
                                {
                                        hMenu.style.left = "" + ( posLeft + 0 ) + "px";
                                }
                        }
                        i++;
                        if( i <= num )
                        {
                                sId += "_" + sTab[i] + "";
                        }
                }
                if( a_id != currentMenu )
                {
                        lastMenu = currentMenu;
                }
                colorMenu( a_id, "#c0d8e9" );
                currentMenu = a_id;
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja ukrywa menu rozwijane
        //
        function setHideMenu( a_id, a_zind )
        {
                if( a_id == currentMenu )
                {
                        clearTimeout( timeOutMenu );
                        timeOutMenu = setTimeout( "hideMenu( '" + a_id + "', 0 )", 300 );
                }
                lastOff = a_id;
                lastMenu = currentMenu;
                colorMenu( a_id, "#ffffff" );
                currentMenu = "";
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja ukrywa menu rozwijane
        //
        function hideMenu( a_id, a_num )
        {
                if( currentMenu == "" )
                {
                        sTabC = a_id.split( "_" );
                        cLength = sTabC.length-1;
                        num = 0;
                        sId = sTabC[num];
                        while( num <= cLength )
                        {
                                hideElements( sId );
                                num++;
                                if( num <= cLength )
                                {
                                        sId += "_" + sTabC[num];
                                }
                        }
                }
                else
                {
                        sTabC = a_id.split( "_" );
                        sTabL = currentMenu.split( "_" );
                        cLength = sTabC.length-1;
                        lLength = sTabL.length-1;
                        sId = "";
                        if( cLength >= lLength )
                        {
                                num = cLength;
                        }
                        else
                        {
                                num = lLength;
                        }
                        for( i = 0; i <= num; i++ )
                        {
                                if( cLength >= lLength )
                                {
                                        if( i == 0 )
                                        {
                                                sId = "" + sTabC[i];
                                        }
                                        else
                                        {
                                                sId += "_" + sTabC[i];
                                        }
                                        if( i <= lLength )
                                        {
                                                if( sTabL[i] != sTabC[i] )
                                                {
                                                        hideElements( sId );
                                                }
                                        }
                                        else
                                        {
                                                hideElements( sId );
                                        }
                                }
                                else
                                {
                                        if( i <= cLength )
                                        {
                                                if( i == 0 )
                                                {
                                                        sId = "" + sTabC[i];
                                                }
                                                else
                                                {
                                                        sId += "_" + sTabC[i];
                                                }
                                                if( sTabL[i] != sTabC[i] )
                                                {
                                                        hideElements( sId );
                                                }
                                        }
                                        else
                                        {
                                                i = num + 1;
                                        }
                                }
                        }
                }
                lastMenu = "";
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja ukrywa menu rozwijane
        //
        function hideElements( a_id )
        {
                k = 0;
                subM = "" + a_id + "_m" + k + "";
                while( oMenu = document.getElementById( subM ) )
                {
                        oMenu.style.display = "none";
                        k++;
                        subM = "" + a_id + "_m" + k + "";
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja ukrywa menu rozwijane
        //
        function colorMenu( a_id, a_color )
        {
                sTab = a_id.split( "_" );
                num = sTab.length-1;
                i = 0;
                sId = "" + sTab[i] + "";
                while( i <= num )
                {
                        mMenu = document.getElementById( "" + sId + "" );
                        if( i > 0 )
                        {
                                mMenu.style.backgroundColor = a_color;
                        }
                        i++;
                        if( i <= num )
                        {
                                sId += "_" + sTab[i] + "";
                        }
                }
        }


//-------------------------------------------------------------------------------


        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja wysyla zamowienie z materialow drukowanych
        //
        function checkOrderForm( txt, txt2 )
        {
                if( ( document.getElementById( "pmimie" ).value != "" ) && ( document.getElementById( "pmnazwisko" ).value != "" ) && ( document.getElementById( "pmfirma" ).value != "" ) && ( document.getElementById( "pmulica" ).value != "" ) && ( document.getElementById( "pmcode" ).value != "" ) && ( document.getElementById( "pmmiasto" ).value != "" ) && ( document.getElementById( "pmphone" ).value != "" ) && ( document.getElementById( "pmemail" ).value != "" ) )
                {
                        i = 0;
                        ord = "";
                        ordid = "";
                        while( inp = document.getElementById( "pm" + i + "" ) )
                        {
                                if( inp.checked )
                                {
                                        ord += document.getElementById( "pmv" + i + "" ).value + ";";
                                        ordid += document.getElementById( "pmid" + i + "" ).value + ";";
                                }
                                i++;
                        }
                        if( ord != "" )
                        {
                                document.getElementById( "pmorder" ).value = ord;
                                document.getElementById( "pmorderid" ).value = ordid;
                                document.forms.printedForm.submit();
                        }
                        else
                        {
                                alert( txt2 );
                        }
                }
                else
                {
                        alert( txt );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja chowa lub pokazuje to co ukryte/odkryte
        //
        function clearOrderForm()
        {
                document.forms.printedForm.reset();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: sbmituje zmiane w ofercie aukcyjnej
        //
        function auctionFormSubmit( a_txt, a_txt2 )
        {
                formatPrice( "acprice" );
                formatNumber( "acpayment" );
                formatNumber( "acdelivery" );
                acprice = document.getElementById( "acprice" ).value;
                acpayment = document.getElementById( "acpayment" ).value;
                acdelivery = document.getElementById( "acdelivery" ).value;
                if( ( acprice != "0.00" ) && ( acpayment != "0" ) && ( acdelivery != "0" ) )
                {
                        if( confirm( a_txt2 ) )
                        {
                                document.getElementById( "accheck" ).value = "1";
                                document.forms.auctionForm.submit();
                        }
                }
                else
                {
                        alert( a_txt );
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: odsyla do wyszukiwania ze stronicowania
        //
        function formatPrice( id )
        {
                oPrice = document.getElementById( id );
                price = oPrice.value;
                pos = price.indexOf( "," )
                if( pos >= 0 )
                {
                        val = price.split( "," );
                        price = val[0] + "." + val[1];
                }
                pF = parseFloat( price );
                price = "" + pF + "";
                if( isNaN( pF ) || ( pF < 0 ) )
                {
                        oPrice.value = "0.00";
                }
                else
                {
                        if( price.indexOf( "." ) >= 0 )
                        {
                                val = price.split( "." );
                                begin = val[0];
                                end = val[1];
                                if( end.length > 0 )
                                {
                                        pI = parseInt( end );
                                        if( isNaN( pI ) )
                                        {
                                                price = begin + ".00";
                                        }
                                        else
                                        {
                                                if( end.length > 2 )
                                                {
                                                        end = end.substr( 0, 2 );
                                                }
                                                else if( end.length < 2 )
                                                {
                                                        end += "0";
                                                }
                                        }
                                        price = begin + "." + end;
                                }
                                else
                                {
                                        price = begin + ".00";
                                }
                        }
                        else
                        {
                                price += ".00"
                        }
                        if( parseFloat( price ) > 999999999999.99 )
                        {
                                price = "999999999999.99";
                        }
                        oPrice.value = price;
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: odsyla do wyszukiwania ze stronicowania
        //
        function formatNumber( id )
        {
                oNum = document.getElementById( id );
                num = oNum.value;
                pI = parseInt( num );
                if( isNaN( pI ) || ( pI < 0 ) )
                {
                        oNum.value = "0";
                }
                else if( pI > 9999 )
                {
                        oNum.value = "9999";
                }
        }

//-------------------------------------------------------------------------------
//
//      tu mini wysiwyg
//
//-------------------------------------------------------------------------------

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: inicjuje wysiwyg
        //
        function initWysiwyg()
        {
                oTArea = document.getElementsByName( "wysiwyg" );
                for( i = 0; i < oTArea.length; i++ )
                {
                        content = getContent( oTArea[i] );
                        if( content != null )
                        {
                                content.designMode = "on";
                        }
                        else
                        {
                                alert( "ERROR: Cannot enable wysiwyg" );
                        }
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: zarzadza tekstowym panelem wysiwyg
        //
        function setTextStyle( nr, style, param )
        {
                obj = document.getElementById( "wysiwyg"+nr+"" );
                content = getContent( obj );
                if( content != null )
                {
                        content.execCommand( style, null, param );
                }
                else
                {
                        alert( "ERROR: Wysiwyg not enabled" );
                }
                
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: pobiera content dla obiektu
        //
        function getContent( obj )
        {
                if( content = obj.contentWindow.document )
                {
                        return content;
                }
                else if( content = obj.document )
                {
                        return content;
                }
                else
                {
                        return null;
                }
                
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: pobiera dane z wysiwyg i wstawia je w ukryte pole tekstowe
        //
        function getWysiwyg( nr )
        {
                frameObj = document.getElementById( "wysiwyg"+nr+"" );
                frame = getContent( frameObj );
                if( frame != null )
                {
                        input = document.getElementById( "wText"+nr+"" );
                        input.value = frame.body.innerHTML;
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: ustawia dane w wysiwyg na dane z pola tekstowego
        //
        function setWysiwyg( nr )
        {
                frameObj = document.getElementById( "wysiwyg"+nr+"" );
                frame = getContent( frameObj );
                if( frame != null )
                {
                        sVal = document.getElementById( "wText"+nr+"" ).value;
                        frame.body.contentEditable = true;
                        frame.body.innerHTML = sVal;
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: ustawia dane w wysiwyg na dane z pola tekstowego
        //
        function emptyWysiwyg( nr )
        {
                frameObj = document.getElementById( "wysiwyg"+nr+"" );
                frame = getContent( frameObj );
                if( frame != null )
                {
                        frame.body.innerHTML = '';
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja wysyla e-kartke
        //
        function sendECard( txt, t1, t2 )
        {
                getWysiwyg( 0 )
                sAdr = document.getElementById( "adresat" ).value;
                sNad = document.getElementById( "nadawca" ).value;
                if( ( sAdr != "" ) && ( sAdr != t1 ) && ( sNad != "" ) && ( sNad != t2 ) )
                {
                        document.forms.eCardForm.submit();
                }
                else
                {
                        alert( txt );
                }
        }

        var currentStamp = 2;

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja przelacza znaczki w e-kartkach
        //
        function changeStamp( direction, number )
        {
                oLeft = document.getElementById( "cardPrevDiv" );
                oStamp = document.getElementById( "stamp" + currentStamp + "" );
                oRight = document.getElementById( "cardNextDiv" );
                if( direction == "prev" )
                {
                        if( currentStamp > 2 )
                        {
                                currentStamp--;
                        }
                }
                else
                {
                        if( currentStamp < number )
                        {
                                currentStamp++;
                        }
                }
                oStamp.style.display = "none";
                oStamp2 = document.getElementById( "stamp" + currentStamp + "" );
                oStamp2.style.display = "block";
                document.getElementById( "znaczek" ).value = "" + currentStamp + "";
                if( currentStamp > 2 )
                {
                        oLeft.style.display = 'block';
                }
                else
                {
                        oLeft.style.display = 'none';
                }
                if( currentStamp < number )
                {
                        oRight.style.display = 'block';
                }
                else
                {
                        oRight.style.display = 'none';
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja zarzadza menu w rittalu
        //
        function showMenu( a_nr, a_count )
        {
                l_num = 0;
                while( l_num < a_count )
                {
                        document.getElementById( "menuDivTop"+l_num+"" ).style.display = "none";
                        document.getElementById( "visTd"+l_num+"" ).style.borderBottomColor = "#eeeeee";
                        l_num++;
                }
                document.getElementById( "menuDivTop"+a_nr+"" ).style.display = "block";
                document.getElementById( "visTd"+a_nr+"" ).style.borderBottomColor = "#e10a16";
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: funkcja zarzadza menu w rittalu
        //
        function alignMenu()
        {
                a_nr = 0;
                while( oVisible = document.getElementById( "visTab"+a_nr+"" ) )
                {
                        if( oVisible.offsetLeft > 250 )
                        {
                                padLeft = 250;
                        }
                        else
                        {
                                padLeft = oVisible.offsetLeft + 5;
                        }
                        width = 550 - padLeft;
                        if( oHidden = document.getElementById( "menuDivTop"+a_nr+"" ) )
                        {
                                oHidden.style.paddingLeft = padLeft+"px";
                                if( oTab = document.getElementById( "hidTab"+a_nr+"" ) )
                                {
                                        oTab.style.width = width + "px";
                                }
                        }
                        a_nr++;
                }
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: dodaje produkt do koszyka
        //
        function alterComparison( value, type )
        {
                if( type == 0 )
                {
                        document.getElementById( "dropProduct" ).value = value;
                }
                else
                {
                        document.getElementById( "dropParam" ).value = value;
                        document.getElementById( "reloadCheck" ).value = "yes";
                }
                document.forms.dropForm.submit();
        }

        /////////////////////////////////////////////////////////////////////////
        //
        //  Opis: dodaje produkt do koszyka
        //
        function setSort( sortBy, sortType )
        {
                document.getElementById( "catalogSortBy" ).value = sortBy;
                document.getElementById( "catalogSortType" ).value = sortType;
                document.forms.catalogsortform.submit();
        }

