var divModal = {

    init: function() {
        this._mainDiv = document.getElementById("modalDiv");
        this._contentDiv = this._mainDiv.getElementsByTagName("div")[0];
        this.reset();
    },

    reset: function() {
        this._dargs = new Array();
    },

    args: function( args ) {
        if (typeof(args) != "undefined") {
            this._dargs = args;
        }
        return this._dargs;
    },

    arg: function( name, val ) {
        this._dargs[name] = val;
    },

    show: function() {
        if ( this._mainDiv.style.visibility != "visible" ) {
            this._mainDiv.style.visibility = "visible";
        }
    },

    hide: function() {
        if ( this._mainDiv.style.visibility != "hidden" ) {
            this._mainDiv.style.visibility = "hidden";
        }
    },

    close: function() {
        if ( divModal._callback ) {
            try {
                eval( divModal._callback + "( divModal )" );
            }
            catch( e ) {
                alert( e );
            }
        }
        divModal.hide();
    },

    contentElem: function() {
        return this._contentDiv;
    },

    content: function( html ) {
        if (typeof(html) != 'undefined') {
            this._contentDiv.innerHTML = html;
        }
        return this._contentDiv.innerHTML;
    },

    callback: function( cb ) {
        if (typeof(cb) != "undefined") {
            this._callback = cb;
        }
        return this._callback;
    },

    width: function( w ) {
        if (typeof(w) != "undefined") {
            this._mainDiv.style.width = w;
        }
        return this._mainDiv.style.width;
    },

    height: function( h ) {
        if (typeof(h) != "undefined") {
            this._mainDiv.style.height = h;
        }
        return this._mainDiv.style.height;
    },

    zorder: function( z ) {
        if (typeof(z) != "undefined") {
            this._mainDiv.style.zIndex = z;
        }
        return this._mainDiv.style.zIndex;
    },

    centerOnScreen: function(oElem, oWin) {
        if (typeof(oElem) == 'undefined') { oElem = this._mainDiv; }
        if (typeof(oWin) == "undefined") { oWin = window; }
        var w = oElem.offsetWidth;
        var h = oElem.offsetHeight;
        var ww = this.getViewportWidth(oWin);
        var wh = this.getViewportHeight(oWin);
        oElem.style.top = ((wh - h) / 2) + "px";
        oElem.style.left = ((ww - w) / 2) + "px";
    },

    getViewportHeight: function(oWin) {
        if (typeof(oWin) == "undefined") { oWin = window; }
        if (oWin.innerHeight!=oWin.undefined) return oWin.innerHeight;
        if (oWin.document.compatMode=='CSS1Compat') return oWin.document.documentElement.clientHeight;
        if (oWin.document.body) return oWin.document.body.clientHeight;
        return oWin.undefined;
    },

    getViewportWidth: function(oWin) {
        if (typeof(oWin) == "undefined") { oWin = window; }
        if (oWin.innerWidth!=oWin.undefined) return oWin.innerWidth;
        if (oWin.document.compatMode=='CSS1Compat') return oWin.document.documentElement.clientWidth;
        if (oWin.document.body) return oWin.document.body.clientWidth;
        return oWin.undefined;
    }
}

