var RBjs_Cookie = function( owner )
{
    this.owner = owner;
    var me = this;
    
    this.get = function (name)
    {
        var nameEQ = name + '=';
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length; i++)
        {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1,c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return null;        
    }
    
    this.set = function (name, value, second)
    {
        if(second)
        {
            var date = new Date();
            date.setTime(date.getTime() + second*1000); 
            var expires = '; expires=' + date.toGMTString();
        }
        else
        {
            var expires = '';
        }
        document.cookie = name + '=' + value + expires + '; path=/';
    }
    
    this.reset = function (name)
    {
        document.cookie = name + '=; -1; path=/';
    }
    
    this.in_string = function (name, splitter, value)
    {
        var pollCookie = me.get(name);
        if(pollCookie != null)
        {
            var pollsVoted = pollCookie.split(splitter + '');
            var pollsLen = pollsVoted.length;
            
            for (var i = 0; i < pollsLen; i++)
            {
                if (pollsVoted[i] == value)
                {
                    return true;
                }
            }
            return false;        
        }
        else
        {
            return false;
        }        
    }
    
}

RBjs.Cookie = new RBjs_Cookie( RBjs );