/**
 * @namespace
 * @author Administrator
 */

if ("undefined" === typeof button) {
	button = {}	
}

Ext.namespace("brodos.button");

/**
 * Button classes
 * 
 * @author Markus Sommersacher
 * @Version all Images ara available as *.PNG
 */

/**
 * @scope brodos.button.Setting.configuration
 * @info  Static brodos button configuration data store
 */
var configuration = { 
                        data: new Array ()
                    };

/**
 * @scope brodos.button.Setting
 * @info  Static brodos button configuration setter
 */
brodos.button.Setting = function (Configuration)
						{
                            for (var Key in Configuration)
                            {
                                if (typeof Configuration[Key] != 'function')
                                {
                                    configuration.data[Key] = Configuration[Key];
                                }
                            }
						}
                        
/**
 * @scope brodos.button.Setting.getConfiguration
 * @info  Static brodos button configuration getter
 */					
brodos.button.Setting.getConfiguration = function (key)
                                         {
                                            if (configuration.data[key]!= undefined)
                                            {
                                                return configuration.data[key];
                                            }
                                            
                                            return key;
                                         }
 
brodos.button.Text =  function (key)
{
	if (brodos.button.Setting.getConfiguration('localization')[key] != null && brodos.button.Setting.getConfiguration('localization')[key] != undefined)
	{
		return brodos.button.Setting.getConfiguration('localization')[key];
	} 
	else 
	{
		return key;
	}
}
		 
brodos.button.Button = function (config) {

	this.showTooltip = false;
	
	this.cls = 'x-btn-text-icon';
	
	this.text = '';
	
	this.tooltip = '';
	
	this.minWidth = 50;
	
	brodos.button.Button.superclass.constructor.call(this, config);
}	
Ext.extend( brodos.button.Button, Ext.Button, {

	/**
	 * @scope brodos.button.Button#
	 * @type Abstract 
	 * 
	 * @info This is the Superclass. All Buttons inherit the Configparams from this class
	 */

	initComponent : function(){
        brodos.button.Button.superclass.initComponent.call(this);
        this.icon = brodos.button.Setting.getConfiguration('resources')+this.icon;
	},
	
	applyText: function (key)
	{
		this.setText(brodos.button.Text(key));
	},
	
	applyDefaultText: function (key)
	{
		if (this.text == undefined || this.text.length < 1)
		{
			this.applyText(key);
		}
	},
	
	applyDefaultTooltip: function (key)
	{
		if(this.showTooltip){
			if (this.tooltip == undefined || this.tooltip.length < 1)
			{
				this.tooltip = brodos.button.Text(key);
			}
		}
	}
});

brodos.button.Search = function (config){

	this.icon = 'Search.gif';
	
	brodos.button.Search.superclass.constructor.call(this, config);
}
Ext.extend( brodos.button.Search, brodos.button.Button, {

	/**
	 * @scope brodos.button.Search
	 */

	initComponent : function(){
        brodos.button.Search.superclass.initComponent.call(this);
		this.applyDefaultText('ESB_SEARCH');
		this.applyDefaultTooltip('ESB_SEARCHTT');
	}
});


brodos.button.FullSearch = function(config){
	this.icon = 'Search.gif';
	
	brodos.button.FullSearch.superclass.constructor.call(this, config);
}
Ext.extend(brodos.button.FullSearch, brodos.button.Button, {

	/**
	 * @scope brodos.button.FullSearch
	 */
	
	initComponent : function(){
        brodos.button.FullSearch.superclass.initComponent.call(this);
		this.applyDefaultText('ESB_FULLSEARCH');
		this.applyDefaultTooltip('ESB_FULLSEARCHTT');
	}
});

brodos.button.AdvancedSearch = function(config){
	this.icon = 'Search.gif';
	
	brodos.button.AdvancedSearch.superclass.constructor.call(this, config);
}
Ext.extend( brodos.button.AdvancedSearch, brodos.button.Button, {

	/**
	 * @scope brodos.button.AdvancedSearch
	 */
	
	initComponent : function(){
        brodos.button.AdvancedSearch.superclass.initComponent.call(this);
		this.applyDefaultText('ESB_ADVANCEDSEARCH');
		this.applyDefaultTooltip('ESB_ADVANCEDSEARCHTT');
	}
});

brodos.button.Cancel = function (config){
	this.icon = 'Cancel.gif';
	
	brodos.button.Cancel.superclass.constructor.call(this,config);
}
Ext.extend( brodos.button.Cancel, brodos.button.Button, {

	/**
	 * @scope brodos.button.Cancel
	 */
	
	initComponent : function(){
        brodos.button.Cancel.superclass.initComponent.call(this);
		this.applyDefaultText('ESB_CANCEL');
		this.applyDefaultTooltip('ESB_CANCELTT');
	}
});

brodos.button.Save = function (config) {
	this.icon = 'Save.gif';
	
	brodos.button.Save.superclass.constructor.call(this,config);
}
Ext.extend(brodos.button.Save, brodos.button.Button, {

	/**
	 * @scope brodos.button.Save
	 */
	
	initComponent : function(){
        brodos.button.Save.superclass.initComponent.call(this);
		this.applyDefaultText('ESB_SAVE');
		this.applyDefaultTooltip('ESB_SAVETT');
	}
});

brodos.button.Next = function(config){
	this.icon = 'Next.gif';
	
	brodos.button.Next.superclass.constructor.call(this, config);
}
Ext.extend(brodos.button.Next, brodos.button.Button, {

	/**
	 * @scope brodos.button.Next
	 */
	
	initComponent : function(){
        brodos.button.Next.superclass.initComponent.call(this);
		this.applyDefaultText('ESB_NEXT');
		this.applyDefaultTooltip('ESB_NEXTTT');
	}
});

brodos.button.Back = function(config){
	this.icon = 'Back.gif';
	
	brodos.button.Back.superclass.constructor.call(this,config);
}
Ext.extend( brodos.button.Back, brodos.button.Button, {

	/**
	 * @scope brodos.button.Back
	 */
	
	initComponent : function(){
        brodos.button.Back.superclass.initComponent.call(this);
		this.applyDefaultText('ESB_BACK');
		this.applyDefaultTooltip('ESB_BACKTT');
	}
});

brodos.button.Show = function (config){
	this.icon = 'Show.gif';
	
	brodos.button.Show.superclass.constructor.call(this, config);
}
Ext.extend(brodos.button.Show, brodos.button.Button, {

	/**
	 * @scope brodos.button.Show
	 */
	
	initComponent : function(){
        brodos.button.Show.superclass.initComponent.call(this);
		this.applyDefaultText('ESB_SHOW');
		this.applyDefaultTooltip('ESB_SHOWTT');
	}
});

brodos.button.Print = function(config){
	this.icon = 'Print.gif';
	
	brodos.button.Print.superclass.constructor.call(this, config);
} 
Ext.extend( brodos.button.Print, brodos.button.Button, {

	/**
	 * @scope brodos.button.Print
	 */
	
	initComponent : function(){
        brodos.button.Print.superclass.initComponent.call(this);
		this.applyDefaultText('ESB_PRINT');
		this.applyDefaultTooltip('ESB_PRINTTT');
	}
});

brodos.button.Login = function (config){
	this.icon = 'Login.gif';
	
	brodos.button.Login.superclass.constructor.call(this, config);
}
Ext.extend( brodos.button.Login, brodos.button.Button, {

	/**
	 * @scope brodos.button.Login 
	 */
	
	initComponent : function(){
        brodos.button.Login .superclass.initComponent.call(this);
		this.applyDefaultText('ESB_LOGIN');
		this.applyDefaultTooltip('ESB_LOGINTT');
	}
});

brodos.button.Send = function(config){
	this.icon = 'Send.gif';
	
	brodos.button.Send.superclass.constructor.call(this, config);
}
Ext.extend( brodos.button.Send, brodos.button.Button, {

	/**
	 * @scope brodos.button.Send 
	 */
	
	initComponent : function(){
        brodos.button.Send .superclass.initComponent.call(this);
		this.applyDefaultText('ESB_SEND');
		this.applyDefaultTooltip('ESB_SENDTT');
	}
});

brodos.button.AddCart = function (config){
	this.icon = 'AddCart.gif';
	
	brodos.button.AddCart.superclass.constructor.call(this, config);
}
Ext.extend(brodos.button.AddCart, brodos.button.Button, {

	/**
	 * @scope brodos.button.AddCart 
	 */
	
	initComponent : function(){
        brodos.button.AddCart .superclass.initComponent.call(this);
		this.applyDefaultText('ESB_ADDCART');
		this.applyDefaultTooltip('ESB_ADDCARTTT');
	}
});

brodos.button.OwnArticle = function(config){
	this.icon = 'OwnArticle.gif';
	
	brodos.button.OwnArticle.superclass.constructor.call(this, config);
}
Ext.extend(brodos.button.OwnArticle, brodos.button.Button, {

	/**
	 * @scope brodos.button.OwnArticle 
	 */
	
	initComponent : function(){
        brodos.button.OwnArticle .superclass.initComponent.call(this);
		this.applyDefaultText('ESB_OWNARTICLE');
		this.applyDefaultTooltip('ESB_OWNARTICLETT');
	}
});

brodos.button.Done = function (config){
	this.icon = 'Done.gif';
	
	brodos.button.Done.superclass.constructor.call(this, config);
}
Ext.extend( brodos.button.Done, brodos.button.Button, {

	/**
	 * @scope brodos.button.Done 
	 */
	
	initComponent : function(){
        brodos.button.OwnArticle .superclass.initComponent.call(this);
		this.applyDefaultText('ESB_DONE');
		this.applyDefaultTooltip('ESB_DONETT');
	}
});

brodos.button.Edit = function(config){
	this.icon = 'Edit.gif';
	
	brodos.button.Edit.superclass.constructor.call(this, config);
}
Ext.extend(brodos.button.Edit, brodos.button.Button, {

	/**
	 * @scope brodos.button.Edit 
	 */
	
	initComponent : function(){
        brodos.button.OwnArticle .superclass.initComponent.call(this);
		this.applyDefaultText('ESB_EDIT');
		this.applyDefaultTooltip('ESB_EDITTT');
	}
});

brodos.button.Navigation = function (config) {

    this.buttonText = config.text;
    this.passive();

    brodos.button.Navigation.superclass.constructor.call(this, config);
}

Ext.extend(brodos.button.Navigation, Ext.Button, {

	/**
	 * @scope brodos.button.Navigation
	 */
	 
    initComponent: function () {
        brodos.button.Navigation.superclass.initComponent.call(this);
    },

    active: function () {
        this.setText('<div class="uac-access-button-text-space-a">' + this.buttonText + '</div>');
        this.removeClass('uac-access-button');
        this.iconAlign = 'top';
        this.addClass('uac-access-button-a');
    },

    passive: function () {
        this.setText('<div class="uac-access-button-text-space">' + this.buttonText + '</div>');
        this.removeClass('uac-access-button-a');
        this.iconAlign = 'top';
        this.addClass('uac-access-button');
    },
	
	allowed: function () {
		this.setText('<div class="uac-access-button-text-space-valid">' + this.buttonText + '</div>');
	},
	
	restricted: function () {
		this.setText('<div class="uac-access-button-text-space-invalid">' + this.buttonText + '</div>');
	}
});


 
/**
 * Load translations and working path from global brodos settings
 */               

brodos.button.Setting({localization: brodos.translation.getRawStore(), resources: brodos.config.get('WDIR')+'/images/button/'}); 