//v.1.2 build 71114

/*
Copyright DHTMLX LTD. http://www.dhtmlx.com
To use this component please contact sales@dhtmlx.com to obtain license
*/
/*
	IMAGE OPTION
*/
dhtmlXCombo_imageOption = function()
{
    this.init();
}

dhtmlXCombo_imageOption.prototype = new dhtmlXCombo_defaultOption;

dhtmlXCombo_imageOption.prototype.setValue = function(attr)
{
    this.value = attr.value||"";
    this.text = attr.text||"";
    this.css = attr.css||"";
    this.content=null;
    this.img_src = attr.img_src||this.getDefImage();
}

dhtmlXCombo_imageOption.prototype.render = function()
{
    if (!this.content) 
    {
        this.content=document.createElement("DIV");
        this.content._self = this;
        this.content.style.cssText='width:100%;overflow:hidden;"+this.css+"';
		if (_isOpera || _isKHTML) this.content.style.padding="2px 0px 2px 0px";
		
		this.content.style.padding="2px 0px 2px 0px";
		
        var html = '<div style="float:left">'+this.text+'</div>';
        if (this.img_src != '')	html += '<div style="float:right; margin: 2px 0px; padding-right: 2px"><img src="'+this.img_src+'" /></div>';
       
        this.content.innerHTML=html;
        this._ctext=_isIE?this.content.innerText:this.content.textContent;
        //this.content.firstChild.onclick = function(e) {(e||event).cancelBubble=true;}
    }
    return this.content;
}

dhtmlXCombo_imageOption.prototype.data = function()
{
	//if (this.content) return [this.value,this.text,this.img_src];
    if (this.content) return [this.value,this._ctext ? this._ctext : this.text,this.img_src];
}

dhtmlXCombo_imageOption.prototype.DrawHeader = function(self, name, width)
{
    var z=document.createElement("DIV");
    z.style.width = width+"px";
    z.className = 'dhx_combo_box';
    z._self = self;
	self.DOMelem = z;
   // this._DrawHeaderImage(self, name, width);
    this._DrawHeaderInput(self, name, width); //-18
	//this._DrawHeaderButton(self, name, width);
    self.DOMParent.appendChild(self.DOMelem);
}

dhtmlXCombo_imageOption.prototype._DrawHeaderImage = function(self, name, width)
{
	var z= document.createElement('img');
    //z.src='';
    z.className = 'dhx_combo_option_img';
    z.style.visibility = 'hidden';
    self.DOMelem.appendChild(z);
	self.DOMelem_image=z;
}

dhtmlXCombo_imageOption.prototype.RedrawHeader = function(self)
{
	//self.DOMelem_image.style.visibility = 'visible';
	//self.DOMelem_image.src = this.img_src;
}

dhtmlXCombo_imageOption.prototype.getDefImage = function(self){ return ""; }

/**
	@descr: set default image for image based options
	@param: url - url of default image
	@type: public
*/
dhtmlXCombo.prototype.setDefaultImage=function(url)
{
	dhtmlXCombo_imageOption.prototype.getDefImage=function()
	{
		return url;
	}
}

dhtmlXCombo_optionTypes['image'] = dhtmlXCombo_imageOption;
