function ContextPanels(handlerApply, handlerCancel){
    this.panel_context = 0;
    this.handlerApply = handlerApply;
    this.handlerCancel = handlerCancel;
    
    $('#mask').bind('click', {eto : this}, function(eventObj){
        if(eventObj.data.eto.panel_context == 1)
            return;
        $('#popuprel').stop().fadeOut(500);
        $('#mask').stop().fadeOut(500);
    });
    
    $('#popuprel2').find('#accept_distrib').bind('click', {eto : this}, function(eventObj){  
        if(eventObj.data.eto.panel_context != 1)
            return;
        $('#mask').stop().fadeOut(500);
        $('#popuprel2').stop().fadeOut(500);
        eventObj.data.eto.panel_context = 0;
        eventObj.data.eto.handlerApply();
    });
                
    $('#popuprel2').find('#cancel_distrib').bind('click', {eto : this}, function(eventObj){
        if(eventObj.data.eto.panel_context != 1)
            return;
        $('#mask').stop().fadeOut(500);
        $('#popuprel2').stop().fadeOut(500);
        eventObj.data.eto.panel_context = 0;
        eventObj.data.eto.handlerCancel();
    });
}

ContextPanels.prototype = {
    showMessage : function(title, text){
        $('#popuprel').find('.window_title h1').html(title);
        $('#popuprel').find('.window_text').html(text);
        $('#mask').stop().fadeTo(500, 0.7);
        $('#popuprel').stop().fadeIn(500, function(){
            $('#mask').stop().delay(3000).fadeOut(500, function(){
                $('#popuprel').fadeOut(1000);
            });                        
        });
    },
                
    showQuestionPanel : function(title, text){
        $('#popuprel2').find('.window_title h1').html(title);
        $('#popuprel2').find('.window_text').html(text);
        $('#mask').stop().fadeTo(500, 0.7, function(){
            $('#popuprel2').stop().fadeIn(500);
        });
        this.panel_context = 1;
    }
}
