text: goog.require('DD.ui.renderer.Component');
  goog.provide('DD.ui.renderer.Fields');
  
  /**
   * @constructor
   */
  DD.ui.renderer.Fields = function()
  {
  	DD.ui.renderer.Component.call(this);
  };
  goog.inherits(DD.ui.renderer.Fields, DD.ui.renderer.Component);
  goog.addSingletonGetter(DD.ui.renderer.Fields);
  
  
  
  
  DD.ui.renderer.Fields.CSS_CLASS = 'DD-fields';
  
  DD.ui.renderer.Fields.prototype.getCssClass = function()
  {
  	return DD.ui.renderer.Fields.CSS_CLASS;
  };
  
  DD.ui.renderer.Fields.prototype.resize = function(component)
  {
  	if (!component.isInDocument())
  		return;
  	var element = component.getElement();
  	if (element.DD_stylesheet)
  		goog.dom.removeNode(element.DD_stylesheet);
  	var content = component.getContentElement();
  	var fields = content.children;
  	var count = fields.length;
  	var allW = content.clientWidth;
  	var setW = 0;
  	var field = null;
  	var percentFields = {};
  	var autoFields = [];
  	var styles = {};
  	var CSSclass = '';
  	for (var w=0, i=0; i<count; i++)
  	{
  		field = fields[i];
  		if (!field.DD_component)
  			continue;
  		
  		var CSSclass = field.DD_component.getCssId();
  		goog.dom.classes.add(field, CSSclass);
  		w = field.DD_component.getWidth();
  		if (w === '')
  		{
  			autoFields.push(CSSclass);
  		}
  		else if (!isNaN(w))
  		{
  			styles[CSSclass] = 'width:'+w+'px';
  			setW += w;
  		}
  		else if (w.indexOf('px')!=-1)
  		{
  			var w_ = parseInt(w);
  			if (!isNaN(w_))
  			{
  				styles[CSSclass] = 'width:' + w_ + 'px';
  				setW += w_;
  			}
  			else
  				autoFields.push(CSSclass);
  		}
  		else if (w.indexOf('%')!=-1)
  		{
  			var w_ = parseInt(w);
  			if (!isNaN(w_))
  				percentFields[CSSclass] = w_;
  			else
  				autoFields.push(CSSclass);
  		}
  		else
  			autoFields.push(CSSclass);
  	}
  	var autoW = allW - setW;
  	for (var i in percentFields)
  	{
  		var w_ = Math.floor(autoW * percentFields[i] / 100);
  		styles[i] = 'width:' + w_ + 'px';
  		setW += w_;
  	}
  	autoW = allW - setW;
  	var w_ = Math.floor(autoW / autoFields.length);
  	for (var i=0; i<autoFields.length; i++)
  		styles[autoFields[i]] = 'width:' + w_ + 'px';
  
  	var styleString = '';
  	for (var i in styles)
  		styleString += ('.'+i+' {'+styles[i]+';} ');
  	element.DD_stylesheet = goog.style.installStyles(styleString);
  };