function getKeyChar(e)
{
	if(! e) e=window.event;
	if(! e) e=this.event;
	//alert('kpin');
	var keynum=e.keyCode || e.which;
	//alert(keynum);
	if(keynum==13)
	{
		return('enter');
		//enter key							
	}
	else if(keynum==38)
	{
		return('up');
		//arrow up							
	}
	else	if(keynum==40)
	{
		return('down');
		//arrow down			
	}
	else if((keynum>47 && keynum<58) ||(keynum>64 && keynum<91))
	{			
		//a number or a letter	
		keychar = String.fromCharCode(keynum)
		return(keychar);
	}
}	
			
function getHeight()
{
	if(arguments[0])
	{
		doc=parent.document;
		win=parent.window;
	}
	else
	{
		doc=document;
		win=window;				
	}
	if(win.innerHeight)
	{
		//alert('window');
		return(win.innerHeight);
	}
	else if(doc.body.offsetHeight)
	{
		return(doc.body.offsetHeight);
	}
	else
		{
			return('not ok');
		}
}	

function maxStrLenArr(arrin)
{
	arrlen=arrin.length;
	//alert(arrlen);
	i=0;
	maxlen=0;
	while(i<arrlen)
	{
		if(arrin[i].length>maxlen)
		{
			maxlen=arrin[i].length;
		}
		i++;
	}
	return(maxlen);
}

function addnbsp(txt,maxlen)
{
	if(!txt) txt='';
	xlen=txt.length;
	if(xlen<maxlen)
	{
		maxlen=parseInt(1.35*maxlen);
		while(xlen<maxlen)
		{
			txt+="&nbsp;";
			xlen++;
		}
	}
	return(txt);
}

function sortcase(txt)
{
	txt=txt.toLowerCase();
	txt1=txt.substr(0,1);
	var re=new RegExp('[^a-z]');
	if(txt1.match(re))
	{
		switch(txt1)
		{
			case 'ö':
			txt1='o';
			break;
			case 'ë':
			txt1='e';
			break;
			case 'ü':
			txt1='u';
			break;
			case 'ä':
			txt1='a';
			break;	
			case 'ï':
			txt1='i';
			break;
		}
		txt=txt1+txt.substr(1);
		//alert(txt);
	}
	return(txt);
}		




/**
*	@class selectdiv 
*/

/**
*	@todo create parameter setting for size of scrolltop and scrollbottom div, search for 12 to find related code
*	@todo create parameter setting for the top and bottom margin setting for the listDiv, taking the margins into account with scrolling
*/

/**
*	constructor
*/
function selectDiv()
{
	//display parameters, these parameters are display parameter settings 
	
	/**
	*	@param {string} scrollContainerId id of the outside div in which the listDiv scrolls
	*/	
	var scrollContainerId;

	/**
	*	@param {string} left position of scrollcontainer, optional can also be defined in the css or html
	*/
	var posLeft;
	
	/**
	*	@param {bool} if true then the x-position will be corrected to fit the viewport
	*/
	var autocorrectLeft;

	/**
	*	@param {integer} if autocorrectLeft and position of container needs correction then the margin will be added to the correction
	*/
	var autocorrectLeftMargin;
	
	/**
	*	@param {string} posTop top position of scrollcontainer, optional can also be defined in the css or html
	*/
	var posTop;

	/**
	*	@param {object} parentElm element that contains the scrollcontainer, used to influence the mouseout
	*/
	var parentElm;

	/**
	*	@param {string} listDivId id of div containing the listItems, scrolls inside the scrollContainer
	*/	
	var listDivId;	
	/**
	*	@param {string} scrollTopDivId id of div used to scroll the list up, onmouseover of this div scrolls the list bottom to top
	*/	
	var scrollTopDivId;
	/**
	*	@param {string} scrollBottomDivId id of div used to scroll the list down, onmouseover of this div scrolls the list top to bottom
	*/	
	var scrollBottomDivId;	
	
	/**
	*	@param {integer} scrollSpeed number of pixels to scroll per millisecond, defaults to 6
	*/
	var scrollSpeed;
	/**
	*	@param {string} titleDivId id of title div element
	*/	
	var titleDivId;	
	/**
	*	@param {int} ruleHeight height of listitems in pixel
	*/	
	var ruleHeight;
	/**
	*	@param {int} minListWidth minimum width of list items in pixel, default = 0
	*/	
	var minListWidth;
	/**
	*	maximum height in pixel the scrollcontainer can get, if the listDiv is smaller	than the maxContainerHeight, the scrollContainer will be the same size as the listDiv
	*/
	var maxContainerHeight;	
	/**
	*	@param {string} liSelectBGColor background color setting of selected list item
	*/
	var liSelectBGColor;
	/**
	*	@param {string} liUnSelectBGColor background color setting of non-selected list item
	*/
	var liUnSelectBGColor;
	/**
	*	@param {string} liSelectColor color setting of selected list item
	*/
	var liSelectColor;
	/**
	*	@param {string} liUnSelectColor color setting of non-selected list item
	*/
	var liUnSelectColor;
	/**
	*	@param {array} arrValue contains the value of the listitems
	*/	
	var arrValue;
	/**
	*	@param {array} arrTxt contains the text of the listitems
	*/
	var arrTxt;
	
	/**
	*	@param {string} divTitle text used as a title for the select
	*/
	var divTitle;	
	//system parameters
	
	var listDivTop;
	
	/**
	*	reference to the current object equivalent to the this keyword	
	*/
	var curObj;
	/**
	*	@param {integer} curLi index of array of currently active list element
	*/	
	var curLi=0;
	var divMove=false;
	/**
	* @param {bool} kPressAdded indicates whether or not the keypress event is added
	*/
	var kPressAdded=false;
	
	var scrollContainerElm='';
	
	var listDivElm='';
	
	var titleDivElm='';
	
	var scrollTopDivElm='';
	
	var scrollBottomDivElm='';
	
	var scrollContainerHeight;
	
	var scrollEnabled;
	
	var closeOnMouseOut;

	var closeContainerTimeOut;	
	
	var closeContainerTimer;
	
	var listItemWidth;
	
	var divTitle='';
	
	/**
	*	@param {bool} stopScroll indicator that is set if scrolling of the listDiv has to be stopped
	*/
	var stopScroll;
	
	/**
	*	calculated height of the listDiv, based on the ruleHeight parameter
	*/
	var listDivCalcHeight;	
	
	this.arrValue=new Array();
	this.arrTxt=new Array();
	this.closeContainerTimeOut=1000;
	
	this.curLi=0;
	this.divMove=false;
	this.kPressAdded=false;
	this.scrollContainerHeight=0;
	this.scrollEnabled=false;
	this.listDivCalcHeight=0;	
	
	this.listDivTop=9;
	
	this.autocorrectLeftMargin=0;
	this.scrollSpeed=6;
	this.minListWidth=0;
}

selectDiv.prototype = {		

	/**
	*	Custom function that is executed onmouseout	of a list item
	*/
	liout: function ()
	{
		arrli=curObj.listDivElm.getElementsByTagName('LI');
		for(licnt=0;licnt<arrli.length;licnt++)
		{
			arrli[licnt].style.color=curObj.liUnSelectColor;
			arrli[licnt].style.backgroundColor=curObj.liUnSelectBGColor;
			if(arrli[licnt].childNodes.length>0)
			{
				arrli[licnt].childNodes[0].style.color=curObj.liUnSelectColor;
				arrli[licnt].childNodes[0].style.backgroundColor=curObj.liUnSelectBGColor;					
			}						
		}
	}
	,
	/**
	*	Custom function that is executed onmouseover	of a list item
	*
	*	@param {string} elmid id of the list element being clicked, the id contains a reference to the index of the value and txt array, id format is 'sd_li_'+index of array element	
	*/	
	liin: function (elmid)
	{
		document.getElementById(elmid).style.color=curObj.liSelectColor;
		document.getElementById(elmid).style.backgroundColor=curObj.liSelectBGColor;					
		if(document.getElementById(elmid).childNodes.length>0)
		{
			document.getElementById(elmid).childNodes[0].style.color=curObj.liSelectColor;
			document.getElementById(elmid).childNodes[0].style.backgroundColor=curObj.liSelectBGColor;					
		}			
	}		
	,
	//system functions

	/**
	*	sorts the value array and the text array in alphabetical order of the text
	*/	
	arrsort: function()
	{
		i=0;			
		while(i<curObj.arrValue.length)
		{
			j=0;
			while(j<i)
			{
				if(sortcase(curObj.arrTxt[i])<sortcase(curObj.arrTxt[j]))
				{
					hulp=curObj.arrTxt[j];						
					curObj.arrTxt[j]=curObj.arrTxt[i];
					curObj.arrTxt[i]=hulp;
					hulp=curObj.arrValue[j];
					curObj.arrValue[j]=curObj.arrValue[i];
					curObj.arrValue[i]=hulp;						
				}
				j++;
			}				
			i++;
		}
	}
	,
	setV: function (arrv,arrt)
	{
		curObj=this;				
		if(arrv.length && typeof(arrv)!="string")
		{
			curObj.arrValue=arrv;

		}
		if(arrt.length && typeof(arrt)!="string")
		{
			curObj.arrTxt=arrt;
		}
		else
		{
			curObj.arrTxt=curObj.arrValue;
		}
	}
	,
	closeContainer: function()
	{
		//alert("close");
		if(curObj.doClose)
		{
			curObj.doContainerMouseOver();
			if(! curObj.closeContainerTimer)
			{
				curObj.scrollContainerElm.style.display = 'none';
				curObj.removeKeyPressCode();
			}
		}
	}
	,
	doContainerMouseOver: function()
	{
		curObj.doClose=false;
		if(curObj.closeContainerTimer)
		{
			clearTimeout(curObj.closeContainerTimer);
		}
		curObj.closeContainerTimer=null;
	}
	,
	doContainerMouseOut: function(elm,evt)
	{
		if(curObj.closeOnMouseOut)
		{
			curObj.doContainerMouseOver();
			//clear the current timeout before setting one
			if(curObj.parentElm)
			{
				//if (checkMouseLeave(elm, evt) && !checkMouseLeave(curObj.parentElm, evt)) alert('noleaveparent');
				if (checkMouseLeave(elm, evt) && checkMouseLeave(curObj.parentElm, evt)) 
				{				
					
					curObj.closeContainerTimer=setTimeout('curObj.closeContainer()',curObj.closeContainerTimeOut);
					curObj.doClose=true;
				}								
			}
			else
			{
				if (checkMouseLeave(elm, evt)) 
				{				
					curObj.closeContainerTimer=setTimeout('curObj.closeContainer()',curObj.closeContainerTimeOut);
					curObj.doClose=true;
				}				
			}
		}
	}
	,
	setScrollContainer: function()
	{
		if(document.getElementById(curObj.scrollContainerId))
		{
			curObj.scrollContainerElm=document.getElementById(curObj.scrollContainerId);				
		}
		else
		{
			curObj.scrollContainerElm=document.createElement('DIV');
			curObj.scrollContainerElm.id=curObj.scrollContainerId;
			document.body.appendChild(curObj.scrollContainerElm);
		}		
		if(curObj.maxContainerHeight>=curObj.listDivCalcHeight)
		{
			curObj.scrollContainerHeight=curObj.listDivCalcHeight;
			curObj.scrollEnabled=false;
		}
		else
		{
			curObj.scrollContainerHeight=curObj.maxContainerHeight;	
			curObj.scrollEnabled=true;
		}				
		curObj.scrollContainerElm.style.height=curObj.scrollContainerHeight+'px';	
		//extend this to a check if the height of the list is smaller and use that	
		curObj.scrollContainerElm.onmouseout=function(evt){if(!evt){if(window.event) {evt=window.event;}else {evt=this.event;}}curObj.doContainerMouseOut(this,evt);};									
		curObj.scrollContainerElm.onmouseover=function(){curObj.doContainerMouseOver();};
		curObj.scrollContainerElm.style.display='block';
		curObj.scrollContainerElm.style.width=curObj.listItemWidth+'px';
		if(curObj.posLeft)
		{
			curObj.scrollContainerElm.style.left=curObj.posLeft;
		}
		if(curObj.autocorrectLeft)
		{
			corX=(f_clientWidth()-parseInt(curObj.scrollContainerElm.style.left)-curObj.listItemWidth+f_scrollLeft());
			//alert(corX);
			if(corX<0)
			{
				//does not fit the viewport
				newLeft=parseInt(curObj.scrollContainerElm.style.left)+corX-curObj.autocorrectLeftMargin;
				if(newLeft<0) newLeft=0; 
				curObj.scrollContainerElm.style.left=newLeft+'px';
			}
		}
		if(curObj.posTop)
		{
			curObj.scrollContainerElm.style.top=curObj.posTop;
		}
	}
	,
	setListDiv: function()
	{
		if(document.getElementById(curObj.listDivId))
		{
			curObj.listDivElm=document.getElementById(curObj.listDivId);
			curObj.listDivElm.innerHTML='';
		}
		else
		{
			curObj.listDivElm=document.createElement('DIV');
			curObj.listDivElm.id=curObj.listDivId;
			curObj.scrollContainerElm.appendChild(curObj.listDivElm);				
		}					
		curObj.listDivElm.style.top=curObj.listDivTop+'px';	
		curObj.listDivElm.style.marginTop='0px';	
		curObj.listDivElm.style.marginBottom='0px';		
		curObj.listDivElm.style.display='block';
	}	
	,	
	setScrollToTop: function()
	{	
		if(curObj.scrollTopDivId)
		{			
			if(document.getElementById(curObj.scrollTopDivId))
			{
				curObj.scrollTopDivElm=document.getElementById(curObj.scrollTopDivId);
			}
			else
			{
				curObj.scrollTopDivElm=document.createElement('DIV');
				curObj.scrollTopDivElm.id=curObj.scrollTopDivId;
				curObj.scrollContainerElm.appendChild(curObj.scrollTopDivElm);				
			}	
			curObj.scrollTopDivElm.onmouseover=function() {curObj.stopScroll=false;curObj.scrollUp();};
			curObj.scrollTopDivElm.onmouseout=function() {curObj.stopScroll=true;};	
		}
		curObj.scrollTopDivElm.style.width=(curObj.listItemWidth)+'px';	
		if(curObj.titleDivId && curObj.divTitle)
		{
			//if(curObj.scrollTopDivElm.style.top)
			//{
			//	curObj.scrollTopDivElm.style.top=parseInt(curObj.scrollTopDivElm.style.top)+20+"px";
			//}
			//else
			{
				curObj.scrollTopDivElm.style.top="20px";
			}			
		}		
		curObj.scrollTopDivElm.style.display='';
		//margin of listdiv parameteriseren		
	}
	,	
	setScrollToBottom: function()
	{	
		if(curObj.scrollBottomDivId)
		{			
			if(document.getElementById(curObj.scrollBottomDivId))
			{
				curObj.scrollBottomDivElm=document.getElementById(curObj.scrollBottomDivId);
			}
			else
			{
				curObj.scrollBottomDivElm=document.createElement('DIV');
				curObj.scrollBottomDivElm.id=curObj.scrollBottomDivId;
				curObj.scrollContainerElm.appendChild(curObj.scrollBottomDivElm);				
			}	
			curObj.scrollBottomDivElm.onmouseover=function() {curObj.stopScroll=false;curObj.scrollDown();};
			curObj.scrollBottomDivElm.onmouseout=function() {curObj.stopScroll=true;};	
		}
		curObj.scrollBottomDivElm.style.width=(curObj.listItemWidth)+'px';	
		curObj.scrollBottomDivElm.style.display='';
		//margin of listdiv parameteriseren		
	}
	,
	setTitleDiv: function()
	{
		if(curObj.titleDivId && curObj.divTitle)
		{
			if(document.getElementById(curObj.titleDivId))
			{
				curObj.titleDivElm=document.getElementById(curObj.titleDivId);
			}
			else
			{
				curObj.titleDivElm=document.createElement('DIV');
				curObj.titleDivElm.id=curObj.titleDivId;
				curObj.scrollContainerElm.appendChild(curObj.titleDivElm);								
			}
			curObj.titleDivElm.style.width=(curObj.listItemWidth)+'px';	
			curObj.titleDivElm.innerHTML=curObj.divTitle;		
			curObj.scrollContainerElm.style.height=curObj.scrollContainerHeight+20+"px";
	
			//alert(curObj.scrollTopDivElm.style.top);
			curObj.listDivTop=curObj.listDivTop+20;	
			if(curObj.listDivElm.style.top)
			{
				curObj.listDivElm.style.top=curObj.listDivTop+"px";
			}
		}				
	}
	,
	setListDivCalcHeight: function()
	{
		curObj.listDivCalcHeight=((curObj.arrValue.length+1)*curObj.ruleHeight);		
	}
	,
	setListItemWidth: function()
	{
		curObj.listItemWidth=(6*maxStrLenArr(curObj.arrTxt));
		if(curObj.listItemWidth<curObj.minListWidth)
		{
			curObj.listItemWidth=curObj.minListWidth;
		}
	}
	,
	createListItem: function(index)
	{
		lielm=document.createElement('LI');
		liId='sd_li_'+index;
		lielm.id=liId;
		lielm.onmouseover=function(){curObj.doMouseOver(this.id);};
		lielm.onmouseout=function(){curObj.doMouseOut(this.id);};
		lielm.onclick=function(){curObj.doClick(this.id);};
		//lielm.innerHTML=addnbsp(arrTxt[i],maxlen);
		lielm.innerHTML="<a href=\"javascript:curObj.doClick('sd_li_"+index+"');\">"+curObj.arrTxt[index]+"</a>";
		lielm.style.width=curObj.listItemWidth;
		return(lielm);		
	}
	,	
	createListDiv: function()
	{				
		arrlen=curObj.arrValue.length;
		if(arrlen>0 && curObj.arrTxt.length==0) curObj.arrTxt=curObj.arrValue;
		//alert(arrlen);
		//curObj.arrsort();			
		
		if(arrlen>0 && curObj.listDivId && curObj.scrollContainerId)
		{
			curObj.setListDivCalcHeight();
			curObj.setListItemWidth();
			curObj.setScrollContainer();	
			curObj.setListDiv();			
			if(curObj.scrollEnabled)
			{
				curObj.setScrollToTop();
				curObj.setScrollToBottom();
			//alert(scrollContainerHeight+" "+listDivCalcHeight);																								
				curObj.hideScrollTop();				
				curObj.showScrollBottom();				
				//listDivCalcHeight=listDivCalcHeight;
			} 
			else
			{			
				curObj.listDivElm.style.top='0px';
				curObj.listDivElm.style.marginTop='3px';
				curObj.destroyScrollElements();
				//contelm.style.height=(listDivCalcHeight-parseInt(contelm.style.top))+'px';
			}
			curObj.setTitleDiv();
		}
		ulelm=document.createElement('UL');
		i=0;			
		while(i<arrlen)
		{
			ulelm.appendChild(curObj.createListItem(i));
			i++;
		}
		if(ulelm)
		{					
			curObj.listDivElm.appendChild(ulelm);	
			curObj.scrollContainerElm.style.display='';
		}	
		curObj.doContainerMouseOver();
	}	
	,
	setKeyPressCode: function ()
	{
		if (!curObj.kPressAdded)
		{
			document.onkeydown=curObj.kp;
			if (window.addEventListener)
			        /** DOMMouseScroll is for mozilla. */
			        window.addEventListener('DOMMouseScroll', curObj.wheel, false);
			/** IE/Opera. */
			window.onmousewheel = document.onmousewheel = curObj.wheel;			
			curObj.kPressAdded=true;
		}
	}
	,
	removeKeyPressCode: function()
	{
		if (curObj.kPressAdded)
		{
			document.onkeydown=null;
			if (window.removeEventListener)
			        /** DOMMouseScroll is for mozilla. */
			        window.removeEventListener('DOMMouseScroll', curObj.wheel, false);
			/** IE/Opera. */
			window.onmousewheel = document.onmousewheel = null;					
			curObj.kPressAdded=false;
		}
	}
	,
	/** Event handler for mouse wheel event.
	 */
	wheel: function(event){
	  var delta = 0;
	  if (!event) /* For IE. */
	  	event = window.event;
	  if (event.wheelDelta) 
	  { /* IE/Opera. */
	  	delta = event.wheelDelta/120;
	    /** In Opera 9, delta differs in sign as compared to IE.
	     */
	    if (window.opera) delta = -delta;
	  } 
	  else if (event.detail) 
	  { /** Mozilla case. */
	    /** In Mozilla, sign of delta is different than in IE.
	     * Also, delta is multiple of 3.
	     */
	    delta = -event.detail/3;
	  }
	  /** If delta is nonzero, handle it.
	   * Basically, delta is now positive if wheel was scrolled up,
	   * and negative, if wheel was scrolled down.
	   */
	  if (delta) curObj.wheelHandle(delta);
	  /** Prevent default actions caused by mouse wheel.
	   * That might be ugly, but we handle scrolls somehow
	   * anyway, so don't bother here..
	   */
	  if (event.preventDefault) event.preventDefault();
		event.returnValue = false;
	}	
	,
	/** 
	* handles the scrolling with them mousewheel
	*
	*	@param {int} delta positive value is mouse is scrolled up, negative if scrolled down
	*/
	wheelHandle: function(delta) 
	{
	  if (delta < 0)
	  {
			curObj.moveDown();
		}
	  else
	  {
			curObj.moveUp();
		}
	}
	,	
	showScrollTop: function()
	{
		if(curObj.scrollEnabled)
		{
			curObj.scrollTopDivElm.style.visibility='visible';
		}
	}
	,
	hideScrollTop: function()
	{
		if(curObj.scrollEnabled)
		{
			curObj.scrollTopDivElm.style.visibility='hidden';
		}		
		else
		{
			curObj.scrollBottomDivElm.style.display='none';
		}		
	}
	,
	showScrollBottom: function()
	{
		if(curObj.scrollEnabled)
		{
			curObj.scrollBottomDivElm.style.visibility='visible';
		}
	}
	,
	hideScrollBottom: function()
	{
		if(curObj.scrollEnabled)
		{
			curObj.scrollBottomDivElm.style.visibility='hidden';
		}
		else
		{
			curObj.scrollBottomDivElm.style.display='none';
		}		
	}
	,	
	destroyScrollElements: function()
	{
		if(curObj.scrollBottomDivId)
		{
			if(document.getElementById(curObj.scrollBottomDivId))
			{
				document.getElementById(curObj.scrollBottomDivId).style.display='none';
			}
		}
		if(curObj.scrollTopDivId)
		{
			if(document.getElementById(curObj.scrollTopDivId))
			{
				document.getElementById(curObj.scrollTopDivId).style.display='none';
			}
		}
	}
	,		
	/**
	*	returns the top value of the div with the listitems
	*/
	getListTop: function()
	{
		curTop=parseInt(curObj.listDivElm.style.top);
		if(isNaN(curTop))
		{
			curTop=0;
		}	
		return(curTop);
	}
	,
	/**
	*	sets the top value of the div with the listitems
	*/
	setListTop: function(curtop)
	{
		if(curtop>=curObj.listDivTop)
		{
			curObj.hideScrollTop();
			curObj.listDivElm.style.top=curObj.listDivTop;
		}
		else if(curtop<(curObj.scrollContainerHeight-curObj.listDivCalcHeight-curObj.listDivTop))
		{
			curObj.hideScrollBottom();
		}
		if(curtop<12+curObj.listDivTop)
		{
			curObj.showScrollTop();
		}
		if(curtop>(curObj.scrollContainerHeight-curObj.listDivCalcHeight))
		{
			curObj.showScrollBottom();
		}
		curObj.listDivElm.style.top=curtop+'px';
	}
	,	
	/**
	*	gets the index of an array where the value starts with strC
	*/
	getCharIndex: function(arrin,strC)
	{
		if(strC)
		{
			strL=strC.length;
			strC=strC.toLowerCase();
			for(i=0;i<arrin.length;i++)
			{
				if(arrin[i].substr(0,strL).toLowerCase()==strC) return(i);
			}		
		}
		return(-1);
	}
	,
	moveUp: function()
	{
		curtop=curObj.getListTop();
		if(curtop<=(-curObj.ruleHeight))
		{
			curObj.divMove=true;
			curObj.setListTop(curtop+curObj.ruleHeight);
		}
		else
		{
			curObj.setListTop(curObj.listDivTop);				
		}	
		if(curObj.curLi>0)
		{
			curObj.liout();
			curObj.curLi--;
			curObj.liin("sd_li_"+curObj.curLi);								
		}		
	}
	,
	moveDown: function()
	{
		curtop=curObj.getListTop();
		if(curtop>=(curObj.scrollContainerHeight-curObj.listDivCalcHeight+curObj.ruleHeight+curObj.listDivTop))
		{
			curObj.divMove=true;
			curObj.setListTop(curtop-curObj.ruleHeight); 
		}
		else
		{	
			//alert('done');
			//curObj.setListTop(curObj.scrollContainerHeight-curObj.listDivCalcHeight-5);
			curObj.setListTop(curObj.listDivTop);
		}
		if(curObj.curLi<(curObj.arrValue.length-1))
		{
			curObj.liout();					
			curObj.curLi++;
			curObj.liin("sd_li_"+curObj.curLi);								
		}				
	}
	,
	setToIndex: function(index)
	{
		//if(index==0) alert('be');
		itemsAway=index-curObj.curLi;
		curTop=curObj.getListTop();
		pixelAway=((index-curObj.curLi)*curObj.ruleHeight);
		if(curTop-pixelAway>=0)
		{
			if(curTop<-curObj.ruleHeight)
			{
				curObj.divMove=true;
			}
			curObj.setListTop(12);	
		}
		else if((curTop-pixelAway)<(curObj.scrollContainerHeight-curObj.listDivCalcHeight))
		{
			if(curTop>((curObj.scrollContainerHeight-curObj.listDivCalcHeight)+curObj.ruleHeight))
			{
				curObj.divMove=true;
			}
			curObj.setListTop((curObj.scrollContainerHeight-curObj.listDivCalcHeight));	
		}
		else
		{
			curObj.divMove=true;
			curObj.setListTop(curTop-pixelAway);
		}
		curObj.curLi=index;
		curObj.liout();	
		curObj.liin("sd_li_"+curObj.curLi);			
	}
	,
	findByChar: function(charTyped)
	{
		index=curObj.getCharIndex(curObj.arrTxt,charTyped);
		if(index>-1)
		{			
			curObj.setToIndex(index);
		}

		//alert(curTop+' '+curObj.curLi);
		//if(curObj.curLi)
		//{
		//	extraY=curObj.ruleHeight*curObj.curLi-curTop;
		//}
		////alert(index);
		//if(index>-1)
		//{
		//	//alert(index*ruleHeight+'px');
		//	topval=(index-1)*curObj.ruleHeight+extraY;
		//	if((topval)<0) topval=0;
		//	curObj.setListTop(-topval);	
		//}
	}
	,	
	kp: function(e)
	{
		if(! e) e=window.event;
		if(! e) e=this.event;		
		kbInput=getKeyChar(e);
		//alert(kbInput);
		if(kbInput=="enter")
		{
			if(curObj.curLi)
			{
				curObj.doClick("sd_li_"+curObj.curLi);
			}
		}
		else if(kbInput=="up")
		{
			//alert(curtop+' '+ruleHeight);
			curObj.moveUp();
		}
		else if(kbInput=="down")
		{
			//alert(contHeight);	
			//alert(curtop+' '+(contHeight-listDivCalcHeight+ruleHeight));
			curObj.moveDown();							
		}
		else if(kbInput)
		{ ////a number or a letter	
			curObj.findByChar(kbInput);			
		}
	}
	,	
	doMouseOver: function(elmid)
	{
		if(!curObj.divMove) 
		{
			curObj.liin(elmid);
			curObj.curLi=elmid.substr(6);
		}
		else
		{
			curObj.divMove=false;
		}				
	}
	,
	doMouseOut: function(elmid)
	{
		if(!curObj.divMove) curObj.liout();
	}
	,	
	reset: function()
	{
		if(curObj.listDivElm)
		{			
			curObj.listDivElm.parentNode.removeChild(curObj.listDivElm);
		}
	}
	,			
	scrollDown: function()
	{			
		curObj.showScrollTop();
		curtop=curObj.getListTop();
		newtop=(curtop-curObj.scrollSpeed);			
		//alert(curtop);
		//alert(curtop+' '+curObj.scrollContainerHeight+' '+curObj.listDivCalcHeight);
		if(newtop<(curObj.scrollContainerHeight-curObj.listDivCalcHeight-3))
		{
			//alert('stop');
			curObj.stopScroll=true;
			curObj.hideScrollBottom();				
		}
		if(! curObj.stopScroll) 
		{
			//alert(newtop);
			curObj.setListTop(newtop);
			setTimeout('curObj.scrollDown()',1);
		}
	}		
	,
	scrollUp: function()
	{			
		curObj.showScrollBottom();
		curtop=curObj.getListTop();
		newtop=(curtop+curObj.scrollSpeed);
		//alert(curtop);0
		if(newtop>12)
		{
			curObj.stopScroll=true;
			curObj.hideScrollTop();			
		}
		if(! curObj.stopScroll) 
		{
			curObj.setListTop(newtop);
			setTimeout('curObj.scrollUp()',1);
		}
	}				
	//"
}
