
    // Simple JavaScript hashtable.
    // by Roger Pence.
    if( typeof( rp ) == "undefined" ) rp = {};

    rp.clientState = new function()
    {
        this.items = new Object();
        this.length = 0;
        
        this.set = function( key, value )
        {
            if ( ! this.keyExists( key ) )
            {
                this.length++;
            }
            this.items[ key ] = value;    
        }

        this.get = function( key )
        {
            if ( this.keyExists( key ) )
            {
                return this.items[ key ];
            } 
        }
        
        this.keyExists = function( key )
        {
            return typeof( this.items[ key ] ) != "undefined"; 
        }
        
        this.remove = function( key )
        {
            if ( this.keyExists( key ) )
            {
                delete this.items[ key ];
                this.length--;   
                return true;
            }
            return false;
        }

        this.removeAll = function()
        {
            this.items = null;
            this.items = new Object();
            this.length = 0;
        }
    }

    this.serialize = function()
    {
        var result = "";
        for ( var key in this.items ) 
        {  
            result += key + ";" + encode64( this.items[ key ] ) + "|";
        }
        return encode64( result );
    }

    this.deserialize = function( value )
    {
        if ( value.length == 0 ) return;
        
        this.removeAll();
        var buffer = decode64( value );

        var valuePairs = buffer.split( "|" );
        for ( var i in valuePairs )
        {
            if ( valuePairs[ i ].length > 0 ) 
            {
                var keyValue = valuePairs[ i ].split( ";" );
                if ( keyValue.length = 2 ) 
                {
                    this.set( keyValue[ 0 ], decode64( keyValue[ 1 ] ) );
                }
            }
        }
    }    