function update ()
{
/* Demo-Program for http://captchas.net */
/* Written by                           */
/* Sebastian Wilhelmi seppi@seppi.de    */
/* Felix Holderied felix@holderied.de   */
/* Last Change: 2008/09/08              */

/* Required Parameters */
  key      = document.getElementById('captcha_key').value
  random   = document.getElementById('captcha_random').value

/* Optional Parameters */
  alphabet = document.getElementById('alphabet').value
  letters  = document.getElementById('letters').value
  width    = document.getElementById('width').value
  height   = document.getElementById('height').value
  color    = document.getElementById('color').value

/* Compute Captcha-Code */
  encryption_base = key + random;  
  if(alphabet != 'abcdefghijklmnopqrstuvwxyz' || letters != '6') 
    encryption_base += ':' + escape (alphabet) + ':' + letters;
  md5 = new String (str_md5 (encryption_base));
  password = ''
  for(var i = 0; i < letters; i++)
  {
    index = md5.charCodeAt (i) % alphabet.length
    password +=  alphabet.charAt (index);
  }

/* Arguments for URL */

/* Add required Arguments */

  arg = '?client=' + document.getElementById('captcha_client').value
  arg +='&random=' + escape (random)
   
/* Add optional Arguments */
  if(alphabet != 'abcdefghijklmnopqrstuvwxyz') arg +='&alphabet=' + escape (alphabet)
  if(letters != 6) arg +='&letters=' + escape (letters)
  
/* Audio arguments are complete */
  audio_name = 'http://audio.captchas.net' + arg
  audio_name_en = audio_name + '&language=en'
  audio_name_de = audio_name + '&language=de'
  audio_name_it = audio_name + '&language=it'
  audio_name_nl = audio_name + '&language=nl'
  audio_name_fr = audio_name + '&language=fr'

/* Height, Width and Color are only needed in image */
  if(width != 240) arg +='&width=' + escape (width)
  if(height != 80) arg +='&height=' + escape (height)
  if(color != '000000') arg +='&color=' + escape (color)
  
/* Image arguments are complete */
  pic_name = 'http://image.captchas.net' + arg

/* Refresh */
  document.getElementById('captcha_pic').src = pic_name
  document.getElementById('captcha_pic_link').value = pic_name
  document.getElementById('captcha_audio').href = audio_name
  document.getElementById('captcha_audio_link').value = audio_name
  document.getElementById('captcha_audio_en').href = audio_name_en
  document.getElementById('captcha_audio_de').href = audio_name_de
  document.getElementById('captcha_audio_it').href = audio_name_it
  document.getElementById('captcha_audio_nl').href = audio_name_nl
  document.getElementById('captcha_audio_fr').href = audio_name_fr
  document.getElementById('captcha_password').value = password
}
