Bw.Widgets.ImageLabel =
{
	superclassName: "Bw.Widgets.Widget",
	selfclassName: "Bw.Widgets.ImageLabel",
	
	create: function (image, label)
	{
		var obj = document.createElement ("DIV");
			
		if (image && image != null) {
			obj.setAttribute ("image", image);
		}
		if (label && label != null) {
			obj.setAttribute ("label", label);
		}
		
		Bw.Core.bootstrap (obj, "Bw.Widgets.ImageLabel");
		
		return obj;
	},
	
	initialize: function ()
	{
		Bw.Widgets.Widget.initialize.call (this);
		
		this.picture = null;
		this.text = null;
		
		this.style.display="inline";
		
		var img = this.getAttribute ("image");
		if (img != null) {
			this.setImage (img);
		}
		
		var txt = this.getAttribute ("label");
		if (txt != null) {
			this.setLabel (txt);
		}
		
		return false;
	},
	
	setImage: function (img)
	{
		var p = this.picture;
		if (p == null)
		{
			p = Bw.Widgets.Image.create();
			with (p.style)
			{
				marginLeft = "2px";
				marginRight = "2px";
				verticalAlign = "middle";
			}
			p.align = "center";
		
			if (this.text != null) {
				this.insertBefore (p, this.text);
			} else {
				this.appendChild (p);
			}
	
			this.picture = p;
		}
		
		if (img != p.getSource()) {
			p.setSource (img);
		}
	},
	
	getImage: function ()
	{
		var p = this.picture;
		return (!p) ? null : p.getSource();
	},
	
	setLabel: function (txt)
	{
		var t = this.text;
		if (t == null)
		{
			t = Bw.Widgets.Label.create ();
			this.appendChild (t);
			this.text=t;
		}
		
		if (txt != t.getValue()) {
			t.setValue (txt);
		}
	},
	
	getLabel: function ()
	{
		var t = this.text;
		return (!t) ? null : t.getValue();
	},
	
	getValue: function ()
	{
		return this.getLabel();
	},
	
	setValue: function (txt)
	{
		return this.setLabel (txt);
	}
};


