arrSelects 		    = new Array();

function updateSelectBox(strTarget,strCMD,strType,bShowActions,strItem){
    strBox = "";
    
    if(strCMD=="delete" && intSelectCounter[strTarget]>1){
        intSelectCounter[strTarget]--;    
        for (var x = 0; x < arrSelectedItems[strTarget].length; ++x) {
	if (x >= strItem) {
		arrSelectedItems[strTarget][x] = arrSelectedItems[strTarget][x + 1];
	}
        } 
	arrSelectedItems[strTarget].pop();

    }else{
        if(strCMD!="delete" && intSelectCounter[strTarget]<arrItems[strTarget].length-1){
            intSelectCounter[strTarget]++;    
        }
    }
        
    arrSelects[strTarget] = arrSelectedItems[strTarget];
        
    for(i=0;i<intSelectCounter[strTarget];i++){
        
        if(!bShowActions){
	        strBox = strBox + '<img src="fileadmin/intern/res/images/layout/mybonedo/transparent.gif" style="width:16px;height:16px;float:left;margin-right:4px;" /><img src="fileadmin/intern/res/images/layout/mybonedo/transparent.gif" style="width:16px;height:16px;float:left;margin-right:4px;" /><input type=hidden id="tx_bonedomysubscriptions_pi1_'+strType+'_id" name="tx_bonedomysubscriptions_pi1['+strType+']" value="'+(arrSelectedItems[strTarget][i]?arrSelectedItems[strTarget][i]:'0')+'" />';	    		    		
	        
	        strBox = strBox + '<DIV class=tx_bonedomysubscriptions_pi1_selectarea>'+ 
            '<DIV class=tx_bonedomysubscriptions_pi1_selectwrap onmouseover="changeSelectStatus(\''+strTarget+'_nl'+i+'\',\'tx_bonedomysubscriptions_pi1_select_on\');" onmouseout="changeSelectStatus(\''+strTarget+'_nl'+i+'\',\'tx_bonedomysubscriptions_pi1_select_off\');">' +
            '<DIV class="tx_bonedomysubscriptions_pi1_selectbutton" id='+strTarget+'_nb'+i+'>'+(arrItems[strTarget][arrSelectedItems[strTarget][i]]?arrItems[strTarget][arrSelectedItems[strTarget][i]]:'keine Auswahl')+'</DIV>' +
            '<DIV class="tx_bonedomysubscriptions_pi1_select_off tx_bonedomysubscriptions_pi1_select"  id="'+strTarget+'_nl'+i+'">' +
            '<UL>';
        	
        	for(var intKey in arrItems[strTarget]){        			            		
        		if(intKey!=arrSelectedItems[strTarget][i]){	
    		        strBox = strBox + '<LI><A href="javascript: return false;" onClick="changeSelectValue(\''+strTarget+'_nb'+i+'\',this.innerHTML,\'tx_bonedomysubscriptions_pi1_'+strType+'_id\',\''+intKey+'\',\''+strTarget+'\',\''+i+'\');arrSelects[\''+strTarget+'\']['+i+']=this.innerHTML;changeSelectStatus(\''+strTarget+'_nl'+i+'\',\'tx_bonedomysubscriptions_pi1_select_off\'); return false;">'+arrItems[strTarget][intKey]+'</A></LI>';
                }
            }        
            
            if(arrSelectedItems[strTarget][i]>0){
    		    strBox = strBox + '<LI><A href="javascript: return false;" onClick="changeSelectValue(\''+strTarget+'_nb'+i+'\',this.innerHTML,\'tx_bonedomysubscriptions_pi1_'+strType+'_id\',\'0\',\''+strTarget+'\',\''+i+'\');arrSelects[\''+strTarget+'\']['+i+']=this.innerHTML;changeSelectStatus(\''+strTarget+'_nl'+i+'\',\'tx_bonedomysubscriptions_pi1_select_off\'); return false;">keine Auswahl</A></LI>';        	
            }    
            
            strBox = strBox + '</UL></DIV></DIV></DIV>';
        }else{
            if(i==0 && intSelectCounter[strTarget]>1){
                strBox = strBox + '<img src="fileadmin/intern/res/images/layout/mybonedo/transparent.gif" style="width:16px;height:16px;float:left;margin-right:4px;" /><img src="fileadmin/intern/res/images/layout/mybonedo/transparent.gif" style="width:16px;height:16px;float:left;margin-right:4px;" /><input type=hidden id="tx_bonedomysubscriptions_pi1_'+strType+'_id_'+i+'" name="tx_bonedomysubscriptions_pi1['+strType+']['+i+']" value="'+(arrSelectedItems[strTarget][i]?arrSelectedItems[strTarget][i]:'0')+'" />';	    		    		            
            }else{  
                if(i==(intSelectCounter[strTarget]-1) && intSelectCounter[strTarget]>1 && intSelectCounter[strTarget]<arrItems[strTarget].length-1){
                    strBox = strBox + '<a href="javascript: return false;" onClick="updateSelectBox(\''+strTarget+'\',\'add\',\''+strType+'\',\''+bShowActions+'\'); return false;"><img src="fileadmin/intern/res/images/layout/mybonedo/mybonedo_subscriptions_add.png" style="width:16px;height:16px;float:left;margin-right:4px;border:0px;" /></a><a href="javascript: return false;" onClick="updateSelectBox(\''+strTarget+'\',\'delete\',\''+strType+'\',\''+bShowActions+'\',\''+i+'\'); return false;"><img src="fileadmin/intern/res/images/layout/mybonedo/mybonedo_subscriptions_delete.png" style="width:16px;height:16px;float:left;margin-right:4px;border:0px;" /></a><input type=hidden id="tx_bonedomysubscriptions_pi1_'+strType+'_id_'+i+'" name="tx_bonedomysubscriptions_pi1['+strType+']['+i+']" value="'+(arrSelectedItems[strTarget][i]?arrSelectedItems[strTarget][i]:'0')+'" />';	    		    		                
                }else{          
                    if(i==(intSelectCounter[strTarget]-1) && intSelectCounter[strTarget]<arrItems[strTarget].length-1){
                        strBox = strBox + '<img src="fileadmin/intern/res/images/layout/mybonedo/transparent.gif" style="width:16px;height:16px;float:left;margin-right:4px;" /><a href="javascript: return false;" onClick="updateSelectBox(\''+strTarget+'\',\'add\',\''+strType+'\',\''+bShowActions+'\'); return false;"><img src="fileadmin/intern/res/images/layout/mybonedo/mybonedo_subscriptions_add.png" style="width:16px;height:16px;float:left;margin-right:4px;border:0px;" /></a><input type=hidden id="tx_bonedomysubscriptions_pi1_'+strType+'_id_'+i+'" name="tx_bonedomysubscriptions_pi1['+strType+']['+i+']" value="'+(arrSelectedItems[strTarget][i]?arrSelectedItems[strTarget][i]:'0')+'" />';	    		    		            
                    }else{
                        strBox = strBox + '<img src="fileadmin/intern/res/images/layout/mybonedo/transparent.gif" style="width:16px;height:16px;float:left;margin-right:4px;" /><a href="javascript: return false;" onClick="updateSelectBox(\''+strTarget+'\',\'delete\',\''+strType+'\',\''+bShowActions+'\',\''+i+'\'); return false;"><img src="fileadmin/intern/res/images/layout/mybonedo/mybonedo_subscriptions_delete.png" style="width:16px;height:16px;float:left;margin-right:4px;border:0px;" /></a><input type=hidden id="tx_bonedomysubscriptions_pi1_'+strType+'_id_'+i+'" name="tx_bonedomysubscriptions_pi1['+strType+']['+i+']" value="'+(arrSelectedItems[strTarget][i]?arrSelectedItems[strTarget][i]:'0')+'" />';	    		    		            
                    }
                }
            }
            strBox = strBox + '<DIV class=tx_bonedomysubscriptions_pi1_selectarea>'+ 
            '<DIV class=tx_bonedomysubscriptions_pi1_selectwrap onmouseover="changeSelectStatus(\''+strTarget+'_nl'+i+'\',\'tx_bonedomysubscriptions_pi1_select_on\');" onmouseout="changeSelectStatus(\''+strTarget+'_nl'+i+'\',\'tx_bonedomysubscriptions_pi1_select_off\');">' +
            '<DIV class="tx_bonedomysubscriptions_pi1_selectbutton" id='+strTarget+'_nb'+i+'>'+(arrItems[strTarget][arrSelectedItems[strTarget][i]]?arrItems[strTarget][arrSelectedItems[strTarget][i]]:'keine Auswahl')+'</DIV>' +
            '<DIV class="tx_bonedomysubscriptions_pi1_select_off tx_bonedomysubscriptions_pi1_select"  id="'+strTarget+'_nl'+i+'">' +
            '<UL>';
        	
        	for(var intKey in arrItems[strTarget]){  
        		// alert(intKey);      			            		
        		if(intKey!=arrSelectedItems[strTarget][i]){	
    		        strBox = strBox + '<LI><A href="javascript: return false;" onClick="changeSelectValue(\''+strTarget+'_nb'+i+'\',this.innerHTML,\'tx_bonedomysubscriptions_pi1_'+strType+'_id_'+i+'\',\''+intKey+'\',\''+strTarget+'\',\''+i+'\');arrSelects[\''+strTarget+'\']['+i+']='+intKey+';changeSelectStatus(\''+strTarget+'_nl'+i+'\',\'tx_bonedomysubscriptions_pi1_select_off\'); return false;">'+arrItems[strTarget][intKey]+'</A></LI>';
                }
            }        
            
            if(arrSelectedItems[strTarget][i]>0){
    		    	strBox = strBox + '<LI><A href="javascript: return false;" onClick="changeSelectValue(\''+strTarget+'_nb'+i+'\',this.innerHTML,\'tx_bonedomysubscriptions_pi1_'+strType+'_id_'+i+'\',\'0\',\''+strTarget+'\',\''+i+'\');arrSelects[\''+strTarget+'\']['+i+']=this.innerHTML;changeSelectStatus(\''+strTarget+'_nl'+i+'\',\'tx_bonedomysubscriptions_pi1_select_off\'); return false;">keine Auswahl</A></LI>';        	
            }    
            
            strBox = strBox + '</UL></DIV></DIV></DIV>';
        }
    }
    document.getElementById(strTarget).innerHTML = strBox;
}    
    
function changeSelectStatus(myElementID,newClassName) {
	document.getElementById(myElementID).className = newClassName+" tx_bonedomysubscriptions_pi1_select";
}

function changeSelectValue(strTarget,strValue,strTargetID,strKey,strParentTarget,strNumber){
    document.getElementById(strTarget).innerHTML = strValue;   
    document.getElementById(strTargetID).value = strKey;
}


