/*js select*/
function JsSelect(name, id, slctVal)
{
	this.Name = name;
	this.Id = id;
	this.Options = new Array();
	
	this.OuterHtml = "";
	this.BorderWidth = 1;
	this.BorderType = " solid";
	this.BorderColor = " #f1c069";
	this.Background = "url(css0214/bg_jsselect.gif) no-repeat 124px 1px";
	this.Width = 144;
	this.Height = 20;
	this.Padding = 4;
	this.Color = "#666";
	this.FontSize = "12px";
	this.BackColor = "#FFFED8";
	this.OverBackColor = "#f17406";
	this.OverColor = "#fff";
	
	this.Write = function(){
		var SpStyle = "display:inline-block; border:" + this.BorderWidth + "px" + this.BorderType + this.BorderColor +"; background:" + this.Background + "; width:" + (this.Width - 2*this.Padding - 2*this.BorderWidth) + "px; height:" + (this.Height - 2*this.BorderWidth)+ "px; line-height:" + (this.Height - 2*this.BorderWidth) + "px; padding:0px " + this.Padding + "px; color:" + this.Color + "; font-size:" + this.FontSize + "; cursor:pointer; overflow:hidden;";
		var UlStyle = "position:absolute; display:none; width:" + (this.Width - 2*this.BorderWidth) + "px; border:" + this.BorderWidth + "px" + this.BorderType + this.BorderColor +"; margin:0; padding:0; list-style-type:none; left:-" + (this.Padding + this.BorderWidth) + "px; top:" + (this.Height - 2*this.BorderWidth) + "px; background-color:" + this.BackColor + ";";
		var LiStyle = "display:block; height:" + this.Height + "px; line-height:" + this.Height + "px; padding:0 " + this.Padding + "px; background:none; color:" + this.Color + ";";
		var LiOverStyle = "display:block; height:" + this.Height + "px; line-height:" + this.Height + "px; padding:0 " + this.Padding + "px; background:" + this.OverBackColor + "; color:" + this.OverColor + ";";
		
		var slctIndex = 0;
		for(var i = 0; i < this.Options.length; i++){
			if(this.Options[i].val.toString() == slctVal) slctIndex = i;
		}
		
		this.OuterHtml += "<span id=\"sp_" + this.Id + "\" style=\"" + SpStyle + "\" onclick=\"OnJsSelectClick('" + this.Id + "');\">\n";
		this.OuterHtml += "<div style=\"position:absolute; width:1px; height:1px;\"><ul id=\"ul_" + this.Id + "\" style=\"" + UlStyle + "\">\n";
		for(var i = 0; i < this.Options.length; i++){
			this.OuterHtml += "<li style=\"" + LiStyle + "\" onclick=\"OnJsSelectItemClick('" + this.Id + "', '" + this.Options[i].txt + "', '" + this.Options[i].val + "');\" onmouseover=\"this.style.cssText='" + LiOverStyle + "';\" onmouseout=\"this.style.cssText='" + LiStyle + "';\">" + this.Options[i].txt + "</li>\n";
		}
		this.OuterHtml += "</ul></div>\n";
		this.OuterHtml += "<input type=\"hidden\" name=\"" + this.Name + "\" id=\"" + this.Id + "\" value=\"" + this.Options[slctIndex].val + "\" />";
		this.OuterHtml += "<span id=\"tx_" + this.Id + "\">" + this.Options[slctIndex].txt + "</span>";
		this.OuterHtml += "</span>";
		
		document.write(this.OuterHtml);
	}
}
function OnJsSelectClick(theId){
	var ulObj = document.getElementById("ul_" + theId);
	ulObj.style.display = (ulObj.style.display == "none") ? "block" : "none";
}
function OnJsSelectItemClick(theId, txt, val){
	var txObj = document.getElementById("tx_" + theId);
	var hdObj = document.getElementById(theId);
	txObj.innerHTML = txt;
	hdObj.value = val;
}
