Studio.ColorPicker = 
{
    sColorApplied  : "",
    sColorSelected : "",
    
    sCurrentPicker  : "",
    sCurrentElement : "",
    
    bAllowColorChange : true,
    
    onColorChange : function(sColor)
    {
        this.sColorSelected = sColor;
    },
    
    onChangeElement : function(sElement, sColor)
    {
    	if (sElement != this.sCurrentElement)
    	{
    		return false;
    	}
	    this.effectSetBoxColor(sElement, sColor);
	    return true;
    },
    
    applyColor : function()
    {
        this.sColorApplied = this.sColorSelected;
    },
    
    effectSetBoxColor : function(sElement, sColor, bForce)
    {
    	if (!bForce && sElement != this.sCurrentElement)
    	{
    		return false;
    	}
        dojo.byId(sElement).style.backgroundColor = sColor;
        return true;
    },
    
    applyGlobalColor : function(sColor)
    {
    	this.effectSetBoxColor('studio_color', sColor, true);
    	this.effectSetBoxColor('options_create_shape__fill', sColor, true);
    	this.effectSetBoxColor('options_edit_shape__fill', sColor, true);
    	this.effectSetBoxColor('options_create_text__color', sColor, true);
    	this.effectSetBoxColor('options_edit_text__color', sColor, true);
    },
    
    showColorPicker : function(sPicker, sElement)
    {
    	if ("" == this.sCurrentPicker && "" == this.sCurrentElement)
    	{
	    	this.sCurrentPicker  = sPicker;
	    	this.sCurrentElement = sElement;
	    	dojo.byId(sPicker).style.visibility = '';
    	}
    },
    
    hideColorPicker : function()
    {
    	dojo.byId(this.sCurrentPicker).style.visibility = 'hidden';
    	this.sCurrentPicker = "";
    	this.sCurrentElement = "";
    }
};