function obj_wea(input)
{
  switch(input.weapon)
  {
    case 0:
      this.id = 0;
      this.version = "reset_dummy";
      this.name = "";
      this.dam = 0;
      this.dist_factor = 0;
      this.dam_delta = 0;
      this.arm_delta = 0;
      this.arm_wear = 0;
      this.arm_protec_factor = 0;
      break;
    case 1:
      this.id = 1;
      this.version = "v1.5";
      this.pic = "small_usp";
      this.name_accu = "usp";
      this.name_short = "usp";
      this.name_long = "H&K USP .45 Tactical";
      this.dam = 132;
      this.dist_factor = 0.01414;
      this.dam_delta = 0.061;
      this.arm_delta = 0.061;
      this.arm_wear = 0.5;
      this.arm_protec_factor = 0.5;
      break;
    case 2:
      this.id = 2;
      this.version = "v1.5";
      this.pic = "small_usp_sil";
      this.name_accu = "usp";
      this.name_short = "usp (sil)";
      this.name_long = "H&K USP .45 Tactical (Silencer)";
      this.dam = 116;
      this.dist_factor = 0.01437;
      this.dam_delta = 0.069;
      this.arm_delta = 0.069;
      this.arm_wear = 0.5;
      this.arm_protec_factor = 0.5;
      break;
    case 3:
      this.id = 3;
      this.version = "v1.5";
      this.pic = "small_glock18";
      this.name_accu = "glock18";
      this.name_short = "glock";
      this.name_long = "Glock18 Select Fire";
      this.dam = 80;
      this.dist_factor = 0.0175;
      this.dam_delta = 0.25;
      this.arm_delta = 0.25;
      this.arm_wear = 0.47;
      this.arm_protec_factor = 0.49;
      break;
    case 4:
      this.id = 4;
      this.version = "v1.5";
      this.pic = "small_deagle";
      this.name_accu = "deagle";
      this.name_short = "deagle";
      this.name_long = "Desert Eagle .50AE";
      this.dam = 218;
      this.dist_factor = 0.01315;
      this.dam_delta = 0.083;
      this.arm_delta = 0.083;
      this.arm_wear = 0.17;
      this.arm_protec_factor = 0.26;
      break;
    case 5:
      this.id = 5;
      this.version = "v1.5";
      this.pic = "small_p228";
      this.name_accu = "p228";
      this.name_short = "p228";
      this.name_long = "SIG P228";
      this.dam = 126;
      this.dist_factor = 0.01323;
      this.dam_delta = 0.143;
      this.arm_delta = 0.143;
      this.arm_wear = 0.3;
      this.arm_protec_factor = 0.37;
      break;
    case 6:
      this.id = 6;
      this.version = "v1.5";
      this.pic = "small_96g";
      this.name_accu = "96g";
      this.name_short = "beretta (l)";
      this.name_long = "96G (left)";
      this.dam = 96;
      this.dist_factor = 0.01458;
      this.dam_delta = 0.292;
      this.arm_delta = 0.292;
      this.arm_wear = 0.47;
      this.arm_protec_factor = 0.46;
      break;
    case 7:
      this.id = 7;
      this.version = "v1.5";
      this.pic = "small_96g";
      this.name_accu = "96g";
      this.name_short = "beretta (r)";
      this.name_long = "96G (right)";
      this.dam = 76;
      this.dist_factor = 0.01667;
      this.dam_delta = 0.263;
      this.arm_delta = 0.263;
      this.arm_wear = 0.48;
      this.arm_protec_factor = 0.45;
      break;
    case 8:
      this.id = 8;
      this.version = "v1.5";
      this.pic = "small_5seven";
      this.name_accu = "5seven";
      this.name_short = "5seven";
      this.name_long = "Five Seven";
      this.dam = 80;
      this.dist_factor = 0.00833;
      this.dam_delta = 0.25;
      this.arm_delta = 0.25;
      this.arm_wear = 0.17;
      this.arm_protec_factor = 0.25;
      break;
    case 9:
      this.id = 9;
      this.version = "v1.5";
      this.pic = "small_tmp";
      this.name_accu = "tmp";
      this.name_short = "tmp";
      this.name_long = "Steyr TMP";
      this.dam = 80;
      this.dist_factor = 0.01083;
      this.dam_delta = 0.25;
      this.arm_delta = 0.25;
      this.arm_wear = 0.5;
      this.arm_protec_factor = 0.5;
      break;
    case 10:
      this.id = 10;
      this.version = "v1.5";
      this.pic = "small_mac10";
      this.name_accu = "mac10";
      this.name_short = "mac10";
      this.name_long = "Ingram MAC-10";
      this.dam = 112;
      this.dist_factor = 0.01250;
      this.dam_delta = 0.071;
      this.arm_delta = 0.071;
      this.arm_wear = 0.55;
      this.arm_protec_factor = 0.53;
      break;
    case 11:
      this.id = 11;
      this.version = "v1.5";
      this.pic = "small_p90";
      this.name_accu = "p90";
      this.name_short = "p90";
      this.name_long = "FN P90";
      this.dam = 84;
      this.dist_factor = 0.00794;
      this.dam_delta = 0.238;
      this.arm_delta = 0.238;
      this.arm_wear = 0.18;
      this.arm_protec_factor = 0.25;
      break;
    case 12:
      this.id = 12;
      this.version = "v1.5";
      this.pic = "small_mp5";
      this.name_accu = "mp5";
      this.name_short = "mp5";
      this.name_long = "H&K MP5-Navy";
      this.dam = 104;
      this.dist_factor = 0.0109;
      this.dam_delta = 0.192;
      this.arm_delta = 0.192;
      this.arm_wear = 0.50;
      this.arm_protec_factor = 0.50;
      break;
    case 13:
      this.id = 13;
      this.version = "v1.5";
      this.pic = "small_ump45";
      this.name_accu = "ump45";
      this.name_short = "ump45";
      this.name_long = "UMP 45";
      this.dam = 119;
      this.dist_factor = 0.01264;
      this.dam_delta = 0.069;
      this.arm_delta = 0.069;
      this.arm_wear = 0.50;
      this.arm_protec_factor = 0.50;
      break;
    case 14:
      this.id = 14;
      this.version = "v1.5";
      this.pic = "small_ak47";
      this.name_accu = "ak47";
      this.name_short = "ak47";
      this.name_long = "AK-47";
      this.dam = 140;
      this.dist_factor = 0.00095;
      this.dam_delta = 0.057;
      this.arm_delta = 0.057;
      this.arm_wear = 0.15;
      this.arm_protec_factor = 0.23;
      break;
    case 15:
      this.id = 15;
      this.version = "v1.5";
      this.pic = "small_m4a1";
      this.name_accu = "m4a1";
      this.name_short = "m4a1";
      this.name_long = "M4A1 Carbine";
      this.dam = 124;
      this.dist_factor = 0.00215;
      this.dam_delta = 0.097;
      this.arm_delta = 0.097;
      this.arm_wear = 0.22;
      this.arm_protec_factor = 0.30;
      break;
    case 16:
      this.id = 16;
      this.version = "v1.5";
      this.pic = "small_m4a1_sil";
      this.name_accu = "m4a1";
      this.name_short = "m4a1 (sil)";
      this.name_long = "M4A1 Carbine (Silencer)";
      this.dam = 128;
      this.dist_factor = 0.00365;
      this.dam_delta = 0.094;
      this.arm_delta = 0.094;
      this.arm_wear = 0.22;
      this.arm_protec_factor = 0.30;
      break;
    case 17:
      this.id = 17;
      this.version = "v1.5";
      this.pic = "small_sg552";
      this.name_accu = "sg552";
      this.name_short = "sg552";
      this.name_long = "SG-552 Commando";
      this.dam = 128;
      this.dist_factor = 0.00365;
      this.dam_delta = 0.094;
      this.arm_delta = 0.094;
      this.arm_wear = 0.21;
      this.arm_protec_factor = 0.30;
      break;
    case 18:
      this.id = 18;
      this.version = "v1.5";
      this.pic = "small_aug";
      this.name_accu = "aug";
      this.name_short = "aug";
      this.name_long = "Steyr Aug";
      this.dam = 126;
      this.dist_factor = 0.00317;
      this.dam_delta = 0.079;
      this.arm_delta = 0.079;
      this.arm_wear = 0.22;
      this.arm_protec_factor = 0.31;
      break;
    case 19:
      this.id = 19;
      this.version = "v1.5";
      this.pic = "small_scout";
      this.name_accu = "scout";
      this.name_short = "scout";
      this.name_long = "Steyr Scout";
      this.dam = 296;
      this.dist_factor = 0.00135;
      this.dam_delta = 0.027;
      this.arm_delta = 0.027;
      this.arm_wear = 0.09;
      this.arm_protec_factor = 0.15;
      break;
    case 20:
      this.id = 20;
      this.version = "v1.5";
      this.pic = "small_awp";
      this.name_accu = "awp";
      this.name_short = "awp";
      this.name_long = "AI Arctic Warfare";
      this.dam = 456;
      this.dist_factor = 0.00058;
      this.dam_delta = 0.035;
      this.arm_delta = 0.035;
      this.arm_wear = 0.01;
      this.arm_protec_factor = 0.03;
      break;
    case 21:
      this.id = 21;
      this.version = "v1.5";
      this.pic = "small_g3sg1";
      this.name_accu = "g3sg1";
      this.name_short = "g3sg1";
      this.name_long = "H&K G3/SG-1";
      this.dam = 236;
      this.dist_factor = 0.00113;
      this.dam_delta = 0.034;
      this.arm_delta = 0.034;
      this.arm_wear = 0.11;
      this.arm_protec_factor = 0.18;
      break;
    case 22:
      this.id = 22;
      this.version = "v1.5";
      this.pic = "small_sg550";
      this.name_accu = "sg550";
      this.name_short = "sg550";
      this.name_long = "SG 550";
      this.dam = 156;
      this.dist_factor = 0.00085;
      this.dam_delta = 0.077;
      this.arm_delta = 0.077;
      this.arm_wear = 0.19;
      this.arm_protec_factor = 0.28;
      break;
    case 23:
      this.id = 23;
      this.version = "v1.5";
      this.pic = "small_m249";
      this.name_accu = "m249";
      this.name_short = "m249";
      this.name_long = "FN M249 Para";
      this.dam = 124;
      this.dist_factor = 0.00215;
      this.dam_delta = 0.097;
      this.arm_delta = 0.097;
      this.arm_wear = 0.17;
      this.arm_protec_factor = 0.25;
      break;
    default:
      break;
  }
}

function obj_input()
{
  this.display_mode = "basic";
  this.display_damage = false;
  this.play_sound = false;
  this.reset_on_weaponswitch = true;
  this.distance = 0;
  this.get_distance = validate_distance;
  this.resetvalue = 0;  // die Null ist nicht trival, da health = 100 - damage
  this.get_resetvalue = validate_resetvalue;
  this.weapon = 0;
  this.helmet = true;
  this.vest = true;
}

function obj_victim(input,wea)
{
  this.head = new obj_zone;
  this.chest = new obj_zone;
  this.stomach = new obj_zone;
  this.leg = new obj_zone;
  this.total = new obj_zone;

  this.head.factor = 1.00;
  this.chest.factor = 0.25;
  this.stomach.factor = 0.31;
  this.leg.factor = 0.18;

  this.life_ave = 0;
  this.life_min = 0;
  this.life_max = 0;

  this.armor_ave = 0;
  this.armor_min = 0;
  this.armor_max = 0;

  this.dist_factor = 1;
  this.calc_basis = calc_basis;

}

function obj_zone()
{
  this.life = new obj_data;
  this.armor = new obj_data;
  this.calc = calc;  // vic
  this.td_code; //html (graphic, wie auch numeric)
  this.td_code; //html (graphic, wie auch numeric, findet NICHT bei 'total' verwendung)
}

function obj_data()
{
  this.ave = 0;
  this.min = 0;
  this.max = 0;
  this.bar_1 = 0;
  this.bar_2 = 0;
  this.bar_3 = 0;
  this.show_bar_1 = false;
  this.show_bar_2 = false;
  this.show_bar_3 = false;
  this.trim_bars = trim_bars;
  this.reset = reset;  // vic
  this.td_code; //html (graphic, wie auch numeric, findet NUR bei 'total' verwendung)
}

function obj_html(input)
{
  this.data_graphic = new obj_data_layout;
  this.data_numeric = new obj_data_layout;
  this.convert_numeric = convert_numeric;  // html
  this.convert_graphic = convert_graphic;  // html
  this.log_distance = 0; // init
  this.log_distance_dim = "m"; // init
}

function obj_data_layout()
{
  this.head = new obj_zone;
  this.chest = new obj_zone;
  this.stomach = new obj_zone;
  this.leg = new obj_zone;
  this.total = new obj_zone;
  this.log = new obj_zone;

  this.table_code;  // html
  this.bar_length = 197;  // pixel
  this.bar_factor = this.bar_length / 100;
  this.bar_length2 = 300;  // pixel
  this.bar_factor2 = this.bar_length2 / 100;
  this.bar_length3 = 300;  // pixel
  this.bar_factor3 = this.bar_length3 / 100;
}

function reset()
{
  this.ave = input.resetvalue;
  this.min = input.resetvalue;
  this.max = input.resetvalue;
}

function calc_basis(zone)
{
  this.dist_factor = 1 - (input.distance * weapon.dist_factor);

  // mit kevlar(protec_factor) wird nur gerechnet, wenn der jeweilge zone auch geschützt ist.
  victim.protec_factor = 0;  // default, fall keine zone geschützt ist -> 0
  if ((zone == "h") && (input.helmet)) victim.protec_factor = weapon.arm_protec_factor;
  if ((zone == "c") && (input.vest)) victim.protec_factor = weapon.arm_protec_factor;
  if ((zone == "s") && (input.vest)) victim.protec_factor = weapon.arm_protec_factor;

  // basisschaden der erzielt wurde (in abh. vom vorhandensein von kevlar (min,ave,max)
  victim.life_ave = victim.dist_factor * weapon.dam * (1 - victim.protec_factor);
  victim.life_min = victim.life_ave * (1 - weapon.dam_delta);
  victim.life_max = victim.life_ave * (1 + weapon.dam_delta);

  // basisschaden der am kelvar erzielt wurde (min,ave,max) - egal ob kevlar im spiel war
  victim.armor_ave = victim.life_ave * weapon.arm_wear;
  victim.armor_min = victim.armor_ave * (1 - weapon.arm_delta);
  victim.armor_max = victim.armor_ave * (1 + weapon.arm_delta);

  // damit ein negativer schaden, den gesamtschaden nicht reduziert
  if (victim.life_ave < 0)  victim.life_ave = 0;
  if (victim.life_min < 0)  victim.life_min = 0;
  if (victim.life_max < 0)  victim.life_max = 0;

  // damit ein negativer kevlarschaden, den gesamtkevlarschaden nicht wieder anhebt
  if (victim.armor_ave < 0)  victim.armor_ave = 0;
  if (victim.armor_min < 0)  victim.armor_min = 0;
  if (victim.armor_max < 0)  victim.armor_max = 0;

  // falls gar kein kevlar zum einsatz kam
  if (victim.protec_factor == 0)  victim.armor_ave = 0;
  if (victim.protec_factor == 0)  victim.armor_min = 0;
  if (victim.protec_factor == 0)  victim.armor_max = 0;
}

function calc()
{
  // neuer schaden = alter schaden + zonenfaktor * aktueller schaden
  this.life.ave = this.life.ave + this.factor * victim.life_ave;
  this.life.min = this.life.min + this.factor * victim.life_min;
  this.life.max = this.life.max + this.factor * victim.life_max;
  // abgreifen der ergebnisse für das totalen (kumulierten) wert
  victim.total.life.ave+= this.factor * victim.life_ave;
  victim.total.life.min+= this.factor * victim.life_min;
  victim.total.life.max+= this.factor * victim.life_max;
  // abgreifen der ergebnisse für das log (keine kumulierten werte)
  html.data_numeric.log.life.ave = Math.round(this.factor * victim.life_ave);
  html.data_numeric.log.life.min = Math.round(this.factor * victim.life_min);
  html.data_numeric.log.life.max = Math.round(this.factor * victim.life_max);

  // neuer kevlarschaden = alter kevlarschaden + zonenfaktor * aktueller kevlarschaden
  this.armor.ave =  this.armor.ave + this.factor * victim.armor_ave;
  this.armor.min =  this.armor.min + this.factor * victim.armor_min;
  this.armor.max =  this.armor.max + this.factor * victim.armor_max;
  // abgreifen der ergebnisse für das totalen (kumulierten) wert
  victim.total.armor.ave+= this.factor * victim.armor_ave;
  victim.total.armor.min+= this.factor * victim.armor_min;
  victim.total.armor.max+= this.factor * victim.armor_max;
  // abgreifen der ergebnisse für das log (keine kumulierten werte)
  html.data_numeric.log.armor.ave = Math.round(this.factor * victim.armor_ave);
  html.data_numeric.log.armor.min = Math.round(this.factor * victim.armor_min);
  html.data_numeric.log.armor.max = Math.round(this.factor * victim.armor_max);
}

function convert_graphic()
{
  this.data_graphic.head.life.bar_1 = Math.round(victim.head.life.min * html.data_graphic.bar_factor);
  this.data_graphic.head.life.bar_2 = Math.round((victim.head.life.max - victim.head.life.min) * html.data_graphic.bar_factor);
  this.data_graphic.head.life.trim_bars();
  this.data_graphic.head.armor.bar_1 = Math.round(victim.head.armor.min * html.data_graphic.bar_factor);
  this.data_graphic.head.armor.bar_2 = Math.round((victim.head.armor.max - victim.head.armor.min) * html.data_graphic.bar_factor);
  this.data_graphic.head.armor.trim_bars();

  this.data_graphic.chest.life.bar_1 = Math.round(victim.chest.life.min * html.data_graphic.bar_factor);
  this.data_graphic.chest.life.bar_2 = Math.round((victim.chest.life.max - victim.chest.life.min) * html.data_graphic.bar_factor);
  this.data_graphic.chest.life.trim_bars();
  this.data_graphic.chest.armor.bar_1 = Math.round(victim.chest.armor.min * html.data_graphic.bar_factor);
  this.data_graphic.chest.armor.bar_2 = Math.round((victim.chest.armor.max - victim.chest.armor.min) * html.data_graphic.bar_factor);
  this.data_graphic.chest.armor.trim_bars();

  this.data_graphic.stomach.life.bar_1 = Math.round(victim.stomach.life.min * html.data_graphic.bar_factor);
  this.data_graphic.stomach.life.bar_2 = Math.round((victim.stomach.life.max - victim.stomach.life.min) * html.data_graphic.bar_factor);
  this.data_graphic.stomach.life.trim_bars();
  this.data_graphic.stomach.armor.bar_1 = Math.round(victim.stomach.armor.min * html.data_graphic.bar_factor);
  this.data_graphic.stomach.armor.bar_2 = Math.round((victim.stomach.armor.max - victim.stomach.armor.min) * html.data_graphic.bar_factor);
  this.data_graphic.stomach.armor.trim_bars();

  this.data_graphic.leg.life.bar_1 = Math.round(victim.leg.life.min * html.data_graphic.bar_factor);
  this.data_graphic.leg.life.bar_2 = Math.round((victim.leg.life.max - victim.leg.life.min) * html.data_graphic.bar_factor);
  this.data_graphic.leg.life.trim_bars();

  /* bar_factor und bar_length werden gesichert, überschrieben, zur berechnung genutzt und anschließend
  wieder in den ausgangszustand zurück versetzt. dies ist notwendig, da die methode trim_bars() mit
  den originalen html.data_graphic.xxx eigenschaften arbeitet. */
  // save
  bar_factor_backup = html.data_graphic.bar_factor;
  bar_length_backup = html.data_graphic.bar_length;

  if (input.display_mode == "basic") // factor und länge überschreiben
  {
  html.data_graphic.bar_factor = html.data_graphic.bar_factor2;
  html.data_graphic.bar_length = html.data_graphic.bar_length2;
  }
  if (input.display_mode == "advanced") // factor und länge überschreiben
  {
  html.data_graphic.bar_factor = html.data_graphic.bar_factor3;
  html.data_graphic.bar_length = html.data_graphic.bar_length3;
  }
  // damit rechnen
  this.data_graphic.total.life.bar_1 = Math.round(victim.total.life.min * html.data_graphic.bar_factor);
  this.data_graphic.total.life.bar_2 = Math.round((victim.total.life.max - victim.total.life.min) * html.data_graphic.bar_factor);
  this.data_graphic.total.life.trim_bars();
  this.data_graphic.total.armor.bar_1 = Math.round(victim.total.armor.min * html.data_graphic.bar_factor);
  this.data_graphic.total.armor.bar_2 = Math.round((victim.total.armor.max - victim.total.armor.min) * html.data_graphic.bar_factor);
  this.data_graphic.total.armor.trim_bars();

  //.. und wiederherstellen
  html.data_graphic.bar_factor = bar_factor_backup;
  html.data_graphic.bar_length = bar_length_backup;

  if (input.display_damage)  // grafiken ggf. über kreuz vertauschen
  {
    file_1a = "bar2_red.gif"; file_1b = "bar2_redlight.gif"; file_1c = "bar2_background.gif";
    file_2a = "bar2_blue.gif"; file_2b = "bar2_bluelight.gif"; file_2c = "bar2_background.gif";
    file_3a = "bar2_yellow.gif"; file_3b = "bar2_yellowlight.gif"; file_3c = "bar2_background.gif";
    file_4a = "bar2_green.gif"; file_4b = "bar2_greenlight.gif"; file_4c = "bar2_background.gif";
    file_0a = "bar3_black.gif"; file_0b = "bar3_blacklight.gif"; file_0c = "bar3_background.gif";
    file_large_1a = "bar4_red.gif"; file_large_1b = "bar4_redlight.gif"; file_large_1c = "bar4_background.gif";
    file_large_0a = "bar4_black.gif"; file_large_0b = "bar4_blacklight.gif"; file_large_0c = "bar4_background.gif";
  }
  else
  {
    file_1a = "bar2_background.gif"; file_1b = "bar2_redlight.gif"; file_1c = "bar2_red.gif";
    file_2a = "bar2_background.gif"; file_2b = "bar2_bluelight.gif"; file_2c = "bar2_blue.gif";
    file_3a = "bar2_background.gif"; file_3b = "bar2_yellowlight.gif"; file_3c = "bar2_yellow.gif";
    file_4a = "bar2_background.gif"; file_4b = "bar2_greenlight.gif"; file_4c = "bar2_green.gif";
    file_0a = "bar3_background.gif"; file_0b = "bar3_blacklight.gif"; file_0c = "bar3_black.gif";
    file_large_1a = "bar4_background.gif"; file_large_1b = "bar4_redlight.gif"; file_large_1c = "bar4_red.gif";
    file_large_0a = "bar4_background.gif"; file_large_0b = "bar4_blacklight.gif"; file_large_0c = "bar4_black.gif";
  }
  this.data_graphic.head.life.bar = "<img src=\"../gfx/bar2_left.gif\" width=1 height=10>";
  if (this.data_graphic.head.life.show_bar_1 == true) this.data_graphic.head.life.bar+= "<img src=\"../gfx/" + file_1a + "\" height=10 width=" + this.data_graphic.head.life.bar_1 + ">";
  if (this.data_graphic.head.life.show_bar_2 == true) this.data_graphic.head.life.bar+= "<img src=\"../gfx/" + file_1b + "\" height=10 width=" + this.data_graphic.head.life.bar_2 + ">";
  if (this.data_graphic.head.life.show_bar_3 == true) this.data_graphic.head.life.bar+= "<img src=\"../gfx/" + file_1c + "\" height=10 width=" + this.data_graphic.head.life.bar_3 + ">";
  this.data_graphic.head.life.bar+= "<img src=\"../gfx/bar2_right.gif\" width=1 height=10><br><img src=\"../gfx/transparent.gif\" width=1 height=2><br>";
  this.data_graphic.head.armor.bar = "<img src=\"../gfx/bar3_left.gif\" width=1 height=5>";
  if (this.data_graphic.head.armor.show_bar_1 == true) this.data_graphic.head.armor.bar+= "<img src=\"../gfx/" + file_0a + "\" height=5 width=" + this.data_graphic.head.armor.bar_1 + ">";
  if (this.data_graphic.head.armor.show_bar_2 == true) this.data_graphic.head.armor.bar+= "<img src=\"../gfx/" + file_0b + "\" height=5 width=" + this.data_graphic.head.armor.bar_2 + ">";
  if (this.data_graphic.head.armor.show_bar_3 == true) this.data_graphic.head.armor.bar+= "<img src=\"../gfx/" + file_0c + "\" height=5 width=" + this.data_graphic.head.armor.bar_3 + ">";
  this.data_graphic.head.armor.bar+= "<img src=\"../gfx/bar3_right.gif\" width=1 height=5>";
  this.data_graphic.head.td_code = "<td>" + this.data_graphic.head.life.bar + this.data_graphic.head.armor.bar + "</td>";

  this.data_graphic.chest.life.bar = "<img src=\"../gfx/bar2_left.gif\" width=1 height=10>";
  if (this.data_graphic.chest.life.show_bar_1 == true) this.data_graphic.chest.life.bar+= "<img src=\"../gfx/" + file_2a + "\" height=10 width=" + this.data_graphic.chest.life.bar_1 + ">";
  if (this.data_graphic.chest.life.show_bar_2 == true) this.data_graphic.chest.life.bar+= "<img src=\"../gfx/" + file_2b + "\" height=10 width=" + this.data_graphic.chest.life.bar_2 + ">";
  if (this.data_graphic.chest.life.show_bar_3 == true) this.data_graphic.chest.life.bar+= "<img src=\"../gfx/" + file_2c + "\" height=10 width=" + this.data_graphic.chest.life.bar_3 + ">";
  this.data_graphic.chest.life.bar+= "<img src=\"../gfx/bar2_right.gif\" width=1 height=10><br><img src=\"../gfx/transparent.gif\" width=1 height=2><br>";
  this.data_graphic.chest.armor.bar = "<img src=\"../gfx/bar3_left.gif\" width=1 height=5>";
  if (this.data_graphic.chest.armor.show_bar_1 == true) this.data_graphic.chest.armor.bar+= "<img src=\"../gfx/" + file_0a + "\" height=5 width=" + this.data_graphic.chest.armor.bar_1 + ">";
  if (this.data_graphic.chest.armor.show_bar_2 == true) this.data_graphic.chest.armor.bar+= "<img src=\"../gfx/" + file_0b + "\" height=5 width=" + this.data_graphic.chest.armor.bar_2 + ">";
  if (this.data_graphic.chest.armor.show_bar_3 == true) this.data_graphic.chest.armor.bar+= "<img src=\"../gfx/" + file_0c + "\" height=5 width=" + this.data_graphic.chest.armor.bar_3 + ">";
  this.data_graphic.chest.armor.bar+= "<img src=\"../gfx/bar3_right.gif\" width=1 height=5>";
  this.data_graphic.chest.td_code = "<td>" + this.data_graphic.chest.life.bar + this.data_graphic.chest.armor.bar + "</td>";

  this.data_graphic.stomach.life.bar = "<img src=\"../gfx/bar2_left.gif\" width=1 height=10>";
  if (this.data_graphic.stomach.life.show_bar_1 == true) this.data_graphic.stomach.life.bar+= "<img src=\"../gfx/" + file_3a + "\" height=10 width=" + this.data_graphic.stomach.life.bar_1 + ">";
  if (this.data_graphic.stomach.life.show_bar_2 == true) this.data_graphic.stomach.life.bar+= "<img src=\"../gfx/" + file_3b + "\" height=10 width=" + this.data_graphic.stomach.life.bar_2 + ">";
  if (this.data_graphic.stomach.life.show_bar_3 == true) this.data_graphic.stomach.life.bar+= "<img src=\"../gfx/" + file_3c + "\" height=10 width=" + this.data_graphic.stomach.life.bar_3 + ">";
  this.data_graphic.stomach.life.bar+= "<img src=\"../gfx/bar2_right.gif\" width=1 height=10><br><img src=\"../gfx/transparent.gif\" width=1 height=2><br>";
  this.data_graphic.stomach.armor.bar = "<img src=\"../gfx/bar3_left.gif\" width=1 height=5>";
  if (this.data_graphic.stomach.armor.show_bar_1 == true) this.data_graphic.stomach.armor.bar+= "<img src=\"../gfx/" + file_0a + "\" height=5 width=" + this.data_graphic.stomach.armor.bar_1 + ">";
  if (this.data_graphic.stomach.armor.show_bar_2 == true) this.data_graphic.stomach.armor.bar+= "<img src=\"../gfx/" + file_0b + "\" height=5 width=" + this.data_graphic.stomach.armor.bar_2 + ">";
  if (this.data_graphic.stomach.armor.show_bar_3 == true) this.data_graphic.stomach.armor.bar+= "<img src=\"../gfx/" + file_0c + "\" height=5 width=" + this.data_graphic.stomach.armor.bar_3 + ">";
  this.data_graphic.stomach.armor.bar+= "<img src=\"../gfx/bar3_right.gif\" width=1 height=5>";
  this.data_graphic.stomach.td_code = "<td>" + this.data_graphic.stomach.life.bar + this.data_graphic.stomach.armor.bar + "</td>";

  this.data_graphic.leg.life.bar = "<img src=\"../gfx/bar2_left.gif\" width=1 height=10>";
  if (this.data_graphic.leg.life.show_bar_1 == true) this.data_graphic.leg.life.bar+= "<img src=\"../gfx/" + file_4a + "\" height=10 width=" + this.data_graphic.leg.life.bar_1 + ">";
  if (this.data_graphic.leg.life.show_bar_2 == true) this.data_graphic.leg.life.bar+= "<img src=\"../gfx/" + file_4b + "\" height=10 width=" + this.data_graphic.leg.life.bar_2 + ">";
  if (this.data_graphic.leg.life.show_bar_3 == true) this.data_graphic.leg.life.bar+= "<img src=\"../gfx/" + file_4c + "\" height=10 width=" + this.data_graphic.leg.life.bar_3 + ">";
  this.data_graphic.leg.life.bar+= "<img src=\"../gfx/bar2_right.gif\" width=1 height=10><br>";
  this.data_graphic.leg.td_code = "<td>" + this.data_graphic.leg.life.bar + "</td>";
  this.data_graphic.head.life.bar = "<img src=\"../gfx/bar2_left.gif\" width=1 height=10>";

  this.data_graphic.total.life.bar = "<img src=\"../gfx/bar4_left.gif\" width=1 height=20>";
  if (this.data_graphic.total.life.show_bar_1 == true) this.data_graphic.total.life.bar+= "<img src=\"../gfx/" + file_large_1a + "\" height=20 width=" + this.data_graphic.total.life.bar_1 + ">";
  if (this.data_graphic.total.life.show_bar_2 == true) this.data_graphic.total.life.bar+= "<img src=\"../gfx/" + file_large_1b + "\" height=20 width=" + this.data_graphic.total.life.bar_2 + ">";
  if (this.data_graphic.total.life.show_bar_3 == true) this.data_graphic.total.life.bar+= "<img src=\"../gfx/" + file_large_1c + "\" height=20 width=" + this.data_graphic.total.life.bar_3 + ">";
  this.data_graphic.total.life.bar+= "<img src=\"../gfx/bar4_right.gif\" width=1 height=20><br>";
  this.data_graphic.total.armor.bar = "<img src=\"../gfx/bar4_left.gif\" width=1 height=20>";
  if (this.data_graphic.total.armor.show_bar_1 == true) this.data_graphic.total.armor.bar+= "<img src=\"../gfx/" + file_large_0a + "\" height=20 width=" + this.data_graphic.total.armor.bar_1 + ">";
  if (this.data_graphic.total.armor.show_bar_2 == true) this.data_graphic.total.armor.bar+= "<img src=\"../gfx/" + file_large_0b + "\" height=20 width=" + this.data_graphic.total.armor.bar_2 + ">";
  if (this.data_graphic.total.armor.show_bar_3 == true) this.data_graphic.total.armor.bar+= "<img src=\"../gfx/" + file_large_0c + "\" height=20 width=" + this.data_graphic.total.armor.bar_3 + ">";
  this.data_graphic.total.armor.bar+= "<img src=\"../gfx/bar4_right.gif\" width=1 height=20>";
  //this.data_graphic.total.td_code = "<td>" + this.data_graphic.total.life.bar + this.data_graphic.total.armor.bar + "</td>";
  this.data_graphic.total.life.td_code = "<td>" + this.data_graphic.total.life.bar + "</td>";
  this.data_graphic.total.armor.td_code = "<td>" + this.data_graphic.total.armor.bar + "</td>";
}


function trim_bars()
{
  if ((this.bar_1 + this.bar_2) < html.data_graphic.bar_length)
  {
    this.bar_3 = html.data_graphic.bar_length - this.bar_2 - this.bar_1;
    this.show_bar_1 = true;
    this.show_bar_2 = true;
    this.show_bar_3 = true;
  }

  if ((this.bar_1 + this.bar_2) >= html.data_graphic.bar_length)
  {
    this.bar_2 = html.data_graphic.bar_length - this.bar_1;
    this.show_bar_1 = true;
    this.show_bar_2 = true;
    this.show_bar_3 = false;
  }

  if ((this.bar_1) >= html.data_graphic.bar_length)
  {
    this.bar_1 = html.data_graphic.bar_length;
    this.show_bar_1 = true;
    this.show_bar_2 = false;
    this.show_bar_3 = false;
  }

  // aus kosmetischen gründen, da width=0 nicht ausgeblendet wird
  if ((this.bar_1 + this.bar_2) == 0)
  {
    this.bar_3 = html.data_graphic.bar_length;
    this.show_bar_1 = false;
    this.show_bar_2 = false;
    this.show_bar_3 = true;
  }
}

function convert_numeric()
{
  var html_18 = "<td style=\"font-size:18px;\" align=right>";
  var html_10 = "<td style=\"font-size:10px;\" align=right>";
  var html_red = "<font color=#D70000>";
  var html_blue = "<font color=#0000DF>";
  var html_yellow = "<font color=#C1C100>";
  var html_green = "<font color=#009F00>";
  var html_black = "<font color=#000000>";

  // die vorfaktoren resultieren aus der überlegung  x-100 = -1(x-100) = a(x-b)
  if (input.display_damage)
  {
    var b = 0;
    var a = 1;
  }
  else // health anzeigen
  {
    var b = -100;
    var a = -1;
  }

  this.data_numeric.head.life.ave = html_18 + html_red + "<nobr><b>" + a * Math.round(victim.head.life.ave + b) + "</b></nobr></font></td>";
  this.data_numeric.head.life.min = html_10 + html_red + "<nobr>&nbsp;" + a * Math.round(victim.head.life.min + b) + "&nbsp;</nobr></font></td>";
  this.data_numeric.head.life.max = html_10 + html_red + "<nobr>&nbsp;" + a * Math.round(victim.head.life.max + b) + "&nbsp;</nobr></font></td>";
  this.data_numeric.head.armor.ave = html_18 + html_black + "<nobr><b>" + a * Math.round(victim.head.armor.ave + b) + "</b></nobr></font></td>";
  this.data_numeric.head.armor.min = html_10 + html_black + "<nobr>&nbsp;" + a * Math.round(victim.head.armor.min + b) + "&nbsp;</nobr></font></td>";
  this.data_numeric.head.armor.max = html_10 + html_black + "<nobr>&nbsp;" + a * Math.round(victim.head.armor.max + b) + "&nbsp;</nobr></font></td>";
  html.data_numeric.head.td_code = html.data_numeric.head.life.min + html.data_numeric.head.life.ave +  html.data_numeric.head.life.max +  html.data_numeric.head.armor.min + html.data_numeric.head.armor.ave +  html.data_numeric.head.armor.max;

  this.data_numeric.chest.life.ave = html_18 + html_blue + "<nobr><b>" + a * Math.round(victim.chest.life.ave + b) + "</b></nobr></font></td>";
  this.data_numeric.chest.life.min = html_10 + html_blue + "<nobr>&nbsp;" + a * Math.round(victim.chest.life.min + b) + "&nbsp;</nobr></font></td>";
  this.data_numeric.chest.life.max = html_10 + html_blue + "<nobr>&nbsp;" + a * Math.round(victim.chest.life.max + b) + "&nbsp;</nobr></font></td>";
  this.data_numeric.chest.armor.ave = html_18 + html_black + "<nobr><b>" + a * Math.round(victim.chest.armor.ave + b) + "</b></nobr></font></td>";
  this.data_numeric.chest.armor.min = html_10 + html_black + "<nobr>&nbsp;" + a * Math.round(victim.chest.armor.min + b) + "&nbsp;</nobr></font></td>";
  this.data_numeric.chest.armor.max = html_10 + html_black + "<nobr>&nbsp;" + a * Math.round(victim.chest.armor.max + b) + "&nbsp;</nobr></font></td>";
  html.data_numeric.chest.td_code = html.data_numeric.chest.life.min + html.data_numeric.chest.life.ave +  html.data_numeric.chest.life.max + html.data_numeric.chest.armor.min + html.data_numeric.chest.armor.ave +  html.data_numeric.chest.armor.max;

  this.data_numeric.stomach.life.ave = html_18 + html_yellow + "<nobr><b>" + a * Math.round(victim.stomach.life.ave + b) + "</b></nobr></font></td>";
  this.data_numeric.stomach.life.min = html_10 + html_yellow + "<nobr>&nbsp;" + a * Math.round(victim.stomach.life.min + b) + "&nbsp;</nobr></font></td>";
  this.data_numeric.stomach.life.max = html_10 + html_yellow + "<nobr>&nbsp;" + a * Math.round(victim.stomach.life.max + b) + "&nbsp;</nobr></font></td>";
  this.data_numeric.stomach.armor.ave = html_18 + html_black + "<nobr><b>" + a * Math.round(victim.stomach.armor.ave + b) + "</b></nobr></font></td>";
  this.data_numeric.stomach.armor.min = html_10 + html_black + "<nobr>&nbsp;" + a * Math.round(victim.stomach.armor.min + b) + "&nbsp;</nobr></font></td>";
  this.data_numeric.stomach.armor.max = html_10 + html_black + "<nobr>&nbsp;" + a * Math.round(victim.stomach.armor.max + b) + "&nbsp;</nobr></font></td>";
  html.data_numeric.stomach.td_code = html.data_numeric.stomach.life.min + html.data_numeric.stomach.life.ave +  html.data_numeric.stomach.life.max + html.data_numeric.stomach.armor.min + html.data_numeric.stomach.armor.ave +  html.data_numeric.stomach.armor.max;

  this.data_numeric.leg.life.ave = html_18 + html_green + "<nobr><b>" + a * Math.round(victim.leg.life.ave + b) + "</b></font></td>";
  this.data_numeric.leg.life.min = html_10 + html_green + "<nobr>&nbsp;" + a * Math.round(victim.leg.life.min + b) + "&nbsp;</font></td>";
  this.data_numeric.leg.life.max = html_10 + html_green + "<nobr>&nbsp;" + a * Math.round(victim.leg.life.max + b) + "&nbsp;</font></td>";
  html.data_numeric.leg.td_code = html.data_numeric.leg.life.min + html.data_numeric.leg.life.ave +  html.data_numeric.leg.life.max + "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>";

  this.data_numeric.total.life.ave = html_18 + html_red + "<nobr><b>" + a * Math.round(victim.total.life.ave + b) + "</b></nobr></font></td>";
  this.data_numeric.total.life.min = html_10 + html_red + "<nobr>&nbsp;" + a * Math.round(victim.total.life.min + b) + "&nbsp;</nobr></font></td>";
  this.data_numeric.total.life.max = html_10 + html_red + "<nobr>&nbsp;" + a * Math.round(victim.total.life.max + b) + "&nbsp;</nobr></font></td>";
  this.data_numeric.total.armor.ave = html_18 + html_black + "<nobr><b>" + a * Math.round(victim.total.armor.ave + b) + "</b></nobr></font></td>";
  this.data_numeric.total.armor.min = html_10 + html_black + "<nobr>&nbsp;" + a * Math.round(victim.total.armor.min + b) + "&nbsp;</nobr></font></td>";
  this.data_numeric.total.armor.max = html_10 + html_black + "<nobr>&nbsp;" + a * Math.round(victim.total.armor.max + b) + "&nbsp;</nobr></font></td>";
  //html.data_numeric.total.td_code = html.data_numeric.total.life.min + html.data_numeric.total.life.ave +  html.data_numeric.total.life.max +  html.data_numeric.total.armor.min + html.data_numeric.total.armor.ave +  html.data_numeric.total.armor.max;
  html.data_numeric.total.life.td_code = html.data_numeric.total.life.min + html.data_numeric.total.life.ave +  html.data_numeric.total.life.max;
  html.data_numeric.total.armor.td_code = html.data_numeric.total.armor.min + html.data_numeric.total.armor.ave +  html.data_numeric.total.armor.max;
}

function print_weapon()
{
  if (input.display_mode == "basic")
  {
    html_text = "<table width=410 style=\"border-color:#AFAFAF; border-style:solid; border-width:1px; background-color:#FFFFFF\" class=BasisFont border=0><tr>";
    html_text+= "<td><img src=\"../gfx/transparent.gif\" width=250 height=1><br><div class=BasisFontCenter><b>" + weapon.name_long + "</b><br><img vspace=5 src=\"gfx/" + weapon.pic + ".gif\"></div></td>";
    html_text+= "<td class=BasisFontSmallRight width=120>take a look at an&nbsp;<br><a href=\"dc_" + weapon.name_accu + "_v15.php\">accuracy test</a>.&nbsp;<br><br>";
    html_text+= "<a href=\"dc_" + weapon.name_accu + "_v15.php\"><img hspace=3 vspace=3 src=\"gfx/v15_active.gif\" border=0></a>";
    html_text+= "</td></tr></table>";
    document.all.weapon_pic.innerHTML = html_text;
  }
  if (input.display_mode == "advanced")
  {
    html_text = "<table width=410 style=\"border-color:#AFAFAF; border-style:solid; border-width:1px; background-color:#FFFFFF\" class=BasisFont border=0><tr>";
    html_text+= "<td><img src=\"../gfx/transparent.gif\" width=250 height=1><br><div class=BasisFontCenter><b>" + weapon.name_long + "</b><br><img src=\"gfx/" + weapon.pic + ".gif\"></div></td>";
    html_text+= "<td valign=top class=BasisFontSmallRight width=120>take a look at an&nbsp;<br><a href=\"dc_" + weapon.name_accu + "_v15.php\">accuracy test</a>.&nbsp;<br><br>";
    html_text+= "";
    html_text+= "</td></tr></table><br>";
    document.all.weapon_pic.innerHTML = html_text;
  }
}

function print_logbox()
{
  if (input.display_mode == "basic")
  {
    html_text = "<span class=desc>how to use...</span><br>";
    html_text+= "<img src=\"gfx/dc2_quickhelp.gif\" width=\"410\" height=\"170\">";
    document.all.logbox.innerHTML = html_text;
  }
  if (input.display_mode == "advanced")
  {
    switch(log_count)
    {
     case 1:
       html_text = "<span class=desc>logbox (" + log_count + " entry)</span>";
       break;
     case log_max:
       html_text = "<span class=desc><font color=\"#D20000\">logbox is full</font> (" + log_count + " entries max.)</span>";
       break;
     default:
       html_text = "<span class=desc>logbox (" + log_count + " entries)</span>";
       break;
    }
    html_text+= "<table cellpadding=0 cellspacing=0 width=0 border=0><tr><td class=CodePhrase>";
    html_text+= "<textarea name=txtarea_logbox rows=10 cols=49 size=5 wrap=physical>";
    html_text+= logbox_text;
    html_text+= "</textarea>";
    html_text+= "</td></tr></table>";
    document.all.logbox.innerHTML = html_text;
  }
}

function print_out()
{
  switch(input.display_mode)
  {
    case "basic":
      html_text = "<img src=\"../gfx/transparent.gif\" width=1 height=16>";  // spacer
      html_text+= "<table class=BasisFontSmall padding=0 cellspacing=0 border=0>";
      html_text+= "<tr><td><img src=\"gfx/dc2_life_legend.gif\" width=302 height=13><td>&nbsp;</td></td><td>&nbsp;</td><td>&nbsp;</td>";
      html_text+= "<tr>" + html.data_graphic.total.life.td_code + html.data_numeric.total.life.td_code + "</tr>";
      html_text+= "<tr>" + html.data_graphic.total.armor.td_code + html.data_numeric.total.armor.td_code + "</tr>";
      html_text+= "<tr><td><img src=\"gfx/dc2_armor_legend.gif\" width=302 height=13><td>&nbsp;</td></td><td>&nbsp;</td><td>&nbsp;</td>";
      html_text+= "</table>";
      document.all.res_value.innerHTML = html_text;
      document.all.advanced_bar.innerHTML = "";

      document.all.option_reset_health.innerHTML = "<img src=\"../gfx/transparent.gif\" width=14 height=16 align=left><a href=\"javascript:reset_data()\">reset health</a><input type=hidden id=reset_data value=100><br>";
      document.all.option_toggle_mode.innerHTML = "";
      document.all.option_auto_reset.innerHTML = "";
      document.all.option_generate_log2html.innerHTML = "";
      document.all.option_helmet.innerHTML = "<img src=\"../gfx/ico_yes.gif\" id=helmet_ico width=14 height=16 align=left><a href=\"javascript:set_helmet()\"><nobr>use kevlar helmet</nobr></a><br>";
      document.all.option_vest.innerHTML = "<img src=\"../gfx/ico_yes.gif\" id=vest_ico width=14 height=16 align=left><a href=\"javascript:set_vest()\"><nobr>use kevlar vest</nobr></a><br>";
      document.all.option_clear_log.innerHTML = "";
      document.all.spacer_for_options.innerHTML = "<img src=\"../gfx/transparent.gif\" width=1 height=68>";
      break;
    case "advanced":
      //html_text = "<img src=\"../gfx/transparent.gif\" width=1 height=15>";  // spacer
      if (input.display_damage) subheadline = "damage"; else subheadline = "health";
      html_text = "<span class=desc>" + subheadline + "</span><img src=\"../gfx/transparent.gif\" width=1 height=13>";  // spacer
      html_text+= "<table class=BasisFontRight padding=0 cellspacing=0 border=0>";
      html_text+= "<tr>" + html.data_graphic.head.td_code + html.data_numeric.head.td_code + "</tr>";
      html_text+= "<tr>" + html.data_graphic.chest.td_code + html.data_numeric.chest.td_code + "</tr>";
      html_text+= "<tr>" + html.data_graphic.stomach.td_code + html.data_numeric.stomach.td_code + "</tr>";
      html_text+= "<tr>" + html.data_graphic.leg.td_code + html.data_numeric.leg.td_code + "</tr>";
      html_text+= "</table>";
      document.all.res_value.innerHTML = html_text;
      html_text = "<table class=BasisFontRight padding=0 cellspacing=0 border=0>";
      html_text+= "<tr>" + html.data_graphic.total.life.td_code + html.data_numeric.total.life.td_code + "</tr>";
      html_text+= "<tr>" + html.data_graphic.total.armor.td_code + html.data_numeric.total.armor.td_code + "</tr>";
      html_text+= "</table>";
      document.all.advanced_bar.innerHTML = html_text;

      document.all.option_reset_health.innerHTML = "<img src=\"../gfx/transparent.gif\" width=14 height=16 align=left><a href=\"javascript:reset_data()\">reset health</a> to <input class=BasisFontSmall type=Text id=reset_data onChange=\"input.get_resetvalue(document.all.reset_data.value)\" value=" + (100 - input.resetvalue) + " size=4 maxlength=3><br>";
      document.all.option_toggle_mode.innerHTML = "<img src=\"../gfx/transparent.gif\" width=14 height=16 align=left><a href=\"javascript:toggle_mode()\"><nobr>toggle damage / health</nobr></a><br>";
      document.all.option_auto_reset.innerHTML = "<img src=\"../gfx/ico_yes.gif\" id=switch_ico width=14 height=16 align=left><a href=\"javascript:reset_on_weaponswitch()\"><nobr>reset on weaponswitch</nobr></a><br>";
      document.all.option_generate_log2html.innerHTML = "<img src=\"../gfx/transparent.gif\" width=14 height=16 align=left><a href=\"javascript:generate_log2html()\"><nobr>generate logbox2html</nobr></a><br>";
      document.all.option_helmet.innerHTML = "<img src=\"../gfx/ico_yes.gif\" id=helmet_ico width=14 height=16 align=left><a href=\"javascript:set_helmet()\"><nobr>use kevlar helmet</nobr></a><br>";
      document.all.option_vest.innerHTML = "<img src=\"../gfx/ico_yes.gif\" id=vest_ico width=14 height=16 align=left><a href=\"javascript:set_vest()\"><nobr>use kevlar vest</nobr></a><br>";
      document.all.option_clear_log.innerHTML = "<img src=\"../gfx/transparent.gif\" width=14 height=16 align=left><a href=\"javascript:clear_log()\">clear logbox</a><br>";
      document.all.spacer_for_options.innerHTML = "";
      break;
    default:
      break;
  }
}

function go(zone)
{
  victim.calc_basis(zone);  // berechnung der basiswerte
  final_calc(); // dies verursacht übrigens den doppelten sound beim klicken.
  // schaden nur berechnen, wenn diese zone auch beschossen wurde.
  if (zone == "h") victim.head.calc();
  if (zone == "c") victim.chest.calc();
  if (zone == "s") victim.stomach.calc();
  if (zone == "l") victim.leg.calc();
  html.convert_graphic();
  html.convert_numeric();
  print_out();
  if (input.display_mode == "advanced") check_log(zone);
  print_logbox();
  play_sound(zone);
}

function final_calc()
{
  document.all.dc2_obj.innerHTML = '<object name="dc2_calc" data="dc2_calculation.php?random=' + Math.random() + '" width="0" height="0"></object>';
}

/*******************************************************************
diese funktion wählt den entsprechenden (waffen)sound aus und spielt
ihn ggf. ab. als soundquellen werden flash-files verwendet.
die funktion wird (nur) über die funktion go(zone) aufgerufen.
folgende werte werden verarbeitet und müssen daher vor dem
funktionsaufruf gesetzt worden sein:
- input.play_sound (reflektiert die userauswahl in im gui.)
- input.display_damage (reflektiert die userauswahl in im gui.
bei 'damage' werden die waffengeräusche, bei 'health' die
aua-geräusche ausgegeben,)
technischer hinweis: das einblenden der swf-files über innerHTML
löst den abspielvorgang aus.

*******************************************************************/
function play_sound(zone)
{
  if (input.play_sound) // hat der user, die soundausgabe angewählt?
  {
    if (input.display_damage) // wurde die schadensanzeige ...
    {
      if (zone == "h") document.all.swf_source.innerHTML = "<object><param name=movie value=dc2_" + weapon.name_accu + ".swf><param name=quality value=high><embed src=dc2_" + weapon.name_accu + ".swf quality=high type=\"application/x-shockwave-flash\"></embed></object>";
      if (zone == "c") document.all.swf_source.innerHTML = "<object><param name=movie value=dc2_" + weapon.name_accu + ".swf><param name=quality value=high><embed src=dc2_" + weapon.name_accu + ".swf quality=high type=\"application/x-shockwave-flash\"></embed></object>";
      if (zone == "s") document.all.swf_source.innerHTML = "<object><param name=movie value=dc2_" + weapon.name_accu + ".swf><param name=quality value=high><embed src=dc2_" + weapon.name_accu + ".swf quality=high type=\"application/x-shockwave-flash\"></embed></object>";
      if (zone == "l") document.all.swf_source.innerHTML = "<object><param name=movie value=dc2_" + weapon.name_accu + ".swf><param name=quality value=high><embed src=dc2_" + weapon.name_accu + ".swf quality=high type=\"application/x-shockwave-flash\"></embed></object>";
    }
    else // ... oder die healthanzeige angewählt.
    {
      if (zone == "h")
      {
       if (input.helmet)  // plong ...
       {
          document.all.swf_source.innerHTML = "<object><param name=movie value=dc2_helmet.swf><param name=quality value=high><embed src=dc2_helmet.swf quality=high type=\"application/x-shockwave-flash\"></embed></object>";
       }
       else  // ... oder 'patsch'
          document.all.swf_source.innerHTML = "<object><param name=movie value=dc2_head.swf><param name=quality value=high><embed src=dc2_head.swf quality=high type=\"application/x-shockwave-flash\"></embed></object>";
      }
      if (zone == "c" || zone == "s") // nutzen die gleichen sounds
      {
       if (input.vest)
          document.all.swf_source.innerHTML = "<object><param name=movie value=dc2_vest.swf><param name=quality value=high><embed src=dc2_vest.swf quality=high type=\"application/x-shockwave-flash\"></embed></object>";
       else
          document.all.swf_source.innerHTML = "<object><param name=movie value=dc2_flesh.swf><param name=quality value=high><embed src=dc2_flesh.swf quality=high type=\"application/x-shockwave-flash\"></embed></object>";
      }
      if (zone == "l") document.all.swf_source.innerHTML = "<object><param name=movie value=dc2_flesh.swf><param name=quality value=high><embed src=dc2_flesh.swf quality=high type=\"application/x-shockwave-flash\"></embed></object>";
    }
  }
}


function validate_distance(myDist, myDim)
{
  if (isNaN(myDist))
  {
    myDist = 0;
  }
  else
  {
    if ((myDist < 0) || (myDist > 999))
      myDist = 0;
  }
  document.all.dist.value = myDist; // den ggf. korrigierten wert zurückschreiben
  if (myDim == "m") this.distance = Math.round(myDist);
  if (myDim == "ft") this.distance = Math.round(myDist * 0.3048);
  if (myDim == "yd") this.distance = Math.round(myDist * 0.9144);
  html.log_distance = Math.round(myDist);
  html.log_distance_dim = myDim;
}

function validate_resetvalue(myValue)
{
  if (isNaN(myValue))
  {
    myValue = 100;
  }
  else
  {
    if ((myValue < 0) || (myValue > 100))
      myValue = 100;
  }
  input.resetvalue = Math.round(100 - eval(myValue));
}

function set_weapon()
{
  input.weapon = eval(document.all.cmb_weapon.value);
  weapon = new obj_wea(input);
  if (input.reset_on_weaponswitch)
  {
    reset_data();
  }
  print_weapon();
}

function toggle_mode()
{
  if (input.display_damage)
    input.display_damage = false;
  else
    input.display_damage = true;
  html.convert_graphic();
  html.convert_numeric();
  print_out();
}


function set_vest()
{
img_ico_yes = new Image();
img_ico_yes.src = "../gfx/ico_yes.gif";

  if (document.all.vest_ico.src == img_ico_yes.src)
  {
    document.all.vest_ico.src = "../gfx/ico_no.gif";
    document.all.helmet_ico.src = "../gfx/ico_no.gif";
    document.all.body_zones_pic.src = "gfx/body_zones_dc2.gif";
    input.helmet = false;
    input.vest = false;
  }
  else
  {
    document.all.vest_ico.src = "../gfx/ico_yes.gif";
    document.all.body_zones_pic.src = "gfx/body_zones_vest_dc2.gif";
    input.vest = true;
  }
}


function set_helmet()
{
img_ico_yes = new Image();
img_ico_yes.src = "../gfx/ico_yes.gif";

  if (document.all.helmet_ico.src == img_ico_yes.src)
  {
    document.all.helmet_ico.src = "../gfx/ico_no.gif";
    document.all.body_zones_pic.src = "gfx/body_zones_vest_dc2.gif";
    input.helmet = false;
  }
  else
  {
    document.all.vest_ico.src = "../gfx/ico_yes.gif";
    document.all.helmet_ico.src = "../gfx/ico_yes.gif";
    document.all.body_zones_pic.src = "gfx/body_zones_helmet_dc2.gif";
    input.helmet = true;
    input.vest = true;
  }
}

function reset_on_weaponswitch()
{
img_ico_yes = new Image();
img_ico_yes.src = "../gfx/ico_yes.gif";

  if (document.all.switch_ico.src == img_ico_yes.src)
  {
    document.all.switch_ico.src = "../gfx/ico_no.gif";
    input.reset_on_weaponswitch = false;
  }
  else
  {
    document.all.switch_ico.src = "../gfx/ico_yes.gif";
    input.reset_on_weaponswitch = true;
  }
}

function set_sound()
{
img_ico_yes = new Image();
img_ico_yes.src = "../gfx/ico_yes.gif";

  if (document.all.sound_ico.src == img_ico_yes.src)
  {
    document.all.sound_ico.src = "../gfx/ico_no.gif";
    input.play_sound = false;
  }
  else
  {
    document.all.sound_ico.src = "../gfx/ico_yes.gif";
    input.play_sound = true;
  }
}

function reset_data()
{
  victim.head.life.reset();
  victim.head.armor.reset();
  victim.chest.life.reset();
  victim.chest.armor.reset();
  victim.stomach.life.reset();
  victim.stomach.armor.reset();
  victim.leg.life.reset();
  victim.total.life.reset();
  victim.total.armor.reset();
  html.convert_graphic();
  html.convert_numeric();
  print_out();
}

function display_mode(mode)
{
  input.display_mode = mode;
  input.resetvalue = 0;  //  health wird immer auf 100 zurückgesetzt;
  input.reset_on_weaponswitch = true;  //  kein 'waffenwechseln' verfügbar;
  input.display_damage = false; // keine 'damageanzeige' verfügbar;
  reset_data();
  html.convert_graphic();
  html.convert_numeric();
  print_weapon();
  print_out();
  print_logbox();
}

function clear_log()
{
  log = new Array();
  log_max = 25;
  log_count = 0;
  uri_length = 0; // init
  logbox_text = " weapon       zone    distance   damage   armor\n";
  logbox_text+= " ----------------------------------------------\n";
  print_logbox();
}

function add_to_log(zone, log_compact)
{
  var tmp_life_ave = "     " + html.data_numeric.log.life.ave + " hp";
  var tmp_armor_ave = "     " + html.data_numeric.log.armor.ave + " ap";
  var tmp_distance = "     " + html.log_distance + " " + html.log_distance_dim;
  log[log_count] = new Array();

  log[log_count]["weapon"] = (weapon.name_short + "           ").slice(0,12);
  if (zone == "h") log[log_count]["zone"] = "head    ";
  if (zone == "c") log[log_count]["zone"] = "chest   ";
  if (zone == "s") log[log_count]["zone"] = "stomach ";
  if (zone == "l") log[log_count]["zone"] = "leg     ";
  log[log_count]["distance"] = tmp_distance.slice(tmp_distance.length - 7, tmp_distance.length);
  log[log_count]["damage_ave"] = tmp_life_ave.slice(tmp_life_ave.length - 8, tmp_life_ave.length);
  log[log_count]["armor_ave"] = tmp_armor_ave.slice(tmp_armor_ave.length - 7, tmp_armor_ave.length);
  log[log_count]["compact"] = log_compact;

  logbox_text+= " " + log[log_count]["weapon"] + " " + log[log_count]["zone"] + " " + log[log_count]["distance"] + " " + log[log_count]["damage_ave"] + " " +  log[log_count]["armor_ave"] + "\n";
  log_count++;
}

function check_log(zone)
{
  var log_w = weapon.id;
  var log_z = zone;
  var log_d = html.log_distance + html.log_distance_dim.slice(0,1);
  var log_have = html.data_numeric.log.life.ave;
  var log_hmax = html.data_numeric.log.life.max;
  var log_hmin = html.data_numeric.log.life.min;
  var log_aave = html.data_numeric.log.armor.ave;
  var log_amax = html.data_numeric.log.armor.max;
  var log_amin = html.data_numeric.log.armor.min;
  var log_compact = "w[]=" + log_w + "," + log_z + "," + log_d + "," + log_hmin + "," + log_have + "," + log_hmax + "," + log_amin + "," + log_aave + "," + log_amax + "&";
  var is_already_logged = false;

  for (var i = 0; i < (log.length); i++)
  {
    if ((log[i]["compact"]) == log_compact) is_already_logged = true;
  }
  // wenn datensatz noch nicht vorhanden und die uri noch kleiner als 2kb ist, dann ...
  if ((!is_already_logged) & (uri_length < 2000) & (log_count < log_max))
  {
    uri_length+= log_compact.length;
    add_to_log(zone, log_compact);
  }
}


function generate_log2html()
{
  var uri = "log2html/dc_log2html.php?";
  if (log_count == 0)
  {
    alert('no data found!\nyour logbox is currently empty.');
  }
  else
  {
    for (var i = 0; i < (log.length); i++)
    {
      uri+= log[i]["compact"];
    }
    window.open(uri,"log2html_wind","toolbar=yes,resizable=yes,scrollbars=yes,width=800");
  }
}
