document.onkeydown = quicksearch;
document.onclick = quicksearch;


function quicksearch($handle) {
 var $object = '';
 var $type = '';
 var $key = '';
 var $search = false;

/* Ziel Objekt */
 if (document.all) {
  $object = event.srcElement.id;
 }
 else {
  $object = $handle.target.id;
 }

/* Ausgelöstes Event */
 if ($handle) {
  $type = $handle.type;
 }
 else {
  $type = window.event.type;
 }

/* QuickSearch Feld */
 if ($object == 'qs_f') {
  if ($type == 'click') {
   if (document.getElementById('qs_f').value == 'Suche') {
    document.getElementById('qs_f').value = '';
   }
  }

  if ($type == 'keydown') {
   if (document.all) {
    $key = window.event.keyCode;
   }
   else {
    $key = $handle.which;
   }

   if ($key == 9) {
    if (document.getElementById('qs_f').value == '') {
     document.getElementById('qs_f').value = 'Suche';
    }
   }
  }
 }

/* QuickSearch Button */
 if ($object == 'qs_b') {
  if ($type == 'click') {
   $search = true;
  }
 }

 if ($type == 'keydown') {
  if (document.all) {
   $key = window.event.keyCode;
  }
  else {
   $key = $handle.which;
  }

  if ($key == 13) {
   $search = true;
  }
 }

/* onblur Event */
 if ($object != 'qs_f' && $object != 'qs_b') {
  if ($type == 'click') {
   if (document.getElementById('qs_f').value == '') {
    document.getElementById('qs_f').value = 'Suche';
   }
  }
 }

/* Suche starten */
 if ($search == true) {
  window.open('CN_search.asp?q=' + document.getElementById('qs_f').value + '&o=a', '_top');
 }
}





function email_protection() {
 for ($n = 0; $n <= document.getElementsByName('spam').length - 1; $n++) {
  $field = document.getElementsByName('spam')[$n];

  $field.innerHTML = rot_decode($field.innerHTML, 13);
  $field.href = rot_decode($field.href, 13);
 }
}





function rot_encode($value, $rotate) {
 $characters = '@-._ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
 $return = '';

 for ($i = 0; $i <= $value.length - 1; $i++) {
  $token = $value.substr($i, 1);
  $position = $characters.indexOf($token);

  if ($position == -1) {
   $return = $return + $token;
  }
  else {
   if ($position + $rotate > $characters.length) {
    $rottoken = $position + $rotate - $characters.length;
   }
   else {
    $rottoken = $position + $rotate;
   }

   $return = $return + $characters.substr($rottoken, 1);
  }
 }

 return $return;
}





function rot_decode($value, $rotate) {
 $characters = '@-._ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
 $return = '';

 for ($i = 0; $i <= $value.length - 1; $i++) {
  $token = $value.substr($i, 1);
  $position = $characters.indexOf($token);

  if ($position == -1) {
   $return = $return + $token;
  }
  else {
   if ($position - $rotate < 0) {
    $rottoken = $characters.length - $rotate + $position;
   }
   else {
    $rottoken = $position - $rotate;
   }

   $return = $return + $characters.substr($rottoken, 1);
  }
 }

 return $return;
}














