

   // ------------------------------------------------------------------------------------------------------------------------------------------------
   // select lists
   // ------------------------------------------------------------------------------------------------------------------------------------------------
   
   
   function listClear ( objList ) {
      if ( objList.length == 0 ) return;
      for ( i=objList.length-1; i >= 0; i-- ) objList.remove(0);
   }



   // NOTE: see note for "newOption()" function !!
   function listCopy ( srcList, destList, documentObject  ) {
      for ( i=0; i < srcList.length; i++ ) {
         listAddItem ( destList, srcList.options[i].value, srcList.options[i].text, documentObject );
      }
   }

   // NOTE: see note for "newOption()" function !!
   function listAddItem ( objList, id, text, documentObject ) {
      objList.add ( newOption(id,text,documentObject) );
   }

   // NOTE: e.g. if you want to add new entries to a select list of an opener window: create always an option element with "opener.document.createElement()" !!!
   // so, the call to other list than the current document should be done like:  newOption("id","text",opener.document);
   function newOption ( id, text, documentObject ) {  
      element        = null;
      if ( documentObject == null ) element = document.createElement('option');
      else                          element = documentObject.createElement('option');
      element.value  = id
      element.text   = text;
      return element;
   }




   function listContains ( objList, key ) {
      for ( i=0; i < objList.length; i++ ) {
         if ( objList.options[i].value == key ) return true;
      }
      return false;
   }

   function listGetSelectedValue ( name ) {
      if ( document.all[name].selectedIndex == -1 ) return null;
      return document.all[name].options[document.all[name].selectedIndex].value;
   }

   function listSelectEntry ( objList, value ) {
      for ( i=0; i < objList.length; i++ ) {
         if ( objList.options[i].value == value ) {
            objList.selectedIndex = i;
            return;
         }
      }
   }



         
   function listRemoveItem ( objList ) {
      if ( objList.selectedIndex == -1 ) return;
      objList.remove ( objList.selectedIndex );
   }
   
   
   

   function listMoveUp ( objList ) {
      ix = objList.selectedIndex;
      if ( ix > 0 ) {
         listSwapEntries ( objList, ix, ix-1 ); 
      }
   }

   function listMoveDown ( objList ) {
      ix = objList.selectedIndex;
      if ( ix < objList.length - 1 ) {
         listSwapEntries ( objList, ix, ix+1 ); 
      }
   }

   function listMoveTop ( objList ) {
      ix = objList.selectedIndex;
      for ( ; ix > 0; ix-- ) {
         listSwapEntries ( objList, ix, ix-1 ); 
      }
   }

   function listMoveBottom ( objList ) {
      ix = objList.selectedIndex;
      for ( ; ix < objList.length - 1; ix++ ) {
         listSwapEntries ( objList, ix, ix+1 ); 
      }
   }

   function listSortAlpha ( objList ) { // algo: by smallest element
      for ( i=0; i < objList.length; i++ ) {
         smallest = i;
         for ( j=i; j < objList.length; j++ ) {
            if ( objList[j].text.toUpperCase() < objList[smallest].text.toUpperCase() ) smallest = j;
         }            
         if ( i != smallest ) listSwapEntries ( objList, i, smallest ); 
      }
   }
   
   function listSwapEntries ( objList, ixFrom, ixTo ) {
      objVal   = objList.options[ixFrom].value;
      objText  = objList.options[ixFrom].text;
      objList.options[ixFrom].value = objList.options[ixTo].value;
      objList.options[ixFrom].text  = objList.options[ixTo].text;
      objList.options[ixTo].value   = objVal;
      objList.options[ixTo].text    = objText;
      objList.selectedIndex         = ixTo;
   }

   function listBuildPositionString ( objList ) {     // return all element values seperated by comma
      var s = "";
      for ( i=0; i < objList.length; i++ ) {
         s += "," + objList.options[i].value;
      }
      if ( s.length > 0 ) return s.substring(1);
      return "";
   }


         


   // ------------------------------------------------------------------------------------------------------------------------------------------------
   // windows
   // ------------------------------------------------------------------------------------------------------------------------------------------------

   function openWindow ( url, name, width, height, scrollbar, resizable ) {
      if ( scrollbar == null ) scrollbar = 'no';
      if ( resizable == null ) resizable = 'no';
      var ref = window.open ( url, name, "height=" + height + ",width=" + width + ",resizable=" + resizable + ",dependent=no,scrollbars=" + scrollbar + ",menubar=no,status=yes,toolbar=no" );
      ref.focus();
   }
   
   
   
   
   // ------------------------------------------------------------------------------------------------------------------------------------------------
   // strings, convertings
   // ------------------------------------------------------------------------------------------------------------------------------------------------

   function trim ( s ) {
      if ( s == null ) return null;
      for ( i=0; s.charAt(i) == ' '; i++ );
      for ( j=s.length-1; s.charAt(j) == ' '; j-- );
      return s.substring(i,j+1)
   }
   
	function isEmpty ( s ) {
    	if ( s == null ) return true;
    	if ( trim(s) == 0 || s.length == 0 ) return true;
		return false;
   	}

   
   
   
   // ------------------------------------------------------------------------------------------------------------------------------------------------
   // input checks
   // ------------------------------------------------------------------------------------------------------------------------------------------------
   
	function checkTextField( field, correctionMessage ) {
	    if( isEmpty(field.value) ) {
	        alert( correctionMessage );
	        field.focus();
	        return false;
	    }
	    return true;
   	}

    // an email address has to contain at least an "add" and one dot...
	function checkEMailField( field, correctionMessage ) {
	    if ( !checkTextField(field,correctionMessage) ) return false;
	    if( field.value.indexOf('@') <= 0 || field.value.indexOf('.') <= 0 ) {  
	        alert( correctionMessage );
	        field.focus();
	        return false;
	    }
	    return true;
   	}

    // a radio group has to contain one selected item
    function checkRadioGroup( fieldGroup, correctionMessage ) {
        for( i=0; i < fieldGroup.length; i++ ) {
            if( fieldGroup[i].checked ) return true;
        }
        alert( correctionMessage );
        if ( fieldGroup.length > 0 ) fieldGroup[0].focus();
        return false;
    }


   
   
   
   // ------------------------------------------------------------------------------------------------------------------------------------------------
   // date functions
   // ------------------------------------------------------------------------------------------------------------------------------------------------
   
    var arrWeekdays_de = new Array ( "Montag", "Dienstag", "Mittwoch",  "Donnerstag", "Freitag", "Samstag",  "Sonntag" );
    var arrWeekdays_en = new Array ( "Monday", "Tuesday",  "Wednesday", "Thursday",   "Friday",  "Saturday", "Sunday"  );

    var arrMonth_de = new Array ( "Januar",  "Februar",  "M&auml;rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember" );
    var arrMonth_en = new Array ( "January", "February", "March",     "April", "May", "June", "July", "August", "September", "October", "November", "December" );
   
   
    function getWeekdayText ( day, language ) {
        if ( day >= 1 && day <= 7 ) {
            if ( "de" == language ) {
                return arrWeekdays_de [ day-1 ];
            }
            return arrWeekdays_en [ day-1 ];
        }
        return "{invalid day}";
    }
    
    function getMonthText ( month, language ) {
        if ( month >= 1 && month <= 12 ) {
            if ( "de" == language ) {
                return arrMonth_de [ month ];
            }
            return arrMonth_en [ month ];
        }
        return "{invalid month}";
    }


