function CookieManager( exp, dom, path ) {
    /* ------------------------------------------------------------ */
    /* Private variables                                            */
    /* ------------------------------------------------------------ */
    var cm_cookies;    //holds ExpandedCookie objects for page's cookies (array)
    var cm_expiration; //holds expiration date for managed cookies (GMT string)
    var cm_domain;     //holds domain information for managed cookies (string)
    var cm_path;       //holds path information for managed cookies (string)

    /* ------------------------------------------------------------ */
    /* Constructor                                                  */
    /* ------------------------------------------------------------ */
    setExpiration( exp );
    setDomain( dom );
    setPath( path );

    refreshCookies();

    /* ------------------------------------------------------------ */
    /* Public Methods                                               */
    /* ------------------------------------------------------------ */
    this.addCookie = addCookie;
    this.removeCookie = removeCookie;
    this.getCookieValue = getCookieValue;
    this.refreshCookies = refreshCookies;

    this.getDomain = getDomain;
    this.getPath = getPath;
    this.getExpiration = getExpiration;

    this.setDomain = setDomain;
    this.setPath = setPath;
    this.setExpiration = setExpiration;
    
    /* ------------------------------------------------------------ */
    /* Private Methods                                              */
    /* ------------------------------------------------------------ */
    function addCookie( name, value ) {
        var temp = new ExpandedCookie( name, value );

        temp.setExpiration( cm_expiration );
        temp.setDomain( cm_domain );
        temp.setPath( cm_path );

        cm_cookies.push( temp );
    }

    function removeCookie( identifier ) { //overload as index:Number or name:String
        if( typeof identifier == "string" ) {
            identifier = getCookieIndex( identifier );
        }

        if( identifier > -1 ) {
            cm_cookies[ identifier ].remove();
        }
    }

    function getCookieValue( identifier ) { //overload as index:Number or name:String
        if( typeof identifier == "string" ) {
            identifier = getCookieIndex( identifier );
        }

        if( identifier > -1 ) {
            return cm_cookies[ identifier ].getValue();
        }
    }

    function refreshCookies() {
        var c = document.cookie;
        var cookies = c.split( "; " );

        //destroy current cookies
        cm_cookies = new Array();

        for( var i in cookies ) {
            var killCookie;
            var today = new Date();

            cookies[ i ] = cookies[ i ].split( "=" );

            killCookie = cookies[ i ][ 0 ] + "=" + cookies[ i ][ 1 ] + "; expires=";
            today.setTime( today.getTime() - ( 24 * 60 * 60 * 1000 ) );
            killCookie += today.toGMTString();
            document.cookie = killCookie;

            addCookie( cookies[ i ][ 0 ], cookies[ i ][ 1 ] );
        }
    }

    function getCookieIndex( name ) {
        var index = -1;
        var i = 0;

        name = name.toUpperCase();

        while( i < cm_cookies.length ) {
            if( cm_cookies[ i ].getName().toUpperCase() == name ) {
                return i;
            }

            i++;
        }

        return -1;
    }

    function getDomain() {
        return cm_domain;
    }

    function getPath() {
        return cm_path;
    }

    function getExpiration() {
        return cm_expiration;
    }

    function setDomain( dom ) {
        cm_domain = dom;
    }

    function setPath( path ) {
        cm_path =  path;
    }

    function setExpiration( exp ) {
        var type = typeof exp;

        switch( type ) {
            case "date":
                cm_expiration = exp.toGMTString();
                break;
            case "int":
            case "float":
                var date = new Date();

                date.setTime( today.getTime() + ( exp * 24 * 60 * 60 * 1000 ) );
                cm_expiration = date.toGMTString();

                break;
            case "string":
                cm_expiration = exp;
                break;
            default:
                break;
        }
    }
}