/******************************************************************************
 *
 * Contains all JavaScript functions in alphabetical sequence used for the vSAF
 * Homepage
 *
 * @author      Hannes 'Geronimo' Schmid
 * @filesource  include.js
 *
 * @copyright   vSAF 2011
 *
 *****************************************************************************/

//-----------------------------------------------------------------------------
// Local constants
//-----------------------------------------------------------------------------
var c_keycode_return        =    13; // key code for keyboard key 'Return'
var c_msg_delay             =  1500; // delay in ms (--> 1.5s) to show message
var c_msg_delay_long        =  6000; // long delay (6s) to show message
var c_state_loaded          =     4; // readyState 'Loaded' (transfer complete)
var c_max_no_funct          =     3; // max. no functions per member of the same function type

// Max. number of characters in input and db fields
//  (if values are changed make sure the relevant db field and the definition
//   in constants.php is changed!)
var c_video_type_file       =     1; // video type 1 (see constants.php)
var c_video_type_youtube    =     2; // video type 2 (see constants.php)
var c_max_size_title        =    80; // max no characters in a group/link/download/video title
var c_max_size_filename     =    40; // max no characters in a file name
var c_max_size_fotograf     =    40; // max no characters in name of the photographer
var c_max_size_linkname     =    40; // max no characters in a link name
var c_max_size_menu_1       =    15; // max no characters for menu left entries
var c_max_size_menu_23      =    40; // max no characters for menu level 2+3 entries
var c_max_size_page_title   =    50; // max no characters in a page title
var c_max_size_url          =   200; // max no characters in an URL
var c_max_size_text         = 65535; // max no characters in a text field
// Max number of characters in field of member table
var c_min_size_username     =     3; // min no characters in username (account)
var c_max_size_username     =    15; // max no characters in username (account)
var c_min_size_password     =     6; // min no characters in password
var c_max_size_password     =    15; // max no characters in password
var c_max_size_callsign     =    30; // max no characters in callsign
var c_max_size_name         =    40; // max no characters in name
var c_max_size_firstname    =    40; // max no characters in firstname
var c_max_size_address      =    40; // max no characters in address
var c_max_size_plz          =    10; // max no characters in PLZ
var c_max_size_location     =    40; // max no characters in location of user
var c_max_size_profession   =    60; // max no characters in users profession
var c_min_size_tel          =    10; // max no characters in telefone number
var c_max_size_tel          =    20; // max no characters in telefone number
var c_max_size_email        =    40; // max no characters in email adress
var c_max_size_skype        =    40; // max no characters in skype id of user
var c_max_size_airport_name =    20; // maximal length of a airport name
var c_max_size_icao_code    =     4; // maximal length of ICAO code
var c_max_size_lat_long     =    10; // maximal size of lattitude / longitude
var c_max_size_reason       =    40; // max no characters in inactivity reason
var c_max_size_wing_name    =    10; // max no characters in wing name
var c_max_size_immatr       =     6; // max no characters in plane registration
var c_max_size_parkp        =    40; // max no characters in park position
// Value rages for input fields
var c_max_size_status       =    20; // maximal no characters in user/admin status
var c_min_size_webpic       =    16; // minimal width/height of a web picture
var c_max_size_webpic       =   740; // maximal width/height of a web picture
var c_min_size_video        =   150; // minimal width/height of a video
var c_max_size_video        =   740; // maximal width/height of a video
var c_min_lab_offset        =  -999; // min value in LabX/YOff (t_airports)
var c_max_lab_offset        =   999; // max value in LabX/YOff (t_airports)
var c_lat_ch_min            =  45.5; // most southern point Switzerland
var c_lat_ch_max            =  47.8; // most northern point Switzerland
var c_long_ch_min           =  5.96; // most western point Switzerland
var c_long_ch_max           =  10.5; // most estern point Switzerland
//
//) || (lat > c_lat_ch_max) || (llong < c_long_ch_min) || (llong > c_long_ch_max))


// File specification for PHP scripts
var c_file_home             = "index.php";              // file spec for index.php (Home)
var c_file_login            = "login.php";              // file spec for loign.php
var c_file_admin_ajax       = "ajax/admin_ajax.php";    // file spec for admin_ajax.php
var c_file_download_ajax    = "ajax/download_ajax.php"; // file spec for download_ajax.php
var c_file_element_ajax     = "ajax/element_ajax.php";  // file spec for element_ajax.php
var c_file_link_ajax        = "ajax/link_ajax.php";     // file spec for link_ajax.php
var c_file_news_ajax        = "ajax/news_ajax.php";     // file spec for news_ajax.php
var c_file_picture_ajax     = "ajax/picture_ajax.php";  // file spec for picture_ajax.php
var c_file_video_ajax       = "ajax/video_ajax.php";    // file spec for video_ajax.php
var c_file_vsaf_ajax        = "ajax/vsaf_ajax.php";     // file spec for vsaf_ajax.php
var c_dir_flowplayer        = "../../flowplayer/";      // directory where flow player is located
var c_file_flowplayer_swf   = "flowplayer-3.2.7.swf";   // filename of flowplayer


//-----------------------------------------------------------------------------
// Local functions (soly used inside the functions in this module, must apear
//                  before they are used! Therefore, the functions are not
//                  listed in alphabetical sequence)
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
//
// Description:  Create the xmlHttp Request
//
function create_request()
// Parameters:
//  Input:      None
//  Output:     Reference to created xmlHttp object
//
//-----------------------------------------------------------------------------
{
  var xmlHttp = null;             // initialize object
  try                             // try to create xmlHttp object
  {
    xmlHttp = new XMLHttpRequest();
  }                               // xmlHttp object for IE7 and modern browsers
  catch (e)                       // xmlHttp object can not be created
  {
    try                           // try to create ActiveX object for IE6
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }                             // ActiveX object for Internet Explorer 6
    catch (E)                     // ActiveX object for IE6 can not be created
    {
      try                         // try to create ActiveX object for IE5
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }                           // ActiveX object for Internet Explorer 5
      catch (failed)              // also activeX object for IE5 can not be created
      {
        xmlHttp = null;           // initialize object
        alert("Browser unterstützt AJAX nicht");
      }                           // output error message
    }
  }
  return xmlHttp;                 // return created object to the caller
}


//-----------------------------------------------------------------------------
//
// Description  Return the x, y coordinates of the specified object on a page
//              (pinched from http://www.quirksmode.org/js/findpos.html)
//
function findPos(obj)             // object to find position on page
//
// Output       Returns the x, y coordinates of the object
//
//-----------------------------------------------------------------------------
{
  var curleft = 0;                // initialize x coordinate
  var curtop  = 0;                // initialize y coordinate
  if (obj.offsetParent)
  {
    do
    {
      curleft += obj.offsetLeft;
      curtop  += obj.offsetTop;
    } while (obj = obj.offsetParent); // '=' is not a syntax error !
  }
  return [curleft, curtop];       // return coordinates of object as array
}


//-----------------------------------------------------------------------------
//
// Description  Encode and escape object passed
//
function enc(obj)           // object to encode and escape
//
// Output       Returns the encoded and escaped object
//
//-----------------------------------------------------------------------------
{
  return escape(encodeURIComponent(obj));
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the ojbect passed exists
//
function exists(obj)        // object to check
//
// Output       Returns on of the following values
//              - false object does not exist
//              - true  object exists
//
//-----------------------------------------------------------------------------
{
  if (typeof(obj) == 'undefined') {return false;}
                                  // object does not exit
  return true;                    // object exists
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the field is numeric (i.e. an integer)
//
function is_numeric(field)        // field to check
//
// Output       Returns on of the following values
//              - false content of field is not numeric
//              - true  content of field is numeric
//
//-----------------------------------------------------------------------------
{
  var valid_chars = "-0123456789"; // list of legal characters in field
  for (i = 0; i < field.length; i++)
  {                               // loop trough all characters in field
    if (valid_chars.indexOf(field.charAt(i)) == -1)
    {                             // current characters is not numeric
      return false;               // field content is not numeric
    }
  }
  return true;                    // field content is numeric
}


/**
 * Checks if the value passed is a PHP script of the form <name>.php
 *
 * @param  link string  Link to check if it is a PHP script
 * @return      bool    Returns on of the following values
 *                      - NULL  link is just empty
 *                      - false link is not a php script of form <name>.php
 *                      - true  link is a php script of form <name>.php
 */
function is_script(link)
{
  link.value = link.value.toLowerCase(); // make sure the link is lower case
  if (link.value == "")          // check if a link is specified
  {return null;}                  // no link specified --> return NULL
  else                            // link has some content
  {
    var parts = link.value.split("."); // separate it into pieces
    if (parts.length != 2)        // content is not just <name>.php
    {return false;}               // link does not contain a PHP script
    else
    {
      if (parts[1] == "php")      // link contains <name>.php
      {return true;}              // link contains a php script
      else
      {return false;}             // link does not contains a php script
    }
  }
}


/**
 * Returns the current date as string in the form 'yyyymmdd'
 *
 * @return          Todays date in format 'yyyymmdd'
 */
function get_today()
{
  var date = new Date();          // get current date object
  var dd   = date.getDate();      // get day
  var mm   = date.getMonth() + 1; // get month (January is 0!)
  var yyyy = date.getFullYear();  // get year in format 'yyyy'
  if (dd < 10) {dd = '0' + dd;} else {dd = dd + '';}
                                  // make day two digits and string
  if (mm < 10) {mm = '0' + mm;} else {mm = mm + '';}
                                  // make month two digits and string
  yyyy = yyyy + '';               // make year a string
  return yyyy + mm + dd;          // return today
}


/**
 * Normalise date passed in form [d]d.[m]m.[yy]yy to form 'yyyymmdd'.
 *
 * @param  in_date  string  Input date to normalise
 * @return          string  Normalised date in format 'yyyymmdd'
 */
function normalise_date(in_date)
{
  var date = in_date.split('.');  // separate date into its component
  var dd   = parseInt(date[0]);   // day as int
  var mm   = parseInt(date[1]);   // month as int
  var yy   = parseInt(date[2]);   // year as int
  if (dd < 10) {dd = '0' + dd;} else {dd = dd + '';}
                                  // make day two digits and string
  if (mm < 10) {mm = '0' + mm;} else {mm = mm + '';}
                                  // make month two digits and string
  if (yy < 100)                   // make year four digits and string
  {
    if (yy < 10) {yy = '0' + yy;} else {yy = yy + '';}
    yy = '20' + yy;
  }
  else {yy = yy + '';}
  return yy + mm + dd;            // return normalise date
}


//-----------------------------------------------------------------------------
//
// Description: Checks if the field only contains basic characters, d.h A..Z,
// a..z, 0..9 and space.
//
function basic_char_ok(field)      // field to validate
//
// Output        0 if field only contains legal characters
//
//-----------------------------------------------------------------------------
{
  var regex = /^[A-Za-z0-9| ]*$/;
  return field.search(regex);
}


//-----------------------------------------------------------------------------
//
// Description: Checks if the field only contains basic characters, d.h A..Z,
// a..z and 0..9.
//
function basic_char_nosp_ok(field)  // field to validate
//
// Output        0 if field only contains legal characters
//
//-----------------------------------------------------------------------------
{
  var regex = /^[A-Za-z0-9]*$/;
  return field.search(regex);
}


//-----------------------------------------------------------------------------
//
// Description: Checks if the field only contains registration characters,
// d.h A..Z, 0..9 and '-'.
//
function immatr_char_ok(field)  // field to validate
//
// Output        0 if field only contains legal characters
//
//-----------------------------------------------------------------------------
{
  var regex = /^[A-Z0-9\-]*$/;
  return field.search(regex);
}


//-----------------------------------------------------------------------------
//
// Description:  Validates if the date passed is reasonable. Format of indate is
//              '[d]d.[m]m.[yy]yy'
//              (pinched from http://www.rodsdot.com/ee/dateValidate1.asp)
//
function date_ok(indate)          // date to validate
//
// Output        0 if date is correct
//
//-----------------------------------------------------------------------------
{
  var regex = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;
  return indate.search(regex);
}


//-----------------------------------------------------------------------------
//
// Description:  Validates if the email adress passed is correct
//              (pinched from http://www.1ngo.de/web/email-check.html)
//
function email_adress_ok(email)   // email adress to validate
//
// Output        0 if email adress is legal
//
//-----------------------------------------------------------------------------
{
  var regex  = /^([^\s@,:"<>]+)@([^\s@,:"<>]+\.[^\s@,:"<>.\d]{2,}|(\d{1,3}\.){3}\d{1,3})$/;
  return email.search(regex);
}


//-----------------------------------------------------------------------------
//
// Description: Checks if the field does not contains the illegal characters
//              ''', '"', '<' or '>' (illegal because they are string or HTML
//              delimitters).
//
function field_char_ok(field)     // field to validate
//
// Output        0 if field does not contains illegal characters
//
//-----------------------------------------------------------------------------
{
  if(field.match(/['\"<>]+/)) {return 1;}
  else                        {return 0;}
}

//-----------------------------------------------------------------------------
//
// Description: Checks if the filename only contains legal characters, d.h A..Z,
//              a..z, 0..9 and the special characters '.', '-' and '_'.
//
function filename_char_ok(filname)  // filename to validate
//
// Output        0 if filename only contains legal characters
//
//-----------------------------------------------------------------------------
{
  var regex = /^[A-Za-z0-9|\.|\-|_]*$/;
  return filname.search(regex);
}


//-----------------------------------------------------------------------------
//
// Description: Checks if the field contains a flot value of the form
//              'nn[.nnnnn]'.
//
function float_ok(field)      // name field to validate
//
// Output        0 if field is a legal float value
//
//-----------------------------------------------------------------------------
{
  var regex = /^\d{1,3}([\.,]\d{1,8})?$/;
  return field.search(regex);
}


//-----------------------------------------------------------------------------
//
// Description: Checks if the link only contains legal characters, d.h A..Z,
//              a..z, 0..9 and ASCII special characters but no space, etc.
//
function link_char_ok(linkn)      // link to validate
//
// Output        0 if link only contains legal characters
//
//-----------------------------------------------------------------------------
{
  var regex = /^[A-Za-z0-9|\+|\"|\*|%|&|\/|\(|\)|=|\?|\[|\]|!|\{|\}|\$|<|>|,|;|\.|:|\-|_]*$/;
  return linkn.search(regex);
}


//-----------------------------------------------------------------------------
//
// Description: Checks if the name field only contains legal characters (A..Z,
//              a..z, 0..9, '-', '_' and space.
//
function name_char_ok(field)      // name field to validate
//
// Output        0 if field only contains legal characters
//
//-----------------------------------------------------------------------------
{
  var regex = /^[A-Za-z0-9|\-|_| ]*$/;
  return field.search(regex);
}


//-----------------------------------------------------------------------------
//
// Description: Checks if the password field only contains legal characters
//              (A..Z, a..z, 0..9 and some ASCII special characters including
//               space.
//
function pwd_char_ok(field)      // password field to validate
//
// Output        0 if field only contains legal characters
//
//-----------------------------------------------------------------------------
{
  var regex = /^[A-Za-z0-9|\+|\*|%|&|!|\$|,|;|\.|:|\-|_| ]*$/;
  return field.search(regex);
}


//-----------------------------------------------------------------------------
//
// Description:  Validates if the year passed is reasonable. Format of indate is
//              '[yy]yy' (Range 1900..2099)
//
function year_ok(inyear)          // year to validate
//
// Output        0 if date is correct
//
//-----------------------------------------------------------------------------
{
  var regex = /^(19|20){0,1}[0-9][0-9]$/;
  return inyear.search(regex);
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the field passed does only contain basic characters
//              (A-Z, a-Z, 0-9 and space). If it contains illegal characters an
//              error is output and focus set to the field. Then javascript
//              processing is aborted
//
function check_basic_char(field,     // field (object) to check
                          fieldname) // name of field to check
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (basic_char_ok(field.value) != 0)
  {
    alert("Das Feld '" + fieldname + "' enthalt unzulässige(s) Zeichen (zulässig sind A-Z, a-z, 0-9 und Leerschlag)");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // all characters in the field are legal
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the field passed does only contain basic characters
//              (A-Z, a-Z and 0-9). If it contains illegal characters an
//              error is output and focus set to the field. Then javascript
//              processing is aborted
//
function check_basic_char_nosp(field,     // field (object) to check
                               fieldname) // name of field to check
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (basic_char_nosp_ok(field.value) != 0)
  {
    alert("Das Feld '" + fieldname + "' enthalt unzulässige(s) Zeichen (zulässig sind A-Z, a-z und 0-9)");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // all characters in the field are legal
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the field passed does only contain plane registration
//              characters (A-Z, 0-9 and '-'). If it contains illegal characters
//              an error is output and focus set to the field. Then javascript
//              processing is aborted
//
function check_immatr_char(field,    // field (object) to check
                          fieldname) // name of field to check
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (immatr_char_ok(field.value) != 0)
  {
    alert("Das Feld '" + fieldname + "' enthalt unzulässige(s) Zeichen (zulässig sind A-Z, 0-9 und '-')");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // all characters in the field are legal
}


//-----------------------------------------------------------------------------
//
// Description  Check if the field passed is empty. If it contains at least one
//              character, an error is output and focus set to the field. Then
//              javascript processing is aborted
//
function check_empty(field,       // field (object) to check
                     fieldname)   // name of field to check
//
// Output        True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (field.value != "")
  {
    alert("Ins Feld '" + fieldname + "' darf keine Eingabe gemacht werden");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // there is some input in the field
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the field passed does not contain illegal characters,
//              (''', '"', '<' or '>' / illegal because they are string or HTML
//              delimiters). If it contains illegal characters an error is
//              output and focus set to the field. Then javascript processing is
//              aborted
//
function check_field_char(field,     // field (object) to check
                          fieldname) // name of field to check
//
// Output        True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (field_char_ok(field.value) != 0)
  {
    alert("Das Feld '" + fieldname + "' enthalt unzulässige(s) Zeichen (unzulässig sind Hochkomma ('), Quote (" + '"' + ") und Pfeile ('<', '>'))\nHinweis: Ersetze Hochkomma oder Quote durch das legale Zeichen (`) (Taste rechts vom '?' mit Shift und dann Leerschlag)");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // all characters in the field are legal
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the filename passed only contains legal characters.
//              If it contains illegal characters an error is output and focus
//              set to the field. Then javascript processing is aborted
//
function check_filename_char(field,     // field (object) to check
                             fieldname) // name of field to check
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (filename_char_ok(field.value) != 0)
  {
    alert("Das Feld '" + fieldname + "' enthalt unzulässige(s) Zeichen\n(unzulässig sind Leerschläge, spezielle Buchstaben (ä,ö, etc.) und Sonderzeichen ausser '-', '_' und '.')");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // all characters in the field are legal
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the link passed only contains legal characters. If it
//              contains illegal characters an error is output and the focus
//              to the field. Then javascript processing is aborted
//
function check_link_char(field,     // field (object) to check
                         fieldname) // name of field to check
//
// Output        True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (link_char_ok(field.value) != 0)
  {
    alert("Das Feld '" + fieldname + "' enthalt unzulässige(s) Zeichen\n(unzulässig sind Leerschläge und spezielle Buchstaben (ä,ö, etc.))");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // all characters in the field are legal
}


//-----------------------------------------------------------------------------
//
// Description  Check if the field passed contains at least one character. If
//              the field is empty, an error is output and focus set to the
//              field. Then javascript processing is aborted
//
function check_not_empty(field,     // field (object) to check
                         fieldname) // name of field to check
//
// Output        True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (field.value == "")
  {
    alert("Ins Feld '" + fieldname + "' muss eine Eingabe gemacht werden");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // there is some input in the field
}


//-----------------------------------------------------------------------------
//
// Description  Check if the field passed contains an acceptable amount of
//              characters. If it contains to many characters an error is
//              output and focus set to the field. Then javascript processing
//              is aborted
//
function check_no_char(field,      // field (object) to check
                       fieldname,  // name of field to check
                       min_size,   // min. no characters in field
                                   //  0: dont check minimal size
                       max_size)   // max. no characters in field
//
// Output        True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if ((min_size > 0) && (field.value.length < min_size))
  {
    alert("Die Eingabe ins Feld '" + fieldname + "' ist mit " + field.value.length + " Zeichen zu kurz\n(min. benötigt werden " + min_size + " Zeichen)");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  if (field.value.length > max_size)
  {
    alert("Die Eingabe ins Feld '" + fieldname + "' ist mit " + field.value.length + " Zeichen zu lange\n(max. zulässig sind " + max_size + " Zeichen)");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // number of characters in field is within limits
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the field passed does not contain illegal characters
//              (for details see name_char_ok(). If the field contains illegal
//               characters an error is output and focus set to the field. Then
//               javascript processing is aborted
//
function check_name_char(field,     // field (object) to check
                         fieldname) // name of field to check
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (name_char_ok(field.value) != 0)
  {
    alert("Das Feld '" + fieldname + "' enthalt unzulässige(s) Zeichen (zulässig sind A-Z, a-z, 0-9, '-', '_' und Leerschlag");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // all characters in the field are legal
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the date passed is of the format 'dd.mm.yyyy'. If not
//              an error is output and focus set to the field. Then javascript
//              processing is aborted
//
function check_date(field,        // field (object) to check
                    fieldname)    // name of field to check
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (date_ok(field.value) != 0)
  {
    alert("Die Eingabe '" + field.value + "' in Feld '" + fieldname + "' ist kein Datum im Format dd.mm.yyyy");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // field contains a legal date
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the year passed is of the format '[yy]yy'. If not
//              an error is output and focus set to the field. Then javascript
//              processing is aborted
//
function check_year(field,        // field (object) to check
                    fieldname)    // name of field to check
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (year_ok(field.value) != 0)
  {
    alert("Die Eingabe '" + field.value + "' in Feld '" + fieldname + "' ist kein Jahr im Format '[yy]yy' im Bereich 1900..2099");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // field contains a legal year
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the year of the admittance to the vSAF is in the range
//              of 2005 till the current year. If not an error is output and
//              focus set to the field. Then javascript processing is aborted.
//
function check_eintritt(field,      // field (object) to check
                        fieldname)  // name of field to check
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  var founding_year = 2005;       // founding year of the vSAF
  var today = new Date();         // get current year
  var year  = (+field.value);     // set up year to check (and make it numeric)
  if (year < 100)                 // only two digits given
  {                               // setup range 1970..2069
    if (year > 69) {year = year + 1900;}
    else           {year = year + 2000;}
  }
  if (year < founding_year)                // start year of vSAF
  {
    alert("Im Jahr " + year + " im Feld '" + fieldname + "' gab es die vSAF noch nicht");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  if (year > today.getFullYear())  // year is in the future
  {
    alert("Das Jahr " + year + " im Feld '" + fieldname + "' liegt in der Zukunft");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  field.value = year;             // set up 4 digits value
  return true;                    // field contains a legal year
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the year of the end of the vSAF membership is after
//              the year of admission (if defined). It is also checked if the
//              exit year is not more than 1 year in the future. If not an error
//              is output and focus set to the field. Then javascript processing
//              is aborted.
//
function check_austritt(field,      // field (object) to check
                        fieldname,  // name of field to check
                        eintritt)   // year of admittance to vSAF (could be empty)
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  var today = new Date();         // get current year
  var year  = (+field.value);     // set up year to check (and make it numeric)
      eintritt = +eintritt;       // make admittance year numerich
  if (year < 100)                 // only two digits given
  {                               // setup range 1970..2069
    if (year > 69) {year = year + 1900;}
    else           {year = year + 2000;}
  }
  if ((eintritt != 0) && (year < eintritt))  // exit before entry to vSAF
  {
    alert("Im Jahr " + year + " in Feld '" + fieldname + "' noch nicht vSAF Mitglied (Eintritt " + eintritt + ")");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  if (year > today.getFullYear() + 1)  // year is more than 1 year in future
  {
    alert("Das Jahr " + year + " im Feld '" + fieldname + "' liegt zuweit in der Zukunft");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  field.value = year;             // set up 4 digits value
  return true;                    // field contains a legal year
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the field contains a legeal email adress. If not an
//              error is output and focus set to the field. Then javascript
//              processing is aborted
//
function check_email(field,       // field (object) to check
                     fieldname)   // name of field to check
//
// Output        True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (email_adress_ok(field.value) != 0)
  {
    alert("Die Eingabe '" + field.value + "' in Feld '" + fieldname + "' ist keine zulässige E-Mail Adresse");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // field contains a legal email adress
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the field content passed is a float value of the form
//              'nn[.nnnn]'. If not an error is output and focus set to the
//              field. Then javascript processing is aborted
//
function check_float(field,       // field (object) to check
                    fieldname)    // name of field to check
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (float_ok(field.value) != 0)
  {
    alert("Die Eingabe '" + field.value + "' in Feld '" + fieldname + "' muss numerisch sein und Format 'nn[.nnnnn]' aufweisen");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // field contains a legal date
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the user is a new user (has an empty password field.
//              For a new user, it is then checked if a new password has been
//              given. If not an error is output and focus set to the input
//              field. Then javascript processing is aborted
//
function check_new_user(pwd_field,  // password field (object) to check
                        in_field)   // input field (object) to check
//
// Output        True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (pwd_field.value == "")     // new user with no password
  {
    if (in_field.value == "")    // user has no password defined
    {
      alert("Du hast kein neues Passwort definiert");
      in_field.focus();           // set focus to the input field
      return false;               // terminate javascript processing
    }
  }
  return true;                    // user has defined a new password
}                                 //  or user is not a new user


//-----------------------------------------------------------------------------
//
// Description  Checks if the field passed does not contain illegal characters
//              (for details see name_char_ok(). If the field contains illegal
//               characters an error is output and focus set to the field. Then
//               javascript processing is aborted
//
function check_pwd_char(field,     // field (object) to check
                        fieldname) // name of field to check
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (pwd_char_ok(field.value) != 0)
  {
    alert("Das Feld '" + fieldname + "' enthalt unzulässige(s) Zeichen (zulässig sind A-Z, a-z, 0-9, '+', '*', '&', '!', '$', ',', ';', '.', ':', '-', '_' und Leerschlag");
    field.focus();                // set focus to the field
    return false;                 // terminate javascript processing
  }
  return true;                    // all characters in the field are legal
}


//-----------------------------------------------------------------------------
//
// Description  Checks if the user has specified a new password. If yes, it is
//              checked if both entries match. If not, an error is output and
//              focus set to the first input field. Then javascript processing
//              is aborted
//
function check_pwd_match(pwd_field1,  // password field 1 (object) to check
                         pwd_field2)  // password field 2 (object) to check
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if ((pwd_field1.value != "") || (pwd_field2.value != ""))
  {                               // user has input into at least one of the two fields
    if (pwd_field1.value != pwd_field2.value)
    {                             // the two entries do not match
      alert("Die beiden eingegebenen neuen Passworte sind nicht gleich");
      pwd_field1.focus();         // set focus to the first input field
      return false;               // terminate javascript processing
    }
  }
  return true;                    // the two entries do match or
}                                 //  user has not input a new password


//-----------------------------------------------------------------------------
//
// Description  Checks if the content of the field is numerical and within the
//              specified numerical value range. If not an error is output and
//              focus set to the input field. Javascript processing is aborted
//
function check_num_range(field,       // numerical field to check
                         fieldname,   // name of field
                         fmin_value,  // minimal allowed numerical value in field
                         fmax_value)  // maximal allowed numerical value in field
//
// Output       True:  No error found
//              False: Check failed
//
//-----------------------------------------------------------------------------
{
  if (!is_numeric(field.value))
  {                               // check field is numeric
    alert("Die Eingabe '" + field.value + "' in Feld '" + fieldname + "' ist nicht numerisch");
    field.focus();                // set focus to the input field
    return false;                 // terminate javascript processing
  }
  if ((field.value < fmin_value) || (field.value > fmax_value))
  {                               // check field is numeric
    alert("Die Eingabe '" + field.value + "' in Feld '" + fieldname + "' ist nicht im Bereich " + fmin_value + ".." + fmax_value);
    field.focus();                // set focus to the input field
    return false;                 // terminate javascript processing
  }
  return true;                    // content of the field is valid
}


//-----------------------------------------------------------------------------
//
// Description: Check if the inactive data is correctly setup
//              reasonN   Reason for inactivity
//              fromN     Inactive from date
//              toN       Inactive to date
//
// Output       True:  No error found
//              False: Check failed

//
function check_inactive_data()
//
//-----------------------------------------------------------------------------
{
  for (i = 0; true; i++)          // loop over all inactivity reasons of current member
  {
    var reason = 'reason' + i;    // setup reason field
    if (document.getElementById(reason) == null) {break;}
                                  // quit loop if no more reasons

    //
    // Check inactivity reason
    //
    if (document.getElementById(reason).value != '')
    {                             // only check if field has some content
      if (!check_no_char(   document.getElementById(reason), "Grund", 0, c_max_size_reason)) {return false;}
      if (!check_field_char(document.getElementById(reason), "Grund"))                       {return false;}
    }

    //
    // Check inactive from date
    //
    fromDate = 'from' + i;        // setup inactive from field
    if (document.getElementById(fromDate).value != '')
    {                             // only check if field has some content
      if (document.getElementById(reason).value == "")
      {
        alert("Ein Von-Datum ohne Grund ergibt keinen Sinn");
        document.getElementById(reason).focus();
        return false;             // quit processing
      }
      if (!check_date(document.getElementById(fromDate), "Von-Datum")) {return "";}
    }

    //
    // Check inactive to date
    //
    toDate = 'to' + i;            // setup inactive to field
    if (document.getElementById(toDate).value != '')
    {                             // only check if field has some content
      if (document.getElementById(reason).value == '')
      {
        alert("Ein Bis-Datum ohne Grund ergibt keinen Sinn");
        document.getElementById(reason).focus();
        return false;             // quit processing
      }
      if (!check_date(document.getElementById(toDate), "Bis-Datum")) {return "";}
    }

    //
    // Check date ranges
    //
    var today = get_today();      // get today in format 'yyyymmdd'
    if (document.getElementById(toDate).value != '')
    {                             // check if to date is in the past
      toDateNorm = normalise_date(document.getElementById(toDate).value);
                                  // to date in form yyyymmdd
      if (toDateNorm < today)
      {
        alert("Das Bis-Datum liegt in der Vergangenheit");
        document.getElementById(toDate).focus();
        return false;             // quit processing
      }
    }
    if ((document.getElementById(fromDate).value != '') &&
        (document.getElementById(toDate).value   != ''))
    {                             // check if from and to date in sequence
      fromDateNorm = normalise_date(document.getElementById(fromDate).value);
      toDateNorm   = normalise_date(document.getElementById(toDate).value);
                                  // dates in form yyyymmdd
      if (toDateNorm < fromDateNorm)
      {
        alert("Das Bis-Datum liegt vor dem Von-Datum");
        document.getElementById(fromDate).focus();
        return false;             // quit processing
      }
    }
  }
  return true;                    // inactive data is valid
}


//-----------------------------------------------------------------------------
//
// Description: Check if the wing data is correctly setup
//              wingN     No check required since defined via dropdown
//              wfunctN   No check required since defined via dropdown
//              immatrN   Check field content
//              parkpN    Check field content
//
// Output       True:  No error found
//              False: Check failed

//
function check_wing_data()
//
//-----------------------------------------------------------------------------
{
  var wings_of_user = '';         // initialise string with wings of user
  for (i = 0; true; i++)          // loop over all wings of current member
  {
    var wing = 'wing' + i;        // setup field of wing
    if ((document.getElementById(wing) == null) ||
        (document.getElementById(wing).options[document.getElementById(wing).selectedIndex].value) == 0) {break;}
                                  // quit loop if no more wings

    //
    // Check if wing already defined
    //
    var wing_id = document.getElementById(wing).options[document.getElementById(wing).selectedIndex].value + 'w';
    var regex = new RegExp(wing_id); // setup regex
    if (wings_of_user.search(regex) != -1)
    {
      alert("Für diese Staffel gibt es bereits einen Eintrag");
      document.getElementById(wing).focus(); // set focus to the field
      return false;               // terminate javascript processing
    }

    //
    // Pilotstatus must be defined
    //
    var wfunct = 'wfunct' + i;    // setup field of wing
    if (document.getElementById(wfunct).options[document.getElementById(wfunct).selectedIndex].value == 0)
    {
      alert("Für die Staffel muss ein Pilotenstatus gewählt werden");
      document.getElementById(wfunct).focus(); // set focus to the field
      return false;               // terminate javascript processing
    }

    //
    // Check registration of pilots plane
    //
    immatr = 'immatr' + i;        // setup field of plane registration
    if (document.getElementById(immatr).value != '') // only check if field has some content
    {
      if (!check_no_char(    document.getElementById(immatr), "Immatrikulation", 0, c_max_size_immatr)) {return false;}
      if (!check_immatr_char(document.getElementById(immatr), "Immatrikulation"))                       {return false;}
    }

    //
    // Check if park postion on homebase
    //
    parkp  = 'parkp' + i;         // setup field for park position
    if (document.getElementById(parkp).value != '') // only check if field has some content
    {
      if (!check_no_char(   document.getElementById(parkp), "Parkposition", 0, c_max_size_parkp)) {return false;}
      if (!check_field_char(document.getElementById(parkp), "Parkposition"))                      {return false;}
    }
    wings_of_user += wing_id;     // add wing id to search string
  }
  return true;                    // wing data is valid
}


//-----------------------------------------------------------------------------
//
// Description:  Return name of group specified by type (see c_elem_type_xxx)
//
function group_name(type)         // specifies the element type
//
//-----------------------------------------------------------------------------
{
  if (type == 0)  {return "Bildergruppe";}
  if (type == 1)  {return "Downloadgruppe";}
  if (type == 2)  {return "Videogruppe";}
  if (type == 3)  {return "Linkgruppe";}
  return "Undefinierte Gruppe";
}


//-----------------------------------------------------------------------------
//
// Description: Adds to the call string the function fields that can appear more
//              than once per user (e.g. the support field).
//
function add_funct_dropdown(string_in, field_name)
//
//-----------------------------------------------------------------------------
{
  var string_out = string_in;     // initialise output string
  var fname      = "";            // initialise actual field name
  for (i = 0; i < c_max_no_funct; i++)
  {
    fname = field_name.concat(i); // setup current field name
    if (document.getElementById(fname) != null)
    {
      string_out = string_out + '&' + fname + '=' + enc(document.getElementById(fname).options[document.getElementById(fname).selectedIndex].value);
    }
  }
  return string_out;              // return updated call string
}


/**
 * Adds to the call string the inactive data that can appear n times (the end is
 * detected by a not existing inactive reason). Only entries with a reason are
 * set up.
 *
 * @param  string_in  string      // input string to complete
 * @return            string      // inactive data added to string_in
 */
function add_inactive_data(string_in)
{
  var string_out = string_in;     // initialise output string
  var j          = 0;             // initialise output index
  for (i = 0; true; i++)          // loop over all inactive data of current member
  {
    reason = 'reason' + i;        // setup inactive reason field
    from   = 'from'   + i;        // setup inactive from field
    to     = 'to'     + i;        // setup inactive to field
    if (document.getElementById(reason) == null) {break;}
                                  // quit loop if no more inactive reasons
    if (document.getElementById(reason).value != '')
    {                             // ignore emtpy entries (no reason)
      string_out = string_out + '&' + 'reason' + j + '=' + enc(document.getElementById(reason).value);
      string_out = string_out + '&' + 'from'   + j + '=' + enc(document.getElementById(from).value);
      string_out = string_out + '&' + 'to'     + j + '=' + enc(document.getElementById(to).value);
      j++;                        // increment output index
    }
  }
  return string_out;              // return updated call string
}


/**
 * Adds to the call string the wing information that can appear n times (the end
 * is detected by a not existing wing name)
 *
 * @param  string_in  string      // input string to complete
 * @return            string      // wing data added to string_in
 */
function add_wing_data(string_in)
{
  var string_out = string_in;     // initialise output string
  for (i = 0; true; i++)          // loop over all wings of current member
  {
    wing   = 'wing'    + i;       // setup field of wing
    wfunct = 'wfunct'  + i;       // setup field of pilot function
    immatr = 'immatr'  + i;       // setup field of plane registration
    parkp  = 'parkp'   + i;       // setup field for park position
    if ((document.getElementById(wing) == null) ||
        (document.getElementById(wing).options[document.getElementById(wing).selectedIndex].value) == 0) {break;}
                                  // quit loop if no more wings
    string_out = string_out + '&' + wing   + '=' + enc(document.getElementById(wing).options[document.getElementById(wing).selectedIndex].value);
    string_out = string_out + '&' + wfunct + '=' + enc(document.getElementById(wfunct).options[document.getElementById(wfunct).selectedIndex].value);
    string_out = string_out + '&' + immatr + '=' + enc(document.getElementById(immatr).value);
    string_out = string_out + '&' + parkp  + '=' + enc(document.getElementById(parkp).value);
  }
  return string_out;              // return updated call string
}


//-----------------------------------------------------------------------------
//
// Description:  Get data from FCK editor
//
function data_from_editor(field)
//
// Parameters:  field             // Name of the edior field
//
//-----------------------------------------------------------------------------
{
  for (var i = 0; i < parent.frames.length; ++i)
  {
    if (parent.frames[i].FCK)
    {
      parent.frames[i].FCK.UpdateLinkedField();
    }
  }
  return document.getElementById(field).value;
}


/**
 * Setup the string to add or update a user.
 *
 * @param  start_string string  Start string to build the call_string
 * @return              string  String that can be used to call the PHP function
 *                              that actually adds or updates the user data.
 *                              If the input data is incorrect, the call_string
 *                              will be empty
 */
function call_string_user(start_string)
{
  //
  // Check user firstname and name is given
  //
  if (!check_not_empty( document.getElementById('vorname'), "Vorname"))                          {return "";}
  if (!check_no_char(   document.getElementById('vorname'), "Vorname", 0, c_max_size_name))      {return "";}
  if (!check_field_char(document.getElementById('vorname'), "Vorname"))                          {return "";}
  if (!check_not_empty( document.getElementById('name'),    "Name"))                             {return "";}
  if (!check_no_char(   document.getElementById('name'),    "Name",    0, c_max_size_firstname)) {return "";}
  if (!check_field_char(document.getElementById('name'),    "Name"))                             {return "";}

  //
  // Check users adress
  //
  if (!check_not_empty( document.getElementById('adresse'), "Adresse"))                            {return "";}
  if (!check_no_char(   document.getElementById('adresse'), "Adresse", 0, c_max_size_address))     {return "";}
  if (!check_field_char(document.getElementById('adresse'), "Adresse"))                            {return "";}
  if (!check_not_empty( document.getElementById('plz'), "PLZ"))                                    {return "";}
  if (!check_no_char(   document.getElementById('plz'), "PLZ", 0, c_max_size_plz))                 {return "";}
  if (!check_field_char(document.getElementById('plz'), "PLZ"))                                    {return "";}
  if (!check_not_empty( document.getElementById('wohnort'), "Wohnort"))                            {return "";}
  if (!check_no_char(   document.getElementById('wohnort'), "Wohnort", 0, c_max_size_location))    {return "";}
  if (!check_field_char(document.getElementById('wohnort'), "Wohnort"))                            {return "";}
  if (document.getElementById('beruf') != "")
  {if (!check_no_char(   document.getElementById('beruf'), "Beruf", 0, c_max_size_profession))     {return "";}
    if (!check_field_char(document.getElementById('beruf'), "Beruf"))                              {return "";}}
  if (document.getElementById('hobbies') != "")
  {if (!check_no_char(   document.getElementById('hobbies'), "Hobbies", 0, c_max_size_profession)) {return "";}
    if (!check_field_char(document.getElementById('hobbies'), "Hobbies"))                          {return "";}}

  //
  // Check birthddate is correct
  //
  if (document.getElementById('gebdatum').value != "")
  {if (!check_date(document.getElementById('gebdatum'), "Geburtsdatum")) {return "";}}

  //
  // Check communication data
  //
  if ((document.getElementById('tel').value == "") && (document.getElementById('natel').value == ""))
  {
    alert("Gib entweder Deine Telefon- oder Deine Natel-Nr. ein");
    document.getElementById('tel').focus();
    return "";                    // quit processing
  }

  if (document.getElementById('tel').value != "")
  {if (!check_no_char(   document.getElementById('tel'),    "Tel",     c_min_size_tel, c_max_size_tel)) {return "";}
    if (!check_field_char(document.getElementById('tel'),   "Tel"))                          {return "";}}
  if (document.getElementById('natel').value != "")
  {if (!check_no_char(   document.getElementById('natel'),  "Natel",   c_min_size_tel, c_max_size_tel)) {return "";}
    if (!check_field_char(document.getElementById('natel'), "Natel"))                        {return "";}}
  if (!check_not_empty(   document.getElementById('email'), "E-Mail"))                       {return "";}
  if (!check_no_char(     document.getElementById('email'), "E.Mail",  0, c_max_size_email)) {return "";}
  if (!check_email(       document.getElementById('email'), "E.Mail"))                       {return "";}
  if (document.getElementById('skype').value != "")
  {if (!check_no_char(   document.getElementById('skype'), "Skype Id", 0, c_max_size_skype)) {return "";}
    if (!check_field_char(document.getElementById('skype'), "Skype Id",   c_max_size_skype)) {return "";}}

  //
  // Check pilot data (Call sign must be given)
  // (the callsign can only contain A-Z, a-z, 0-9 and space)
  //
  if (!check_not_empty( document.getElementById('callsign'), "Callsign"))                         {return "";}
  if (!check_no_char(   document.getElementById('callsign'), "Callsign", 0, c_max_size_callsign)) {return "";}
  if (!check_basic_char(document.getElementById('callsign'), "Callsign"))                         {return "";}

  //
  // Check if the inactive and wing data is correct
  //
  if (!check_inactive_data()) {return "";}
  if (!check_wing_data())     {return "";}

  //
  // Check Vereinsdaten
  //
  if (document.getElementById('eintritt').value != "")
  {if (!check_year(     document.getElementById('eintritt'), "Eintrittsjahr in vSAF")) {return "";}
    if (!check_eintritt(document.getElementById('eintritt'), "Eintrittsjahr in vSAF")) {return "";}}
  if (document.getElementById('austritt').value != "")
  {if (!check_year(     document.getElementById('austritt'), "Austrittsjahr aus vSAF"))  {return "";}
    if (!check_austritt(document.getElementById('austritt'), "Austrittsjahr aus vSAF", document.getElementById('eintritt').value)) {return "";}}

  //
  // Check login data
  //
  if (!check_not_empty(  document.getElementById('benutzername'), "Benutzername"))                                           {return "";}
  if (!check_no_char(    document.getElementById('benutzername'), "Benutzername", c_min_size_username, c_max_size_username)) {return "";}
  if (!check_name_char(  document.getElementById('benutzername'), "Benutzername"))                                           {return "";}
  if (!check_new_user(   document.getElementById('passwort'),  document.getElementById('passwort1')))                        {return "";}
  if (document.getElementById('passwort1').value != "")
  {if (!check_no_char(  document.getElementById('passwort1'), "Neues Passwort",  c_min_size_password, c_max_size_password))  {return "";}
    if (!check_pwd_char( document.getElementById('passwort1'), "Neues Passwort"))                                            {return "";}
    if (!check_not_empty(document.getElementById('passwort2'), "Passwort wiederholen"))                                      {return "";}
    if (!check_pwd_match(document.getElementById('passwort1'), document.getElementById('passwort2')))                        {return "";}}

  //
  // Setup call to store the user settings
  //
  var call_string = start_string; // initialize call string
  call_string = call_string + "&mstatus="         + enc(document.getElementById('mstatus').options[document.getElementById('mstatus').selectedIndex].value);
  call_string = call_string + "&astatus="         + enc(document.getElementById('astatus').options[document.getElementById('astatus').selectedIndex].value);
  call_string = call_string + "&benutzername="    + enc(document.getElementById('benutzername').value);
  if (document.getElementById('passwort1').value != "")
  {
    call_string = call_string + "&passwort="      + enc(document.getElementById('passwort1').value);
  }
  call_string = call_string + "&callsign="        + enc(document.getElementById('callsign').value);
  call_string = call_string + "&name="            + enc(document.getElementById('name').value);
  call_string = call_string + "&vorname="         + enc(document.getElementById('vorname').value);
  call_string = call_string + "&adresse="         + enc(document.getElementById('adresse').value);
  call_string = call_string + "&plz="             + enc(document.getElementById('plz').value);
  call_string = call_string + "&wohnort="         + enc(document.getElementById('wohnort').value);
  call_string = call_string + "&beruf="           + enc(document.getElementById('beruf').value);
  call_string = call_string + "&hobbies="         + enc(document.getElementById('hobbies').value);
  call_string = call_string + "&tel="             + enc(document.getElementById('tel').value);
  call_string = call_string + "&natel="           + enc(document.getElementById('natel').value);
  call_string = call_string + "&email="           + enc(document.getElementById('email').value);
  call_string = call_string + "&skype="           + enc(document.getElementById('skype').value);
  call_string = call_string + "&gebdatum="        + enc(document.getElementById('gebdatum').value);
  call_string = call_string + "&eintritt="        + enc(document.getElementById('eintritt').value);
  call_string = call_string + "&austritt="        + enc(document.getElementById('austritt').value);
  call_string = add_funct_dropdown(call_string, 'vereinfunkt');
  call_string = add_funct_dropdown(call_string, 'supportfunkt');
  call_string = add_funct_dropdown(call_string, 'vsaffunkt');
  call_string = add_inactive_data(call_string);
  call_string = add_wing_data(call_string);
  return call_string;              // return call string
}


//-----------------------------------------------------------------------------
// Public functions
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
//
// Description  Pass on email text to be sent
//
function absenden()
//
//-----------------------------------------------------------------------------
{
  var reason  = document.getElementById('reason').value;
  var name    = document.getElementById('name').value;
  var email   = document.getElementById('email').value;
  var message = document.getElementById('message').value;
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                // HTML code to <div> with id = 'answer'
      if (xmlHttp.responseText.search(/Dank/) != -1)
      {                         // check if successfully sent
        window.setTimeout("location.replace(c_file_home);", c_msg_delay_long);
      }                         // if yes wait a bit and the go to home
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=absenden&reason=" + reason + "&name=" + enc(name) + "&email=" + enc(email) + "&message=" + enc(message), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Just redraw current page
//
function abort()
//
//-----------------------------------------------------------------------------
{
  location.reload();
}


//-----------------------------------------------------------------------------
//
// Description:  Add new airport to the database
//
function airport_add()
// Parameters:  name                // Name of airport to add
//              code                // ICAO code of airport
//              type                // Type of airport
//              lat                 // latitude of airport
//              long                // longitude of airport
//              labxoff             // Label axis x offset
//              labyoff             // Label axis y offset
//              descr (via editor)  // Description of airport
//
//-----------------------------------------------------------------------------
{
  var name    = document.getElementById('name').value;
  var code    = document.getElementById('code').value;
  var type    = document.getElementById('type').value;
  var lat     = document.getElementById('lat').value;
  var llong   = document.getElementById('long').value;
  var labxoff = document.getElementById('labxoff').value;
  var labyoff = document.getElementById('labyoff').value;
  var descr   = data_from_editor('FCKeditor');

  //
  // Check if airport name is given and not more than max. no chars
  //
  if (!check_not_empty( document.getElementById('name'), "Flugplatzname"))                             {return;}
  if (!check_no_char(   document.getElementById('name'), "Flugplatzname", 0, c_max_size_airport_name)) {return;}
  if (!check_field_char(document.getElementById('name'), "Flugplatzname"))                             {return;}

  //
  // If ICAO code is given check not more than max. no chars and only a..z, A..z and 0..9
  //
  if (code != '')
  {
    if (!check_no_char(        document.getElementById('code'), "ICAO Code", 0, c_max_size_icao_code)) {return;}
    if (!check_basic_char_nosp(document.getElementById('code'), "ICAO Code"))                          {return;}
  }

  //
  // Check lattitude and longitude
  //
  if ((lat == "") || (llong == ""))
  {
    alert("Bitte Flughafenposition (Latitude und Longitude angeben'");
    if (llong == "") {document.getElementById('long').focus();}
    if (lat   == "") {document.getElementById('lat').focus();}
    return;                    // quit processing
  }
  if (!check_float(document.getElementById('lat'),  "Latitude"))  {return;}
  if (!check_float(document.getElementById('long'), "Longitude")) {return;}
  if ((lat < c_lat_ch_min) || (lat > c_lat_ch_max) || (llong < c_long_ch_min) || (llong > c_long_ch_max))
  {
    alert("Flugplatz nicht in der Schweiz (Latitude: " + c_lat_ch_min + ".." + c_lat_ch_max + " / Longitude: " + c_long_ch_min + ".." + c_long_ch_max + ")");
    if ((llong < c_long_ch_min) || (llong > c_long_ch_max)) {document.getElementById('long').focus();}
    if ((lat   < c_lat_ch_min)  || (lat   > c_lat_ch_max))  {document.getElementById('lat').focus();}
    return;                    // quit processing
  }

  //
  // Check label offsets
  //
  if (labxoff != '')
  {if (!check_num_range(document.getElementById('labxoff'), "Label X Offset" , c_min_lab_offset, c_max_lab_offset)) {return;}}
  if (labyoff != '')
  {if (!check_num_range(document.getElementById('labyoff'), "Label Y Offset" , c_min_lab_offset, c_max_lab_offset)) {return;}}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_vsaf_ajax + "?action=airport_add&name=" + enc(name) + "&code=" + enc(code) + "&type=" + enc(type) + "&lat=" + enc(lat) + "&long=" + enc(llong) + "&labxoff=" + enc(labxoff) + "&labyoff=" + enc(labyoff) + "&descr=" + enc(descr), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete exiting airport from the database
//
function airport_delete(id,           // id of the airport to delete
                        airport_name) // name of the airport to delete
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll der Flugplatz '" + airport_name + "' wirklich gelöscht werden?"))
  {                                // delete confirmed --> execute
    xmlHttp = create_request();    // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        location.reload();
      }
    };
    xmlHttp.open("GET", c_file_vsaf_ajax + "?action=airport_delete&id=" + id, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Edit the data of an existing airport
//
function airport_edit(id)         // id of the airport to edit
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there

  };
  xmlHttp.open("GET", c_file_vsaf_ajax + "?action=airport_edit&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Get the data of an new airport
//
function airport_new()
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there
  };
  xmlHttp.open("GET", c_file_vsaf_ajax + "?action=airport_new", true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Update the data of an existing airport in the database
//
function airport_update(id)        // ID of the airport to update
// Parameters:  name               // Name of airport to add
//              code               // ICAO code of airport
//              type               // Type of airport
//              lat                // latitude of airport
//              long               // longitude of airport
//              labxoff            // Label axis x offset
//              labyoff            // Label axis y offset
//              descr (via editor) // Description of airport
//
//-----------------------------------------------------------------------------
{
  var name    = document.getElementById('name').value;
  var code    = document.getElementById('code').value;
  var type    = document.getElementById('type').value;
  var lat     = document.getElementById('lat').value;
  var llong   = document.getElementById('long').value;
  var labxoff = document.getElementById('labxoff').value;
  var labyoff = document.getElementById('labyoff').value;
  var descr   = data_from_editor('FCKeditor');

  //
  // Check if airport name is given and not more than max. no chars
  //
  if (!check_not_empty( document.getElementById('name'), "Flugplatzname"))                             {return;}
  if (!check_no_char(   document.getElementById('name'), "Flugplatzname", 0, c_max_size_airport_name)) {return;}
  if (!check_field_char(document.getElementById('name'), "Flugplatzname"))                             {return;}

  //
  // If ICAO code is given check not more than max. no chars and only a..z, A..z and 0..9
  //
  if (code != '')
  {
    if (!check_no_char(        document.getElementById('code'), "ICAO Code", 0, c_max_size_icao_code)) {return;}
    if (!check_basic_char_nosp(document.getElementById('code'), "ICAO Code"))                          {return;}
  }

  //
  // Check lattitude and longitude
  //
  if ((lat == "") || (llong == ""))
  {
    alert("Bitte Flughafenposition (Latitude und Longitude angeben'");
    if (llong == "") {document.getElementById('long').focus();}
    if (lat   == "") {document.getElementById('lat').focus();}
    return;                    // quit processing
  }
  if (!check_float(document.getElementById('lat'),  "Latitude"))  {return;}
  if (!check_float(document.getElementById('long'), "Longitude")) {return;}
  if ((lat < c_lat_ch_min) || (lat > c_lat_ch_max) || (llong < c_long_ch_min) || (llong > c_long_ch_max))
  {
    alert("Flugplatz nicht in der Schweiz (Latitude: " + c_lat_ch_min + ".." + c_lat_ch_max + " / Longitude: " + c_long_ch_min + ".." + c_long_ch_max + ")");
    if ((llong < c_long_ch_min) || (llong > c_long_ch_max)) {document.getElementById('long').focus();}
    if ((lat   < c_lat_ch_min)  || (lat   > c_lat_ch_max))  {document.getElementById('lat').focus();}
    return;                    // quit processing
  }

  //
  // Check label offsets
  //
  if (labxoff != '')
  {if (!check_num_range(document.getElementById('labxoff'), "Label X Offset" , c_min_lab_offset, c_max_lab_offset)) {return;}}
  if (labyoff != '')
  {if (!check_num_range(document.getElementById('labyoff'), "Label Y Offset" , c_min_lab_offset, c_max_lab_offset)) {return;}}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_vsaf_ajax + "?action=airport_update&id=" + id + "&name=" + enc(name) + "&code=" + enc(code) + "&type=" + enc(type) + "&lat=" + enc(lat) + "&long=" + enc(llong) + "&labxoff=" + enc(labxoff) + "&labyoff=" + enc(labyoff) + "&descr=" + enc(descr), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Add new download to the database
//
function download_add()
// Parameters:  group_name          // download group the download belongs to
//              name                // name of the download
//              filename            // (new) filename of the download
//              filename_ori        // current filename of the download
//              cdate               // creation date of the download
//              descr (via editor)  // description of the download
//              recht               // right required to see download
//
//-----------------------------------------------------------------------------
{
  var group_name    = document.getElementById('group_name').value;
  var name          = document.getElementById('name').value;
  var dfilename     = document.getElementById('filename').value;
  var dfilename_ori = document.getElementById('filename_ori').value;
  var cdate         = document.getElementById('cdate').value;
  var descr         = data_from_editor('FCKeditor');
  var recht         = document.getElementById('recht').value;

  //
  // Check if download title is given, not more than max. no char and only legal ASCII characters
  //
  if (!check_not_empty( document.getElementById('name'), "Downloadtitel"))                      {return;}
  if (!check_no_char(   document.getElementById('name'), "Downloadtitel", 0, c_max_size_title)) {return;}
  if (!check_field_char(document.getElementById('name'), "Downloadtitel"))                      {return;}

  //
  // Check if filename is given, not more than max. no char and only legal ASCII characters
  //
  if (!check_not_empty(      document.getElementById('filename'), "Dateiname"))                         {return;}
  if (!check_no_char(        document.getElementById('filename'), "Dateiname", 0, c_max_size_filename)) {return;}
  if (!check_filename_char(  document.getElementById('filename'), "Dateiname"))                         {return;}

  //
  // Check if creation date is not empty and correct ([d]d.[m]m.[yy]yy)
  //
  if (!check_not_empty(document.getElementById('cdate'), "Datum")) {return;}
  if (!check_date(     document.getElementById('cdate'), "Datum")) {return;}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      if (xmlHttp.responseText == "OK")
      {
        location.reload();
      }
      else
      {
        document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
        pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
        window.scrollTo(pos[0], pos[1]);
      }                           // and scroll there
    }
  };
  xmlHttp.open("GET", c_file_download_ajax + "?action=download_add&group_name=" + enc(group_name) + "&name=" + enc(name) + "&filename=" + dfilename + "&filename_ori=" + dfilename_ori + "&cdate=" + cdate + "&descr=" + enc(descr) + "&recht=" + recht, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete exiting download from the database and directory
//
function download_delete(id,        // id of the download to delete
                         dfilename) // name of the download to delete
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll der Download '" + dfilename + "' wirklich gelöscht werden?"))
  {                                // delete confirmed --> execute
    xmlHttp = create_request();    // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        location.reload();
      }
    };
    xmlHttp.open("GET", c_file_download_ajax + "?action=download_delete&id=" + id, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Edit the data of an existing download
//
function download_edit(id)        // id of the download to edit
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);  // and scroll there
      f_tcalInit();                     // start scaning for tcal calendar
    }
  };
  xmlHttp.open("GET", c_file_download_ajax + "?action=download_edit&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete unwanted download from directory 'uploaded'
//
function download_ignore(dfilename) // name of file to ignore
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll der Download '" + dfilename + "' wirklich gelöscht werden?"))
  {                               // delete confirmed --> execute
    xmlHttp = create_request();   // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        location.reload();
      }
    };
    xmlHttp.open("GET", c_file_download_ajax + "?action=download_ignore&filename=" + dfilename, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Get the data of an new download
//
function download_new(dfilename)  // name of file to add to downloads
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);  // and scroll there
      f_tcalInit();                     // start scaning for tcal calendar
    }
  };
  xmlHttp.open("GET", c_file_download_ajax + "?action=download_new&filename=" + dfilename, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Update the data of an existing download in the database
//
function download_update(id)        // id of the download to update
// Parameters:  group_name          // download group the download belongs to
//              name                // name of the download
//              filename            // (new) filename of the download
//              filename_ori        // current filename of the download
//              cdate               // creation date of the download
//              descr (via editor)  // description of the download
//              recht               // right required to see download
//
//-----------------------------------------------------------------------------
{
  var group_name    = document.getElementById('group_name').value;
  var name          = document.getElementById('name').value;
  var dfilename     = document.getElementById('filename').value;
  var dfilename_ori = document.getElementById('filename_ori').value;
  var cdate         = document.getElementById('cdate').value;
  var descr         = data_from_editor('FCKeditor');
  var recht         = document.getElementById('recht').value;

  //
  // Check if download title is given, not more than max. no char and only legal ASCII characters
  //
  if (!check_not_empty( document.getElementById('name'), "Downloadtitel"))                      {return;}
  if (!check_no_char(   document.getElementById('name'), "Downloadtitel", 0, c_max_size_title)) {return;}
  if (!check_field_char(document.getElementById('name'), "Downloadtitel"))                      {return;}

  //
  // Check if filename is given, not more than max. no char and only legal ASCII characters
  //
  if (!check_not_empty(    document.getElementById('filename'), "Dateiname"))                         {return;}
  if (!check_no_char(      document.getElementById('filename'), "Dateiname", 0, c_max_size_filename)) {return;}
  if (!check_filename_char(document.getElementById('filename'), "Dateiname"))                         {return;}

  //
  // Check if creation date is not empty and correct ([d]d.[m]m.[yy]yy)
  //
  if (!check_not_empty(document.getElementById('cdate'), "Datum")) {return;}
  if (!check_date(     document.getElementById('cdate'), "Datum")) {return;}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      if (xmlHttp.responseText == "OK")
      {
        location.reload();
      }
      else
      {
        document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
        pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
        window.scrollTo(pos[0], pos[1]);
      }                           // and scroll there
    }
  };
  xmlHttp.open("GET", c_file_download_ajax + "?action=download_update&id=" + id + "&group_name=" + enc(group_name) + "&name=" + enc(name) + "&filename=" + dfilename + "&filename_ori=" + dfilename_ori + "&cdate=" + cdate + "&descr=" + enc(descr) + "&recht=" + recht, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Move existing element (picture, download, video or link)
//               down in the display sequence (--> higher id)
//
function element_down(type,       // element type (see c_elem_type_xxx)
                      id)         // id of the element to move down
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();      // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_element_ajax + "?action=element_down&type=" + type + "&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Move existing database table entry down in the display sequence
//               (--> higher id)
//
function entry_down(table,        // database table (see c_db_tab_xxx)
                    id)           // id of the entry to move down
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();      // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_element_ajax + "?action=entry_down&table=" + enc(table) + "&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Move existing element (picture, download, video or link) up
//               in the display sequence (--> smaller id)
//
function element_up(type,         // element type (see c_elem_type_xxx)
                    id)           // id of the element to move up
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_element_ajax + "?action=element_up&type=" + type + "&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Move existing database table entry up in the display sequence
// (--> smaller id)
//
function entry_up(table,          // database table (see c_db_tab_xxx)
                  id)             // id of the entry to move up
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_element_ajax + "?action=entry_up&table=" + enc(table) + "&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Add new group to the database table of the specified type
//
function element_group_add(type,    // element type (see c_elem_type_xxx)
                           topic)   // id of page level 1
// Parameters:  group               // name of the group
//              page                // page the group belongs to
//              descr (via editor)  // description of element group
//              recht               // right required to see group
//
//-----------------------------------------------------------------------------
{
  var group = document.getElementById('group').value;
  var page  = document.getElementById('page').value;
  var descr = data_from_editor('FCKeditor');
  var recht = document.getElementById('recht').value;

  //
  // Check if a group name has been input
  //
  if (!check_not_empty( document.getElementById('group'), group_name(type)))                      {return;}
  if (!check_no_char(   document.getElementById('group'), group_name(type), 0, c_max_size_title)) {return;}
  if (!check_field_char(document.getElementById('group'), group_name(type)))                      {return;}

  //
  // Check if a group name has been input
  //
  if (!check_not_empty( document.getElementById('page'), group_name(type))) {return;}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_element_ajax + "?action=element_group_add&type=" + enc(type) + "&topic=" + enc(topic) + "&group=" + enc(group) + "&page=" + enc(page) + "&descr=" + enc(descr) + "&recht=" + enc(recht), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete exiting group from the database table of the specified type
//
function element_group_delete(type,   // element type (see c_elem_type_xxx)
                              id,     // id of the group to delete
                              group)  // name of the group to delete
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll die " + group_name(type) + " '" + group + "' und ihr Inhalt wirklich gelöscht werden?"))
  {                                // delete confirmed --> execute
    xmlHttp = create_request();    // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        location.reload();
      }
    };
    xmlHttp.open("GET", c_file_element_ajax + "?action=element_group_delete&type=" + type + "&id=" + id, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Move existing group down in the display sequence (--> higher id)
//
function element_group_down(type,   // element type (see c_elem_type_xxx)
                            id)     // id of the group to move down
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_element_ajax + "?action=element_group_down&type=" + type + "&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Edit the data of an existing group
//
function element_group_edit(type,   // element type (see c_elem_type_xxx)
                            topic,  // id of page level 1
                            id)     // id of the group to edit
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();      // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there
  };
  xmlHttp.open("GET", c_file_element_ajax + "?action=element_group_edit&type=" + type + "&topic=" + enc(topic) + "&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Get the data of an new group
//
function element_group_new(type,    // element type (see c_elem_type_xxx)
                           topic,   // id of page level 1
                           page_id) // id of current page
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there
  };
  if (exists(page_id)) {xmlHttp.open("GET", c_file_element_ajax + "?action=element_group_new&type=" + type + "&topic=" + enc(topic) + "&page_id=" + page_id, true);}
  else                 {xmlHttp.open("GET", c_file_element_ajax + "?action=element_group_new&type=" + type + "&topic=" + enc(topic),                         true);}
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Move existing group up in the display sequence (--> smaller id)
//
function element_group_up(type,   // element type (see c_elem_type_xxx)
                          id)     // id of the group to move up
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();      // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_element_ajax + "?action=element_group_up&type=" + type + "&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Update the data of an existing group in the database
//
function element_group_update(type,   // element type (see c_elem_type_xxx)
                              topic,  // id of page level 1
                              id)     // id of the group to update
// Parameters:  group                 // name of the group
//              page                  // page the group belongs to
//              descr (via editor)    // description of group
//              recht                 // right required to see group
//
//-----------------------------------------------------------------------------
{
  var group = document.getElementById('group').value;
  var page  = document.getElementById('page').value;
  var descr = data_from_editor('FCKeditor');
  var recht = document.getElementById('recht').value;

  //
  // Check if a group name has been input
  //
  if (!check_not_empty( document.getElementById('group'), group_name(type)))                      {return;}
  if (!check_no_char(   document.getElementById('group'), group_name(type), 0, c_max_size_title)) {return;}
  if (!check_field_char(document.getElementById('group'), group_name(type)))                      {return;}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_element_ajax + "?action=element_group_update&type=" + enc(type) + "&topic=" + enc(topic) + "&id=" + enc(id) + "&group=" + enc(group) + "&page=" + enc(page) + "&descr=" + enc(descr) + "&recht=" + enc(recht), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description: Change the links of all web pictures to the current environment
//              (development, test or production)
//
function env_picture_adapt()
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('journal').innerHTML = xmlHttp.responseText;
    }                             // HTML code to <div> with id = 'journal'
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=env_picture_adapt", true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description: Change the links of all web pictures to the current environment
//              (development, test or production)
//
function env_picture_check(type)
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('journal').innerHTML = xmlHttp.responseText;
    }                             // HTML code to <div> with id = 'journal'
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=env_picture_check&type=" + type, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description: Passes the text to search for onto the ajax routine
//
function env_text_search()
//
// Parameters:  text_sea_text     // text to search in database
//
//-----------------------------------------------------------------------------
{
  var text_sea = document.getElementById('text_sea').value;

  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('journal').innerHTML = xmlHttp.responseText;
    }                             // HTML code to <div> with id = 'journal'
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=env_text_search&text_sea=" + enc(text_sea), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description: Passes the text to replace onto the ajax routine
//
function env_text_replace(do_replace)
//
// Parameters:  text_rsea         // text to search in database
//              text_repl         // text to replace it in database
//
//-----------------------------------------------------------------------------
{
  var text_rsea = document.getElementById('text_rsea').value;
  var text_repl = document.getElementById('text_repl').value;

  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('journal').innerHTML = xmlHttp.responseText;
    }                             // HTML code to <div> with id = 'journal'
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=env_text_replace&text_sea=" + enc(text_rsea) + "&text_repl=" + enc(text_repl) + "&do_replace=" + enc(do_replace), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}
//
//
//-----------------------------------------------------------------------------
//
// Description: Request to output the entire homepage text the ajax routine
//
function env_text_output()
//
// Parameters:  None
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('journal').innerHTML = xmlHttp.responseText;
    }                             // HTML code to <div> with id = 'journal'
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=env_text_output", true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Just jump to page 'home'
//
function home()
//
//-----------------------------------------------------------------------------
{
  location.replace(c_file_home);
}


//-----------------------------------------------------------------------------
//
// Description:  Locks or unlocks the homepage for normal users
//
function homepage(target_state)   // 'lock':   Homepage locked for normal users
//                                // 'unlock': Homepage free for use
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      if (xmlHttp.responseText == "OK")
      {
        location.reload();
      }
      else
      {
        document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      }
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=homepage&state=" + target_state, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Add new link to the database
//
function link_add()
// Parameters:  group_name          // link group the link belongs to
//              name                // name of the link (www.xxx.xx)
//              ltitle              // title of link
//              cdate               // creation date of the link
//              descr (via editor)  // description of the link
//              url                 // URL of the link (http://www.xxx.xx)
//              recht               // right required to see link
//
// Remark        lurl + ltitle used because url + title are JavaScript keywords!
//
//-----------------------------------------------------------------------------
{
  var group_name = document.getElementById('group_name').value;
  var name       = document.getElementById('name').value;
  var lurl       = document.getElementById('url').value;
  var ltitle     = document.getElementById('ltitle').value;
  var cdate      = document.getElementById('cdate').value;
  var descr      = data_from_editor('FCKeditor');
  var recht      = document.getElementById('recht').value;

  //
  // Check if the 'Angezeigte URL' is not empty and not to long
  //
  if (!check_not_empty( document.getElementById('name'), "Angezeigte URL"))                         {return;}
  if (!check_no_char(   document.getElementById('name'), "Angezeigte URL", 0, c_max_size_linkname)) {return;}
  if (!check_field_char(document.getElementById('name'), "Angezeigte URL"))                         {return;}

  //
  // Check if the 'Echte URL' is not empty, not to long and a correct URL
  //
  if (!check_not_empty( document.getElementById('url'), "Echte URL"))                    {return;}
  if (!check_no_char(   document.getElementById('url'), "Echte URL", 0, c_max_size_url)) {return;}
  if (!check_field_char(document.getElementById('url'), "Echte URL"))                    {return;}

  //
  // Check if link title is given, not more than max. no char and only legal ASCII characters
  //
  if (!check_not_empty( document.getElementById('ltitle'), "Linktitel"))                      {return;}
  if (!check_no_char(   document.getElementById('ltitle'), "Linktitel", 0, c_max_size_title)) {return;}
  if (!check_field_char(document.getElementById('ltitle'), "Linktitel"))                      {return;}

  //
  // Check if creation date is not empty and correct ([d]d.[m]m.[yy]yy)
  //
  if (!check_not_empty(document.getElementById('cdate'), "Datum")) {return;}
  if (!check_date(     document.getElementById('cdate'), "Datum")) {return;}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_link_ajax + "?action=link_add&group_name=" + enc(group_name) + "&name=" + enc(name) + "&title=" + enc(ltitle) + "&cdate=" + cdate + "&descr=" + enc(descr) + "&url=" + enc(lurl) + "&recht=" + recht, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete exiting link from the database
//
function link_delete(id,          // id of the link to delete
                     name)        // name of the link to delete
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll der Link '" + name + "' wirklich gelöscht werden?"))
  {                                // delete confirmed --> execute
    xmlHttp = create_request();    // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        location.reload();
      }
    };
    xmlHttp.open("GET", c_file_link_ajax + "?action=link_delete&id=" + id, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Edit the data of an existing link
//
function link_edit(id)            // id of the link to edit
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);  // and scroll there
      f_tcalInit();                     // start scaning for tcal calendar
    }
  };
  xmlHttp.open("GET", c_file_link_ajax + "?action=link_edit&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Get the data of an new link
//
function link_new(page_id)        // id of page to add link to
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);  // and scroll there
      f_tcalInit();                     // start scaning for tcal calendar
    }
  };
  xmlHttp.open("GET", c_file_link_ajax + "?action=link_new&page_id=" + page_id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Update the data of an existing link in the database
//
function link_update(id)            // id of the link to update
// Parameters:  group_name          // link group the link belongs to
//              name                // name of the link (www.xxx.xx)
//              url                 // URL of the link (http://www.xxx.xx)
//              ltitle              // title of the link
//              cdate               // creation date of the link
//              descr (via editor)  // description of the link
//              recht               // right required to see link
//
// Remark        lurl + ltitle used because url + title are JavaScript keywords!
//
//-----------------------------------------------------------------------------
{
  var group_name = document.getElementById('group_name').value;
  var name       = document.getElementById('name').value;
  var lurl       = document.getElementById('url').value;
  var ltitle     = document.getElementById('ltitle').value;
  var cdate      = document.getElementById('cdate').value;
  var descr      = data_from_editor('FCKeditor');
  var recht      = document.getElementById('recht').value;

  //
  // Check if the 'Angezeigte URL' is not empty and not to long
  //
  if (!check_not_empty( document.getElementById('name'), "Angezeigte URL"))                         {return;}
  if (!check_no_char(   document.getElementById('name'), "Angezeigte URL", 0, c_max_size_linkname)) {return;}
  if (!check_field_char(document.getElementById('name'), "Angezeigte URL"))                         {return;}

  //
  // Check if the 'Echte URL' is not empty, not to long and a legal URL
  //
  if (!check_not_empty( document.getElementById('url'), "Echte URL"))                    {return;}
  if (!check_no_char(   document.getElementById('url'), "Echte URL", 0, c_max_size_url)) {return;}
  if (!check_field_char(document.getElementById('url'), "Echte URL"))                    {return;}

  //
  // Check if link title is given, not more than max. no char and only legal ASCII characters
  //
  if (!check_not_empty( document.getElementById('ltitle'), "Linktitel"))                      {return;}
  if (!check_no_char(   document.getElementById('ltitle'), "Linktitel", 0, c_max_size_title)) {return;}
  if (!check_field_char(document.getElementById('ltitle'), "Linktitel"))                      {return;}

  //
  // Check if creation date is not empty and correct ([d]d.[m]m.[yy]yy)
  //
  if (!check_not_empty(document.getElementById('cdate'), "Datum")) {return;}
  if (!check_date(     document.getElementById('cdate'), "Datum")) {return;}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();    // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_link_ajax + "?action=link_update&id=" + id + "&group_name=" + enc(group_name) + "&name=" + enc(name) + "&title=" + enc(ltitle) + "&cdate=" + cdate + "&descr=" + enc(descr) + "&url=" + enc(lurl) + "&recht=" + recht, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Verify if username and password match a known vSAF member
//
function login()
// Parameters:  None
//
//-----------------------------------------------------------------------------
{
  var benutzername = document.getElementById('benutzername').value;
  var passwort     = document.getElementById('passwort').value;
  xmlHttp = create_request();      // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      if (xmlHttp.responseText == "OK")
      {
        location.reload();
      }
      else
      {
        document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
        pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
        window.scrollTo(pos[0], pos[1]);
      }                           // and scroll there
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=login&benutzername=" + enc(benutzername) + "&passwort=" + passwort, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
function logout()
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=logout", true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Show all data of the specified member
//
function member_data_show(id)
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();    // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=member_data_show&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Add new news to the database
//
function news_add()
// Parameters:  date              // date of the news
//              title             // title of the news
//              text (via editor) // text of the news
//              recht             // right required to read news
//
//-----------------------------------------------------------------------------
{
  var date  = document.getElementById('date').value;
  var title = document.getElementById('title').value;
  var text  = data_from_editor('FCKeditor');
  var recht = document.getElementById('recht').value;

  //
  // Check if news date is not empty and correct ([d]d.[m]m.[yy]yy)
  //
  if (!check_not_empty(document.getElementById('date'), "Datum")) {return;}
  if (!check_date(     document.getElementById('date'), "Datum")) {return;}

  //
  // Check if a news titel has been given and longer than max. no characters
  //
  if (!check_not_empty( document.getElementById('title'), "Newstitel"))                      {return;}
  if (!check_no_char(   document.getElementById('title'), "Newstitel", 0, c_max_size_title)) {return;}
  if (!check_field_char(document.getElementById('title'), "Newstitel"))                      {return;}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
       location.reload();
    }
  };
  xmlHttp.open("POST", c_file_news_ajax + "?action=news_add&date=" + enc(date) + "&title=" + enc(title) + "&recht=" + enc(recht), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send("&text=" + enc(text));
}


//-----------------------------------------------------------------------------
//
// Description:  Delete exiting news from the database
//
function news_delete(id,          // id of the news to delete
                     ntitle)      // title of the news to delete
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll die News '" + ntitle + "' wirklich gelöscht werden?"))
  {                               // delete confirmed --> execute
    xmlHttp = create_request();   // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        location.reload();
      }
    };
    xmlHttp.open("GET", c_file_news_ajax + "?action=news_delete&id=" + id, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Edit the data of an existing news
//
function news_edit(id)            // id of the news to edit
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'new_news'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);  // and scroll there
      f_tcalInit();                     // start scaning for tcal calendar
    }
  };
  xmlHttp.open("GET", c_file_news_ajax + "?action=news_edit&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);             // edit news item
}


//-----------------------------------------------------------------------------
//
// Description:  Get the data of new news
//
function news_new()
// Parameters:  None
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'new_news'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);  // and scroll there
      f_tcalInit();               // start scaning for tcal calendar
    }
  };
  xmlHttp.open("GET", c_file_news_ajax + "?action=news_new", true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);             // get data of new news item
}


//-----------------------------------------------------------------------------
//
// Description:  Update the data of an existing news in the database
//
function news_update(id)          // id of the news to update
// Parameters:  date              // date of the news
//              title             // title of the news
//              text              // text of the news
//              recht             // right required to read news
//
//-----------------------------------------------------------------------------
{
  var date  = document.getElementById('date').value;
  var title = document.getElementById('title').value;
  var text  = data_from_editor('FCKeditor');
  var recht = document.getElementById('recht').value;

  //
  // Check if news date is not empty and correct ([d]d.[m]m.[yy]yy)
  //
  if (!check_not_empty(document.getElementById('date'), "Datum")) {return;}
  if (!check_date(     document.getElementById('date'), "Datum")) {return;}

  //
  // Check if a news titel has been given and longer than max. no characters
  //
  if (!check_not_empty( document.getElementById('title'), "Newstitel"))                      {return;}
  if (!check_no_char(   document.getElementById('title'), "Newstitel", 0, c_max_size_title)) {return;}
  if (!check_field_char(document.getElementById('title'), "Newstitel"))                      {return;}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();    // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("POST", c_file_news_ajax + "?action=news_update&id=" + id + "&date=" + enc(date) + "&title=" + enc(title) + "&recht=" + enc(recht), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send('&text=' + enc(text));
}


//-----------------------------------------------------------------------------
//
// Description:  Add new menu item to the database
//
function page_add(id)             // id of parent page
// Parameters:  menu              // menu point of the page
//              link              // link associated with page
//                                // (level 1 only / not supported on other levels)
//              ptitle            // title of page
//              checkDate         // method to check for page content updates
//              right             // right required to see page
//
// Remark        ptitle used because title is a JavaScript keyword!
//
//-----------------------------------------------------------------------------
{
  var menu_size = "";             // initialise no characters of menu
  var no_title  = false;          // initialise to 'a title can be input'
  var menu      = document.getElementById('menu').value;
  var link      = "";             // link only set up if level 1
  var ptitle    = document.getElementById('ptitle').value;
  var checkDate = document.getElementById('checkDate').value;
  var right     = document.getElementById('right').value;

  //
  // Check field 'link'
  //
  if (id == "")                   // no parent page defined --> level 1
  {                               // check field 'link' --> must be given
    link = document.getElementById('link').value;
    if (!check_not_empty(document.getElementById('link'), "Script oder Link")) {return;}
    if (is_script(document.getElementById('link'))) // link is a php script
    {                             // convert script name to lower case
      document.getElementById('link').value = document.getElementById('link').value.toLowerCase();
      if (!check_no_char(        document.getElementById('link'), "Script (oder Link)", 0, c_max_size_filename)) {return;}
      if (!check_filename_char(  document.getElementById('link'), "Script (oder Link)"))                         {return;}
    }
    else                          // link is an external link
    {
      if (!check_no_char(  document.getElementById('link'), "(Script oder) Link", 0, c_max_size_url)) {return;}
      if (!check_link_char(document.getElementById('link'), "(Script oder) Link"))                    {return;}
      no_title = true;            // to specify a title with an external link makes no sense

    }
    menu_size = c_max_size_menu_1; // define allowed menu size
  }
  else                            // parent page defined --> level 2 or higher
  {                               // no need to check 'link' since field not show on input form
    menu_size = c_max_size_menu_23; // define allowed menu size
  }

  //
  // Check if the menu point has been input
  //
  if (!check_not_empty( document.getElementById('menu'), "Menupunkt"))               {return;}
  if (!check_no_char(   document.getElementById('menu'), "Menupunkt", 0, menu_size)) {return;}
  if (!check_field_char(document.getElementById('menu'), "Menupunkt"))               {return;}

  //
  // Check page title
  //
  if (no_title)                   // external link --> a title makes no sense
  {if (!check_empty(document.getElementById('ptitle'), "Seitentitel"))                                {return;}}
  else
  {if (!check_no_char(   document.getElementById('ptitle'), "Seitentitel", 0, c_max_size_page_title)) {return;}
    if (!check_field_char(document.getElementById('ptitle'), "Seitentitel"))                           {return;}}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();    // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      if (xmlHttp.responseText == "OK")
      {
        location.reload();
      }
      else
      {
        document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
        pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
        window.scrollTo(pos[0], pos[1]);
      }                           // and scroll there
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=page_add&id=" + id + "&menu=" + enc(menu) + "&link=" + enc(link) + "&title=" + enc(ptitle) + "&right=" + right + "&checkDate=" + checkDate, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete exiting menu item from database
//
function page_delete(id,          // id of the menu item to delete
                     menu,        // menu item to delete
                     show_page)   //
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll der Menupunkt '" + menu + "' wirklich gelöscht werden?"))
  {                                // delete confirmed --> execute
    xmlHttp = create_request();    // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        if (xmlHttp.responseText == "OK")
        {
          if (show_page == "")
          {location.replace(c_file_home);}
          else
          {location.replace(show_page);}
        }
        else
        {
          document.getElementById('answer').innerHTML = xmlHttp.responseText;
        }                          // HTML code to <div> with id = 'answer'
      }
    };
    xmlHttp.open("GET", c_file_admin_ajax + "?action=page_delete&id=" + id, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Move existing page item down in the display sequence (--> higher id)
//
function page_down(id)            // id of the menu item to move down
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=page_down&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Edit the data of an existing menu item
//
function page_edit(id)            // id of the menu item to edit
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=page_edit&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);             // edit news item
}


//-----------------------------------------------------------------------------
//
// Description  Edit content of page
//
function page_edit_content(id)    // id of page to edit content
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('editable_text').innerHTML = xmlHttp.responseText;
      window.setTimeout("new_text_box();", 0);
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=page_edit_content&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Get data of new menu item to add
//
function page_new(id)             // id of parent menu to add a new menu item
// Parameters:  None
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=page_new&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);             // get data of new menu item
}


//-----------------------------------------------------------------------------
//
// Description:  Call page to show picture in full size
//
function page_put(acc_string)     // access string of page to call
//
//-----------------------------------------------------------------------------
{
  //
  // Call new page specified via access string
  //
  location.replace(acc_string);
}


//-----------------------------------------------------------------------------
//
// Description:  Move existing page item up in the display sequence (--> smaller id)
//
function page_up(id)              // id of the menu item to move up
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=page_up&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Update the data of an existing menu item in the database
//
function page_update(id)          // id of the page to update
// Parameters:  pid               // id of the parent page (NULL in level 1)
//              menu              // menu point of the page
//              link              // link associated with page
//                                // (level 1 only / not supported on other levels)
//              link_ori          // original link associated with page
//              ptitle            // title of page
//              checkDate         // method to check for page content updates
//              right             // right required to see page
//
//-----------------------------------------------------------------------------
{
  var menu_size = "";             // initialise no characters of menu
  var no_title  = false;          // initialise to 'a title can be input'
  var menu      = document.getElementById('menu').value;
  var link      = "";             // only set if level 1
  var link_ori  = "";             // only set if level 1
  var ptitle    = document.getElementById('ptitle').value;
  var checkDate = document.getElementById('checkDate').value;
  var right     = document.getElementById('right').value;

  //
  // Check field 'link'
  //
  if (document.getElementById('pid').value == "") // no parent page defined --> level 1
  {                               // check field 'link' --> must be given
    link     = document.getElementById('link').value;
    link_ori = document.getElementById('link_ori').value;
    if (!check_not_empty(document.getElementById('link'), "Script oder Link")) {return;}
    if (is_script(document.getElementById('link'))) // link is a php script
    {                             // convert script name to lower case
      document.getElementById('link').value = document.getElementById('link').value.toLowerCase();
      if (!check_no_char(        document.getElementById('link'), "Script (oder Link)", 0, c_max_size_filename)) {return;}
      if (!check_filename_char(  document.getElementById('link'), "Script (oder Link)"))                         {return;}
   }
    else
    {
      if (!check_no_char(  document.getElementById('link'), "(Script oder) Link", 0, c_max_size_url)) {return;}
      if (!check_link_char(document.getElementById('link'), "(Script oder) Link"))                    {return;}
      no_title = true;            // to specify a title with an externa link makes no sense
    }
    menu_size = c_max_size_menu_1; // define allowed menu size
  }
  else                            // parent page defined --> level 2 or higher
  {                               // no need to check 'link' since field not show on input form
    menu_size = c_max_size_menu_23; // define allowed menu size
  }

  //
  // Check if the menu point has been input
  //
  if (!check_not_empty( document.getElementById('menu'), "Menupunkt"))               {return;}
  if (!check_no_char(   document.getElementById('menu'), "Menupunkt", 0, menu_size)) {return;}
  if (!check_field_char(document.getElementById('menu'), "Menupunkt"))               {return;}

  //
  // Check page title
  //
  if (no_title)                   // external link --> a title makes no sense
  {if (!check_empty(document.getElementById('ptitle'), "Seitentitel"))                                {return;}}
  else
  {if (!check_no_char(   document.getElementById('ptitle'), "Seitentitel", 0, c_max_size_page_title)) {return;}
    if (!check_field_char(document.getElementById('ptitle'), "Seitentitel"))                           {return;}}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      if (xmlHttp.responseText == "OKhome")
      {                           // link of page changed --> show home
        location.replace(c_file_home);
      }
      else                        // link of page unchanged
      {
        if (xmlHttp.responseText == "OK")
        {
          location.reload();
        }
        else
        {
          document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
          pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
          window.scrollTo(pos[0], pos[1]);
        }                         // and scroll there
      }
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=page_update&id=" + id + "&menu=" + enc(menu) + "&link=" + enc(link) + "&link_ori=" + enc(link_ori) + "&title=" + enc(ptitle) + "&right=" + right + "&checkDate=" + checkDate, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description  Update edited page content in database
//
function page_update_content(id,        // id of page with edited content
                             upd_date)  // contains true if change date should be updated
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('editable_text').innerHTML = xmlHttp.responseText;
      location.reload();
    }
  };

  var text = data_from_editor('FCKeditor');
  xmlHttp.open("POST", c_file_admin_ajax + "?action=page_update_content&id=" + id + "&upd_date=" + upd_date, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send("&text=" + escape(text));
}


//-----------------------------------------------------------------------------
//
// Description:  Add new picture to the database
//
function picture_add()
// Parameters:  group_name        // picture group the picture belongs to
//              filename          // (new) filename of the picture
//              filename_ori      // current filename of the picture
//              cdate             // creation date of the picture
//              photographer1/2   // fotographer of the picture
//              comment           // comment to the picture
//              recht             // right required to see the picture
//
//-----------------------------------------------------------------------------
{
  var group_name    = document.getElementById('group_name').value;
  var dfilename     = document.getElementById('filename').value;
  var dfilename_ori = document.getElementById('filename_ori').value;
  var cdate         = document.getElementById('cdate').value;
  var photographer1 = document.getElementById('photographer1').value;
  var photographer2 = document.getElementById('photographer2').value;
  var photographer  = "";
  var comment       = document.getElementById('comment').value;
  var recht         = document.getElementById('recht').value;

  //
  // Check if filename is given, not more than max. no char and only legal ASCII characters
  //
  if (!check_not_empty(      document.getElementById('filename'), "Dateiname"))                         {return;}
  if (!check_no_char(        document.getElementById('filename'), "Dateiname", 0, c_max_size_filename)) {return;}
  if (!check_filename_char(  document.getElementById('filename'), "Dateiname"))                         {return;}

  //
  // Check if creation date is not empty and correct ([d]d.[m]m.[yy]yy)
  //
  if (!check_not_empty(document.getElementById('cdate'), "Datum")) {return;}
  if (!check_date(     document.getElementById('cdate'), "Datum")) {return;}

  //
  // If photographer is specified check it is within limits
  //
  if ((document.getElementById('photographer1').value != "") && (document.getElementById('photographer2').value != ""))
  {
    alert("Nur in einem der beiden 'Fotograf' Felder den Ersteller des Bildes angeben");
    document.getElementById('photographer1').focus(); // set focus to first field
    return;                       // terminate javascript processing
  }
  if (document.getElementById('photographer2').value != "")
  {if (!check_no_char(   document.getElementById('photographer2'), "Fotograf", 0, c_max_size_fotograf)) {return;}
    if (!check_field_char(document.getElementById('photographer2'), "Fotograf"))                         {return;}}
  photographer = photographer1 + photographer2; // setup photographer of picture

  //
  // If any given check comment
  //
  if (document.getElementById('comment').value != "")
  {if (!check_no_char(   document.getElementById('comment'), "Bildkommentar", 0, c_max_size_text)) {return;}
    if (!check_field_char(document.getElementById('comment'), "Bildkommentar"))                     {return;}}


  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();    // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      if (xmlHttp.responseText == "OK")
      {
        if (location.toString().indexOf("picture_name=") == -1)
        {                         // page does not show the unprocessed picture in full size
          location.reload();      // just reload page
        }
        else                      // page does show the unprocessed picture in full size
        {                         // set up URL to show current picture
          acc_string = location.toString().substr(0, location.toString().indexOf("picture_name=")) + "group=" + group_name;
          location.replace(acc_string);
        }
      }
      else
      {
        document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
        pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
        window.scrollTo(pos[0], pos[1]);
      }                           // and scroll there
    }
  };
  xmlHttp.open("GET", c_file_picture_ajax + "?action=picture_add&group_name=" + enc(group_name) + "&filename=" + dfilename +"&filename_ori=" + dfilename_ori + "&cdate=" + cdate + "&photographer=" + enc(photographer) + "&comment=" + enc(comment) + "&recht=" + recht, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete exiting picture from the database and directory
//
function picture_delete(id,         // id of the picture to delete
                        dfilename,  // name of the picture to delete
                        acc_string) // access string if current page cannot be
                                    //  shown anymore
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll das Bild '" + dfilename + "' wirklich gelöscht werden?"))
  {                               // delete confirmed --> execute
    xmlHttp = create_request();   // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        if (acc_string == "")     // reload current page
        {location.reload();}
        else                      // display specified page
        {location.replace(acc_string);}
      }
    };
    xmlHttp.open("GET", c_file_picture_ajax + "?action=picture_delete&id=" + id, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Edit the data of an existing picture
//
function picture_edit(id)         // id of the picture to edit
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);  // and scroll there
      f_tcalInit();                     // start scaning for tcal calendar
    }
  };
  xmlHttp.open("GET", c_file_picture_ajax + "?action=picture_edit&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete unwanted picture from directory 'uploaded'
//
function picture_ignore(dfilename,  // name of picture to ignore
                        acc_string) // access string if current page cannot be
                                    //  shown anymore
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll die Datei '" + dfilename + "' wirklich gelöscht werden?"))
  {                                // delete confirmed --> execute
    xmlHttp = create_request();    // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        if (acc_string == "")     // reload current page
        {location.reload();}
        else                      // display specified page
        {location.replace(acc_string);}
      }
    };
    xmlHttp.open("GET", c_file_picture_ajax + "?action=picture_ignore&filename=" + dfilename, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Get the data of an new picture
//
function picture_new(dfilename)   // name of file to add
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);  // and scroll there
      f_tcalInit();               // start scaning for tcal calendar
    }
  };
  xmlHttp.open("GET", c_file_picture_ajax + "?action=picture_new&filename=" + dfilename, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Show installed picture in full size
//
function picture_show(id)         // id of picture to show in full size
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('picture_out').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'picture_out'
      pos = findPos(document.getElementById('picture_out'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there
  };
  xmlHttp.open("GET", c_file_picture_ajax + "?action=picture_show&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Show unprocessd picture in full size
//
function picture_show_name(name,    // name of picture to show in full size
                           script)  // script to call to show unprocessed pictures
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('picture_out').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'picture_out'
      pos = findPos(document.getElementById('picture_out'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there
  };
  xmlHttp.open("GET", c_file_picture_ajax + "?action=picture_show_name&name=" + enc(name) + "&script=" + script, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Update the data of an existing picture in the database
//
function picture_update(id)       // id of the picture to update
// Parameters:  group_name        // picture group the picture belongs to
//              filename          // (new) filename of the picture
//              filename_ori      // current filename of the picture
//              cdate             // creation date of the picture
//              photographer1/2   // fotographer of the picture
//              comment           // comment to the picture
//              recht             // right required to see picture
//
//-----------------------------------------------------------------------------
{
  var group_name    = document.getElementById('group_name').value;
  var dfilename     = document.getElementById('filename').value;
  var dfilename_ori = document.getElementById('filename_ori').value;
  var cdate         = document.getElementById('cdate').value;
  var photographer1 = document.getElementById('photographer1').value;
  var photographer2 = document.getElementById('photographer2').value;
  var photographer  = "";
  var comment       = document.getElementById('comment').value;
  var recht         = document.getElementById('recht').value;

  //
  // Check if filename is given, not more than max. no char and only legal ASCII characters
  //
  if (!check_not_empty(      document.getElementById('filename'), "Dateiname"))                         {return;}
  if (!check_no_char(        document.getElementById('filename'), "Dateiname", 0, c_max_size_filename)) {return;}
  if (!check_filename_char(  document.getElementById('filename'), "Dateiname"))                         {return;}

  //
  // Check if creation date is not empty and correct ([d]d.[m]m.[yy]yy)
  //
  if (!check_not_empty(document.getElementById('cdate'), "Datum")) {return;}
  if (!check_date(     document.getElementById('cdate'), "Datum")) {return;}

  //
  // If photographer given check it is within limits
  //
  if ((document.getElementById('photographer1').value != "") && (document.getElementById('photographer2').value != ""))
  {
    alert("Nur in einem der beiden 'Fotograf' Felder den Ersteller des Bildes angeben");
    document.getElementById('photographer1').focus(); // set focus to first field
    return;                       // terminate javascript processing
  }
  if (document.getElementById('photographer2') != "")
  {if (!check_no_char(   document.getElementById('photographer2'), "Fotograf", 0, c_max_size_fotograf)) {return;}
    if (!check_field_char(document.getElementById('photographer2'), "Fotograf"))                         {return;}}
  photographer = photographer1 + photographer2; // setup photographer of picture

  //
  // If any given check comment
  //
  if (document.getElementById('comment').value != "")
  {if (!check_no_char(   document.getElementById('comment'), "Bildkommentar", 0, c_max_size_text)) {return;}
    if (!check_field_char(document.getElementById('comment'), "Bildkommentar"))                     {return;}}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      if (xmlHttp.responseText == "OK")
      {
        if (location.toString().indexOf("picture=") == -1)
        {                         // page does not show just one picture in full size
          location.reload();      // just reload page
        }
        else                      // page does show just one picture in full size
        {                         // set up URL to show current picture
          acc_string = location.toString().substr(0, location.toString().indexOf("picture=")) + "picture=" + id;
          location.replace(acc_string);
        }
      }
      else
      {
        document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'picture_out'
        pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
        window.scrollTo(pos[0], pos[1]);
      }                           // and scroll there
    }
  };
  xmlHttp.open("GET", c_file_picture_ajax + "?action=picture_update&id=" + id + "&group_name=" + enc(group_name) + "&filename=" + dfilename + "&filename_ori=" + dfilename_ori + "&cdate=" + cdate + "&photographer=" + enc(photographer) + "&comment=" + enc(comment) + "&recht=" + recht, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Add new video to the database
//
function video_add()
// Parameters:  group_name          // video group the video belongs to
//              type                // video type (numeric)
//              filename            // (new) filename of the video
//              filename_ori        // current filename of the video
//              shadow              // add drop shadow to tumbnail (yes / no)
//              url                 // URL of the web video
//              cdate               // creation date of the video
//              duration            // duration in minute of the video
//              widht               // width of the video
//              height              // height of the video
//              name                // name of the video
//              descr (via editor)  // description of the video
//              recht               // right required to see video
//
//-----------------------------------------------------------------------------
{
  var group_name    = document.getElementById('group_name').value;
  var type          = document.getElementById('type').value;
  var dfilename     = document.getElementById('filename').value;
  var dfilename_ori = document.getElementById('filename_ori').value;
  var shadow        = document.getElementById('shadow').value;
  var url           = document.getElementById('url').value;
  var cdate         = document.getElementById('cdate').value;
  var duration      = document.getElementById('duration').value;
  var width         = document.getElementById('width').value;
  var height        = document.getElementById('height').value;
  var name          = document.getElementById('name').value;
  var descr         = data_from_editor('FCKeditor');
  var recht         = document.getElementById('recht').value;

  //
  // Check video type and filename/URL match
  //
  if ((type == c_video_type_file) && (filename == ""))
  {
    alert("Ein Video vom Typ 'Datei' benötigt einen Dateinamen");
    document.getElementById('filename').focus();
    return;                    // quit processing
  }
  if ((type == c_video_type_file) && (url != ""))
  {
    alert("Ein Video vom Typ 'Datei' kann keine URL aufweisen");
    document.getElementById('url').focus();
    return;                    // quit processing
  }
  if ((type != c_video_type_file) && (url == ""))
  {
    if (type == c_video_type_youtube) {alert("Ein YouTube Video benötigt eine Video ID");}
    else                              {alert("Ein Web Video benötigt eine URL");}
    document.getElementById('url').focus();
    return;                    // quit processing
  }
  if ((type != c_video_type_file) && (filename == ""))
  {
    alert("Ein Video mit einem andern Typ als 'Datei' benötigt keinen Dateinamen");
    document.getElementById('filename').focus();
    return;                    // quit processing
  }

  //
  // If a filename has been given, check its size and characters
  //
  if (filename != "")
  {
    if (!check_no_char(      document.getElementById('filename'), "Dateiname", 0, c_max_size_filename)) {return;}
    if (!check_filename_char(document.getElementById('filename'), "Dateiname"))                         {return;}
  }

  //
  // If an URL has been given, check its size and characters
  //
  if (url != "")
  {
    if (!check_no_char(   document.getElementById('url'), "URL", 0, c_max_size_url)) {return;}
    if (!check_field_char(document.getElementById('url'), "URL"))                    {return;}
  }

  //
  // Check if video title is given, not more than max. no char and only legal ASCII characters
  //
  if (!check_not_empty( document.getElementById('name'), "Videotitel"))                      {return;}
  if (!check_no_char(   document.getElementById('name'), "Videotitel", 0, c_max_size_title)) {return;}
  if (!check_field_char(document.getElementById('name'), "Videotitel"))                      {return;}

  //
  // Check if creation date is not empty and correct ([d]d.[m]m.[yy]yy)
  //
  if (!check_not_empty(document.getElementById('cdate'), "Datum")) {return;}
  if (!check_date(     document.getElementById('cdate'), "Datum")) {return;}

  //
  // Check if width and heigth are both given or both not given
  //
  if (((width != "") && (height == "")) || ((width == "") && (height != "")))
  {
    alert("Entweder Breite und Höhe spezifizieren oder beide weglassen (--> Defaultgrösse verwenden)'");
    document.getElementById('width').focus();
    return;                    // quit processing
  }

  //
  // If width is given, check it its in range
  //
  if (width != "")
  {
    if (!check_num_range(document.getElementById('width'), "Breite", c_min_size_video, c_max_size_video)) {return;}
  }

  //
  // If width is given, check it its in range
  //
  if (height != "")
  {
    if (!check_num_range(document.getElementById('height'), "Höhe", c_min_size_video, c_max_size_video)) {return;}
  }

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      if (xmlHttp.responseText == "OK")
      {
        location.reload();
      }
      else
      {
        document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
        pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
        window.scrollTo(pos[0], pos[1]);
      }                           // and scroll there
    }
  };
  xmlHttp.open("GET", c_file_video_ajax + "?action=video_add&group_name=" + enc(group_name) + "&type=" + enc(type) + "&filename=" + enc(dfilename) + "&filename_ori=" + enc(dfilename_ori) + "&shadow=" + enc(shadow) + "&url=" + enc(url) + "&cdate=" + enc(cdate) + "&duration=" + enc(duration) + "&width=" + enc(width) + "&height=" + enc(height) + "&name=" + enc(name) + "&descr=" + enc(descr) + "&recht=" + enc(recht), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete exiting video from the database and directory
//
function video_delete(id,     // id of the video to delete
                      title)  // title of the video to delete
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll der Video '" + title + "' wirklich gelöscht werden?"))
  {                                // delete confirmed --> execute
    xmlHttp = create_request();    // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        location.reload();
      }
    };
    xmlHttp.open("GET", c_file_video_ajax + "?action=video_delete&id=" + id, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Edit the data of an existing video
//
function video_edit(id)        // id of the video to edit
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);  // and scroll there
      f_tcalInit();                     // start scaning for tcal calendar
    }
  };
  xmlHttp.open("GET", c_file_video_ajax + "?action=video_edit&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete unwanted video from directory 'uploaded'
//
function video_ignore(dfilename) // name of file to ignore
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll der Video '" + dfilename + "' wirklich gelöscht werden?"))
  {                               // delete confirmed --> execute
    xmlHttp = create_request();   // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        location.reload();
      }
    };
    xmlHttp.open("GET", c_file_video_ajax + "?action=video_ignore&filename=" + dfilename, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Get the data of an new video
//
function video_new(type,          // type of video (see c_video_type_xxx)
                   par2)          // filename if video on homepage or
                                  // id of page to put new video
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);  // and scroll there
      f_tcalInit();               // start scaning for tcal calendar
    }
  };
  if (type == c_video_type_file) {param = "&filename=" + par2;}
  else                           {param = "&page_id="  + par2;}
  xmlHttp.open("GET", c_file_video_ajax + "?action=video_new&type=" + type + param, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Play the specified homepage video
//
function video_play(id)           // id of the homepage video to play
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
                                  // and scroll there
      $f("player", c_dir_flowplayer + c_file_flowplayer_swf,
          {clip: {autoPlay: true}} // ", scaling: 'fit'" removed because it caused problems
        );
    }
  };
  xmlHttp.open("GET", c_file_video_ajax + "?action=video_play&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Play the specified homepage video
//
function video_play_file(filename)  // filename of unprocessed video to play
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
                                  // and scroll there
      $f("player", c_dir_flowplayer + c_file_flowplayer_swf,
          {clip: {autoPlay: true}} // ", scaling: 'fit'" removed because it caused problems
        );
    }
  };
  xmlHttp.open("GET", c_file_video_ajax + "?action=video_play_file&filename=" + filename, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Play the specified web video
//
function video_play_web(id)       // id of the web video to play
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
                                  // and scroll there
    }
  };
  xmlHttp.open("GET", c_file_video_ajax + "?action=video_play_web&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Update the data of an existing video in the database
//
function video_update(id)           // id of the video to update
// Parameters:  group_name          // video group the video belongs to
//              type                // video type (numeric)
//              filename            // (new) filename of the video
//              filename_ori        // current filename of the video
//              shadow              // add drop shadow to tumbnail (yes / no)
//              url                 // URL of the web video
//              cdate               // creation date of the video
//              duration            // duration in minute of the video
//              widht               // width of the video
//              height              // height of the video
//              name                // name of the video
//              descr (via editor)  // description of the video
//              recht               // right required to see video
//
//-----------------------------------------------------------------------------
{
  var group_name    = document.getElementById('group_name').value;
  var type          = document.getElementById('type').value;
  var dfilename     = document.getElementById('filename').value;
  var dfilename_ori = document.getElementById('filename_ori').value;
  var shadow        = document.getElementById('shadow').value;
  var url           = document.getElementById('url').value;
  var cdate         = document.getElementById('cdate').value;
  var duration      = document.getElementById('duration').value;
  var width         = document.getElementById('width').value;
  var height        = document.getElementById('height').value;
  var name          = document.getElementById('name').value;
  var descr         = data_from_editor('FCKeditor');
  var recht         = document.getElementById('recht').value;

  //
  // Check video type and filename/URL match
  //
  if ((type == c_video_type_file) && (filename == ""))
  {
    alert("Ein Video vom Typ 'Datei' benötigt einen Dateinamen");
    document.getElementById('filename').focus();
    return;                    // quit processing
  }
  if ((type == c_video_type_file) && (url != ""))
  {
    alert("Ein Video vom Typ 'Datei' kann keine URL aufweisen");
    document.getElementById('url').focus();
    return;                    // quit processing
  }
  if ((type != c_video_type_file) && (url == ""))
  {
    if (type == c_video_type_youtube) {alert("Ein YouTube Video benötigt eine Video ID");}
    else                               {alert("Ein Web Video benötigt eine URL");}
    document.getElementById('url').focus();
    return;                    // quit processing
  }
  if ((type != c_video_type_file) && (filename == ""))
  {
    alert("Ein Video mit einem andern Typ als 'Datei' benötigt keinen Dateinamen");
    document.getElementById('filename').focus();
    return;                    // quit processing
  }

  //
  // If a filename has been given, check its size and characters
  //
  if (filename != "")
  {
    if (!check_no_char(      document.getElementById('filename'), "Dateiname", 0, c_max_size_filename)) {return;}
    if (!check_filename_char(document.getElementById('filename'), "Dateiname"))                         {return;}
  }

  //
  // If an URL has been given, check its size and characters
  //
  if (url != "")
  {
    if (!check_no_char(   document.getElementById('url'), "URL", 0, c_max_size_url)) {return;}
    if (!check_field_char(document.getElementById('url'), "URL"))                    {return;}
  }

  //
  // Check if video title is given, not more than max. no char and only legal ASCII characters
  //
  if (!check_not_empty( document.getElementById('name'), "Videotitel"))                      {return;}
  if (!check_no_char(   document.getElementById('name'), "Videotitel", 0, c_max_size_title)) {return;}
  if (!check_field_char(document.getElementById('name'), "Videotitel"))                      {return;}

  //
  // Check if creation date is not empty and correct ([d]d.[m]m.[yy]yy)
  //
  if (!check_not_empty(document.getElementById('cdate'), "Datum")) {return;}
  if (!check_date(     document.getElementById('cdate'), "Datum")) {return;}

  //
  // Check if width and heigth are both given or both not given
  //
  if (((width != "") && (height == "")) || ((width == "") && (height != "")))
  {
    alert("Entweder Breite und Höhe spezifizieren oder beide weglassen (--> Defaultgrösse verwenden)'");
    document.getElementById('width').focus();
    return;                    // quit processing
  }

  //
  // If width is given, check it is in range
  //
  if (width != "")
  {
    if (!check_num_range(document.getElementById('width'), "Breite", c_min_size_video, c_max_size_video)) {return;}
  }

  //
  // If width is given, check it is in range
  //
  if (height != "")
  {
    if (!check_num_range(document.getElementById('height'), "Höhe", c_min_size_video, c_max_size_video)) {return;}
  }

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      if (xmlHttp.responseText == "OK")
      {
        location.reload();
      }
      else
      {
        document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
        pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
        window.scrollTo(pos[0], pos[1]);
      }                           // and scroll there
    }
  };
  xmlHttp.open("GET", c_file_video_ajax + "?action=video_update&id=" + enc(id) + "&group_name=" + enc(group_name) + "&type=" + enc(type) + "&filename=" + enc(dfilename) + "&filename_ori=" + enc(dfilename_ori) + "&shadow=" + enc(shadow) + "&url=" + enc(url) + "&cdate=" + enc(cdate) + "&duration=" + enc(duration) + "&width=" + enc(width) + "&height=" + enc(height) + "&name=" + enc(name) + "&descr=" + enc(descr) + "&recht=" + enc(recht), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description: Changes the state of the administrator (activates or deactivates
//              the change rights of the user (user is an administrator))
//
function user_change_admin()
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      if (xmlHttp.responseText == "OK")
      {                           // user has already loged on during session
        location.reload();
      }
      else                        // admin must logon with this session
      {
        location.replace(c_file_login);
      }
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=user_change_admin", true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete exiting vSAF member from database
//
function user_delete(id,          // id of the user to delete
                     name)        // name of the user to delete
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll das Mitglied '" + name + "' wirklich gelöscht werden?"))
  {                               // delete confirmed --> execute
    xmlHttp = create_request();   // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        document.getElementById("answer").innerHTML = xmlHttp.responseText;
        window.setTimeout("location.reload();", c_msg_delay);
      }
    };
    xmlHttp.open("GET", c_file_admin_ajax + "?action=user_delete&id=" + id, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Edit the data of an exiting vSAF member
//
function user_edit(id)            // id of the user to edit
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);  // and scroll there
      f_tcalInit();                     // start scaning for tcal calendar
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=user_edit&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//----------------------------------------------------------------------------
//
// Description  Add new user state data into database
//
function user_state_add()
//
//-----------------------------------------------------------------------------
{
  //
  // Check if status name is given and not more than max. no chars
  //
  if (!check_not_empty( document.getElementById('status'), "Status"))                       {return;}
  if (!check_no_char(   document.getElementById('status'), "Status", 0, c_max_size_status)) {return;}
  if (!check_field_char(document.getElementById('status'), "Status"))                       {return;}

  //
  // Put the user state data to store together
  //
  var call_string = c_file_admin_ajax            + "?action=user_state_add";
  call_string = call_string + "&status="         + document.getElementById('status').value;
  call_string = call_string + "&is_member="      + document.getElementById('is_member').value;
  call_string = call_string + "&is_vsaf="        + document.getElementById('is_vsaf').value;
  call_string = call_string + "&is_memberstate=" + document.getElementById('is_memberstate').value;
  call_string = call_string + "&is_adminstate="  + document.getElementById('is_adminstate').value;
  call_string = call_string + "&is_editable="    + document.getElementById('is_editable').value;
  call_string = call_string + "&r_downl="        + document.getElementById('r_downl').value;
  call_string = call_string + "&r_vsafdl="       + document.getElementById('r_vsafdl').value;
  call_string = call_string + "&r_vsafvid="      + document.getElementById('r_vsafvid').value;
  call_string = call_string + "&r_member="       + document.getElementById('r_member').value;
  call_string = call_string + "&r_verein="       + document.getElementById('r_verein').value;
  call_string = call_string + "&c_owndata="      + document.getElementById('c_owndata').value;
  call_string = call_string + "&c_downl="        + document.getElementById('c_downl').value;
  call_string = call_string + "&c_videos="       + document.getElementById('c_videos').value;
  call_string = call_string + "&c_pict="         + document.getElementById('c_pict').value;
  call_string = call_string + "&c_links="        + document.getElementById('c_links').value;
  call_string = call_string + "&c_news="         + document.getElementById('c_news').value;
  call_string = call_string + "&c_texts="        + document.getElementById('c_texts').value;
  call_string = call_string + "&c_memb="         + document.getElementById('c_memb').value;
  call_string = call_string + "&c_struc="        + document.getElementById('c_struc').value;
  call_string = call_string + "&s_admin="        + document.getElementById('s_admin').value;

  //
  // Update the user record if the could be assembled successful
  //
  xmlHttp = create_request();   // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById("answer").innerHTML = xmlHttp.responseText;
      window.setTimeout("location.reload();", c_msg_delay);
    }
  };
  xmlHttp.open("GET", call_string, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete exiting user state from database
//
function user_state_delete(id,          // id of the user state delete
                           status) // name of the user state delete
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll der Status '" + status + "' wirklich gelöscht werden?"))
  {                                // delete confirmed --> execute
    xmlHttp = create_request();    // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        document.getElementById("answer").innerHTML = xmlHttp.responseText;
        window.setTimeout("location.reload();", c_msg_delay);
      }
    };
    xmlHttp.open("GET", c_file_admin_ajax + "?action=user_state_delete&id=" + id + "&status=" + enc(status), true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Edit data of member state
//
function user_state_edit(type,    // type of user entry (member or admin)
                         id)      // id of the user state to edit
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=user_state_edit&type=" + type + "&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Move existing database table entry up in the display sequence
// (--> smaller id)
//
function user_state_entry_up(type,  // type of user entry (member or admin)
                             id)    // id of the entry to move up
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=user_state_entry_up&type=" + enc(type) + "&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Get data for new user state
//
function user_state_new(type)     // type of user entry (member or admin)
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=user_state_new&type=" + type, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//----------------------------------------------------------------------------
//
// Description  Update existing user state data in database
//
function user_state_update(id)    // id of user state in rights table
//
//-----------------------------------------------------------------------------
{
  //
  // Check if status name is given and not more than max. no chars
  //
  if (!check_not_empty( document.getElementById('status'), "Status"))                       {return;}
  if (!check_no_char(   document.getElementById('status'), "Status", 0, c_max_size_status)) {return;}
  if (!check_field_char(document.getElementById('status'), "Status"))                       {return;}

  //
  // Put the user state data to store together
  //
  var call_string = c_file_admin_ajax            + "?action=user_state_update&id=" + id;
  call_string = call_string + "&status="         + document.getElementById('status').value;
  call_string = call_string + "&is_member="      + document.getElementById('is_member').value;
  call_string = call_string + "&is_vsaf="        + document.getElementById('is_vsaf').value;
  call_string = call_string + "&is_memberstate=" + document.getElementById('is_memberstate').value;
  call_string = call_string + "&is_adminstate="  + document.getElementById('is_adminstate').value;
  call_string = call_string + "&is_editable="    + document.getElementById('is_editable').value;
  call_string = call_string + "&r_downl="        + document.getElementById('r_downl').value;
  call_string = call_string + "&r_vsafdl="       + document.getElementById('r_vsafdl').value;
  call_string = call_string + "&r_vsafvid="      + document.getElementById('r_vsafvid').value;
  call_string = call_string + "&r_member="       + document.getElementById('r_member').value;
  call_string = call_string + "&r_verein="       + document.getElementById('r_verein').value;
  call_string = call_string + "&c_owndata="      + document.getElementById('c_owndata').value;
  call_string = call_string + "&c_downl="        + document.getElementById('c_downl').value;
  call_string = call_string + "&c_videos="       + document.getElementById('c_videos').value;
  call_string = call_string + "&c_pict="         + document.getElementById('c_pict').value;
  call_string = call_string + "&c_links="        + document.getElementById('c_links').value;
  call_string = call_string + "&c_news="         + document.getElementById('c_news').value;
  call_string = call_string + "&c_texts="        + document.getElementById('c_texts').value;
  call_string = call_string + "&c_memb="         + document.getElementById('c_memb').value;
  call_string = call_string + "&c_struc="        + document.getElementById('c_struc').value;
  call_string = call_string + "&s_admin="        + document.getElementById('s_admin').value;

  //
  // Update the user record if the could be assembled successful
  //
  xmlHttp = create_request();   // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById("answer").innerHTML = xmlHttp.responseText;
      window.setTimeout("location.reload();", c_msg_delay);
    }
  };
  xmlHttp.open("GET", call_string, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


/**
 * Update the existing user data in the database.
 *
 * @param  type   int   Type of data to edit
 *                      - 1: own data updated by user
 *                      - 2: vSAF member data update by admin
 * @param  id     int   Id of user in member table
 */
function user_update(type, id)
{
  //
  // Check if new or already existing user
  //
  var module;
  if (id == 0)                    // user is new
  {
    module = c_file_admin_ajax + "?action=user_add&type=" + type;
  }                               // call function user_add
  else                            // already existing user
  {
    module = c_file_admin_ajax + "?action=user_update&type=" + type + "&id=" + id;
  }                               // call function user_update

  //
  // Put the user data to store together
  //
  var call_string = call_string_user(module);

  //
  // Update the user record if the could be assembled successful
  //
  if (call_string != "")
  {
    xmlHttp = create_request();   // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        document.getElementById("answer").innerHTML = xmlHttp.responseText;
        window.setTimeout("location.reload();", c_msg_delay);
      }
    };
    xmlHttp.open("GET", call_string, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Show specified group of vSAF mail addresses
//
function vsaf_mail_adr_show(group)
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();    // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }
  };
  xmlHttp.open("GET", c_file_admin_ajax + "?action=vsaf_mail_adr_show&group=" + group, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete unwanted web picture from directory 'web_images'
//
function web_picture_delete(dfilename,  // name of web picture to delete
                            acc_string) // access string if current page cannot be
                                        //  shown anymore
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll das Homepage Bild '" + dfilename + "' wirklich gelöscht werden?"))
  {                               // delete confirmed --> execute
    xmlHttp = create_request();   // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        if (acc_string == "")    // reload current page
        {location.reload();}
        else                      // display specified page
        {location.replace(acc_string);}
      }
    };
    xmlHttp.open("GET", c_file_picture_ajax + "?action=web_picture_delete&filename=" + dfilename, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Edit the data of a web picture
//
function web_picture_edit(dfilename)  // name of file that contains web picture
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there
  };
  xmlHttp.open("GET", c_file_picture_ajax + "?action=web_picture_edit&filename=" + dfilename, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Show web picture in full size
//
function web_picture_show(name,       // name of picture to show in full size
                          acc_string) // access string to show all web pictures
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('picture_out').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'picture_out'
      pos = findPos(document.getElementById('picture_out'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there
  };
  xmlHttp.open("GET", c_file_picture_ajax + "?action=web_picture_show&name=" + enc(name) + "&acc_string=" + enc(acc_string), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Update an existing web picture
//
function web_picture_update()
// Parameters:  filename_ori      // current filename of web picture
//              filename          // new filename of web picture
//              width             // new width of web picture
//              shadow            // add drop shadow (yes / no)
//
//-----------------------------------------------------------------------------
{
  var pfilename_ori = document.getElementById('filename_ori').value;
  var pfilename     = document.getElementById('filename').value;
  var pwidth        = document.getElementById('width').value;
  var shadow        = document.getElementById('shadow').value;

  //
  // If filename is given, check not more than max. no char and only legal ASCII characters
  //
  if (document.getElementById('filename').value != "")
  {
    if (!check_no_char(      document.getElementById('filename'), "Dateiname", 0, c_max_size_filename)) {return;}
    if (!check_filename_char(document.getElementById('filename'), "Dateiname"))                         {return;}
  }

  //
  // If new size specified, check legal value range and that filename is given
  //
  if (document.getElementById('width').value != "")
  {
    if (!check_num_range(document.getElementById('width'), "Neue Breite", c_min_size_webpic, c_max_size_webpic)) {return;}
    if (!check_not_empty(document.getElementById('filename'), "Dateiname")) {return;}
  }

  //
  // If shadow should be added, check that filename is given
  //
  if (document.getElementById('shadow').value != "")
  {
    if (!check_not_empty(document.getElementById('filename'), "Dateiname")) {return;}
  }

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      if (xmlHttp.responseText == "OK")
      {
        if (location.toString().indexOf("web_picture_name=") == -1)
        {                         // page does not show just one picture in full size
          acc_string = location.toString();
        }
        else                      // page does show just one picture in full size
        {                         // set up URL to show current picture
          acc_string = location.toString().substr(0, location.toString().indexOf("web_picture_name=")) + "web_picture_name=" + pfilename;
        }
        location.replace(acc_string);
      }
      else
      {
        document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'picture_out'
        pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
        window.scrollTo(pos[0], pos[1]);
      }                           // and scroll there
    }
  };
  xmlHttp.open("GET", c_file_picture_ajax + "?action=web_picture_update&filename_ori=" + pfilename_ori + "&filename=" + pfilename + "&width=" + pwidth + "&shadow=" + shadow, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Add new wing to the database
//
function wing_add()
// Parameters:  name                // name of wing to add (vFlst xx)
//              homebase            // ID of homebase of wing in t_airports
//              descr (via editor)  // short description of wing
//
//-----------------------------------------------------------------------------
{
  var name     = document.getElementById('name').value;
  var homebase = document.getElementById('homebase').value;
  var descr    = data_from_editor('FCKeditor');

  //
  // Check if name is given and not more than max. no chars
  //
  if (!check_not_empty( document.getElementById('name'), "Staffelname"))                          {return;}
  if (!check_no_char(   document.getElementById('name'), "Staffelname", 0, c_max_size_wing_name)) {return;}
  if (!check_field_char(document.getElementById('name'), "Staffelname"))                          {return;}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_vsaf_ajax + "?action=wing_add&name=" + enc(name) + "&homebase=" + homebase + "&descr=" + enc(descr), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Delete exiting wing from the database
//
function wing_delete(id,          // id of the wing to delete
                     wing_name)   // name of the wing to delete
//
//-----------------------------------------------------------------------------
{
  if (confirm("Soll die Staffel '" + wing_name + "' wirklich gelöscht werden?"))
  {                                // delete confirmed --> execute
    xmlHttp = create_request();    // create xmlHttp object
    xmlHttp.onreadystatechange = function()
    {
      if (xmlHttp.readyState == c_state_loaded)
      {
        location.reload();
      }
    };
    xmlHttp.open("GET", c_file_vsaf_ajax + "?action=wing_delete&id=" + id, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
    xmlHttp.send(null);
  }
}


//-----------------------------------------------------------------------------
//
// Description:  Edit the data of an existing wing
//
function wing_edit(id)            // id of the wing to edit
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there

  };
  xmlHttp.open("GET", c_file_vsaf_ajax + "?action=wing_edit&id=" + id, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Get the data of an new wing
//
function wing_new()
//
//-----------------------------------------------------------------------------
{
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      document.getElementById('answer').innerHTML = xmlHttp.responseText;
                                  // HTML code to <div> with id = 'answer'
      pos = findPos(document.getElementById('answer'));
                                  // get position of <div> element
      window.scrollTo(pos[0], pos[1]);
    }                             // and scroll there
  };
  xmlHttp.open("GET", c_file_vsaf_ajax + "?action=wing_new", true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Update the data of an existing wing in the database
//
function wing_update(id)            // ID of the wing to update
// Parameters:  name                // name of wing to add (vFlst xx)
//              homebase            // ID of homebase of wing in t_airports
//              descr (via editor)  // short description of wing
//
//-----------------------------------------------------------------------------
{
  var name     = document.getElementById('name').value;
  var homebase = document.getElementById('homebase').value;
  var descr    = data_from_editor('FCKeditor');

  //
  // Check if name is given and not more than max. no chars
  //
  if (!check_not_empty( document.getElementById('name'), "Staffelname"))                          {return;}
  if (!check_no_char(   document.getElementById('name'), "Staffelname", 0, c_max_size_wing_name)) {return;}
  if (!check_field_char(document.getElementById('name'), "Staffelname"))                          {return;}

  //
  // Call ajax routine if all checks passed
  //
  xmlHttp = create_request();     // create xmlHttp object
  xmlHttp.onreadystatechange = function()
  {
    if (xmlHttp.readyState == c_state_loaded)
    {
      location.reload();
    }
  };
  xmlHttp.open("GET", c_file_vsaf_ajax + "?action=wing_update&id=" + id + "&name=" + enc(name) + "&homebase=" + homebase + "&descr=" + enc(descr), true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
  xmlHttp.send(null);
}


//-----------------------------------------------------------------------------
//
// Description:  Calls the specified function if return is hit
//
function submit(evnt,             // event passed on (deliberatly misspelled)
                ftarget,          // function to call if retrun hit
                par1,             // 1st function parameter
                par2,             // 2nd function parameter
                par3)             // 3rd function parameter
//
// Remark:      This function must be placed at the very end of this file
//              because it calls functions and they must be defined when called
//
//-----------------------------------------------------------------------------
{
  //
  // Get key pressed
  //
  var keypressed = 0;             // initialise key pressed
  if(window.event)                // currently running under Internet Explorer
  {keypressed = evnt.keyCode;}    //  event stored in keyCode
  else if(evnt.which)             // currently running under Firefox, Opera, etc.
  {keypressed = evnt.which;}      //  event stored in which

  //
  // Call specified function if key 'Return' is hit
  //
  if (keypressed == c_keycode_return)
  {
    switch (ftarget)
    {
      case "login":               // call function login()
        login();
        break;
      case "user_update":         // call fuction user_update()
        user_update(par1, par2);
        break;

      case "page_add":            // call fuction page_add()
        page_add(par1);
        break;
      case "page_update":         // call fuction page_update()
        page_update(par1);
        break;

      case "download_add":        // call fuction download_add()
        download_add();
        break;
      case "download_update":     // call fuction download_update()
        download_update(par1);
        break;

      case "element_group_add":   // call fuction element_group_add()
        element_group_add(par1, par2);
        break;
      case "element_group_update": // call fuction element_group_update()
        element_group_update(par1, par2, par3);
        break;

      case "link_add":            // call fuction link_add()
        link_add();
        break;
      case "link_update":         // call fuction link_update()
        link_update(par1);
        break;

      case "news_add":            // call fuction news_add()
        news_add();
        break;
      case "news_update":         // call fuction news_update()
        news_update(par1);
        break;

      case "picture_add":         // call fuction picture_add()
        picture_add();
        break;
      case "picture_update":      // call fuction picture_update()
        picture_update(par1);
        break;

      case "video_add":           // call fuction video_add()
        video_add();
        break;
      case "video_update":        // call fuction video_update()
        video_update(par1);
        break;

      case "env_text_search":     // call fuction env_text_search()
        env_text_search();
        break;

      default:                    // unknown function called
        alert("** Software error **: Function submit(); Call to " + ftarget + "(" + par1 + ", " + par2 + ", " + par3 + ") undefined");
        break;
    }
  }
}

