function openPlainWindow(theURL,winName,features) { 
  theWin = window.open(theURL,winName,features);
  theWin.focus();
}

function openCalendar(formname, fieldnr, origin) {
      if (origin == "root")   var openURI = 'lib/calendar.htm?' + formname + ',' + fieldnr + ',-1,-1';
      if (origin == "subdir") var openURI = '../lib/calendar.htm?' + formname + ',' + fieldnr + ',-1,-1';
      openPlainWindow(openURI,'Kalender','width=140,height=138,top=215,left=610');
}

function fillList(items, itemsID, selectedItems, formname, listname) {
    
    with (document[formname][listname]) {
        
        for (i=0; i<document[formname][listname].lenght; i++) options[0] = null;
        
        for (i=0; i<items.length; i++) {
            newOption = new Option(items[i]);
            options[i]       = newOption;
            options[i].value = itemsID[i];
    
            if (listname == "lbLocation" && itemsID[i] == selectedItems) {
                options[i].selected = true;
            }
    
            if (listname == "lbCategory[]") {
                for (k=0; k < selectedItems.length; k++) {
                    if (selectedItems[k] == itemsID[i]) {
                        options[i].selected = true;
                    }
                }
            } 
        }
  
        if (listname == "lbCategory[]")  newOption = new Option("-----------------------------------------------");
        if (listname == "lbLocation")    newOption = new Option("----------------------------------------");
        options[i] = newOption;
        options[i].value = "0";
    }
}

