function imitateSelect(param)
{
	var l = new lgz ();
	this.speed = 30;
	this.padding = false;
	this.button = l.$(param.button.id);
	this.show = l.$(param.show.id);
	if(0 < param.defaults.listRow)
	{
		var amount = (param.defaults.listRow*20);
		if(this.show.scrollHeight > amount)
		{
			this.show.style.height = amount+'px';
			this.padding = true;
		}
	}
	if(1 === param.defaults.fitWidth) this.fitWidth();
	this.shows = this.checkingTag(this.show,param.show.tag);
	this.show.style.display = (0 === param.defaults.spread) ?'none' :'block';
	this.param = param;
	this.l = l;
	this.annalTag = false;
	this.annalSelect = false;
	this.annalInterval = false;
	this.tagMouse();
}

imitateSelect.prototype.checkingTag = function(obt,tag) /* 验证元素 */
{
/*
多级的 BUG: (可使用校验功能解决此问题,暂未开发)
	<div>
		<li> //如果此位置和获取的Tag相同,将无法取得Tag元素
		<ul>
			<li> </li>
		</ul>
		</li>
	</div>
*/
	var OBTID = obt.id,OBTNN=obt.nodeName,TAGUPPER=tag.toUpperCase();
	var tags = obt.getElementsByTagName(tag),i,y,result = new Array();
	function checkingParent(_obt)
	{
		var parent = _obt.parentNode,r;
		if(parent.nodeName != OBTNN)
		{
			if(parent.nodeName == TAGUPPER) return false;
			r = checkingParent(parent);
		}
		else
		{
			if(parent.id == OBTID) return true;
			r = checkingParent(parent);
		}
		return r;
	}
	
	for(i=0,y=0;i<tags.length;i++)
	{
		if(checkingParent(tags[i])){result[y]=tags[i];y++;}
	}
	return result;
}

imitateSelect.prototype.fitWidth = function() /* 自动适应字符宽度 */
{
	var sW = parseInt(this.show.scrollWidth),cW = parseInt(this.show.clientWidth);
	if(sW > cW)
	{
		if(this.padding === true) sW += 20;
		this.show.style.width = sW+'px';
	}
}

imitateSelect.prototype.tagMouse = function() /* 鼠标相关动作赋值 */
{
	var i,hidden = document.createElement('input'),_this=this,hId=this.param.defaults.hiddenId,aaaa;
	hidden.type = 'hidden';
	hidden.value = 'all';
	hidden.name = this.param.defaults.hiddenName;
	hidden.id = hId;
	this.button.appendChild(hidden);
	
	/* 滚动 */
	var obt = this.l.$(this.param.button.sId),_this=this,int,_speed = this.speed,timeout,sW,cW;
	function startScroll(){int = setInterval(LEFT,_speed);} /* 启动 */
	function resetScroll(){obt.scrollLeft=0;clearTimeout(timeout);timeout = setTimeout(startScroll,3000);}/* 复位 */
	function LEFT () /* 动作 */
	{
		if(obt.scrollLeft >=(sW-cW))
		{
			clearInterval(int);clearTimeout(timeout);
			timeout = setTimeout(resetScroll,3000);return;
		}
		obt.scrollLeft ++;
	}
	
	this.button.onclick = function()/* 按钮点击 */
	{
		_this.show.style.display = _this.show.style.display == 'none' ?'block' :'none';
		if(_this.annalSelect !== false)
		{
			_this.resetShows();
			_this.shows[_this.annalSelect].style.backgroundColor='#9CF';
		}
	}
	
	/* 数据列表 */
	for(i=0;i<this.shows.length;i++)
	{
		this.shows[i].lang = i;
		this.shows[i].onmouseover = function () /* 鼠标OVER */
		{
			this.style.backgroundColor='#9CF';
			if(_this.annalTag !== false && _this.annalTag != this.lang) _this.shows[_this.annalTag].style.backgroundColor='#FFFFFF';
			_this.annalTag = this.lang; 
		}
		
		this.shows[i].onclick = function()	/* 下拉点击 */
		{
			_this.show.style.display = 'none';
			if(this.lang === _this.annalSelect)return false;
			clearInterval(int);
			_this.l.$(hId).value=this.getAttribute(_this.param.button.label);
			_this.l.$(_this.param.button.sId).innerHTML = this.innerHTML;
			_this.annalSelect = _this.annalTag = this.lang;
			sW = parseInt(obt.scrollWidth);cW = obt.clientWidth;
			if(sW > cW) resetScroll();
		}
	}
	
}

/* 初始化下载菜单 */
imitateSelect.prototype.resetShows = function()
{
	var i=0;
	for(i;i<this.shows.length;i++)
		this.shows[i].style.backgroundColor='#FFF';
}
