function Cookie(){
        var name, value, expires, path="/", domain, secure=false;
        this.setName = function(sName){ name=sName; }
        this.getName = function(){ return name; }
        this.getValue = function(){
            return unescape(
                (value instanceof Array)?
                    value.join("&"):
                    value
            );
        }

        this.setValue = function(sValue){ value=escape(sValue); }
        this.add = function(key, val){
            if(!(value instanceof Array)){
                var temp = value;
                value = [];
                if(temp){
                    value[value.length] = temp;
                }
            }
            value[value.length] = key+"="+val;
        }
        this.setExpires = function(date){ expires=date; }
        this.getExpires = function(){ return expires; }
        this.setDomain = function(sD){ domain=sD; }
        this.getDomain = function(){ return domain; }
        this.setSecure = function(scr){ secure = !!scr; }
        this.getSecure = function(){ return secure; }
        this.save = function(){
            if(name  && value){
                if(value instanceof Array){
                    // if the value is as array, we join the array
                    value=value.join("&");
                }
                document.cookie = name+'='+ value +
                    ( ( expires ) ? ';expires='+expires.toGMTString() : '' ) + //expires.toGMTString()
                    ( ( path ) ? ';path=' + path : '' ) +
                    ( ( domain ) ? ';domain=' + domain : '' ) +
                    ( ( secure ) ? ';secure' : '' );
            }
        }
        this.remove = function(){
            // The cookie removed if the expires date is before today
            expires = new Date(new Date().getTime()-1000*60*60*24);
            this.save();
        }
    };

    Cookie.get = function(name){
        /*
            the document.cookie return a string contains all the cookies available in the browser for the specific domain in format of: Name=Value;Name=Value;Name=Value
            this function take only the cookie with the requested name and return a Cookie object with it's value.
            if there isn't a cookie with the requested name, the function returns an empty cookie object with the requested name
        */
        var start = document.cookie.indexOf( name + "=" );
        var len = start + name.length + 1;
        var cookie = new Cookie();
        if ( !((( !start ) && ( name != document.cookie.substring( 0, name.length ) )) || (start==-1) ) ) {
            var end = document.cookie.indexOf( ';', len );
            if ( end == -1 ) end = document.cookie.length;
            cookie.setValue(unescape( document.cookie.substring( len, end ) ));
        }

        cookie.setName(name);
        return cookie;
    }