/**
 * @author gerardo.lopez
 */
Ext.ns('Ext.ux.clv2');

Ext.ux.clv2.windowMessageError = function(config){
    // call parent constructor
    Ext.ux.clv2.windowMessageError.superclass.constructor.call(this, config);
    this.on('beforeclose', this.hideSpotlight, this);
    this.on('beforehide', this.hideSpotlight, this);
    this.on('beforeshow', this.showSpotlight, this);
	this.on('collapse', this.showSpotlight, this);
    this.on('move', this.showSpotlight, this);
    this.on('resize', this.showSpotlight, this);
}; 
Ext.extend(Ext.ux.clv2.windowMessageError, Ext.Window, {
    width: 326,
    buttonAlign: 'center',
    closable: false,
    resizable: false,
    hideSpotlight: hideSpotlight,
    showSpotlight: showSpotlight
});

Ext.ux.clv2.panelMessageError = function(config){
    // call parent constructor
    Ext.ux.clv2.panelMessageError.superclass.constructor.call(this, config);
    this.on('beforeclose', this.hideSpotlight, this);
    this.on('beforehide', this.hideSpotlight, this);
    this.on('beforeshow', this.showSpotlight, this);
}; 
Ext.extend(Ext.ux.clv2.panelMessageError, Ext.Panel, {});

var showErrorMessage = function(typeError){
    var fatalError;
    var titleError;
    var heightWindow;
    //var error=				
    switch (typeError) {
        case 'system':
            fatalError = '<div class="x-content-mt">We\'re sorry; the system has encountered and error and cannot proceed</div><div class="x-content-mt">Please try again by returning to the home page, logging<br> out of the application, and the loggin back in.</div><div class="x-content-mt">This error has been logged and our technical team<br>notified.</div>';
            titleError = 'System Error';
            heightWindow = 200;
            break;
        case 'connection':
            fatalError = '<div class="x-content-mt">We\'re sorry; a connection problem is preventing the<br>application from responding</div><div class="x-content-mt">Check your Internet connection, restart your web<br>browser, and try again<br>';
            titleError = 'Connection Error';
            heightWindow = 165;
            break;
    }    		
    var panelError = new Ext.ux.clv2.panelMessageError({
        html: fatalError
    });
    
    
    var btnReturn = new Ext.Toolbar.Button({
        // text: 'Send',
        ctCls: 'cancel-btn',
        handler: function(){
            this.window.close();
        }
    });
    
    var windowError = new Ext.ux.clv2.windowMessageError({
        items: panelError,
        iconCls: 'errorIcon',
        cls: 'clv2-window-error clv2-btns',
        title: titleError,
        height: heightWindow,
        buttons: [btnReturn]
    });
    Ext.apply(btnReturn, {
        'window': windowError
    });
    windowError.show();
}
