MediaWiki:Zerospace DE.js

From OGC
Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences
var imperial_alien_id = new Array();
imperial_alien_id['head_structure'] = new Array();
imperial_alien_id['skin_tone'] = new Array();
imperial_alien_id['skin_color'] = new Array();
imperial_alien_id['traits'] = new Array();

// imperial_alien_id['organic']
//   0 = android
//   1 = organic
//   2 = synthetic
// imperial_alien_id['subtype_artifical']
//   1 = obvious
//   2 = lifelike
// imperial_alien_id['type']
//   1 = humanoid
//   2 = anthropomorphic animal
//   3 = anthropomorphic plant
//   4 = insectoid
//  10 = uncommon
//  11 = colonial
//  12 = crystalline
//  13 = cybernetic
//  14 = gaseous
//  15 = myconoid
//  16 = viscous fluid
// imperial_alien_id['subtype_animal']
//   0 = none
//   1 = avian
//   2 = canine
//   3 = cephalopod
//   4 = feline
//   5 = mustelid
//   6 = reptilian
// imperial_alien_id['symmetry']
//   1 = humanoid bilateral
//   2 = dendriform bilateral
//   3 = globular bilateral
//   4 = serpentine bilateral
//   5 = dendriform radial
//   6 = globular radial
//   7 = serpentine radial
// imperial_alien_id['hair']
//   0 = hairless
//   1 = hair
//   2 = feathers
//   3 = scales
//   4 = spines
// imperial_alien_id['head_structure'][0]
// imperial_alien_id['head_structure'][1]
//   0 = none
//   1 = antennae
//   2 = brow ridges
//   3 = cranial ridges
//   4 = horns
//   5 = pointed ears
//   6 = tentacles
// imperial_alien_id['skin_tone'][0]
// imperial_alien_id['skin_tone'][1]
//   1 = colorless
//   2 = pale
//   3 = light
//   4 = medium
//   5 = deep
//   6 = dark
//   9 = absolute
// imperial_alien_id['skin_color'][0]
// imperial_alien_id['skin_color'][1]
//   1 = white
//   2 = red
//   3 = brown
//   4 = yellow
//   5 = green
//   6 = blue
//   9 = grey
//  10 = black
// imperial_alien_id['eye_type']
//   0 = NA
//   1 = circular pupil
//   2 = horizontally slit pupil
//   3 = vertically slit pupil
//   4 = pupilless
//   5 = solid color
//   6 = compound
// imperial_alien_id['traits'][0]
// imperial_alien_id['traits'][1]
// imperial_alien_id['traits'][...]

function print_r(printthis, returnoutput)
{
	var output = '';

	if ($.isArray(printthis) || typeof(printthis) == 'object')
	{
		for(var i in printthis)
		{
			output += i + ' : ' + print_r(printthis[i], true) + '\n';
		}
	}
	else
	{
		output += printthis;
	}

	if (returnoutput && returnoutput == true)
	{
		return output;
	}
	else
	{
		alert(output);
	}
}

function roll_dice(dice_size, dice_count)
{
	dice_size =  typeof dice_size  !== 'undefined' ? dice_size  : 6;
	dice_count = typeof dice_count !== 'undefined' ? dice_count : 1;

	var dice_total = 0;

	for (i = 0; i < dice_count; i++)
	{
		dice_total += Math.floor((Math.random() * dice_size) + 1);
	}

	return dice_total;
}

function random_character()
{
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
	var rnum = Math.floor(Math.random() * chars.length);
	var random_character = chars.substring(rnum, rnum+1);
	
	return random_character;
}

function get_android_model()
{
	var android_model = '';
	var dice_size = 3;
	var dice_count = 6;
	var android_model_prefix_roll   = roll_dice(dice_size, dice_count);
	var android_model_prefix_length = Math.floor((android_model_prefix_roll - 2)/6) + 1;
	var android_model_suffix_roll   = roll_dice(dice_size, dice_count);
	var android_model_suffix_length = Math.floor((android_model_suffix_roll - 2)/6) + 1;

	for (i = 0; i < android_model_prefix_length; i++)
	{
		android_model += random_character();
	}

	android_model += '-';
	
	for (i = 0; i < android_model_suffix_length; i++)
	{
		android_model += random_character();
	}
	
	return android_model;
}

function get_exotic_alien_symmetry(is_android)
{
	is_android = typeof is_android !== 'undefined' ? is_android : false;

	var exotic_alien_symmetry;
	var organism_type = 'Lebewesen';
	var dice_size = 6;
	var dice_count = 1;
	var exotic_alien_symmetry_roll = roll_dice(dice_size, dice_count);

	if (is_android)
	{
		organism_type = 'Android';
	}

	switch (exotic_alien_symmetry_roll)
	{
		case 1:
			imperial_alien_id['symmetry'] = 2; // dendriform bilateral
			exotic_alien_symmetry = 'Verzweigt-' + organism_type + ' achsensymmetrischer';
			break;
		case 2:
			imperial_alien_id['symmetry'] = 5; // dendriform radial
			exotic_alien_symmetry = 'Verzweigt-' + organism_type + ' radialsymmetrischer';
			break;
		case 3:
			imperial_alien_id['symmetry'] = 3; // globular bilateral
			exotic_alien_symmetry = 'Kugelförmig-' + organism_type + ' achsensymmetrischer';
			break;
		case 4:
			imperial_alien_id['symmetry'] = 6; // globular radial
			exotic_alien_symmetry = 'Kugelförmig-' + organism_type + ' radialsymmetrischer';
			break;
		case 5:
			imperial_alien_id['symmetry'] = 4; // serpentine bilateral
			exotic_alien_symmetry = 'Gewunden-' + organism_type + ' achsensymmetrischer';
			break;
		case 6:
			imperial_alien_id['symmetry'] = 7; // serpentine radial
			exotic_alien_symmetry = 'Gewunden-' + organism_type + ' radialsymmetrischer';
	}

	return exotic_alien_symmetry;
}

function get_exotic_alien_animal()
{
	var exotic_alien_animal;
	var dice_size = 6;
	var dice_count = 1;
	var exotic_alien_animal_roll = roll_dice(dice_size, dice_count);

	switch (exotic_alien_animal_roll)
	{
		case 1:
			imperial_alien_id['subtype_animal'] = 1;
			exotic_alien_animal = "Vogel";
			break;
		case 2:
			imperial_alien_id['subtype_animal'] = 2;
			exotic_alien_animal = "Hund(e)";
			break;
		case 3:
			imperial_alien_id['subtype_animal'] = 3;
			exotic_alien_animal = "Tintenfisch";
			break;
		case 4:
			imperial_alien_id['subtype_animal'] = 4;
			exotic_alien_animal = "Katze(n)";
			break;
		case 5:
			imperial_alien_id['subtype_animal'] = 5;
			exotic_alien_animal = "Marder";
			break;
		case 6:
			imperial_alien_id['subtype_animal'] = 6;
			exotic_alien_animal = "Reptil";
	}

	return exotic_alien_animal;
}

function get_exotic_alien_weird_biology()
{
	var exotic_alien_weird_biology;
	var dice_size = 6;
	var dice_count = 1;
	var exotic_alien_weird_biology_roll = roll_dice(dice_size, dice_count);
	var exotic_alien_symmetry;

	// set defaults
	imperial_alien_id['type'] = 1; // humanoid

	switch (exotic_alien_weird_biology_roll)
	{
		case 1:
			imperial_alien_id['type'] = 11; // colonial
			exotic_alien_weird_biology = "Kolonialorganismus";
			exotic_alien_symmetry      = get_exotic_alien_symmetry();
			exotic_alien_weird_biology = exotic_alien_symmetry + ' ' + exotic_alien_weird_biology;
			break;
		case 2:
			imperial_alien_id['type'] = 12; // crystalline
			exotic_alien_weird_biology = "Kristallorganismus";
			exotic_alien_symmetry      = get_exotic_alien_symmetry();
			exotic_alien_weird_biology = exotic_alien_symmetry + ' ' + exotic_alien_weird_biology;
			break;
		case 3:
			imperial_alien_id['type'] = 13; // cybernetic
			exotic_alien_weird_biology = "Cyborg";
			exotic_alien_symmetry      = get_exotic_alien_symmetry();
			exotic_alien_weird_biology = exotic_alien_symmetry + ' ' + exotic_alien_weird_biology;
			break;
		case 4:
			imperial_alien_id['type'] = 14; // gaseous
			exotic_alien_weird_biology = "Gasförmiges Alien";
			break;
		case 5:
			imperial_alien_id['type'] = 15; // myconoid
			exotic_alien_weird_biology = "Pilzartig";
			exotic_alien_symmetry      = get_exotic_alien_symmetry();
			exotic_alien_weird_biology = exotic_alien_symmetry + ' ' + exotic_alien_weird_biology;
			break;
		case 6:
			imperial_alien_id['type'] = 16; // viscous fluid
			exotic_alien_weird_biology = "Viskoses Alien";
	}

	return exotic_alien_weird_biology;
}

function get_exotic_alien_type(is_android)
{
	is_android = typeof is_android !== 'undefined' ? is_android : false;

	var exotic_alien_type;
	var dice_size = 6;
	var dice_count = 1;

	if (is_android)
	{
		dice_size = 5;
	}

	var exotic_alien_type_roll = roll_dice(dice_size, dice_count);
	var exotic_alien_animal;
	var exotic_alien_symmetry;

	// set defaults
	imperial_alien_id['type'] = 1; // humanoid

	switch (exotic_alien_type_roll)
	{
		case 1:
			imperial_alien_id['type'] = 1; // humanoid
			exotic_alien_animal       = get_exotic_alien_animal();

			if (exotic_alien_animal == "Katze(n)")
			{
				exotic_alien_animal   = "Katzen";
				exotic_alien_type     = exotic_alien_animal + "-köpfiger Humanoid";
			}
			else if (exotic_alien_animal == "Hund(e)")
			{
				exotic_alien_animal   = "Hunde";
				exotic_alien_type     = exotic_alien_animal + "-köpfiger Humanoid";
			}
			else
			{
				exotic_alien_type     = exotic_alien_animal + "-köpfiger Humanoid";
			}

			if (is_android)
			{
				exotic_alien_type += ' Android';
			}
			else
			{
				exotic_alien_type += ' Lebewesen';
			}

			break;
		case 2:
			imperial_alien_id['type'] = 2; // anthropomorphic animal
			exotic_alien_animal       = get_exotic_alien_animal();

			if (exotic_alien_animal == "Katze(n)")
			{
				exotic_alien_animal   = "Katze";
				exotic_alien_type     = "Anthropomorphe " + exotic_alien_animal;
			}
			else if (exotic_alien_animal == "Reptil")
			{
				exotic_alien_type     = "Anthropomorphes " + exotic_alien_animal;
			}
			else if (exotic_alien_animal == "Hund(e)")
			{
				exotic_alien_animal   = "Hund";
				exotic_alien_type     = "Anthropomorpher " + exotic_alien_animal;
			}
			else
			{
				exotic_alien_type     = "Anthropomorpher " + exotic_alien_animal;
			}

			if (is_android)
			{
				exotic_alien_type += ' Android';
			}

			break;
		case 3:
			imperial_alien_id['type'] = 3; // anthropomorphic plant
			exotic_alien_type         = "Anthropomorphe Pflanze";

			if (is_android)
			{
				exotic_alien_type += ' Android';
			}

			break;
		case 4:
			imperial_alien_id['type'] = 4; // insectoid
			exotic_alien_type         = "Insektoid";

			if (is_android)
			{
				exotic_alien_type += ' Android';
			}
			else
			{
				exotic_alien_type += ' Lebewesen';
			}

			break;
		case 5:
			imperial_alien_id['type'] = 10; // uncommon
			exotic_alien_symmetry     = get_exotic_alien_symmetry(is_android);
			exotic_alien_type         = exotic_alien_symmetry;
			break;
		case 6:
			exotic_alien_type         = get_exotic_alien_weird_biology();
	}

	return exotic_alien_type;
}

function get_alien_type()
{
	var alien_type;
	var dice_size = 6;
	var dice_count = 3;
	var alien_type_roll = roll_dice(dice_size, dice_count);
	var exotic_alien_type;

	// set defaults
	imperial_alien_id['type'] = 1; // humanoid
	imperial_alien_id['organic'] = 1; // organic
	imperial_alien_id['subtype_animal'] = 0; // NA
	imperial_alien_id['subtype_artifical'] = 0; // NA
	imperial_alien_id['symmetry'] = 1; // humanoid bilateral

	if (alien_type_roll <= 13)
	{
		imperial_alien_id['type'] = 1; // humanoid
		imperial_alien_id['organic'] = 1; // organic
		alien_type = 'humanoider Organismus';
	}
	else if (alien_type_roll <= 15)
	{
		imperial_alien_id['organic'] = 0; // android
		imperial_alien_id['subtype_artifical'] = 1; // obvious
		dice_size = 100;
		dice_count = 1;
		var android_type_roll = roll_dice(dice_size, dice_count);

		if (android_type_roll <= 50)
		{
			imperial_alien_id['type'] = 1; // humanoid
			alien_type = 'humanoider Android';
		}
		else if (android_type_roll <= 55)
		{
			imperial_alien_id['type'] = 1; // humanoid
			imperial_alien_id['subtype_artifical'] = 2; // lifelike
			alien_type = 'lebensechter humanoider Android';
		}
		else if (android_type_roll <= 99)
		{
			exotic_alien_type = get_exotic_alien_type(true);
			alien_type        = exotic_alien_type;
		}
		else
		{
			imperial_alien_id['subtype_artifical'] = 2; // lifelike
			exotic_alien_type = get_exotic_alien_type(true);
			alien_type        = 'lebensechter ' + exotic_alien_type;
		}
	}
	else
	{
		imperial_alien_id['organic'] = 1; // organic
		exotic_alien_type = get_exotic_alien_type();
		alien_type        = exotic_alien_type;
	}

	return alien_type;
}

function is_alien_skin_patterned()
{
	var alien_skin_patterned = false;
	var dice_size = 6;
	var dice_count = 1;
	var alien_skin_patterned_roll = roll_dice(dice_size, dice_count);

	if (alien_skin_patterned_roll == 6)
	{
		var alien_skin_patterned = true;
	}

	return alien_skin_patterned;
}

function get_alien_skin_intensity()
{
	var alien_skin_intensity;
	var dice_size = 5;
	var dice_count = 1;
	var alien_skin_intensity_roll = roll_dice(dice_size, dice_count);
	var imperial_index = typeof imperial_alien_id['skin_tone'][0] === 'undefined' ? 0 : 1;

	switch (alien_skin_intensity_roll)
	{
		case 1:
			imperial_alien_id['skin_tone'][imperial_index] = 2; // pale
			alien_skin_intensity = "Blass-";
			break;
		case 2:
			imperial_alien_id['skin_tone'][imperial_index] = 3; // light
			alien_skin_intensity = "Hell-";
			break;
		case 3:
			imperial_alien_id['skin_tone'][imperial_index] = 4; // medium
			alien_skin_intensity = "";
			break;
		case 4:
			imperial_alien_id['skin_tone'][imperial_index] = 5; // deep
			alien_skin_intensity = "Tief-";
			break;
		case 5:
			imperial_alien_id['skin_tone'][imperial_index] = 6; // dark
			alien_skin_intensity = "Dunkel-";
			break;
	}

	return alien_skin_intensity;
}

function get_alien_skin_color(is_obvious_android)
{
	is_obvious_android = typeof is_obvious_android !== 'undefined' ? is_obvious_android : false;
	
	var alien_skin_color;
	var dice_size = 6;
	var dice_count = 1;
	var alien_skin_color_roll = roll_dice(dice_size, dice_count);
	var imperial_index = typeof imperial_alien_id['skin_color'][0] === 'undefined' ? 0 : 1;

	if (!is_obvious_android)
	{
		switch (alien_skin_color_roll)
		{
			case 1:
				imperial_alien_id['skin_color'][imperial_index] = 6; // blue
				alien_skin_color = "Blau";
				break;
			case 2:
				imperial_alien_id['skin_color'][imperial_index] = 3; // brown
				alien_skin_color = "Braun";
				break;
			case 3:
				imperial_alien_id['skin_color'][imperial_index] = 5; // green
				alien_skin_color = "Grün";
				break;
			case 4:
				imperial_alien_id['skin_color'][imperial_index] = 9; // grey
				alien_skin_color = "Grau";
				break;
			case 5:
				imperial_alien_id['skin_color'][imperial_index] = 2; // red
				alien_skin_color = "Rot";
				break;
			case 6:
				imperial_alien_id['skin_color'][imperial_index] = 4; // yellow
				alien_skin_color = "Gelb";
		}
	}
	else
	{
		dice_size = 10;
		dice_count = 1;
		var android_color_roll = roll_dice(dice_size, dice_count);

		switch (android_color_roll)
		{
			case 1:
				imperial_alien_id['skin_color'][imperial_index] = 2; // red
				alien_skin_color = "Rot";
				break;
			case 2:
				imperial_alien_id['skin_color'][imperial_index] = 3; // orange
				alien_skin_color = "Orange";
				break;
			case 3:
				imperial_alien_id['skin_color'][imperial_index] = 4; // yellow
				alien_skin_color = "Gelb";
				break;
			case 4:
				imperial_alien_id['skin_color'][imperial_index] = 5; // green
				alien_skin_color = "Grün";
				break;
			case 5:
				imperial_alien_id['skin_color'][imperial_index] = 6; // blue
				alien_skin_color = "Blau";
				break;
			case 6:
				imperial_alien_id['skin_color'][imperial_index] = 7; // purple
				alien_skin_color = "Lila";
				break;
			default:
				imperial_alien_id['skin_color'][imperial_index] = 9; // grey
				alien_skin_color = "Grau";
		}
	}

	return alien_skin_color;
}

function get_alien_skin_combo(is_obvious_android)
{
	is_obvious_android = typeof is_obvious_android !== 'undefined' ? is_obvious_android : false;
	
	var alien_skin_combo;
	var dice_size = 4;
	var dice_count = 1;
	var increase_contrast_roll = roll_dice(dice_size, dice_count);
	var increase_contrast = false;

	var alien_skin_intensity = get_alien_skin_intensity();
	var alien_skin_color = get_alien_skin_color(is_obvious_android);
	var android_finish = '';

	var imperial_index = typeof imperial_alien_id['skin_color'][0] === 'undefined' ? 0 : 1;

	if (increase_contrast_roll == 1)
	{
		increase_contrast = true;
	}
	
	if (increase_contrast && alien_skin_color == "Grau")
	{
		if (alien_skin_intensity == "Blass-")
		{
			imperial_alien_id['skin_tone'][imperial_index] = 1; // colorless
			alien_skin_intensity = "";
			imperial_alien_id['skin_color'][imperial_index] = 1;
			alien_skin_color     = "Schneeweiß";
		}
		else if (alien_skin_intensity == "Dunkel-")
		{
			imperial_alien_id['skin_tone'][imperial_index] = 10; // absolute
			alien_skin_intensity = "";
			imperial_alien_id['skin_color'][imperial_index] = 10;
			alien_skin_color     = "Pechschwarz";
		}
	}

	if (is_obvious_android)
	{
		dice_size = 6;
		dice_count = 1;
		var android_finish_roll = roll_dice(dice_size, dice_count);

		switch (android_finish_roll)
		{
			case 1:
				android_finish = ", matt";
				break;
			case 2:
				android_finish = ", glänzend";
				break;
			case 3:
				android_finish = ", glänzend";
				break;
			default:
				android_finish = ", metallic";
		}
	}

	alien_skin_combo = alien_skin_intensity + " " + alien_skin_color + android_finish;

	return alien_skin_combo;
}

function get_alien_skin(is_obvious_android)
{
	is_obvious_android = typeof is_obvious_android !== 'undefined' ? is_obvious_android : false;
	
	var alien_skin;
	var alien_skin_2;
	var has_alien_skin_patterned = is_alien_skin_patterned();

	if (has_alien_skin_patterned)
	{
		alien_skin   = get_alien_skin_combo(is_obvious_android);
		alien_skin_2 = alien_skin;

		while (alien_skin_2 == alien_skin)
		{
			alien_skin_2 = get_alien_skin_combo(is_obvious_android);
		}

		alien_skin += " und " + alien_skin_2;
	}
	else
	{
		alien_skin = get_alien_skin_combo(is_obvious_android);
	}

	return alien_skin;
}

function get_alien_eyes_type()
{
	var alien_eyes_type;
	var dice_size = 6;
	var dice_count = 1;
	var alien_eyes_type_roll = roll_dice(dice_size, dice_count);

	switch (alien_eyes_type_roll)
	{
		case 1:
			imperial_alien_id['eye_type'] = 1; // circular pupil
			alien_eyes_type = "mit kreisförmigen Pupillen";
			break;
		case 2:
			imperial_alien_id['eye_type'] = 2; // horizontally slit pupil
			alien_eyes_type = "mit horizontal schlitzförmigen Pupillen";
			break;
		case 3:
			imperial_alien_id['eye_type'] = 3; // vertically slit pupil
			alien_eyes_type = "mit vertikal schlitzförmigen Pupillen";
			break;
		case 4:
			imperial_alien_id['eye_type'] = 4; // pupilless
			alien_eyes_type = "ohne Pupillen";
			break;
		case 5:
			imperial_alien_id['eye_type'] = 5; // solid color
			alien_eyes_type = "mit vollfarbigen Pupillen";
			break;
		case 6:
			imperial_alien_id['eye_type'] = 6; // compound
			alien_eyes_type = "Facettenaugen";
	}

	return alien_eyes_type;
}

function get_alien_eyes_intensity()
{
	var alien_eyes_intensity;
	var dice_size = 6;
	var dice_count = 1;
	var alien_eyes_intensity_roll = roll_dice(dice_size, dice_count);

	switch (alien_eyes_intensity_roll)
	{
		case 1:
			alien_eyes_intensity = "Blass-";
			break;
		case 2:
			alien_eyes_intensity = "Hell-";
			break;
		case 3:
			alien_eyes_intensity = "";
			break;
		case 4:
			alien_eyes_intensity = "Tief-";
			break;
		case 5:
			alien_eyes_intensity = "Dunkel-";
			break;
		case 6:
			alien_eyes_intensity = "Glühend-";
	}

	return alien_eyes_intensity;
}

function get_alien_eyes_color()
{
	var alien_eyes_color;
	var dice_size = 6;
	var dice_count = 1;
	var alien_eyes_color_roll = roll_dice(dice_size, dice_count);

	switch (alien_eyes_color_roll)
	{
		case 1:
			alien_eyes_color = "Blau";
			break;
		case 2:
			alien_eyes_color = "Braun";
			break;
		case 3:
			alien_eyes_color = "Grün";
			break;
		case 4:
			alien_eyes_color = "Grau";
			break;
		case 5:
			alien_eyes_color = "Rot";
			break;
		case 6:
			alien_eyes_color = "Gelb";
	}

	return alien_eyes_color;
}

function get_alien_eyes(is_lifelike_humanoid)
{
	is_lifelike_humanoid = typeof is_lifelike_humanoid !== 'undefined' ? is_lifelike_humanoid : true;
	
	// set defaults
	imperial_alien_id['eye_type'] = 0;

	var alien_eyes;
	var dice_size = 2;
	var dice_count = 1;
	var increase_contrast_roll = roll_dice(dice_size, dice_count);
	var increase_contrast;
	var alien_eyes_intensity = get_alien_eyes_intensity();
	var alien_eyes_color = get_alien_eyes_color();
	var alien_eyes_type = '';

	if (increase_contrast_roll == 1)
	{
		increase_contrast = true;
	}
	else
	{
		increase_contrast = false;
	}

	if (increase_contrast && alien_eyes_color == "Grau")
	{
		if (alien_eyes_intensity == "Blass-")
		{
			alien_eyes_intensity = "";
			alien_eyes_color = "Schneeweiß";
		}
		else if (alien_eyes_intensity == "Dunkel-")
		{
			alien_eyes_intensity = "";
			alien_eyes_color = "Pechschwarz";
		}
	}

	if (is_lifelike_humanoid)
	{
		alien_eyes_type = ", " + get_alien_eyes_type();
	}
	
	alien_eyes = alien_eyes_intensity + " " + alien_eyes_color + alien_eyes_type;

	return alien_eyes;
}

function get_alien_humanoid_head_structure()
{
	var dice_size = 6;
	var dice_count = 1;
	var alien_humanoid_head_structure_roll = roll_dice(dice_size, dice_count);
	var alien_humanoid_head_structure_text;

	switch (alien_humanoid_head_structure_roll)
	{
		case 1:
			alien_humanoid_head_structure_text = "Antennen";
			break;
		case 2:
			alien_humanoid_head_structure_text = "Augenwülste";
			break;
		case 3:
			alien_humanoid_head_structure_text = "Kopfwülste";
			break;
		case 4:
			alien_humanoid_head_structure_text = "Hörner";
			break;
		case 5:
			alien_humanoid_head_structure_text = "Spitze Ohren";
			break;
		case 6:
			alien_humanoid_head_structure_text = "Tentakeln";
	}

	var alien_humanoid_head_structure = new Array();
	alien_humanoid_head_structure['id']   = alien_humanoid_head_structure_roll;
	alien_humanoid_head_structure['text'] = alien_humanoid_head_structure_text;

	return alien_humanoid_head_structure;
}

function get_alien_humanoid_head_hair_intensity()
{
	var alien_humanoid_head_hair_intensity;
	var dice_size = 6;
	var dice_count = 1;
	var alien_humanoid_head_hair_intensity_roll = roll_dice(dice_size, dice_count);

	switch (alien_humanoid_head_hair_intensity_roll)
	{
		case 1:
			alien_humanoid_head_hair_intensity = "Blass-";
			break;
		case 2:
			alien_humanoid_head_hair_intensity = "Hell-";
			break;
		case 3:
			alien_humanoid_head_hair_intensity = "";
			break;
		case 4:
			alien_humanoid_head_hair_intensity = "Tief-";
			break;
		case 5:
			alien_humanoid_head_hair_intensity = "Dunkel-";
			break;
		case 6:
			alien_humanoid_head_hair_intensity = "Leuchtend-";
	}

	return alien_humanoid_head_hair_intensity;
}

function get_alien_humanoid_head_hair_color()
{
	var alien_humanoid_head_hair_color;
	var dice_size = 6;
	var dice_count = 1;
	var alien_humanoid_head_hair_color_roll = roll_dice(dice_size, dice_count);

	switch (alien_humanoid_head_hair_color_roll)
	{
		case 1:
			alien_humanoid_head_hair_color = "Blau";
			break;
		case 2:
			alien_humanoid_head_hair_color = "Braun";
			break;
		case 3:
			alien_humanoid_head_hair_color = "Grün";
			break;
		case 4:
			alien_humanoid_head_hair_color = "Grau";
			break;
		case 5:
			alien_humanoid_head_hair_color = "Rot";
			break;
		case 6:
			alien_humanoid_head_hair_color = "Gelb";
	}

	return alien_humanoid_head_hair_color;
}

function get_alien_humanoid_head_hair()
{
	var alien_humanoid_head_hair;
	var dice_size = 2;
	var dice_count = 1;
	var increase_contrast_roll = roll_dice(dice_size, dice_count);
	var increase_contrast;
	var alien_humanoid_head_hair_intensity = get_alien_humanoid_head_hair_intensity();
	var alien_humanoid_head_hair_color = get_alien_humanoid_head_hair_color();

	if (increase_contrast_roll == 1)
	{
		increase_contrast = true;
	}
	else
	{
		increase_contrast = false;
	}

	if (increase_contrast && alien_humanoid_head_hair_color == "Grau")
	{
		if (alien_humanoid_head_hair_intensity == "Blass-")
		{
			alien_humanoid_head_hair_intensity = "";
			alien_humanoid_head_hair_color = "Schneeweiß";
		}
		else if (alien_humanoid_head_hair_intensity == "Dunkel-")
		{
			alien_humanoid_head_hair_intensity = "";
			alien_humanoid_head_hair_color = "Pechschwarz";
		}
	}

	alien_humanoid_head_hair = alien_humanoid_head_hair_intensity + " " + alien_humanoid_head_hair_color;

	return alien_humanoid_head_hair;
}

function get_alien_humanoid_head_structure_count()
{
	var alien_humanoid_head_structure_count;
	dice_size = 3;
	dice_count = 1;
	var alien_humanoid_head_structure_roll = roll_dice(dice_size, dice_count);

	alien_humanoid_head_structure_count = alien_humanoid_head_structure_roll - 1;

	return alien_humanoid_head_structure_count;
}

function get_alien_humanoid_head_hair_exists()
{
	var alien_humanoid_head_hair_exists;
	var dice_size = 2;
	var dice_count = 1;
	var alien_humanoid_head_hair_roll = roll_dice(dice_size, dice_count);

	if(imperial_alien_id['subtype_animal'] == 1) // avian
	{
		imperial_alien_id['hair'] = 2; // feathers
		alien_humanoid_head_hair_exists = true;
	}
	else
	{
	
		switch (alien_humanoid_head_hair_roll)
		{
			case 1:
				if(imperial_alien_id['subtype_animal'] == 6) // reptilian
				{
					imperial_alien_id['hair'] = 3; // scales
					alien_humanoid_head_hair_exists = true;
				}
				else
				{
					imperial_alien_id['hair'] = 0; // hairless
					alien_humanoid_head_hair_exists = false;
				}
				break;
			case 2:
				if(imperial_alien_id['subtype_animal'] == 6) // reptilian
				{
					imperial_alien_id['hair'] = 4; // spines
					alien_humanoid_head_hair_exists = true;
				}
				else
				{
					imperial_alien_id['hair'] = 1; // hair
					alien_humanoid_head_hair_exists = true;
				}
				break;
		}
	}

	return alien_humanoid_head_hair_exists;
}

function get_alien_humanoid_head()
{
	var alien_humanoid_head;
	var alien_humanoid_head_hair;
	var alien_humanoid_head_structure;
	var alien_humanoid_head_structure_2;

	var alien_humanoid_head_hair_exists = get_alien_humanoid_head_hair_exists();
	var alien_humanoid_head_structure_count = get_alien_humanoid_head_structure_count();

	switch (imperial_alien_id['hair'])
	{
		case 0:
			alien_humanoid_head_hair = 'unbehaart';
			break;
		case 1:
			alien_humanoid_head_hair = get_alien_humanoid_head_hair();
			alien_humanoid_head_hair = alien_humanoid_head_hair + ' Haare';
			break;
		case 2:
			alien_humanoid_head_hair = get_alien_humanoid_head_hair();
			alien_humanoid_head_hair = alien_humanoid_head_hair + ' Federn';
			break;
		case 3:
			alien_humanoid_head_hair = get_alien_humanoid_head_hair();
			alien_humanoid_head_hair = alien_humanoid_head_hair + ' Schuppen';
			break;
		case 4:
			alien_humanoid_head_hair = get_alien_humanoid_head_hair();
			alien_humanoid_head_hair = alien_humanoid_head_hair + ' Knochenplatten';
			break;
	}

	if (alien_humanoid_head_structure_count)
	{
		alien_humanoid_head_structure = get_alien_humanoid_head_structure();

		imperial_alien_id['head_structure'][0] = alien_humanoid_head_structure['id'];
		alien_humanoid_head_structure = alien_humanoid_head_structure['text'] + ', ';
	}
	else
	{
		imperial_alien_id['head_structure'][0] = 0;
		alien_humanoid_head_structure = '';
	}
	
	if (alien_humanoid_head_structure_count == 2)
	{
		imperial_alien_id['head_structure'][1] = imperial_alien_id['head_structure'][0];

		while (imperial_alien_id['head_structure'][1] == imperial_alien_id['head_structure'][0])
		{
			alien_humanoid_head_structure_2 = get_alien_humanoid_head_structure();
			
			imperial_alien_id['head_structure'][1] = alien_humanoid_head_structure_2['id'];
		}

		alien_humanoid_head_structure += alien_humanoid_head_structure_2['text'] + ', ';
	}

	alien_humanoid_head = alien_humanoid_head_structure + alien_humanoid_head_hair;

	return alien_humanoid_head;
}

function get_alien_head(is_lifelike_humanoid)
{
	is_lifelike_humanoid = typeof is_lifelike_humanoid !== 'undefined' ? is_lifelike_humanoid : true;

	var alien_head = '';
	
	// set defaults
	imperial_alien_id['head_structure'] = [];
	imperial_alien_id['head_structure'][0] = 0;

	if (is_lifelike_humanoid)
	{
		alien_head = get_alien_humanoid_head();
	}

	return alien_head;
}

function get_alien_species(is_android)
{
	var alien_species;

	if (is_android)
	{
		alien_species = get_android_model();
	}
	else
	{
		alien_species = generate_alien_species();
	}

	return alien_species;
}

function get_alien_traits(is_android)
{
	is_android = typeof is_android !== 'undefined' ? is_android : false;

	var alien_traits = new Array();
	var alien_traits_list = new Array();
	var alien_traits_taken = new Array();
	var alien_traits_count = 0;
	var alien_traits_total = 0;
	var dice_size = 6;
	var dice_count = 1;
	var alien_traits_total_roll;
	var alien_traits_total_roll;
	var alien_trait_found; // -1 means not found

	// set defaults
	imperial_alien_id['traits'] = [];

	alien_traits_list[1] = '360° Sicht';
	alien_traits_list[2] = 'Luftwesen';
	alien_traits_list[3] = 'Wasserwesen';
	alien_traits_list[4] = 'Tarnung';
	alien_traits_list[5] = 'Haftend';
	alien_traits_list[6] = 'Datenverbindung';
	alien_traits_list[7] = 'Energieschild';
	alien_traits_list[8] = 'Faszinierend';
	alien_traits_list[9] = 'Eiswesen';
	alien_traits_list[10] = 'Zähflüssig';
	alien_traits_list[11] = 'Heilung';
	alien_traits_list[12] = 'Schwerweltler';
	alien_traits_list[13] = 'Hypersensitiv';
	alien_traits_list[14] = 'Gewaltig';
	alien_traits_list[15] = 'Unsterblich';
	alien_traits_list[16] = 'Immunität gegen Gifte';
	alien_traits_list[17] = 'Immunität gegen Ersticken';
	alien_traits_list[18] = 'Feuerwesen';
	alien_traits_list[19] = 'Lebensentzug';
	alien_traits_list[20] = 'Sprachgenie';
	alien_traits_list[21] = 'Rechengenie';
	alien_traits_list[22] = 'Geistesverbindung';
	alien_traits_list[23] = 'Geistesschild';
	alien_traits_list[24] = 'Multitasking';
	alien_traits_list[25] = 'Natürlich Gepanzert';
	alien_traits_list[26] = 'Natürliche Waffen';
	alien_traits_list[27] = 'Nachtsicht';
	alien_traits_list[28] = 'Perfekte Erinnerung';
	alien_traits_list[29] = 'Regeneration';
	alien_traits_list[30] = 'Selbstversorgend';
	alien_traits_list[31] = 'Gestaltwandler';
	alien_traits_list[32] = 'Stasis';
	alien_traits_list[33] = 'Erdwesen';
	alien_traits_list[34] = 'Telepathie';
	alien_traits_list[35] = 'Winzig';
	alien_traits_list[36] = 'Beunruhigend';

	if (is_android)
	{
		alien_traits_count = 2;
		alien_traits_total = 2;
		alien_traits[0] = 'Immunität gegen Gifte';
		imperial_alien_id['traits'][0] = 17;
		alien_traits[1] = 'Immunität gegen Ersticken';
		imperial_alien_id['traits'][1] = 18;
	}

	alien_traits_total_roll = roll_dice(dice_size, dice_count);

	switch (alien_traits_total_roll)
	{
		case 1:
			alien_traits_total += 1;
			break;
		case 6:
			alien_traits_total += 3;
			break;
		default:
			alien_traits_total += 2;
			break;
	}

	dice_size = 36;
	dice_count = 1;

	while (alien_traits_count < alien_traits_total)
	{
		alien_traits_roll = roll_dice(dice_size, dice_count);
		alien_trait_found = alien_traits.indexOf(alien_traits_list[alien_traits_roll]);

		if (alien_trait_found === -1)
		{
			alien_traits[alien_traits_count] = alien_traits_list[alien_traits_roll];
			imperial_alien_id['traits'][alien_traits_count] = alien_traits_roll;
			alien_traits_count++;
		}
	}

	imperial_alien_id['traits'].sort;
	alien_traits.sort();
	
	return alien_traits;
}

function get_imperial_catalog_id(imperial_alien_id)
{
	var imperial_catalog_id;
	
	imperial_alien_id['head_structure'].sort(function (a, b) {  return a - b;  });
	imperial_alien_id['traits'].sort(function (a, b) {  return a - b;  });

	imperial_catalog_id = imperial_alien_id['organic'] + '-';
	imperial_catalog_id += imperial_alien_id['subtype_artifical'] + '-';
	imperial_catalog_id += imperial_alien_id['type'] + '-';
	imperial_catalog_id += imperial_alien_id['subtype_animal'] + '-';
	imperial_catalog_id += imperial_alien_id['symmetry'] + '-{';
	imperial_catalog_id += imperial_alien_id['head_structure'].join('|');
	imperial_catalog_id += '}-';
	imperial_catalog_id += imperial_alien_id['eye_type'] + '-{';
	imperial_catalog_id += imperial_alien_id['traits'].join('|');
	imperial_catalog_id += '}';

	return imperial_catalog_id;
}

function is_obvious_android()
{
	var is_obvious_android = false;
	
	if (imperial_alien_id['organic'] == 0)
	{
		if (imperial_alien_id['subtype_artifical'] == 1)
		{
			is_obvious_android = true;
		}
	}

	return is_obvious_android;
}

function is_lifelike_humanoid()
{
	var is_lifelike_humanoid = true;

	// is obvious android OR is exotic alien
	if (is_obvious_android() || imperial_alien_id['type'] >= 10)
	{
		is_lifelike_humanoid = false;
	}
	
	return is_lifelike_humanoid;
}

function format_imperial_alien_id(imperial_alien_id)
{
	var formatted_imperial_alien_id;

	formatted_imperial_alien_id = "<pre>ISSCID: ";
	formatted_imperial_alien_id += get_imperial_catalog_id(imperial_alien_id);
	formatted_imperial_alien_id += "</pre>";
	
	return formatted_imperial_alien_id;
}

function format_alien_output(alien_output)
{
	var formatted_alien_output;

	formatted_alien_output = "<div class=\"sidebar_title\">Imperialer Katalog der Intelligenten Spezies</div>\n";
	formatted_alien_output += '<div class="sidebar_subtitle">';

	if (!imperial_alien_id['organic'])
	{
		formatted_alien_output += "<strong>Android:</strong> Model " + alien_output['species'];
	}
	else
	{
		formatted_alien_output += '<strong>Spezies:</strong> ' + alien_output['species'];
	}

	formatted_alien_output += "</div>\n";
	formatted_alien_output += '<div><strong>Typ:</strong> ' + alien_output['type'] + "</div>\n";

	if (is_lifelike_humanoid())
	{
		formatted_alien_output += '<div><strong>Kopf:</strong> ' + alien_output['head'] + "</div>\n";
	}
	
	if (is_lifelike_humanoid())
	{
		formatted_alien_output += '<div><strong>Haut:</strong> ' + alien_output['skin'] + "</div>\n";
	}
	else
	{
		formatted_alien_output += '<div><strong>Farbe:</strong> ' + alien_output['skin'] + "</div>\n";
	}

	formatted_alien_output += '<div><strong>Augen:</strong> ' + alien_output['eyes'] + "</div>\n";
	formatted_alien_output += '<div><strong>Eigenschaften:</strong>';
	formatted_alien_output += "<ul>\n";

	var alien_traits_count = alien_output['traits'].length;

	for (var i = 0; i < alien_traits_count; i++)
	{
		formatted_alien_output += '<li>' + alien_output['traits'][i] + "</li>\n";
	}

	formatted_alien_output += "</ul>\n";
	formatted_alien_output += "</div>\n";

	formatted_alien_output += format_imperial_alien_id(imperial_alien_id)

	return formatted_alien_output;
}

function generate_alien()
{
	var alien_output = new Array();
	alien_output['traits'] = new Array();

	alien_output['type'] = get_alien_type();
	alien_output['species'] = get_alien_species(!imperial_alien_id['organic']);
	alien_output['head'] = get_alien_head(is_lifelike_humanoid());
	alien_output['skin'] = get_alien_skin(is_obvious_android());
	alien_output['eyes'] = get_alien_eyes(is_lifelike_humanoid());
	alien_output['traits'] = get_alien_traits(!imperial_alien_id['organic']);

	document.getElementById("random_alien_output_DE").innerHTML = format_alien_output(alien_output);
}

//
// This code based on:
// Retro Alien Name Generator
// http://www.springhole.net/writing_roleplaying_randomators/retroaliennames.htm
//

var alien_vocab = new Array();
var intIncr
var intCat

intCat =0
intIncr=0

//The data stored is pretty simple.  It works like this:
//
// The alien_vocab array has sub arrays that are named lists of data.
//
//alien_vocab[intCat]= new Array(); - The alien_vocab Array actually holds other arrays.
//alien_vocab[intCat][0]="FIRST" - This is the name of the list of data in this sub array.  The name helps the program find the data.
//alien_vocab[intCat][1] = new Array() - Yep, ANOTHER array - this is the array that holds the actual data.
//alien_vocab[intCat][1][intIncr++]="First thing <SECOND>" // See that <SECOND> tag?  Anything in brackets references another list.
//alien_vocab[intCat][1][intIncr++]="First thing <THIRD>"
//
// Unless it's the last entry, don't forget to increment and reset the counters!
//
//intCat++
//intIncr=0


alien_vocab[intCat]= new Array();
alien_vocab[intCat][0]="FIRST"
alien_vocab[intCat][1] = new Array()
//alien_vocab[intCat][1][intIncr++]="<options>\n<options>\n<options>\n<options>\n<options>"
alien_vocab[intCat][1][intIncr++]="<options>"

intCat++
intIncr=0
alien_vocab[intCat]= new Array();
alien_vocab[intCat][0]="options"
alien_vocab[intCat][1] = new Array()
alien_vocab[intCat][1][intIncr++]="<firstconsonant><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstconsonant><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstconsonant><apos><vowel><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstconsonant><apos><vowel><apos><midletters><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstconsonant><apos><vowel><apos><midletters><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstconsonant><apos><vowel><apos><midletters><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstconsonant><apos><vowel><apos><midletters><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstconsonant><apos><vowel><apos><midletters><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstconsonant><apos><vowel><apos><midletters><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstvowel><apos><midletters><apos><vowel><apos><midletters><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstconsonant><apos><ending><space><firstconsonant><apos><vowel><apos><midletters><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstconsonant><apos><vowel><apos><midletters><apos><ending><space><firstconsonant><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstvowel><apos><ending><space><firstconsonant><apos><vowel><apos><midletters><apos><ending>"
alien_vocab[intCat][1][intIncr++]="<firstconsonant><apos><vowel><apos><midletters><apos><ending><space><firstvowel><apos><ending>"

intCat++
intIncr=0
alien_vocab[intCat]= new Array();
alien_vocab[intCat][0]="firstvowel"
alien_vocab[intCat][1] = new Array()
alien_vocab[intCat][1][intIncr++]="A"
alien_vocab[intCat][1][intIncr++]="E"
alien_vocab[intCat][1][intIncr++]="I"
alien_vocab[intCat][1][intIncr++]="I<apos>a"
alien_vocab[intCat][1][intIncr++]="O"
alien_vocab[intCat][1][intIncr++]="U"
alien_vocab[intCat][1][intIncr++]="U<apos>a"

intCat++
intIncr=0
alien_vocab[intCat]= new Array();
alien_vocab[intCat][0]="firstconsonant"
alien_vocab[intCat][1] = new Array()
alien_vocab[intCat][1][intIncr++]="B"
alien_vocab[intCat][1][intIncr++]="B<apos>l"
alien_vocab[intCat][1][intIncr++]="B<apos>r"
alien_vocab[intCat][1][intIncr++]="D"
alien_vocab[intCat][1][intIncr++]="D<apos>r"
alien_vocab[intCat][1][intIncr++]="Ch"
alien_vocab[intCat][1][intIncr++]="F"
alien_vocab[intCat][1][intIncr++]="F<apos>l"
alien_vocab[intCat][1][intIncr++]="F<apos>r"
alien_vocab[intCat][1][intIncr++]="G"
alien_vocab[intCat][1][intIncr++]="G<apos>l"
alien_vocab[intCat][1][intIncr++]="G<apos>r"
alien_vocab[intCat][1][intIncr++]="H"
alien_vocab[intCat][1][intIncr++]="J"
alien_vocab[intCat][1][intIncr++]="K"
alien_vocab[intCat][1][intIncr++]="K<apos>h"
alien_vocab[intCat][1][intIncr++]="K<apos>l"
alien_vocab[intCat][1][intIncr++]="K<apos>r"
alien_vocab[intCat][1][intIncr++]="L"
alien_vocab[intCat][1][intIncr++]="M"
alien_vocab[intCat][1][intIncr++]="N"
alien_vocab[intCat][1][intIncr++]="P"
alien_vocab[intCat][1][intIncr++]="P<apos>l"
alien_vocab[intCat][1][intIncr++]="P<apos>r"
alien_vocab[intCat][1][intIncr++]="R"
alien_vocab[intCat][1][intIncr++]="S"
alien_vocab[intCat][1][intIncr++]="Sh"
alien_vocab[intCat][1][intIncr++]="S<apos>l"
alien_vocab[intCat][1][intIncr++]="S<apos>m"
alien_vocab[intCat][1][intIncr++]="S<apos>n"
alien_vocab[intCat][1][intIncr++]="S<apos>t"
alien_vocab[intCat][1][intIncr++]="T"
alien_vocab[intCat][1][intIncr++]="Th"
alien_vocab[intCat][1][intIncr++]="Th<apos>r"
alien_vocab[intCat][1][intIncr++]="T<apos>r"
alien_vocab[intCat][1][intIncr++]="V"
alien_vocab[intCat][1][intIncr++]="W"
alien_vocab[intCat][1][intIncr++]="X"
alien_vocab[intCat][1][intIncr++]="Y"
alien_vocab[intCat][1][intIncr++]="Z"

intCat++
intIncr=0
alien_vocab[intCat]= new Array();
alien_vocab[intCat][0]="vowel"
alien_vocab[intCat][1] = new Array()
alien_vocab[intCat][1][intIncr++]="a"
alien_vocab[intCat][1][intIncr++]="a<apos>a"
alien_vocab[intCat][1][intIncr++]="e"
alien_vocab[intCat][1][intIncr++]="e<apos>e"
alien_vocab[intCat][1][intIncr++]="i"
alien_vocab[intCat][1][intIncr++]="o"
alien_vocab[intCat][1][intIncr++]="o<apos>o"
alien_vocab[intCat][1][intIncr++]="u"
alien_vocab[intCat][1][intIncr++]="u<apos>u"

intCat++
intIncr=0
alien_vocab[intCat]= new Array();
alien_vocab[intCat][0]="midletters"
alien_vocab[intCat][1] = new Array()
alien_vocab[intCat][1][intIncr++]="b"
alien_vocab[intCat][1][intIncr++]="b<apos>l"
alien_vocab[intCat][1][intIncr++]="b<apos>r"
alien_vocab[intCat][1][intIncr++]="ch"
alien_vocab[intCat][1][intIncr++]="d"
alien_vocab[intCat][1][intIncr++]="d<apos>r"
alien_vocab[intCat][1][intIncr++]="f"
alien_vocab[intCat][1][intIncr++]="fr"
alien_vocab[intCat][1][intIncr++]="fl"
alien_vocab[intCat][1][intIncr++]="g"
alien_vocab[intCat][1][intIncr++]="g<apos>l"
alien_vocab[intCat][1][intIncr++]="g<apos>r"
alien_vocab[intCat][1][intIncr++]="h"
alien_vocab[intCat][1][intIncr++]="j"
alien_vocab[intCat][1][intIncr++]="k"
alien_vocab[intCat][1][intIncr++]="k<apos>l"
alien_vocab[intCat][1][intIncr++]="k<apos>s"
alien_vocab[intCat][1][intIncr++]="k<apos>r"
alien_vocab[intCat][1][intIncr++]="k<apos>t"
alien_vocab[intCat][1][intIncr++]="l"
alien_vocab[intCat][1][intIncr++]="l<apos>b"
alien_vocab[intCat][1][intIncr++]="l<apos>d"
alien_vocab[intCat][1][intIncr++]="l<apos>k"
alien_vocab[intCat][1][intIncr++]="l<apos>l"
alien_vocab[intCat][1][intIncr++]="l<apos>m"
alien_vocab[intCat][1][intIncr++]="l<apos>r"
alien_vocab[intCat][1][intIncr++]="l<apos>s"
alien_vocab[intCat][1][intIncr++]="l<apos>t"
alien_vocab[intCat][1][intIncr++]="m"
alien_vocab[intCat][1][intIncr++]="n"
alien_vocab[intCat][1][intIncr++]="n<apos>d"
alien_vocab[intCat][1][intIncr++]="n<apos>t"
alien_vocab[intCat][1][intIncr++]="p"
alien_vocab[intCat][1][intIncr++]="p<apos>k"
alien_vocab[intCat][1][intIncr++]="p<apos>l"
alien_vocab[intCat][1][intIncr++]="p<apos>r"
alien_vocab[intCat][1][intIncr++]="r"
alien_vocab[intCat][1][intIncr++]="r<apos>d"
alien_vocab[intCat][1][intIncr++]="r<apos>j"
alien_vocab[intCat][1][intIncr++]="r<apos>k"
alien_vocab[intCat][1][intIncr++]="r<apos>l"
alien_vocab[intCat][1][intIncr++]="r<apos>r"
alien_vocab[intCat][1][intIncr++]="r<apos>s"
alien_vocab[intCat][1][intIncr++]="r<apos>t"
alien_vocab[intCat][1][intIncr++]="s"
alien_vocab[intCat][1][intIncr++]="sh"
alien_vocab[intCat][1][intIncr++]="s<apos>l"
alien_vocab[intCat][1][intIncr++]="s<apos>n"
alien_vocab[intCat][1][intIncr++]="s<apos>m"
alien_vocab[intCat][1][intIncr++]="s<apos>t"
alien_vocab[intCat][1][intIncr++]="t"
alien_vocab[intCat][1][intIncr++]="th"
alien_vocab[intCat][1][intIncr++]="th<apos>r"
alien_vocab[intCat][1][intIncr++]="t<apos>r"
alien_vocab[intCat][1][intIncr++]="v"
alien_vocab[intCat][1][intIncr++]="x"
alien_vocab[intCat][1][intIncr++]="x<apos>x"
alien_vocab[intCat][1][intIncr++]="y"
alien_vocab[intCat][1][intIncr++]="z"
alien_vocab[intCat][1][intIncr++]="z<apos>g"
alien_vocab[intCat][1][intIncr++]="z<apos>l"
alien_vocab[intCat][1][intIncr++]="z<apos>n"
alien_vocab[intCat][1][intIncr++]="z<apos>m"
alien_vocab[intCat][1][intIncr++]="z<apos>t"
alien_vocab[intCat][1][intIncr++]="z<apos>z"

intCat++
intIncr=0
alien_vocab[intCat]= new Array();
alien_vocab[intCat][0]="ending"
alien_vocab[intCat][1] = new Array()
alien_vocab[intCat][1][intIncr++]="a"
alien_vocab[intCat][1][intIncr++]="ak"
alien_vocab[intCat][1][intIncr++]="ar"
alien_vocab[intCat][1][intIncr++]="ax"
alien_vocab[intCat][1][intIncr++]="an"
alien_vocab[intCat][1][intIncr++]="e<apos>a"
alien_vocab[intCat][1][intIncr++]="e<apos>e"
alien_vocab[intCat][1][intIncr++]="ek"
alien_vocab[intCat][1][intIncr++]="i<apos>a"
alien_vocab[intCat][1][intIncr++]="ik"
alien_vocab[intCat][1][intIncr++]="in"
alien_vocab[intCat][1][intIncr++]="is"
alien_vocab[intCat][1][intIncr++]="ix"
alien_vocab[intCat][1][intIncr++]="ok"
alien_vocab[intCat][1][intIncr++]="on"
alien_vocab[intCat][1][intIncr++]="o<apos>o"
alien_vocab[intCat][1][intIncr++]="os"
alien_vocab[intCat][1][intIncr++]="ox"
alien_vocab[intCat][1][intIncr++]="oz"

intCat++
intIncr=0
alien_vocab[intCat]= new Array();
alien_vocab[intCat][0]="apos"
alien_vocab[intCat][1] = new Array()
alien_vocab[intCat][1][intIncr++]="'"
alien_vocab[intCat][1][intIncr++]=""
alien_vocab[intCat][1][intIncr++]=""
alien_vocab[intCat][1][intIncr++]=""
alien_vocab[intCat][1][intIncr++]=""
alien_vocab[intCat][1][intIncr++]=""


intCat++
intIncr=0
alien_vocab[intCat]= new Array();
alien_vocab[intCat][0]="space"
alien_vocab[intCat][1] = new Array()
alien_vocab[intCat][1][intIncr++]=" "
alien_vocab[intCat][1][intIncr++]=" "
alien_vocab[intCat][1][intIncr++]=" "
alien_vocab[intCat][1][intIncr++]="-"


// Leave to Copy!
intCat++
intIncr=0
alien_vocab[intCat]= new Array();
alien_vocab[intCat][0]=""
alien_vocab[intCat][1] = new Array()
alien_vocab[intCat][1][intIncr++]=""

function generate_alien_species_GenNumber(nRange)
{
	var iNumGen
	iNumGen = Math.round((Math.random() * nRange));

	return iNumGen;
}

function generate_alien_species_GetFrom(aArray)
{
	var undefined
	var sReturn
	sReturn = aArray[generate_alien_species_GenNumber(aArray.length)];
	if (sReturn == undefined)
	{
		sReturn = generate_alien_species_GetFrom(aArray)
	}
	return sReturn
}

function generate_alien_species_GetArray(sArrayName)
{
	for (var intLooper=0;intLooper <alien_vocab.length;intLooper++)
	{
		if (alien_vocab[intLooper][0]==sArrayName)
		{
			return alien_vocab[intLooper][1];
			break;
		}
	}
}

function generate_alien_species_ScanLine(sLine)
{
	var iTagStart, iTagEnd
	var sKey

	if (sLine.indexOf("<") > -1)
	{
		iTagStart = sLine.indexOf("<");
		iTagEnd = sLine.indexOf(">");
		
		sKey = sLine.substr(iTagStart+1, iTagEnd-(iTagStart+1));

		sKey = generate_alien_species_GetFrom(generate_alien_species_GetArray(sKey))
		sLine = sLine.substr(0, iTagStart) + sKey + sLine.substr(iTagEnd+1, (sLine.length - iTagEnd))

	}
	

	if (sLine.indexOf("<") > - 1)
	{
		sLine = generate_alien_species_ScanLine(sLine)
	}

	return sLine;
}

function generate_alien_species()
{
	sLine = generate_alien_species_GetFrom(generate_alien_species_GetArray("FIRST"));

	sLine = generate_alien_species_ScanLine(sLine)

	return sLine;
}

//
// Inserts the HTML into the page
//

$(function () {
	var random_alien_button_DE = document.getElementById('random_alien_button_DE');

	if (random_alien_button_DE != null)
	{
		var formatted_alien_output;
		
		formatted_alien_output = "<div class=\"sidebar_title\">Imperialer Katalog der Intelligenten Spezies</div>\n";
		formatted_alien_output += '<div class="sidebar_subtitle">';
		formatted_alien_output += 'Benutze den Knopf um dir einen Zufälligen eintrag im Imperialen Katalog der Intelligenten Spezies, der umfssensten Datenbank im Universum in dieser hinsicht, anzeigen zu lassen.';
		formatted_alien_output += '</div>';
		
		random_alien_button_DE.innerHTML = '<input type="button" value="Suche Spezies..." onclick="generate_alien();" />';
		random_alien_output_DE.innerHTML = formatted_alien_output;
	}
}());