function eShadowDialog(name, html, header, iOptions, iOptionsShadowBox)
{
    var that = this;
    var options = {postUrl      : '',
                   startLoading : null,
                   endLoading   : null};
    
    var sended = false;
    
    setup();
    
    this.open = function()
    {
        if (true === sended) {
            eShadowBox.updateCurrentContent(null, html);
        }
        
        eShadowBox.open(name);
    }
    
    this.submitForm = function(form)
    {
        if (typeof(options.startLoading) == 'function') {
            options.startLoading();
        }
        
        var postData = $(form).serializeArray();
        
        $.post(options.postUrl, postData, submitResult, 'json');
    }
    
    function submitResult(data)
    {
        if (typeof(options.endLoading) == 'function') {
            options.endLoading();
        }
        
        if (data.result) {
            sended = true;
            eShadowBox.updateCurrentContent(null, data.html);
        } else {
            eShadowBox.updateCurrentContent(null, data.html);
        }
    }
    
    function setup()
    {
        if (null !== iOptions) {
            options = $.extend(options, iOptions);
        }
        
        var opts = (null !== iOptionsShadowBox) ? iOptionsShadowBox : {};
        
        eShadowBox.setup(name, html, header, opts);
    }        
}