<public:component>

<public:attach event="oncontentready" onevent="FnInit()" />
</public:component>

<script language="JScript">
document.imgs=new Array();
document.imgs[0]=new Image;
document.imgs[0].src='../includes/htc/images/toolbar.buttonarrow.gif';


var _objSelect;					//小箭头对像
var _Nodes;						//节点集(数据)
var _arrData = Array();			//数据数组
var _DefaultItem = 0;			//默认选项
var _Pops = null;				//POP窗口
var _PopsObjXY;					//对像坐标
var _PopsHeight;				//POP窗口高
var _PopsWidth;					//POP窗口宽

var _DefLeftWidth = '80px';		//默认左边DIV宽度
var _DefBgColor = '';			//默认背景色
var _DefBorderColor = '#DACBAD';//默认边框色




function FnInit(){
	_Nodes = element.children;
	if(_Nodes.length==0)return;	//如果没有数据项则退出,只有一个也退出
	element.style.display = 'block';

	_PopsObjXY = element.getBoundingClientRect();						//获得对像坐标

	
	if(element.style.width != '')_DefLeftWidth = element.style.width;	//获得用户设置宽度
	if(element.style.backgroundColor != '')_DefBgColor = element.style.backgroundColor;	//获得用户设置背景色
	if(element.style.borderColor != '')_DefBorderColor = element.style.borderColor;		//获得用户设置边框色
	
	for(var i=0; i<_Nodes.length;i++)_arrData[i] = _Nodes[i].innerText.split('|');
	for(var i=0; i<_arrData.length; i++)if(_arrData[i][2]==1){_DefaultItem = i;break;}
	element.innerHTML = '';	//清空对像内容

	_objSelect = document.createElement('div');
	with(element.style){
		styleFloat	= 'left';
		width		= _DefLeftWidth;
		height		= '19px';
		border		= '1px #DACBAD solid';
		borderRight	= 'none';
		paddingTop	= '3px';
		textAlign	= 'center';
		cursor		= 'default';
		backgroundColor = _DefBgColor;
		borderColor = _DefBorderColor;
	}
	with(_objSelect.style){
		styleFloat	= 'left';
		width		= '14px';
		height		= '19px';
		border		= '1px #DACBAD solid';
		textAlign	= 'center';
		cursor		= 'default';
		backgroundImage = 'url('+document.imgs[0].src+')';
		backgroundRepeat= 'no-repeat';
		backgroundPosition= 'center center';
		backgroundColor = _DefBgColor;
		borderColor = _DefBorderColor;
	}

	_PopsHeight = 18 * (_arrData.length-1) + _arrData.length-1;							//根据数据量计算POP窗高度
	_PopsWidth = parseInt(element.style.width) + parseInt(_objSelect.style.width);	//获得POP窗宽度
	element.innerText = _arrData[_DefaultItem][0];									//设置默认项文字
	element.insertAdjacentElement('afterEnd', _objSelect);							//插入箭头对像

	//添加事件
	with(element){
		oncontextmenu=function(){return false;}
		onselectstart=function(){return false;}
		attachEvent("onmouseover", OnMouseOver);
		attachEvent("onmouseout", OnMouseOut);
		attachEvent("onclick", new Function(_arrData[_DefaultItem][1]));
	}
	with(_objSelect){
		oncontextmenu=function(){return false;}
		onselectstart=function(){return false;}
		attachEvent("onmouseover", OnMouseOver);
		attachEvent("onmouseout", OnMouseOut);
		attachEvent("onclick", ListOnclick);
	}


};

function OnMouseOver(){
	element.style.backgroundColor = '#FFF';
	_objSelect.style.backgroundColor = '#FFF';
	element.style.borderColor = '#316ac5';
	_objSelect.style.borderColor = '#316ac5';
}

function OnMouseOut(){
	element.style.backgroundColor = _DefBgColor;
	_objSelect.style.backgroundColor = _DefBgColor;
	element.style.borderColor = _DefBorderColor;
	_objSelect.style.borderColor = _DefBorderColor;
};

function ListOnclick(){

	if(_Pops != null){_Pops.show(_PopsObjXY.left, _PopsObjXY.top+20, _PopsWidth, _PopsHeight+9, document.body);return;}

	_Pops = window.createPopup();
	var DIV = _Pops.document.createElement('div');
		DIV.style.border = '1px #316ac5 solid';
		DIV.style.font = '12px 宋体';
		DIV.style.padding = '3px';
		DIV.style.cursor = 'default';
	for(var i=1; i<_arrData.length; i++){
		var ListDiv = _Pops.document.createElement('div');
			ListDiv.style.height = '18px';
			ListDiv.style.padding = '3px 0px 0px 12px';
			ListDiv.style.border = '1px #FFF solid';
			ListDiv.innerText = _arrData[i][0];
			ListDiv.onclick = new Function(_arrData[i][1] + 'popshide();');
			ListDiv.onmouseover = new Function("this.style.backgroundColor = '#9AC1FF';this.style.border='1px #316ac5 solid';");
			ListDiv.onmouseout = new Function("this.style.backgroundColor = '';this.style.border='1px #FFF solid';");
			DIV.appendChild(ListDiv);
	}
	_Pops.document.body.oncontextmenu=function(){return false;}
	_Pops.document.body.onselectstart=function(){return false;}
	_Pops.document.body.insertAdjacentElement("beforeEnd", DIV);
	_Pops.show(_PopsObjXY.left, _PopsObjXY.top+20, _PopsWidth, _PopsHeight+9, document.body);
}
function popshide(){if(_Pops != null)_Pops.hide();}
</script>