<!--

//require mintajax lib

function zmSelect(n)
{
	this.prefix = "";
	this.selObj = null;
	this.width = 0;
	this.oName = n;
	this.addXY = {x:0, y:0};
	this.timeout = null;
	this.styles = {
		main : "selectMain",
		options : "selectOptionsAll",
		option : "selectOption",
		optionHover : "selectOptionHover"
	};

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	this.zmien = function(sid, idt, adx, ady)
	{
		this.selObj = this.getDoc(sid);
		this.prefix = sid+"_dv_";
		this.addXY = {x:adx||0, y:ady||0};
		
		var elem = '';
		var onmouse = '';
		var dv = this.getDoc(idt);
		var width = GetWidth(idt);
		
		width = (width > 0)? this.width : this.width;

		for(var i=0; i<this.selObj.options.length; i++)
		{
			onmouse = 'onmouseover="'+this.oName+'.mouse(1, this);" onmouseout="'+this.oName+'.mouse(0, this);"';
			elem += '<div style="width:'+width+'px;" onclick="'+this.oName+'.clickOption('+i+');" class="'+this.styles.option+'" '+onmouse+'>'+this.selObj.options[i].text+'</div>';
		}
		
		var str = '<div id="'+this.prefix+'_1" style="width:'+width+'px;" class="'+this.styles.main+'" onclick="'+this.oName+'.showOptions();"></div>';
		str += '<div id="'+this.prefix+'_2" style="width:'+width+'px; position:absolute; left:0; top:0; display:none;" class="'+this.styles.options+'">'+elem+'</div>';

		dv.innerHTML = ''+str ;//+ '<div onclick="'+this.oName+'.showOptions();">'+this.arrowSrc+'</div>';

		this.updateText();

		//this.getDoc(this.prefix+"_2").style.display = "none";
		$(this.prefix+"_1").style.width = GetWidth(this.selObj);
		$(this.prefix+"_2").style.width = GetWidth(this.selObj);

		this.selObj.style.display = "none";
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	this.showOptions = function()
	{
		var pos = GetPos(this.prefix+"_1");

		$(this.prefix+"_2").style.display = "block";
		
		$(this.prefix+"_2").style.left = pos.x + this.addXY.x;
		$(this.prefix+"_2").style.top = pos.y + GetHeight(this.prefix+"_1") + this.addXY.y;

		//var that = this;
		//AddEvent(document.body, "click", function(){that.eventClick(that)}) ;
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	this.clickOption = function(n)
	{
		if(n != undefined)
		{
			this.selObj.selectedIndex = n;
			this.updateText();
		}
		
		//var that = this;
		//RemoveEvent(document.body, "click", that.eventClick) ;

		$(this.prefix+"_2").style.display = "none";
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	this.mouse = function(n, obj)
	{
		obj.className = (n == 1)? this.styles.optionHover : this.styles.option ;

		if(n == 1)
			clearInterval(this.timeout);
		else
		{
			var that = this;
			this.timeout = setTimeout(function(){that.clickOption();}, 500);
		}
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	this.mouseout = function(x)
	{
		//obj.className = (n == 1)? this.styles.optionHover : this.styles.option ;
		//timeout	
		//alert(x);
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	this.updateText = function()
	{
		var text = this.selObj.options[this.selObj.selectedIndex].text;
		
		this.getDoc(this.prefix+"_1").innerHTML = (text.length > 0)? text : "&nbsp;&nbsp;&nbsp;" ;
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	this.getDoc = function(s)
	{
		return (typeof s == "object")? s : document.getElementById(s) ;
	}
}

//-->
