var nextRowIndex = 1;
var keyTimeOut;
var rowCounter = 1;
function trimSelectList(textValue, divId, fillFieldsName,  fillFieldsLabel, fillFieldsWidth,url, docFormName, readFieldsName,addedOnclickAction){
			
    var cursorValues=textValue.substring(0,textValue.indexOf(">"));

    cursorValues=cursorValues.substring(cursorValues.indexOf("'")+1,cursorValues.length);
			
    var offset=cursorValues.substring(0,cursorValues.indexOf("'"));
			
    cursorValues=cursorValues.substring(cursorValues.indexOf("pageCount"),cursorValues.length);
    cursorValues=cursorValues.substring(cursorValues.indexOf("'")+1,cursorValues.length);
    var pageCount=cursorValues.substring(0,cursorValues.indexOf("'"));
			
    cursorValues=cursorValues.substring(cursorValues.indexOf("pageSize"),cursorValues.length);
    cursorValues=cursorValues.substring(cursorValues.indexOf("'")+1,cursorValues.length);
    var pageSize=cursorValues.substring(0,cursorValues.indexOf("'"));
			
    cursorValues=cursorValues.substring(cursorValues.indexOf("totalSize"),cursorValues.length);
    cursorValues=cursorValues.substring(cursorValues.indexOf("'")+1,cursorValues.length);
    var totalSize=cursorValues.substring(0,cursorValues.indexOf("'"));
			
    var totalSizeText = "Eintr&auml;ge gefunden "+totalSize;
    var pageActions="";
			
    if(url.indexOf("offset")!=-1){
        url=url.substring(0,url.indexOf("offset")-1);
    }
			
    var activePage = Math.floor((totalSize-(totalSize-offset))/pageSize);
			
    //alert("totalSize="+totalSize+";offset="+offset+";activePage="+activePage+";pageSize="+pageSize+";pageCount="+pageCount);
			
    url =deleteParameter(url,'pageSize');
    url =deleteParameter(url,'offset');
						
    if(pageCount<10){
        pageActions=setPageActions(0,pageCount,activePage,pageActions,url,pageSize,divId, fillFieldsName, fillFieldsLabel, fillFieldsWidth,pageCount,docFormName, readFieldsName,totalSize,addedOnclickAction);
    }else{
        var cursorStart=(Math.floor(activePage/pageSize)*pageSize);
        var cursorCount=(cursorStart+10);
        if(cursorCount>pageCount){
            cursorCount=cursorStart+(pageCount-cursorStart);
        }
        pageActions=setPageActions(cursorStart,cursorCount,activePage,pageActions,url,pageSize,divId, fillFieldsName, fillFieldsLabel, fillFieldsWidth,pageCount,docFormName, readFieldsName,totalSize,addedOnclickAction);
    }
						
    textValue = textValue.substring(textValue.indexOf(">")+1,textValue.length);
    textValue = textValue.replace("</csv>","");
			
    var fieldLabel = fillFieldsLabel.split("|");
    var fieldWidth = fillFieldsWidth.split("|");
			
    var tableCellNumber=0;
			
    var selectList="<table id='"+divId+"SelectTable' style='table-layout:fixed;' class='selectTable'><colgroup><col width='18px'>";
    for (var tdEmp = 0; tdEmp< fieldLabel.length; tdEmp++){
        if(fieldLabel[tdEmp].length>0 && fieldWidth[tdEmp].length>0){
            tableCellNumber++;
            selectList=selectList+"<col style='width:"+fieldWidth[tdEmp]+"'>";
        }
    }
    selectList=selectList+"</colgroup>";

    selectList=selectList+"<tr><td colspan='"+(tableCellNumber+1)+"' class='selectLineDiv' ><table border='0' cellpadding='0' cellspacing='0' width='100%' style='table-layout:auto;'><tr><td style='padding-right:5px;white-space:nowrap;font-size:8pt;font-weight:bold;'>";
    selectList=selectList+totalSizeText+"</td><td style='padding-right:5px;font-size:8pt;font-weight:bold;'>Seite:</td><td width='90%' style='white-space:nowrap;'><div style='white-space:nowrap;'>"+pageActions+"</div></td>";
    selectList=selectList+"<td width='80' style='vertical-align:top;'>"+ getCloseListAction(divId)+"</td></tr></table></td></tr>";
		
    selectList=selectList+"<tr><td class='selectTableHeaderTd' style='width:18px;'><img src='images/pixel_transparent.gif' width='16' height='1'/></td>";
    for (var tdH = 0; tdH < fieldLabel.length; tdH++){
        if(fieldLabel[tdH].length>0 && fieldWidth[tdH].length>0){
            selectList=selectList+"<td class='selectTableHeaderTd' style='width:"+fieldWidth[tdH]+";'>"+fieldLabel[tdH]+"</td>";
        }
    }
    selectList=selectList+"</tr>";
			
    if(textValue.length>0){
        var rowsContent = textValue.split("||");
        var trStyle="";
        var selectListCounter=0;
			
        var fillFields = fillFieldsName.split("|");
        {
            for (var row = 0; row < rowsContent.length; row++){
                selectListCounter++;
					
                if(selectListCounter%2==0){
                    trStyle="selectLineDiv";
                }else{
                    trStyle="selectBgLineDiv";
                }
					
                var trContent = rowsContent[row];
                var tdContent = trContent.split(";");
					
                var onclickAktion ="";
                for (var i = 0; i < fillFields.length; i++){
                    if(fillFields[i].length>0){
                        onclickAktion=onclickAktion+"document.forms[\""+docFormName+"\"].elements[\""+fillFields[i]+"\"].value=$(\""+docFormName+divId+row+i+"\").value;";
                    }
                }
                onclickAktion =onclickAktion+"document.getElementById(\""+divId+"\").innerHTML=\"\";";
                if(addedOnclickAction.length>0){
                    onclickAktion =onclickAktion+addedOnclickAction;
                }
						
						
                var hiddenFieldsList="";
                for (var emptyTd = 0; emptyTd < tdContent.length; emptyTd++){
                    if(fieldLabel[emptyTd].length==0 && fieldWidth[emptyTd].length==0){
                        hiddenFieldsList = hiddenFieldsList+"<input type='hidden' id='"+docFormName+divId+row+emptyTd+"' value='"+tdContent[emptyTd]+"' />" ;
                    }
                }
						
                selectList = selectList+"<tr id='"+divId+"_"+selectListCounter+"' ><td class='"+trStyle+"Img'><div id='"+divId+"_"+selectListCounter+"Action' style='display: none; font-size: 0px;'>"+onclickAktion+"</div><img src='images/check.gif' width='13' height='12' style='cursor:pointer;' onclick='"+onclickAktion+"'/>"+hiddenFieldsList+"</td>";
		
                for (var td = 0; td < tdContent.length; td++){
                    if(fieldLabel[td].length>0 && fieldWidth[td].length>0){
                        selectList = selectList+"<td class='"+trStyle+"' >";
                        selectList = selectList+tdContent[td];
                        selectList = selectList+"<input type='hidden' id='"+docFormName+divId+row+td+"' value='"+tdContent[td]+"' />" ;
                        selectList = selectList+"</td>";
                    }
                }
                selectList=selectList+"</tr>";
            }
        }
    }else{
        selectList = selectList+"<tr><td colspan='"+(tableCellNumber+1)+"' class='selectLineDiv' >Keine Eintr&auml;ge vorhanden</td></tr>";
    }
    selectList = selectList+"</table>";
    return selectList;
}
		
function getCloseListAction(divId){
    var closeAction="";
			
    //closeAction="<div style='width:12px;height:12px;cursor:pointer;'><img src='images/close.gif' width='10' height='10' style='cursor:pointer;padding-left:2px;' onclick='document.getElementById(\""+divId+"\").innerHTML=\"\";'/></div>";
			
			
    closeAction="<div class='buttonContainer' id='"+divId+"closeAction' onclick='document.getElementById(\""+divId+"\").innerHTML=\"\";' onmouseover='switchCssClass(\""+divId+"closeActionBgDiv\",\"buttonDivActivRed\");' onmouseout='switchCssClass(\""+divId+"closeActionBgDiv\",\"buttonDivRed\");'>";
    closeAction=closeAction+"<table class='buttonTab' cellpadding='0' cellspacing='0'><tr>";
    closeAction=closeAction+"<td class='buttonDivRed' id='"+divId+"closeActionBgDiv'>&nbsp;</td>";
    closeAction=closeAction+"<td class='buttonTextRed' id='"+divId+"closeAction_button_text'>Schliessen</td>";
    closeAction=closeAction+"</tr></tbody></table></div>";
			
    return closeAction;
		
}
		
function trimShowList(textValue, divId, fillFieldsName,  fillFieldsLabel, fillFieldsWidth,url, docFormName, readFieldsName){
						
    var cursorValues=textValue.substring(0,textValue.indexOf(">"));

    cursorValues=cursorValues.substring(cursorValues.indexOf("'")+1,cursorValues.length);
			
    cursorValues=cursorValues.substring(cursorValues.indexOf("pageCount"),cursorValues.length);
    cursorValues=cursorValues.substring(cursorValues.indexOf("'")+1,cursorValues.length);
			
    cursorValues=cursorValues.substring(cursorValues.indexOf("pageSize"),cursorValues.length);
    cursorValues=cursorValues.substring(cursorValues.indexOf("'")+1,cursorValues.length);
			
    cursorValues=cursorValues.substring(cursorValues.indexOf("totalSize"),cursorValues.length);
    cursorValues=cursorValues.substring(cursorValues.indexOf("'")+1,cursorValues.length);
    var totalSize=cursorValues.substring(0,cursorValues.indexOf("'"));
			
    var totalSizeText = "Bewegungen "+totalSize;
					
    var selectList= "";
						
    textValue = textValue.substring(textValue.indexOf(">")+1,textValue.length);
    textValue = textValue.replace("</csv>","");

    var fieldLabel = fillFieldsLabel.split("|");
    var fieldWidth = fillFieldsWidth.split("|");

    selectList=selectList+"<table id='"+divId+"SelectTable' style='table-layout:fixed;' class='selectTable'><colgroup><col width='18px'>";
    for (var tdEmp = 0; tdEmp< fieldLabel.length; tdEmp++){
        selectList=selectList+"<col style='width:"+fieldWidth[tdEmp]+"'>";
    }
    selectList=selectList+"<col width='18px'></colgroup>";

    var itemExist = false;
    if(textValue.indexOf("</details>")!=-1){
        itemExist=true;
    }
    if(itemExist){
        var item = textValue.substring(textValue.indexOf(">")+1,textValue.indexOf("</details>"));
        if(item.length>0){
            selectList=selectList+"<tr><td colspan='"+(fieldLabel.length+2)+"' style='border-left:1px solid #818a90;border-right:1px solid #818a90;' >";
            selectList = setItemTable(selectList,item,divId);
            selectList=selectList+"</td></tr>";
        }
        textValue = textValue.substring(textValue.indexOf("</details>")+10,textValue.length);
    }

    selectList=selectList+"<tr><td colspan='"+(fieldLabel.length+2)+"' style='border-bottom:1px solid #818a90;border-top:1px solid #818a90;' class='selectLineDiv' ><table border='0' cellpadding='0' cellspacing='0' width='100%' style='table-layout:auto;'><tr><td style='padding-right:5px;white-space:nowrap;font-size:8pt;font-weight:bold;'>";
    selectList=selectList+totalSizeText+"</td><td style='padding-right:5px;font-size:8pt;font-weight:bold;'></td><td width='90%' style='white-space:nowrap;'></td>";
    if(itemExist){
        selectList=selectList+"<td width='12'></td></tr></table></td></tr>";
    }else{
        selectList=selectList+"<td width='12' style='vertical-align:top;cursor:pointer;'><div style='width:12px;height:12px;cursor:pointer;'><img src='images/close.gif' width='10' height='10' style='cursor:pointer;padding-left:2px;' onclick='document.getElementById(\""+divId+"\").innerHTML=\"\";'/></div></td></tr></table></td></tr>";
    }
		
    selectList=selectList+"<tr><td class='selectTableHeaderTd' style='width:18px;'><img src='images/pixel_transparent.gif' width='16' height='1'/></td>";
    for (var tdH = 0; tdH < fieldLabel.length; tdH++){
        selectList=selectList+"<td class='selectTableHeaderTd' style='width:"+fieldWidth[tdH]+";'>"+fieldLabel[tdH]+"</td>";
    }
    selectList=selectList+"<td class='selectTableHeaderTd' style='width:18px;'><img src='images/pixel_transparent.gif' width='16' height='1'/></td></tr>";
			
    if(textValue.length>0){
        var rowsContent = textValue.split("||");
        var trStyle="";
        var selectListCounter=0;
			
        var fillFields = fillFieldsName.split("|");
        {
            for (var row = 0; row < rowsContent.length; row++){
                selectListCounter++;
					
                if(selectListCounter%2==0){
                    trStyle="selectLineDiv";
                }else{
                    trStyle="selectBgLineDiv";
                }
					
                var trContent = rowsContent[row];
                var tdContent = trContent.split(";");
						
                if(tdContent[0].length>0){
                    trStyle=tdContent[0];
                }
						
                selectList = selectList+"<tr id='"+divId+"_"+selectListCounter+"' ><td class='"+trStyle+"Img'>&#160;</td>";
                for (var td = 1; td < tdContent.length; td++){
                    selectList = selectList+"<td class='"+trStyle+"' >";
                    selectList = selectList+tdContent[td];
                    selectList = selectList+"</td>";
                }
                selectList=selectList+"<td class='"+trStyle+"Img'>&#160;</td>";
                selectList=selectList+"</tr>";
            }
        }
    }else{
        selectList = selectList+"<tr><td colspan='"+(fieldLabel.length+2)+"' class='selectLineDiv' >Keine Eintr&auml;ge vorhanden</td></tr>";
    }
    selectList = selectList+"</table>";
    return selectList;
}
function setItemTable(selectList, itemValue, divId) {	
    selectList = selectList+"<div class='innerContentTable' style='padding-bottom:7px;'><table border='0' cellpadding='0' cellspacing='0' width='100%' style='background-color: #FFFFFF;table-layout:auto;'><colgroup><col><col width='45%'><col><col width='45%'></colgroup>"
    selectList=selectList+"<tr><td colspan='4' style='padding-bottom:4px;'><table border='0' cellpadding='0' cellspacing='0' width='100%' style='background-color: #FFFFFF;table-layout:auto;'><tr>"
    selectList=selectList+"<td width='99%' class='textWheat8'>Hilfsmitteldaten</td><td width='12' style='vertical-align:top;cursor:pointer;'><div style='width:12px;height:12px;cursor:pointer;'><img src='images/close.gif' width='10' height='10' style='cursor:pointer;padding-left:2px;' onclick='document.getElementById(\""+divId+"\").innerHTML=\"\";'/></div></td>";
    selectList = selectList+"</tr></table></td></tr>"
    var itemRows = itemValue.split("||");
    for (var itemRow = 0; itemRow < itemRows.length; itemRow++){
        var trContent = itemRows[itemRow];
        var tdContent = trContent.split(";");
        selectList = selectList+"<tr>";
        if(tdContent[1].indexOf("colspan")!=-1){
            selectList = selectList+"<td class='textWheat8' "+tdContent[1]+">"+tdContent[0]+"</td>";
        }else if(tdContent[2].indexOf("colspan")!=-1){
            selectList = selectList+"<td class='contentLable'>"+tdContent[0]+"</td><td class='contentData' "+tdContent[2]+">"+tdContent[1]+"</td>";
        }else{
            selectList = selectList+"<td class='contentLable'>"+tdContent[0]+"</td><td class='contentData' >"+tdContent[1]+"</td>";
            selectList = selectList+"<td class='contentLable'>"+tdContent[2]+"</td><td class='contentData' >"+tdContent[3]+"</td>";
        }
        selectList = selectList+"</tr>";
    }
    selectList = selectList+"</table></div>";
    return selectList;
}
		
function setPageActions(pageCountStart,cursorCount, activePage,pageActions,url,pageSize,divId, fillFieldsName, fillFieldsLabel, fillFieldsWidth,pageCount,docFormName, readFieldsName,totalSize,addedOnclickAction){
			
    var ajaxFunctionName="ajaxSelectListRequest";
    //addedOnclickAction=addedOnclickAction.replace(/\"/g, "'");

    for (var curs=pageCountStart; curs<cursorCount; curs++){
        if(curs>=pageSize){
            if(curs==pageCountStart){
                pageActions=pageActions+"<div class='cursorStyle' style='font-weight:bold;' onclick='"+ajaxFunctionName+"(\""+url+"&pageSize="+pageSize+"\",\"false\",\""+divId+"\",\""+fillFieldsName+"\",\""+fillFieldsLabel+"\",\""+fillFieldsWidth+"\",\""+docFormName+"\",\""+readFieldsName+"\",\"\",\""+addedOnclickAction+"\");'>&#60;&#60;</div>";
            }
						
            if(curs==pageCountStart && curs>0){
                pageActions=pageActions+"<div class='cursorStyle' style='font-weight:bold;' onclick='"+ajaxFunctionName+"(\""+url+"&offset="+((pageSize*(curs-1))+1)+"&pageSize="+pageSize+"\",\"false\",\""+divId+"\",\""+fillFieldsName+"\",\""+fillFieldsLabel+"\",\""+fillFieldsWidth+"\",\""+docFormName+"\",\""+readFieldsName+"\",\"\",\""+addedOnclickAction+"\");'>&#60;</div>";
            }
        }
					
					
        if(curs==activePage){
            pageActions=pageActions+"<div class='cursorStyle' style='font-weight:bold;' onclick='"+ajaxFunctionName+"(\""+url+"&offset="+((pageSize*curs))+"&pageSize="+pageSize+"\",\"false\",\""+divId+"\",\""+fillFieldsName+"\",\""+fillFieldsLabel+"\",\""+fillFieldsWidth+"\",\""+docFormName+"\",\""+readFieldsName+"\",\"\",\""+addedOnclickAction+"\");'>"+(curs+1)+"</div>";
        }else{
            pageActions=pageActions+"<div class='cursorStyle' onclick='"+ajaxFunctionName+"(\""+url+"&offset="+((pageSize*curs))+"&pageSize="+pageSize+"\",\"false\",\""+divId+"\",\""+fillFieldsName+"\",\""+fillFieldsLabel+"\",\""+fillFieldsWidth+"\",\""+docFormName+"\",\""+readFieldsName+"\",\"\",\""+addedOnclickAction+"\");'>"+(curs+1)+"</div>";
        }
        if(curs<pageCount && cursorCount<pageCount ){
            if(curs==(cursorCount-1) ){
                pageActions=pageActions+"<div class='cursorStyle' style='font-weight:bold;' onclick='"+ajaxFunctionName+"(\""+url+"&offset="+((pageSize*(curs+1))+1)+"&pageSize="+pageSize+"\",\"false\",\""+divId+"\",\""+fillFieldsName+"\",\""+fillFieldsLabel+"\",\""+fillFieldsWidth+"\",\""+docFormName+"\",\""+readFieldsName+"\",\"\",\""+addedOnclickAction+"\");'>&#62;</div>";
            }
            if(curs==(cursorCount-1)){
                pageActions=pageActions+"<div class='cursorStyle' style='font-weight:bold;' onclick='"+ajaxFunctionName+"(\""+url+"&offset="+(totalSize-pageSize)+"&pageSize="+pageSize+"\",\"false\",\""+divId+"\",\""+fillFieldsName+"\",\""+fillFieldsLabel+"\",\""+fillFieldsWidth+"\",\""+docFormName+"\",\""+readFieldsName+"\",\"\",\""+addedOnclickAction+"\");'>&#62;&#62;</div>";
            }
        }
				
    }
    return pageActions;
}
		
function trimOneRowList(textValue, divId, fillFieldsName,  fillFieldsLabel, fillFieldsWidth,url, docFormName, readFieldsName){

    var testValues = textValue;

    testValues=testValues.substring(testValues.indexOf("totalSize"),testValues.length);
    testValues=testValues.substring(testValues.indexOf("'")+1,testValues.length);
    var totalSize=testValues.substring(0,testValues.indexOf("'"));
			
    if(totalSize>1){
        selectList = trimSelectList(textValue,divId, fillFieldsName, fillFieldsLabel, fillFieldsWidth,url,docFormName, readFieldsName,'');
        return selectList;
    }else{
        textValue = textValue.substring(textValue.indexOf(">")+1,textValue.length);
        textValue = textValue.replace("</csv>","");
					
        if(textValue.length>0){
            var rowsContent = textValue.split("||");
            var fillFields = fillFieldsName.split("|");
            if(rowsContent.length==1){
					
                var trContent = rowsContent[0];
                var tdContent = trContent.split(";");
						
                var onclickAktion ="";
                for (var i = 0; i < fillFields.length; i++){
                    onclickAktion=onclickAktion+"document.forms[\""+docFormName+"\"].elements[\""+fillFields[i]+"\"].value=\""+tdContent[i]+"\";";
                }
                eval(onclickAktion);
            }
        }
        return "";
    }
}
function resetSelectFields(formName,textFieldName, selectFillFields){
    if($(formName)){
        var formObj = $(formName);
        var fillFields = selectFillFields.split("|");
        for (var i = 0; i < fillFields.length; i++){
            if(fillFields[i].length>0 && formObj[fillFields[i]]&& fillFields[i]!=textFieldName){
                formObj[fillFields[i]].value='';
            }
        }
    }
}
function checkTextBoxDiv(comboBoxDivName,checkItemSelectTableName,inputFieldId){
    var divName = ""+comboBoxDivName;
    

    if($(divName).style.display == 'block'){
        $(divName).style.display = 'none';
    }else{
        if(checkItemSelectTableName!= undefined && checkItemSelectTableName.length>0){
            resetOptionColor(checkItemSelectTableName);
        }
        $(divName).style.display = 'block';
        
        if((document.body.clientHeight-60)<$(divName).offsetHeight){
            $(divName).style.height=(document.body.clientHeight-60)+"px";
        }
        if(inputFieldId !=undefined && inputFieldId.length>0){
            var optionValue = $(inputFieldId).value;
            if(optionValue.length>0){
                findOptionValue (optionValue, checkItemSelectTableName,comboBoxDivName);
            }
        }
    }
}
function resetOptionColor(checkItemSelectTableName) {
    for (var rowId=2; rowId<$(checkItemSelectTableName).rows.length; rowId++){
        var nextSearchRow = $(checkItemSelectTableName).rows[rowId];
        var nextRowId = nextSearchRow.id;
        for (var cellId=0; cellId<nextSearchRow.cells.length; cellId++){
            nextSearchRow.cells[cellId].className='optionFieldTd';
            if(nextSearchRow.cells[cellId].style.background!=''){
                nextSearchRow.cells[cellId].style.background='';
            }
        }
    //$(nextRowId).style.background='';
    }
    rowCounter = 1;
    nextRowIndex = 1;
}
function findOptionValue (inputValue, checkItemSelectTableName,selectListDivId) {
    var findValue=false;
    for (var rowId=2; rowId<$(checkItemSelectTableName).rows.length; rowId++){
        var nextSearchRow = $(checkItemSelectTableName).rows[rowId];
        var nextRowId = nextSearchRow.id;
        if($(nextRowId+"Span")){
            nextCellInnerHTML = $(nextRowId+"Span").innerHTML;
            //alert(nextCellInnerHTML+"; indexOF "+inputValue+"="+nextCellInnerHTML.toLowerCase().indexOf(inputValue.toLowerCase()));
            if(nextCellInnerHTML.toLowerCase().indexOf(inputValue.toLowerCase())==0){
                activRowSelectAction=$(nextRowId+"Action").innerHTML;
                eval(activRowSelectAction);
                for (var cellId=0; cellId<nextSearchRow.cells.length; cellId++){
                    nextSearchRow.cells[cellId].style.background='#CCCCCC';
                }
                $(selectListDivId).style.display='block';
                rowCounter = 1;
                nextRowIndex = rowId
                rowId = $(checkItemSelectTableName).rows.length;
                findValue = true;
            }
        }
    }
    return findValue;
}
function deleteParameter(url, paramVal) {
    if(url.indexOf(paramVal)>0){
        urlHelp =url.substring(url.indexOf(paramVal),url.length);
        var urlReplase="";
        if(urlHelp.indexOf('&')>0){
            urlReplase =url.substring(url.indexOf(paramVal),(url.indexOf(paramVal))+urlHelp.indexOf('&'));
        }else{
            urlReplase =url.substring(url.indexOf(paramVal),(url.indexOf(paramVal))+urlHelp.length);
        }
        url =url.replace("&"+urlReplase,"");
    }
    return url;
}
function checkKeyCode(event, eventDivId, idFieldName,minLen,noSpace, oneRowSelect){
    var preSelectAction = false;
    var eventDivIdAction = document.getElementsByName(eventDivId+'JsActionValue')[0].value;
    var eventDivIdEvalAction = "";
    eventDivIdEvalAction =setEvalActions(eventDivIdAction, ";");
    if(event!=null && event.keyCode==40 && $(eventDivId).innerHTML==''){
        eval(eventDivIdEvalAction);
    }else if(event!=null && (event.keyCode==8||event.keyCode==46)){
        var resetAction = document.getElementsByName(eventDivId+'JsActionValueReset')[0].value;
        eval(resetAction);
        eval(eventDivIdEvalAction);
    }else if (document.getElementsByName(idFieldName)[0].value.length >=minLen && event!=null && event.keyCode!=13 && event.keyCode!=9 && event.keyCode!=37 && event.keyCode!=39 && event.keyCode!=38 && event.keyCode!=40 && event.keyCode!=27){
        if(oneRowSelect){
            eval(eventDivIdEvalAction);
        }else{
            if(!noSpace || (noSpace && event.keyCode!=32) ){
                if(keyTimeOut != null){
                    window.clearTimeout(keyTimeOut);
                }
                preSelectAction = true;
                keyTimeOut = window.setTimeout(eventDivIdEvalAction, 1000);
            }
        }
    }
    return preSelectAction;
}
function setEvalActions(actionsList, actionsSeparator){
    var evalActions = "";
    while (actionsList.indexOf(actionsSeparator)!= -1) {
        var nextIdValue=actionsList.substring(0, actionsList.indexOf(actionsSeparator));
        while(nextIdValue.indexOf("'")!=-1){
            nextIdValue =nextIdValue.replace("'","\"");
        }
        evalActions = evalActions+"eval("+nextIdValue+");\n";
        actionsList = actionsList.substring((actionsList.indexOf(actionsSeparator)+1), actionsList.length);
    }
    return evalActions;
}
function switchCssClass(elementId , className){
    if($(elementId)){
        $(elementId).className=className;
    }
}
function checkItemSelect(key, selectListDivId, idFieldName  ) {
    if ((key == 40 || key == 38) && nextRowIndex == 0 && $(selectListDivId+"SelectTable") && $(selectListDivId+"SelectTable").rows[2] ){
        if($(selectListDivId+"SelectTable").rows[2].cells[0].className.indexOf("Img")!=-1 ){//liste ohne showDiv
            rowCounter = 1;
        }
    }else if((key != 40 && key != 38 & key != 37 && key != 39)){
        nextRowIndex = 1;
    }

    {
        if(navigator.userAgent.indexOf('Safari') != -1) {
            checkSafariItem(key, selectListDivId+"SelectTable");
        }else{
            checkItem(key, selectListDivId+"SelectTable");
        }
    }

    if (key == 27) { // escape
        $(selectListDivId).innerHTML='';
    }else {
    { // SingleSelect
        if (key == 8 ) {// backspace
            activRowSelectAction="";
        }else if (key == 13 && activRowSelectAction.length >0) { // enter
            eval(activRowSelectAction);
            activRowSelectAction="";
            nextRowIndex = 0;
        }
    }
    }
}
function checkSafariItem (key, checkSafariItemTableName) {

    if (key == 40 && $(checkSafariItemTableName) && $(checkSafariItemTableName).rows[Math.floor(nextRowIndex)+rowCounter] ) {// Pfeil nach unten
        setNotActiveRow(checkSafariItemTableName, (nextRowIndex));

        if(nextRowIndex == 0 ){
            nextRowIndex = -1;
        }else{
            if(nextRowIndex == -1){
                nextRowIndex = 1;
            }else{
                nextRowIndex = nextRowIndex+(rowCounter/2);
            }
        }

        setActiveRow(checkSafariItemTableName, nextRowIndex);
    }

    if (key == 38 && $(checkSafariItemTableName) && $(checkSafariItemTableName).rows[(Math.floor(nextRowIndex-(rowCounter/2)))] && nextRowIndex>2) {// Pfeil nach oben
        setNotActiveRow(checkSafariItemTableName, (nextRowIndex));

        nextRowIndex = nextRowIndex-(rowCounter/2);

        setActiveRow(checkSafariItemTableName, nextRowIndex);
    }

}
function checkItem (key, checkItemTableName) {

    if (key == 40 && $(checkItemTableName) && $(checkItemTableName).rows[nextRowIndex+rowCounter]) {// Pfeil nach unten

        setNotActiveRow(checkItemTableName, nextRowIndex);

        if(nextRowIndex == 0){
            nextRowIndex = 1;
        }else{
            nextRowIndex = nextRowIndex+rowCounter;
        }
        setActiveRow(checkItemTableName, nextRowIndex);
    }


    if (key == 38 && $(checkItemTableName) && $(checkItemTableName).rows[(nextRowIndex-rowCounter)]  && nextRowIndex>2) {// Pfeil nach oben
        setNotActiveRow(checkItemTableName, nextRowIndex);

        nextRowIndex = nextRowIndex-rowCounter;

        setActiveRow(checkItemTableName, nextRowIndex);

    }
}
function setNotActiveRow(setNotActiveRowTableName, nextRowIndexValue){

    if($(setNotActiveRowTableName).rows[nextRowIndexValue] ){
        nextRow = $(setNotActiveRowTableName).rows[nextRowIndexValue];
        for (var i=0; i<nextRow.cells.length; i++){
            entryClassName = nextRow.cells[i].className;
            if(entryClassName.indexOf("Active")!= -1){
                entryClassName = entryClassName.substring(0, (entryClassName.length-6));
                nextRow.cells[i].className = entryClassName;
            }
        }
    }
}
function setActiveRow(setActiveRowTableName, nextRowIndexValue){

    if($(setActiveRowTableName)){
        if($(setActiveRowTableName).rows[nextRowIndexValue] ){
            nextRow = $(setActiveRowTableName).rows[nextRowIndexValue];

            var nextRowId=nextRow.id;

            if($(nextRowId+"Action")){
                activRowSelectAction = $(nextRowId+"Action").innerHTML;
            }else{
                activRowSelectAction="";
            }

            if(nextRowIndexValue >= 1 ){
                for (var i=0; i<nextRow.cells.length; i++){
                    entryClassName = nextRow.cells[i].className;
                    if(entryClassName.indexOf("Active")== -1){
                        nextRow.cells[i].className = entryClassName+"Active";
                    }
                }
            }
        }
    }
    return activRowSelectAction;
}

