
function __comboBox(){
	this.targetStyle	=	'position:absolute;border:#808080 1px solid;background:url(/Images/comboBox/cbTargetBg.gif);'+
							'padding:1px;background-color:#fff;background-repeat:repeat-x;overflow: auto;';
	this.itemStyle		=	'height:19px;border-left:#eee 1px solid;border-right:#eee 1px solid;overflow:hidden;'+
							'padding:3px;padding-top:0px;cursor:default;text-align:left;';
	this.itemOverStyle	=	'height:19px;background:url(/Images/comboBox/cbItemBgOver.gif);border-left:#BFA277 1px solid;'+
							'border-right:#BFA277 1px solid;padding:3px;padding-top:0px;overflow:hidden;cursor:default;'+
							'text-align:left;';
	EventDispatcher.initialize(this);

	this.show=function(){
		var o			=	arguments[0];
		var tBox		=	arguments[1];
		var dataSorce	=	arguments[2];
		var hideId		=	arguments[3];
		var theHTML		=	arguments[4];
		var size		=	arguments[5] || {};
		
		var target		=	Global.getId('combo_'+tBox.id) ||tBox.parentNode.insertBefore(document.createElement("div"),tBox);
		target.id='combo_'+tBox.id;
		target.style.cssText=this.targetStyle;
		 
		if(size.width){
			target.style.width=size.width+'px';
			var width=size.width-tBox.offsetWidth-o.offsetWidth;
			if((target.offsetLeft+size.width+5)>document.body.clientWidth)
				target.style.left=target.offsetLeft-width-3+'px';
		}
		if(size.height) target.style.height=size.height+'px';
		target.style.top=target.offsetTop+tBox.offsetHeight+'px';
		this.target=target;
		if(dataSorce!=null){
			var hideBox=Global.getId(hideId);
			if(hideBox==null){
				hideBox					=	tBox.parentNode.appendChild(document.createElement('input'));
				Global.ie?hideBox.style.display	='none':hideBox.type='hidden';
				hideBox.id				=	hideId;
				hideBox.name			=	hideId;
				hideBox.value			=	dataSorce[0].value;
			}
			this.textBox	=	tBox;
			this.hideBox	=	hideBox;
			var length	=	dataSorce.length;
			var strHtml	=	'';	
			for(var i=0;i<length;i++){
				strHtml+='<div style="'+this.itemStyle+'" onmouseover="this.style.cssText=\''+this.itemOverStyle+
				'\'" onmouseout="this.style.cssText=\''+this.itemStyle+'\'" onclick="ComboBox.setSelectValue(this,\''+
				dataSorce[i].value+'\')">'+dataSorce[i].text+'</div>';
				if(dataSorce[i].selected){
					tBox.value		=	dataSorce[i].text;
					hideBox.value	=	dataSorce[i].value;
				}
			}
			target.innerHTML=strHtml;
		}else if(theHTML!=null){
			target.innerHTML=theHTML;
		}
		PopMenu.add(o,target);
	}
	
	this.setSelectValue=function(obj,value){
		this.textBox.value=obj.innerHTML;
		this.hideBox.value=value;
		
		this.setHide();
		this.dispatchEvent({type:"onChange",target:this.textBox,text:obj.innerHTML,value:value});
	}
	this.setHide=function(){
		PopMenu.setHide(this.target);
	}
}

var ComboBox=new __comboBox();