// JavaScript Document
var weaponNumber = 0;

function addNew()
{
	var weaponLine = "<select size='1' name='weaponSelect' id='weaponSelectId" + weaponNumber;
	weaponLine = weaponLine + "' onChange='selectWeapon(" + weaponNumber + ");'><option selected>------SWDS-----</option>";	
	weaponLine = weaponLine + "<option>Silmarite Longsword</option><option>Silmarite Armingsword</option><option>Ardamian Bastardsword</option>";
	weaponLine = weaponLine + "<option>Ardamian Greatsword</option><option>Imperial Shamshir </option><option>Imperial Kilij</option>";
	weaponLine = weaponLine + "<option>Imperial Khopesh</option><option>Elven Longsword</option><option>Elven Leftsword</option><option>Dwarven Battlesword (Dwarven Shortsword)</option>";
	weaponLine = weaponLine + "<option>Aumethor Katana</option><option>Aumethor Sevenringed Broadsword</option><option>Aumethor Nomadgutter (Wakazashi)</option>";
	weaponLine = weaponLine + "<option>------AXES-----</option><option>Hand Axe</option><option>War Axe</option><option>Great Axe</option>";
	weaponLine = weaponLine + "<option>Halberd</option><option>Troll Mattock</option><option>------CLBS-----</option><option>Wooden Club</option>";
	weaponLine = weaponLine + "<option>Morning Star</option><option>Holy Water Sprinkler</option><option>Quarter Staff</option><option>War Maul</option>";
	weaponLine = weaponLine + "<option>Troll Maul</option><option>Greathammer</option><option>Warhammer</option><option>Ball &amp; Chain</option>";
	weaponLine = weaponLine + "<option>------SPRS----</option><option>Longspear</option><option>Shortspear</option><option>Aumethor Nomadspear</option><option>Knight's Lance</option>";
	weaponLine = weaponLine + "<option>Phalanx Pike</option><option>------DGRS-----</option><option>Silmarite Leftguard Dagger</option><option>Imperial Throwing Knife</option>";
	weaponLine = weaponLine + "<option>Knife</option><option>Dagger</option><option>Throwing Knife</option><option>Aumethor Tanto</option><option>Elven Moongleam</option>";
	weaponLine = weaponLine + "<option>------SHLD-----</option><option>Ardamian Round Shield</option><option>Silmarite Shield</option><option>Imperial Target Shield</option>";
	weaponLine = weaponLine + "<option>Imperial Legion Shield</option><option>Aumethor Hide Shield</option><option>Duellist's Buckler</option><option>------BOWS-----</option>";
	weaponLine = weaponLine + "<option>Shortbow - Hunting Arrow</option><option>Shortbow - War Arrow</option><option>Shortbow - Fire Arrow</option>";
	weaponLine = weaponLine + "<option>Longbow - Hunting Arrow</option><option>Longbow - War Arrow</option><option>Longbow - Fire Arrow</option><option>Elven Bow - Elven Arrow</option>";
	weaponLine = weaponLine + "<option>Imperial Bow - War Arrow</option><option>Bow of Bin-Erek - War Arrow</option><option>Hand Crossbow - Quarrel</option>";
	weaponLine = weaponLine + "<option>Light Crossbow - Quarrel</option><option>Medium Crossbow - Quarrel</option><option>Heavy Crossbow - Quarrel</option>";
	weaponLine = weaponLine + "<option>Crossbow of the Hidden - Quarrel</option><option>-----MISC------</option><option>Whip</option><option>Sling</option><option>Garotte</option>";
	weaponLine = weaponLine + "</select>";

	if(navigator.appName != "Microsoft Internet Explorer")
	{
		var parentNode = document.createElement('tr');
		parentNode.id = "dynamic" + weaponNumber;
	
		var childNodeOptions = document.createElement('td');
		childNodeOptions.id = "weasel" + weaponNumber;
				
		childNodeOptions.innerHTML = weaponLine;
		parentNode.appendChild(childNodeOptions);
		
		var childNodeCategory = document.createElement('td');
		childNodeCategory.id = "weacat" + weaponNumber;
		parentNode.appendChild(childNodeCategory);
		
		var childNodeDamage = document.createElement('td');
		childNodeDamage.id = "weadam" + weaponNumber;
		parentNode.appendChild(childNodeDamage);
		
		var childNodeSpeed = document.createElement('td');
		childNodeSpeed.id = "weaspe" + weaponNumber;
		parentNode.appendChild(childNodeSpeed);
	
		var childNodeReach = document.createElement('td');
		childNodeReach.id = "wearea" + weaponNumber;
		parentNode.appendChild(childNodeReach);
		
		var childNodeQuality = document.createElement('td');
		childNodeQuality.id = "weaqua" + weaponNumber;
		parentNode.appendChild(childNodeQuality);		
		
		var childNodeEncumbrance = document.createElement('td');
		childNodeEncumbrance.id = "weaenc" + weaponNumber;
		parentNode.appendChild(childNodeEncumbrance);
	
		var childNodeRequirements = document.createElement('td');
		childNodeRequirements.id = "weareq" + weaponNumber;
		parentNode.appendChild(childNodeRequirements);
		
		var childNodeCostprice = document.createElement('td');
		childNodeCostprice.id = "weaprc" + weaponNumber;
		parentNode.appendChild(childNodeCostprice);	
		
		var childNodeNotes = document.createElement('td');
		childNodeNotes.id = "weanot" + weaponNumber;
		parentNode.appendChild(childNodeNotes);
			
		//Add the parent node to the table!!
		document.getElementById('weaponTableId').appendChild(parentNode);
	}
	else
	{
		var objSource = document.getElementById('weaponTableId');
		var parentNode, currentTD;//, currentSelect, temp;
		parentNode = objSource.insertRow();
		parentNode.id = "dynamic" + weaponNumber;
		
		currentTD = parentNode.insertCell();
		currentTD.id = "weasel" + weaponNumber;
		currentTD.innerHTML = weaponLine;
		
		currentTD = parentNode.insertCell();
		currentTD.id = "weacat" + weaponNumber;
		
		currentTD = parentNode.insertCell();
		currentTD.id = "weadam" + weaponNumber;
		
		currentTD = parentNode.insertCell();
		currentTD.id = "weaspe" + weaponNumber;
		
		currentTD = parentNode.insertCell();
		currentTD.id = "wearea" + weaponNumber;
		
		currentTD = parentNode.insertCell();
		currentTD.id = "weaqua" + weaponNumber;
		
		currentTD = parentNode.insertCell();
		currentTD.id = "weaenc" + weaponNumber;
						
		currentTD = parentNode.insertCell();
		currentTD.id = "weareq" + weaponNumber;
		
		currentTD = parentNode.insertCell();				
		currentTD.id = "weaprc" + weaponNumber;
						
		currentTD = parentNode.insertCell();
		currentTD.id = "weanot" + weaponNumber;
		
	}
	
	//ready for a new parent (new weapon in the weapons table)
	weaponNumber += 1;
	
	return(1);
}

function selectWeapon(number)
{
	var weaCategory;
	var weaDamage;
	var weaSpeed;
	var weaReach;
	var weaQuality;
	var weaEncumbrance;
	var weaRequirements;
	var weaCostprice;
	var weaNotes;
	
	var Sword1 = "1H Sword";
	var Sword2 = "2H Sword";
	var Spear1 = "1H Spear";
	var Spear2 = "2H Spear";
	var Axe1 = "1H Axe";
	var Axe2 = "2H Axe";
	var Club1 = "1H Club";
	var Club2 = "2H Club";
	var Knife = "1H Knife";
	var Chain1 = "1H Chain";
	var Chain2 = "2H Chain";
	var Hammer1 = "1H Hammer";
	var Hammer2 = "2H Hammer";
	var Shield = "1H Shield";
	var Bow = "Bow";
	var XBow = "Crossbow";
	var Other = "Other";
	
	var D4 = "1D4";
	var D6 = "1D6";
	var D8 = "1D8";
	var D10 = "1D10";
	var D12 = "1D12";
	var D20 = "1D20";
	var D100 = "1D100";

	var index = document.getElementById('weaponSelectId' + number).selectedIndex;
	switch(parseInt(index))
	{
	/*
	weaCategory;
	weaDamage;
	weaSpeed;
	weaReach;
	weaQuality;
	weaEncumbrance;
	weaRequirements;
	weaCostprice;
	weaNotes;	
	*/
		case 0://  <option>------SWDS-----</option>
			weaCategory = "";
			weaDamage = "";
			weaSpeed = "";
			weaReach = "";
			weaQuality = "";
			weaEncumbrance = "";
			weaRequirements = "";
			weaCostprice = "";
			weaNotes = "";
			break;
		case 1://  <option selected>Silmarite Longsword</option>
			weaCategory = Sword1;
			weaDamage = D10;
			weaSpeed = "2";
			weaReach = "1.5 m";
			weaQuality = "10";
			weaEncumbrance = "1.5";
			weaRequirements = "55 str";
			weaCostprice = "2 gold";
			weaNotes = "";			
			break;
		case 2: // <option>Silmarite Armingsword</option>
			weaCategory = Sword1;
			weaDamage = D8 + "+1";
			weaSpeed = "2";
			weaReach = "1.3 m";
			weaQuality = "10";
			weaEncumbrance = "1.5";
			weaRequirements = "45 str";
			weaCostprice = "15 silver";
			weaNotes = "";					
			break;
		case 3://  <option>Ardamian Bastardsword</option>
			weaCategory = "1H or 2H Sword";
			weaDamage = D10 + "+1";
			weaSpeed = "2";
			weaReach = "1.8 m";
			weaQuality = "12";
			weaEncumbrance = "2.0";
			weaRequirements = "65/45 str";
			weaCostprice = "23 silver";
			weaNotes = "";			
			break;
		case 4:// <option>Ardamian Greatsword</option>
			weaCategory = Sword2;
			weaDamage = "2D8";
			weaSpeed = "1";
			weaReach = "2 m";
			weaQuality = "12";
			weaEncumbrance = "4.0";
			weaRequirements = "55 str";
			weaCostprice = "4 gold";
			weaNotes = "";					
			break;
		case 5: //  <option>Imperial Shamshir </option>
			weaCategory = Sword1;
			weaDamage = D6 + "+2";
			weaSpeed = "2";
			weaReach = "1.0 m";
			weaQuality = "10";
			weaEncumbrance = "1.5";
			weaRequirements = "35 str";
			weaCostprice = "15 silver";
			weaNotes = "";					
			break;
		case 6: //  <option>Imperial Kilij</option>
			weaCategory = Sword1;
			weaDamage = D6 + "+3";
			weaSpeed = "2";
			weaReach = "1.0 m";
			weaQuality = "10";
			weaEncumbrance = "1.5";
			weaRequirements = "45 str";
			weaCostprice = "15 silver";
			weaNotes = "";					
			break;
		case 7: //  <option>Imperial Khopesh</option>
			weaCategory = Sword1;
			weaDamage = "2D6+2";
			weaSpeed = "1";
			weaReach = "1.6 m";
			weaQuality = "14";
			weaEncumbrance = "5.0";
			weaRequirements = "45 str";
			weaCostprice = "4 gold";
			weaNotes = "";					
			break;
		case 8://  <option>Elven Longsword</option>
			weaCategory = Sword1;
			weaDamage = D10 + "+1";
			weaSpeed = "2";
			weaReach = "1.6 m";
			weaQuality = "10";
			weaEncumbrance = "1.5";
			weaRequirements = "60 str";
			weaCostprice = "10 gold";
			weaNotes = "+1 critical / +5 special";					
			break;
		case 9: //  <option>Elven Leftsword</option>
			weaCategory = Sword1;
			weaDamage = D6 + "+1";
			weaSpeed = "2";
			weaReach = "1.0 m";
			weaQuality = "10";
			weaEncumbrance = "1.0";
			weaRequirements = "40 str";
			weaCostprice = "8 gold";
			weaNotes = "+5 special. Piercing.";					
			break;
		case 10: // <option>Dwarven Battlesword (Dwarven Shortsword)</option>
			weaCategory = Sword1 + " or " + Sword2 + "(Dwarves)";
			weaDamage = D8+ "+1";
			weaSpeed = "2";
			weaReach = "1.2 m";
			weaQuality = "14";
			weaEncumbrance = "1.5";
			weaRequirements = "50 str";
			weaCostprice = "4 gold";
			weaNotes = "Piercing";		
			break;
		case 11: // <option>Aumethor Katana</option>
			weaCategory = Sword1;
			weaDamage = D12;
			weaSpeed = "2";
			weaReach = "0.9 m";
			weaQuality = "12";
			weaEncumbrance = "1.0";
			weaRequirements = "35 str / 45 agi";
			weaCostprice = "3 gold";
			weaNotes = "";		
			break;
		case 12: // <option>Aumethor Sevenringed Broadsword</option>
			weaCategory = Sword1;
			weaDamage = D8 + "+1";
			weaSpeed = "2";
			weaReach = "1.2 m";
			weaQuality = "10";
			weaEncumbrance = "1.5";
			weaRequirements = "45 str";
			weaCostprice = "2 gold";
			weaNotes = "+5 parry (pommel cloth and rings)";		
			break;
		case 13: // <option>Aumethor Nomadgutter (Wakazashi)</option>
			weaCategory = Sword1;
			weaDamage = D8;
			weaSpeed = "2";
			weaReach = "0.6 m";
			weaQuality = "10";
			weaEncumbrance = "0.5";
			weaRequirements = "30 str";
			weaCostprice = "1 gold";
			weaNotes = "Piercing";		
			break;
		case 14:
			weaCategory = "";
			weaDamage = "";
			weaSpeed = "";
			weaReach = "";
			weaQuality = "";
			weaEncumbrance = "";
			weaRequirements = "";
			weaCostprice = "";
			weaNotes = "";
			break;			
		case 15: // <option>Hand Axe</option>
			weaCategory = Axe1;
			weaDamage = D6 + "+1";
			weaSpeed = "2";
			weaReach = "0.5 m";
			weaQuality = "6";
			weaEncumbrance = "0.5";
			weaRequirements = "";
			weaCostprice = "3 silver";
			weaNotes = "";		
			break;
		case 16: // <option>War Axe</option>
			weaCategory = Axe1;
			weaDamage = D8 + "+2";
			weaSpeed = "2";
			weaReach = "1.0 m";
			weaQuality = "8";
			weaEncumbrance = "1.0";
			weaRequirements = "55 str";
			weaCostprice = "1 gold";
			weaNotes = "";			
			break;
		case 17: // <option>Great Axe</option>
			weaCategory = Axe2;
			weaDamage = "2D6+2";
			weaSpeed = "1";
			weaReach = "1.8 m";
			weaQuality = "2";
			weaEncumbrance = "2.0";
			weaRequirements = "55 str";
			weaCostprice = "3 gold";
			weaNotes = "";		
			break;
		case 18: // <option>Halberd</option>
			weaCategory = Axe2;
			weaDamage = "3D6";
			weaSpeed = "1";
			weaReach = "3.0 m";
			weaQuality = "10";
			weaEncumbrance = "3.0";
			weaRequirements = "65 str";
			weaCostprice = "4 gold";
			weaNotes = "Piercing when set vs. charge";		
			break;
		case 19: // <option>Troll Mattock</option>
			weaCategory = Axe2;
			weaDamage = "2D6+4";
			weaSpeed = "1";
			weaReach = "3.0 m";
			weaQuality = "12";
			weaEncumbrance = "8.0";
			weaRequirements = "90 str";
			weaCostprice = "5 silver";
			weaNotes = "";		
			break;
		case 20: // <option>------CLBS-----</option>
			weaCategory = "";
			weaDamage = "";
			weaSpeed = "";
			weaReach = "";
			weaQuality = "";
			weaEncumbrance = "";
			weaRequirements = "";
			weaCostprice = "";
			weaNotes = "";
			break;
		case 21: // <option>Wooden Club</option>
			weaCategory = Club1;
			weaDamage = D6;
			weaSpeed = "2";
			weaReach = "0.5 m";
			weaQuality = "4";
			weaEncumbrance = "0.5";
			weaRequirements = "";
			weaCostprice = "";
			weaNotes = "";		
			break;
		case 22: // <option>Morning Star</option>
			weaCategory = Club1;
			weaDamage = D10;
			weaSpeed = "2";
			weaReach = "1.3";
			weaQuality = "10";
			weaEncumbrance = "2.5";
			weaRequirements = "65 str";
			weaCostprice = "22 sp";
			weaNotes = "";		
			break;
		case 23: // <option>Holy Water Sprinkler</option>
			weaCategory = Club1;
			weaDamage = D10;
			weaSpeed = "2";
			weaReach = "1.3";
			weaQuality = "10";
			weaEncumbrance = "2.5";
			weaRequirements = "65 str";
			weaCostprice = "32 sp";
			weaNotes = "Piercing";		
			break;
		case 24: // <option>Quarter Staff</option>
			weaCategory = Club2;
			weaDamage = D8;
			weaSpeed = "1";
			weaReach = "2.0 m";
			weaQuality = "8";
			weaEncumbrance = "1.5";
			weaRequirements = "";
			weaCostprice = "5 copper";
			weaNotes = "";		
			break;
		case 25: // <option>War Maul</option>
			weaCategory = Club1;
			weaDamage = "1D10+2";
			weaSpeed = "2";
			weaReach = "1.6";
			weaQuality = "10";
			weaEncumbrance = "2.5";
			weaRequirements = "70 str";
			weaCostprice = "2 gold";
			weaNotes = "";		
			break;
		case 26: // <option>Troll Maul</option>
			weaCategory = Club2;
			weaDamage = "2D8";
			weaSpeed = "1";
			weaReach = "3.0 m";
			weaQuality = "12";
			weaEncumbrance = "6.0";
			weaRequirements = "85 str";
			weaCostprice = "1 gold";
			weaNotes = "";
			break;
		case 27: // <option>Greathammer</option>
			weaCategory = Club2;
			weaDamage = "2D6+2";
			weaSpeed = "1";
			weaReach = "1.8 m";
			weaQuality = "10";
			weaEncumbrance = "2.5";
			weaRequirements = "55 str";
			weaCostprice = "2 gold";
			weaNotes = "";		
			break;
		case 28: // <option>Warhammer</option>
			weaCategory = Club1;
			weaDamage = "1D8+1";
			weaSpeed = "2";
			weaReach = "1.0 m";
			weaQuality = "10";
			weaEncumbrance = "1.0";
			weaRequirements = "45 str";
			weaCostprice = "1 gold";
			weaNotes = "";		
			break;
		case 29: // <option>Ball &amp; Chain</option>
			weaCategory = Chain1;
			weaDamage = "1D10+1";
			weaSpeed = "1";
			weaReach = "2.0 m";
			weaQuality = "8";
			weaEncumbrance = "2.0";
			weaRequirements = "50 str / 50 agi";
			weaCostprice = "25 silver";
			weaNotes = "Fumble range +2";		
			break;
		case 30: // <option>------SPRS----</option>
			weaCategory = "";
			weaDamage = "";
			weaSpeed = "";
			weaReach = "";
			weaQuality = "";
			weaEncumbrance = "";
			weaRequirements = "";
			weaCostprice = "";
			weaNotes = "";
			break;
		case 31: // <option>Longspear</option>
			weaCategory = Spear2;
			weaDamage = "1D10+1";
			weaSpeed = "1";
			weaReach = "2.0 m";
			weaQuality = "10";
			weaEncumbrance = "2.0";
			weaRequirements = "45 str";
			weaCostprice = "3 silver";
			weaNotes = "Piercing. Can be set to receive charge.";		
			break;
		case 32: // <option>Shortspear</option>
			weaCategory = Spear1;
			weaDamage = "1D8+1";
			weaSpeed = "2";
			weaReach = "1.6 m";
			weaQuality = "8";
			weaEncumbrance = "1.5";
			weaRequirements = "35 str";
			weaCostprice = "2 silver";
			weaNotes = "Piercing. Can be thrown.";		
			break;
		case 33: // <option>Aumethor Nomadspear</option>
			weaCategory = Spear1;
			weaDamage = "1D10";
			weaSpeed = "1";
			weaReach = "2.0 m";
			weaQuality = "10";
			weaEncumbrance = "3.0";
			weaRequirements = "65 str";
			weaCostprice = "15 silver";
			weaNotes = "Piercing. Used as lance.";		
			break;
		case 34: // <option>Knight's Lance</option>
			weaCategory = Spear1;
			weaDamage = "1D10+1";
			weaSpeed = "0";
			weaReach = "3.0 m";
			weaQuality = "10";
			weaEncumbrance = "3.5";
			weaRequirements = "35 str / 35 agi";
			weaCostprice = "4 gold";
			weaNotes = "Piercing. Used as a lance. Horse's damage bonus";		
			break;
		case 35: // <option>Phalanx Pike</option>
			weaCategory = Spear2;
			weaDamage = "2T6+2";
			weaSpeed = "0";
			weaReach = "4.0 m";
			weaQuality = "12";
			weaEncumbrance = "4.0";
			weaRequirements = "55 str";
			weaCostprice = "15 silver";
			weaNotes = "Piercing. Can be set to receive charge.";		
			break;
		case 36:// <option>------DGRS-----</option>
			weaCategory = "";
			weaDamage = "";
			weaSpeed = "";
			weaReach = "";
			weaQuality = "";
			weaEncumbrance = "";
			weaRequirements = "";
			weaCostprice = "";
			weaNotes = "";
			break;
		case 37: // <option>Silmarite Leftguard Dagger</option>
			weaCategory = Knife;
			weaDamage = "1D4+2";
			weaSpeed = "3";
			weaReach = "0.3 m";
			weaQuality = "10";
			weaEncumbrance = "0.5";
			weaRequirements = "35 agi";
			weaCostprice = "8 silver";
			weaNotes = "Piercing. Blade Breaker (str vs (qua*5)).";		
			break;
		case 38: // <option>Imperial Throwing Knife</option>
			weaCategory = Other;
			weaDamage = "1D6";
			weaSpeed = "1 / AGI SR";
			weaReach = "Thrown";
			weaQuality = "";
			weaEncumbrance = "0.3";
			weaRequirements = "50 agi";
			weaCostprice = "5 silver";
			weaNotes = "Piercing";		
			break;
		case 39: // <option>Knife</option>
			weaCategory = Knife;
			weaDamage = "1D3+1";
			weaSpeed = "3";
			weaReach = "0.2 m";
			weaQuality = "6";
			weaEncumbrance = "0.2";
			weaRequirements = "";
			weaCostprice = "1 silver";
			weaNotes = "Piercing";		
			break;
		case 40:// <option>Dagger</option>
			weaCategory = Knife;
			weaDamage = "1D4+2";
			weaSpeed = "3";
			weaReach = "0.3 m";
			weaQuality = "10";
			weaEncumbrance = "0.5";
			weaRequirements = "35 agi";
			weaCostprice = "5 silver";
			weaNotes = "Piercing";		
			break;
		case 41: // <option>Throwing Knife</option>
			weaCategory = Other;
			weaDamage = "1D4";
			weaSpeed = "1 / AGI SR";
			weaReach = "Thrown";
			weaQuality = "";
			weaEncumbrance = "0.3";
			weaRequirements = "50 agi";
			weaCostprice = "3 silver";
			weaNotes = "Piercing";		
			break;
		case 42: // <option>Aumethor Tanto</option>			
			weaCategory = Knife;
			weaDamage = "1D4+2";
			weaSpeed = "3";
			weaReach = "0.3 m";
			weaQuality = "8";
			weaEncumbrance = "0.5";
			weaRequirements = "35 agi";
			weaCostprice = "5 silver";
			weaNotes = "Piercing";
			break;
		case 43: // <option>Elven Moongleam</option>
			weaCategory = Knife;
			weaDamage = "1D4+2";
			weaSpeed = "3";
			weaReach = "0.4 m";
			weaQuality = "10";
			weaEncumbrance = "0.5";
			weaRequirements = "35 agi";
			weaCostprice = "5 silver";
			weaNotes = "Piercing. +5 special";		
			break;
		case 44: // <option>------SHLD-----</option>
			weaCategory = "";
			weaDamage = "";
			weaSpeed = "";
			weaReach = "";
			weaQuality = "";
			weaEncumbrance = "";
			weaRequirements = "";
			weaCostprice = "";
			weaNotes = "";
			break;
		case 45: // <option>Ardamian Round Shield</option>
			weaCategory = Shield;
			weaDamage = D6;
			weaSpeed = "2";
			weaReach = "0.5";
			weaQuality = "8";
			weaEncumbrance = "4.0";
			weaRequirements = "55 str";
			weaCostprice = "1 gold";
			weaNotes = "Protects arm + 2 locations vs. missile";		
			break;
		case 46: // <option>Silmarite Shield</option>
			weaCategory = Shield;
			weaDamage = D6;
			weaSpeed = "3";
			weaReach = "0.3";
			weaQuality = "12";
			weaEncumbrance = "3.0";
			weaRequirements = "45 str";
			weaCostprice = "2 gold";
			weaNotes = "Protects arm + 1 locations vs. missile";		
			break;
		case 47: // <option>Imperial Target Shield</option>
			weaCategory = Shield;
			weaDamage = D6;
			weaSpeed = "3";
			weaReach = "0.3";
			weaQuality = "12";
			weaEncumbrance = "3.0";
			weaRequirements = "45 str";
			weaCostprice = "2 gold";
			weaNotes = "Protects arm + 1 locations vs. missile";		
			break;
		case 48: // <option>Imperial Legion Shield</option>
			weaCategory = Shield;
			weaDamage = D6;
			weaSpeed = "2";
			weaReach = "0.6";
			weaQuality = "18";
			weaEncumbrance = "7.0";
			weaRequirements = "65 str";
			weaCostprice = "6 gold";
			weaNotes = "Protects whole body vs. missiles";		
			break;
		case 49: // <option>Aumethor Hide Shield</option>
			weaCategory = Shield;
			weaDamage = D4;
			weaSpeed = "3";
			weaReach = "0.3";
			weaQuality = "6";
			weaEncumbrance = "1.5";
			weaRequirements = "25 str";
			weaCostprice = "8 silver";
			weaNotes = "Protects arm + 1 locations vs. missile";		
			break;
		case 50: // <option>Duellist's Buckler</option>
			weaCategory = Shield;
			weaDamage = D4;
			weaSpeed = "3";
			weaReach = "0.15";
			weaQuality = "10";
			weaEncumbrance = "1.0";
			weaRequirements = "45 agi";
			weaCostprice = "2 gold";
			weaNotes = "Protects arm vs. missile";		
			break;
		case 51: // <option>------BOWS-----</option>
			weaCategory = "";
			weaDamage = "";
			weaSpeed = "";
			weaReach = "";
			weaQuality = "";
			weaEncumbrance = "";
			weaRequirements = "";
			weaCostprice = "";
			weaNotes = "";
			break;
		case 52: // <option>Shortbow - Hunting Arrow</option>
			weaCategory = Bow;
			weaDamage = "1D8+1";
			weaSpeed = "1 / AGI SR";
			weaReach = "90/120";
			weaQuality = "5";
			weaEncumbrance = "1.0";
			weaRequirements = "45 agi / 45 str";
			weaCostprice = "1 gold / 3 copper";
			weaNotes = "Piercing";		
			break;
		case 53: // <option>Shortbow - War Arrow</option>
			weaCategory = Bow;
			weaDamage = "1D8+2";
			weaSpeed = "1 / AGI SR";
			weaReach = "90/120";
			weaQuality = "5";
			weaEncumbrance = "1.0";
			weaRequirements = "45 agi / 45 str";
			weaCostprice = "1 gold / 4 copper";
			weaNotes = "Piercing";		
			break;
		case 54: // <option>Shortbow - Fire Arrow</option>
			weaCategory = Bow;
			weaDamage = "1D8+1";
			weaSpeed = "1 / AGI SR";
			weaReach = "90/120";
			weaQuality = "5";
			weaEncumbrance = "1.0";
			weaRequirements = "45 agi / 45 str";
			weaCostprice = "1 gold / 1 silver";
			weaNotes = "Piercing. 2D6 Flame Damage";		
			break;
		case 55: // <option>Longbow - Hunting Arrow</option>
			weaCategory = Bow;
			weaDamage = "1D8";
			weaSpeed = "1 / AGI SR";
			weaReach = "90/275";
			weaQuality = "6";
			weaEncumbrance = "1.0";
			weaRequirements = "55 agi / 35 str";
			weaCostprice = "15 silver";
			weaNotes = "Piercing";		
			break;
		case 56: // <option>Longbow - War Arrow</option>
			weaCategory = Bow;
			weaDamage = "1D8+1";
			weaSpeed = "1 / AGI SR";
			weaReach = "90/275";
			weaQuality = "6";
			weaEncumbrance = "1.0";
			weaRequirements = "55 agi / 35 str";
			weaCostprice = "15 silver";
			weaNotes = "Piercing";		
			break;
		case 57: // <option>Longbow - Fire Arrow</option>
			weaCategory = Bow;
			weaDamage = "1D8";
			weaSpeed = "1 / AGI SR";
			weaReach = "90/275";
			weaQuality = "5";
			weaEncumbrance = "1.0";
			weaRequirements = "55 agi / 35 str";
			weaCostprice = "15 silver / 1 silver";
			weaNotes = "Piercing. 2D6 Flame Damage";		
			break;
		case 58: // <option>Elven Bow - Elven Arrow</option>
			weaCategory = Bow;
			weaDamage = "1D8+2";
			weaSpeed = "1 / AGI SR";
			weaReach = "120/275";
			weaQuality = "7";
			weaEncumbrance = "1.0";
			weaRequirements = "55 agi / 35 str";
			weaCostprice = "6 gold/2 silver";
			weaNotes = "Piercing. +2 critical";		
			break;
		case 59: // <option>Imperial Bow - War Arrow</option>
			weaCategory = Bow;
			weaDamage = "1D8+3";
			weaSpeed = "1 / AGI SR";
			weaReach = "120/225";
			weaQuality = "7";
			weaEncumbrance = "1.5";
			weaRequirements = "45 agi / 55 str";
			weaCostprice = "3 gold / 4 copper";
			weaNotes = "Piercing";		
			break;
		case 60: // <option>Bow of Bin-Erek - War Arrow</option>
			weaCategory = Bow;
			weaDamage = "1D8+4";
			weaSpeed = "1 / AGI SR";
			weaReach = "120/225";
			weaQuality = "7";
			weaEncumbrance = "1.5";
			weaRequirements = "45 agi / 55 str";
			weaCostprice = "5 gold / 4 copper";
			weaNotes = "Piercing";		
			break;
		case 61: // <option>Hand Crossbow - Quarrel</option>
			weaCategory = XBow;
			weaDamage = "1D4+2";
			weaSpeed = "1 + AGI SR";
			weaReach = "10/30";
			weaQuality = "4";
			weaEncumbrance = "0.5";
			weaRequirements = "";
			weaCostprice = "4 gold";
			weaNotes = "Piercing";		
			break;
		case 62: // <option>Light Crossbow - Quarrel</option>
			weaCategory = XBow;
			weaDamage = "1D6+2";
			weaSpeed = "1 + AGI SR";
			weaReach = "40/225";
			weaQuality = "6";
			weaEncumbrance = "3.5";
			weaRequirements = "45 str";
			weaCostprice = "2 gold";
			weaNotes = "Piercing";		
			break;
		case 63: // <option>Medium Crossbow - Quarrel</option>
			weaCategory = XBow;
			weaDamage = "2D4+2";
			weaSpeed = "1 + SR AGI /2 rounds";
			weaReach = "50/270";
			weaQuality = "8";
			weaEncumbrance = "5.0";
			weaRequirements = "55 str";
			weaCostprice = "3 gold";
			weaNotes = "Piercing";		
			break;
		case 64: // <option>Heavy Crossbow - Quarrel</option>
			weaCategory = XBow;
			weaDamage = "2D6+2";
			weaSpeed = "1 + SR AGI /3 rounds";
			weaReach = "50/300";
			weaQuality = "10";
			weaEncumbrance = "5.0";
			weaRequirements = "65 str";
			weaCostprice = "4 gold";
			weaNotes = "Piercing";		
			break;
		case 65: // <option>Crossbow of the Hidden - Quarrel</option>
			weaCategory = XBow;
			weaDamage = "2D6+3";
			weaSpeed = "1 + SR AGI /2 rounds";
			weaReach = "50/300";
			weaQuality = "10";
			weaEncumbrance = "6.0";
			weaRequirements = "70 str";
			weaCostprice = "7 gold";
			weaNotes = "Piercing";		
			break;
		case 66: // <option>-----MISC------</option>
			weaCategory = "";
			weaDamage = "";
			weaSpeed = "";
			weaReach = "";
			weaQuality = "";
			weaEncumbrance = "";
			weaRequirements = "";
			weaCostprice = "";
			weaNotes = "";
			break;
		case 67: // <option>Whip</option>
			weaCategory = Other;
			weaDamage = "1D3";
			weaSpeed = "1/AGI SR";
			weaReach = "3.0 m";
			weaQuality = "4";
			weaEncumbrance = "1.0";
			weaRequirements = "45 agi";
			weaCostprice = "5 silver";
			weaNotes = "";		
			break;
		case 68: // <option>Sling</option>
			weaCategory = Other;
			weaDamage = "1D8/1D10";
			weaSpeed = "1/AGI SR";
			weaReach = "100/100";
			weaQuality = "-";
			weaEncumbrance = "0.2";
			weaRequirements = "45 agi";
			weaCostprice = "1 silver";
			weaNotes = "";		
			break;
		case 69: // <option>Garotte</option>
			weaCategory = "Other";
			weaDamage = "1 + suffocation";
			weaSpeed = "Surprise";
			weaReach = "From behind";
			weaQuality = "-";
			weaEncumbrance = "-";
			weaRequirements = "-";
			weaCostprice = "5 copper";
			weaNotes = "Victim can attempt to wrestle free";			
			break;
	}
	document.getElementById('weacat' + number).innerHTML = weaCategory;
	document.getElementById('weadam' + number).innerHTML = weaDamage;
	document.getElementById('weaspe' + number).innerHTML = weaSpeed;
	document.getElementById('wearea' + number).innerHTML = weaReach;
	document.getElementById('weaqua' + number).innerHTML = weaQuality;
	document.getElementById('weaenc' + number).innerHTML = weaEncumbrance;
	document.getElementById('weareq' + number).innerHTML = weaRequirements;
	document.getElementById('weaprc' + number).innerHTML = weaCostprice;
	document.getElementById('weanot' + number).innerHTML = weaNotes;					

	return(1);
}

function calculateBeauty()
{
	beauty = document.getElementById('appearance_beauty').value;
	personalFavor = "";

	if(beauty > 95)
	{
		personalFavor = "Permanent bonus of +5 categories on flirting and first impression";
	}
	else if(beauty > 90)
	{
		personalFavor = "Permanent bonus of +4 categories on flirting and first impression";
	}
	else if(beauty > 85)
	{
		personalFavor =  "Permanent bonus of +3 categories on flirting and first impression";	
	}
	else if(beauty > 75)
	{
		personalFavor =  "Permanent bonus of +2 categories on flirting and first impression";	
	}
	else if(beauty > 65)
	{
		personalFavor =   "Permanent bonus of +1 category on flirting and first impression";	
	}
	else if(beauty > 35)
	{
		personalFavor = "";	
	}
	else if(beauty > 25)
	{
		personalFavor =   "Permanent penalty of -1 category on flirting and first impression";	
	}
	else if(beauty > 15)
	{
		personalFavor = "Permanent penalty of -2 categories on flirting and first impression";	
	}
	else
	{
		personalFavor = "Permanent penalty of -3 categories on flirting and first impression";	
	}
	document.getElementById('beauty').innerHTML = personalFavor;
}

function calculateCharm()
{
	charm = document.getElementById('appearance_charm').value;
	personalFavor = "";

	if(charm > 90)
	{
		personalFavor = "Permanent bonus of +4 categories on conversation and speeches";	
	}
	else if(charm > 80)
	{
		personalFavor =  "Permanent bonus of +3 categories on conversation and speeches";	
	}
	else if(charm > 70)
	{
		personalFavor =  "Permanent bonus of +2 categories on conversation and speeches";	
	}
	else if(charm > 60)
	{
		personalFavor =  "Permanent bonus of +1 category on conversation and speeches";	
	}
	else if(charm > 40)
	{
		personalFavor = "";	
	}
	else if(charm > 30)
	{
		personalFavor =   "Permanent penalty of -1 category on conversation and speeches";	
	}
	else if(charm > 20)
	{
		personalFavor =   "Permanent penalty of -2 categories on conversation and speeches";	
	}
	else if(charm > 10)
	{
		personalFavor =   "Permanent penalty of -3 categories on conversation and speeches";	
	}
	else
	{
		personalFavor =   "Permanent penalty of -4 categories on conversation and speeches";	
	}
	document.getElementById('charm').innerHTML = personalFavor;	
}

function calculateHitPoints()
{
	/*
	01-10	1	3	2
	11-25	2	4	3
	26-75	3	5	4
	76-125	4	6	5
	126-170	5	7	6
	171-190	6	8	7
	191-200	7	9	8
	201-225	8	10	9
	*/
	
	kilos = calculateWeight(document.CharacterForm.raceSelect.selectedIndex, document.getElementById('genderSelectId').selectedIndex, document.getElementById('size_weight').value, 1);
	stamina = document.getElementById('health_stamina').value;
	result = parseInt(kilos) + parseInt(stamina);
	arms = 0;
	chest = 0;
	rest = 0;
	bloodpoints = 0;
	partresult = 0;
	
	if(result > 220)
	{
		partresult = (parseInt(result) - 220);
		partresult = Math.round(partresult);
		partresult = Math.round((partresult / 30));
		arms = partresult;
		chest = partresult;
		rest = partresult;
		bloodpoints = partresult;	
	}
	if(result > 200)
	{
		arms = 8 + partresult;
		chest = 10 + partresult;
		rest = 9 + partresult;
		bloodpoints = 22 + (partresult * 2);	
	}
	else if(result > 190)
	{
		arms = 7;
		chest = 9;
		rest = 8;
		bloodpoints = 20;	
	}
	else if(result > 170)
	{
		arms = 6;
		chest = 8;
		rest = 7;
		bloodpoints = 18;	
	}
	else if(result > 125)
	{
		arms = 5;
		chest = 7;
		rest = 6;
		bloodpoints = 16;	
	}
	else if(result > 75)
	{
		arms = 4;
		chest = 6;
		rest = 5;
		bloodpoints = 14;	
	}
	else if(result > 25)
	{
		arms = 3;
		chest = 5;
		rest = 4;
		bloodpoints = 12;	
	}
	else
	{
		arms = 2;
		chest = 4;
		rest = 3;
		bloodpoints = 10;	
	}
	document.getElementById('stamina_notes').innerHTML = "Arms: " + arms + " Chest: " + chest + " Legs, abdomen and head: " + rest + " Blood Points: " + bloodpoints;
}

function setMaster(child1_elementId, child2_elementId, value)
{
	if(validate(value))
	{
		document.getElementById(child1_elementId).value = value;
		document.getElementById(child2_elementId).value = value;
		return(1);
	}
	else
	{
		alert("You must enter a number between 1 and 110");
		return(0);
	}
}

function setModifier(elementId, value)
{
	document.getElementById(elementId).innerHTML = determineModifier(value);
}

function calculateDamage()
{
	calculateDamageBonus(calculateWeight(document.CharacterForm.raceSelect.selectedIndex, document.getElementById('genderSelectId').selectedIndex, document.getElementById('size_weight').value, 1), document.getElementById('health_muscle').value);
}

function calculateSize()
{
	calculateHeight(document.CharacterForm.raceSelect.selectedIndex, document.getElementById('genderSelectId').selectedIndex, document.getElementById('size_height').value);
	calculateWeight(document.CharacterForm.raceSelect.selectedIndex, document.getElementById('genderSelectId').selectedIndex, document.getElementById('size_weight').value, 0);
}


function professionSkills()
{
	profession = document.getElementById('professionSelectId').selectedIndex; //a whole lot of professions
	race = document.getElementById('raceSelectId').selectedIndex;
	var realage = 1;
	switch(parseInt(race))
	{
		case 11: //The Hidden: Forest Cannibal
		case 12: //The Hidden: Mountain Cannibal
			realage = 0.8;
			break;
		case 13: //Elf: The Fallen of Dharghenaas
		case 14: //Elf: Imperialite Islander
			realage = 0.1;
			break;
		case 15: //Half-Elf: Blessed of Sil'Dhuron
		case 16: //Half-Elf: The Exiled
			realage = 0.5;
			break;
		case 17: //Dwarf: Divine Shield of the City of Gods
		case 18: //Dwarf: Warrior Clansman of the City of War
			realage = 0.4;
			break;
		default:
			realage = 1;
	}
	
	age = document.getElementById('ageId').value;

	if(parseInt(age) == null)
		return(0);

	realage = (parseFloat(age) * parseFloat(realage));

	skillAge = parseInt(realage) - 15;
	if(parseInt(skillAge)<0)
		skillAge = 0;
	if(parseInt(skillAge)>40)
	{
		lessLearning = parseInt(skillAge) - 40;
		lessLearning = parseInt(lessLearning) / 3;
		skillAge = 40 + parseInt(lessLearning);
	}
	
	//first we need to nullify any previous values
	document.getElementById('agiskill').innerHTML = "";
	document.getElementById('comskill').innerHTML = "";
	document.getElementById('manskill').innerHTML = "";	
	document.getElementById('knoskill').innerHTML = "";
	document.getElementById('steskill').innerHTML = "";
	document.getElementById('melskill').innerHTML = "";
	document.getElementById('ranskill').innerHTML = "";
	document.getElementById('magskill').innerHTML = "";		
	
	//then we insert our new values!	
	switch(profession)
	{	
		case 0: //Warrior
			document.getElementById('melskill').innerHTML = (parseInt(skillAge) * 25);
			document.getElementById('ranskill').innerHTML = (parseInt(skillAge) * 15);
			document.getElementById('agiskill').innerHTML = (parseInt(skillAge) * 10);		
			break;		
		case 1: //Champion (Pit Fighter or Gladiator)
			document.getElementById('melskill').innerHTML = (parseInt(skillAge) * 30);
			document.getElementById('agiskill').innerHTML = (parseInt(skillAge) * 20);
			break;
		case 2: //Duellist
			document.getElementById('melskill').innerHTML = (parseInt(skillAge) * 25);
			document.getElementById('agiskill').innerHTML = (parseInt(skillAge) * 25);
			break;
		case 3: //Noble
			document.getElementById('comskill').innerHTML = (parseInt(skillAge) * 15);
			document.getElementById('melskill').innerHTML = (parseInt(skillAge) * 15);
			document.getElementById('agiskill').innerHTML = (parseInt(skillAge) * 10);
			document.getElementById('knoskill').innerHTML = (parseInt(skillAge) * 25);			
			break;
		case 4: //Hunter / Poacher
			document.getElementById('steskill').innerHTML = (parseInt(skillAge) * 20);
			document.getElementById('ranskill').innerHTML = (parseInt(skillAge) * 25);
			document.getElementById('knoskill').innerHTML = (parseInt(skillAge) * 5);
			break;
		case 5: //Archer
			document.getElementById('melskill').innerHTML = (parseInt(skillAge) * 10);
			document.getElementById('ranskill').innerHTML = (parseInt(skillAge) * 35);
			document.getElementById('agiskill').innerHTML = (parseInt(skillAge) * 5);
			break;
		case 6: //Assassin
			document.getElementById('manskill').innerHTML = (parseInt(skillAge) * 10);
			document.getElementById('ranskill').innerHTML = (parseInt(skillAge) * 25);
			document.getElementById('steskill').innerHTML = (parseInt(skillAge) * 15);
			break;
		case 7: //Burglar
			document.getElementById('steskill').innerHTML = (parseInt(skillAge) * 20);
			document.getElementById('manskill').innerHTML = (parseInt(skillAge) * 15);
			document.getElementById('agiskill').innerHTML = (parseInt(skillAge) * 15);
			break;
		case 8: //Pickpocket
			document.getElementById('steskill').innerHTML = (parseInt(skillAge) * 10);
			document.getElementById('manskill').innerHTML = (parseInt(skillAge) * 25);
			document.getElementById('comskill').innerHTML = (parseInt(skillAge) * 10);
			document.getElementById('agiskill').innerHTML = (parseInt(skillAge) * 5);			
			break;
		case 9: //Magician
			document.getElementById('magskill').innerHTML = (parseInt(skillAge) * 30);
			document.getElementById('knoskill').innerHTML = (parseInt(skillAge) * 20);
			break;
		case 10: //Conjuror
			document.getElementById('magskill').innerHTML = (parseInt(skillAge) * 45);
			document.getElementById('knoskill').innerHTML = (parseInt(skillAge) * 5);
			break;
		case 11: //Necromancer
			document.getElementById('magskill').innerHTML = (parseInt(skillAge) * 25);
			document.getElementById('knoskill').innerHTML = (parseInt(skillAge) * 25);
			break;
		case 12: //Diviner
			document.getElementById('magskill').innerHTML = (parseInt(skillAge) * 40);
			document.getElementById('knoskill').innerHTML = (parseInt(skillAge) * 10);
			break;
		case 13: //Priest
			document.getElementById('magskill').innerHTML = (parseInt(skillAge) * 30);
			document.getElementById('knoskill').innerHTML = (parseInt(skillAge) * 10);
			document.getElementById('comskill').innerHTML = (parseInt(skillAge) * 10);			
			break;
		case 14: //Warrior-Priest
			document.getElementById('magskill').innerHTML = (parseInt(skillAge) * 10);
			document.getElementById('melskill').innerHTML = (parseInt(skillAge) * 30);
			document.getElementById('agiskill').innerHTML = (parseInt(skillAge) * 10);
			break;
		case 15: //Holy Champion
			document.getElementById('melskill').innerHTML = (parseInt(skillAge) * 40);
			document.getElementById('agiskill').innerHTML = (parseInt(skillAge) * 10);
			break;
		case 16: //Merchant
			document.getElementById('knoskill').innerHTML = (parseInt(skillAge) * 15);
			document.getElementById('comskill').innerHTML = (parseInt(skillAge) * 35);		
			break;
	}	
	
}

function determineModifier(value)
{
	if(validate(value))
	{
		var res = "<div align='center'><b>"
		if(value > 109)
		{
			res = res + "x7.5";
		}
		else if (value > 108)
		{
			res = res + "x7.0";
		}
		else if(value >107)
		{
			res = res + "x6.5";
		}
		else if(value >106)
		{
			res = res + "x6.0";
		}
		else if(value >105)
		{
			res = res + "x5.5";
		}
		else if(value >104)
		{
			res = res + "x5.0";
		}
		else if(value >103)
		{
			res = res + "x4.5";
		}
		else if(value >102)
		{
			res = res + "x4.0";
		}
		else if(value >101)
		{
			res = res + "x3.5";
		}
		else if(value >100)
		{
			res = res + "x3.0";
		}
		else if(value >99)
		{
			res = res + "x2.75";
		}
		else if(value >98)
		{
			res = res + "x2.5";
		}
		else if(value >97)
		{
			res = res + "x2.25";
		}
		else if(value >95)
		{
			res = res + "x2.0";
		}
		else if(value >90)
		{
			res = res + "x1.9";
		}
		else if(value >85)
		{
			res = res + "x1.75";
		}
		else if(value >80)
		{
			res = res + "x1.6";
		}
		else if(value >75)
		{
			res = res + "x1.5";
		}
		else if(value >70)
		{
			res = res + "x1.4";
		}
		else if(value >65)
		{
			res = res + "x1.25";
		}
		else if(value >60)
		{
			res = res + "x1.1";
		}
		else if(value >40)
		{
			res = res + "x1.0";
		}
		else if(value >35)
		{
			res = res + "x0.9";
		}
		else if(value >30)
		{
			res = res + "x0.75";
		}
		else if(value >25)
		{
			res = res + "x0.6";
		}
		else if(value >20)
		{
			res = res + "x0.5";
		}
		else if(value >10)
		{
			res = res + "x0.4";
		}
		else
		{
			res = res + "x0.25";
		}

		res = res + "</b></div>"
		//alert(placement);
		return(res);
		//alert(res);
	}
	else
	{
		alert("You must enter a number between 1 and 110");
	}
}

function validate(value)
{
	//alert("1");
	if(!isNaN(value) && (value < 111 && value > 0))
		return(1);
	else
		return(0);
}

function diceList()
{
	HEA = 0;
	SIZ = 0;
	APP = 0;
	SOU = 0;
	SEN = 0;
	AGI = 0;
	COM = 0;
	MAN = 0;
	KNO = 0;
	STE = 0;
	MEL = 0;
	RAN = 0;
	MAG = 0;

	gender = document.getElementById('genderSelectId').selectedIndex; //0 is male, 1 is female

	switch(gender)
	{
		case 0:
			HEA = HEA + 1;
			break;
		case 1:
			APP = APP + 1;
			break;
	}
	
	race = document.getElementById('raceSelectId').selectedIndex; //a whole lot of races 0 - 18
	
	switch(race)
	{
		case 0: //Human: Silmarite Kingdomer
		 	SOU = SOU + 1;
			break;
		case 1: //Human: Belemarian Imperial
			KNO = KNO + 1;
			break;
		case 2: //Human: Careshite Imperial
			COM = COM + 1;
			break;
		case 3: //Human: Ethenorden Nomad
			MAG = MAG + 1;
			break;
		case 4: //Human: Of the Conquered Lands
			COM = COM + 1;
			break;
		case 5: //Human: Obaayn Desert Tribal
			AGI = AGI + 1;
			break;
		case 6: //Human: Of the Haku People
			AGI = AGI + 1;
			break;
		case 7: //Human: Dharghenaas Aboriginal
			SEN = SEN + 1;
			break;
		case 8: //Human: City State dweller from Northern Aumethorion
			COM = COM + 1;
			break;
		case 9: //Human: Of the Ling People
			COM = COM + 1;
			break;
		case 10: //Human: Steppe Horse Nomad
			AGI = AGI + 1;
			break;
		case 11: //The Hidden: Forest Cannibal
			STE = STE + 1;
			break;
		case 12: //The Hidden: Mountain Cannibal
			STE = STE + 1;	
			break;
		case 13: //Elf: The Fallen of Dharghenaas
			APP = APP + 1;
			SOU = SOU + 1;
			SEN = SEN + 1;
			AGI = AGI + 1;
			KNO = KNO + 1;
			STE = STE + 1;
			RAN = RAN + 1;
			MAG = MAG + 1;
			break;
		case 14: //Elf: Imperialite Islander
			APP = APP + 1;
			SOU = SOU + 1;
			SEN = SEN + 1;
			AGI = AGI + 1;
			COM = COM + 1;
			KNO = KNO + 1;
			RAN = RAN + 1;
			MAG = MAG + 1;		
			break;
		case 15: //Half-Elf: Blessed of Sil'Dhuron
			SOU = SOU + 2;
			APP = APP + 1;
			MAG = MAG + 2;
			break;
		case 16: //Half-Elf: The Exiled
			SOU = SOU + 1;
			APP = APP + 1;
			MAG = MAG + 1;	
			break;
		case 17: //Dwarf: Divine Shield of the City of Gods
			HEA = HEA + 1;
			SOU = SOU + 1;
			KNO = KNO + 1;
			break;
		case 18: //Dwarf: Warrior Clansman of the City of War
			HEA = HEA + 1;
			SIZ = SIZ + 1;
			MEL = MEL + 1;
			break;
	}
	
	culture = document.getElementById('cultureSelectId').selectedIndex; //0 is primitive, 1 is barbaric, 2 is civilized
	
	switch(culture)
	{
		case 0: //primitive
			SOU = SOU + 1;
			break;		
		case 1: //barbarian
			AGI = AGI + 1;
			break;		
		case 2: //civilized
			KNO = KNO + 1;
			break;		
	}
	
	profession = document.getElementById('professionSelectId').selectedIndex; //a whole lot of professions
	
	switch(profession) //4 points
	{	
		case 0: //Warrior
			MEL = MEL + 2;
			RAN = RAN + 1;
			HEA = HEA + 1;			
			break;		
		case 1: //Champion (Pit Fighter or Gladiator)
			HEA = HEA + 2;
			MEL = MEL + 2;
			break;
		case 2: //Duellist
			MEL = MEL + 3;
			AGI = AGI + 1;
			break;
		case 3: //Noble
			AGI = AGI + 1;
			COM = COM + 1;
			MEL = MEL + 2;
			break;
		case 4: //Hunter / Poacher
			RAN = RAN + 2;
			STE = STE + 1;
			SEN = SEN + 1;
			break;
		case 5: //Archer
			RAN = RAN + 3;
			MEL = MEL + 1;
			break;
		case 6: //Assassin
			MAN = MAN + 1;
			RAN = RAN + 2;
			STE = STE + 1;
			break;
		case 7: //Burglar
			AGI = AGI + 1;
			MAN = MAN + 1;
			STE = STE + 2;
			break;
		case 8: //Pickpocket
			MAN = MAN + 2;
			COM = COM + 1;
			AGI = AGI + 1;
			break;
		case 9: //Magician
			SOU = SOU + 1;
			KNO = KNO + 1;
			MAG = MAG + 2;
			break;
		case 10: //Conjuror
			SOU = SOU + 2
			MAG = MAG + 2;
			break;
		case 11: //Necromancer
			MAG = MAG + 3;
			KNO = KNO + 1;
			break;
		case 12: //Diviner
			SOU = SOU + 3;
			MAG = MAG + 1;
			break;
		case 13: //Priest
			SOU = SOU + 2;
			COM = COM + 1;
			MAG = MAG + 1;
			break;
		case 14: //Warrior-Priest
			MEL = MEL + 2;
			SOU = SOU + 2;
			break;
		case 15: //Holy Champion
			MEL = MEL + 2;
			HEA = HEA + 1;
			SOU = SOU + 1;
			break;
		case 16: //Merchant
			COM = COM + 3;
			KNO = KNO + 1;		
			break;
	}
	document.getElementById('health_dice').innerHTML = diceChoice(HEA);
	document.getElementById('size_dice').innerHTML = diceChoice(SIZ);
	document.getElementById('soul_dice').innerHTML = diceChoice(SOU);
	document.getElementById('appearance_dice').innerHTML = diceChoice(APP);
	document.getElementById('senses_dice').innerHTML = diceChoice(SEN);
	
	document.getElementById('agility_dice').innerHTML = diceChoice(AGI);
	document.getElementById('communication_dice').innerHTML = diceChoice(COM);
	document.getElementById('manipulation_dice').innerHTML = diceChoice(MAN);
	document.getElementById('knowledge_dice').innerHTML = diceChoice(KNO);
	document.getElementById('stealth_dice').innerHTML = diceChoice(STE);
	document.getElementById('melee_dice').innerHTML = diceChoice(MEL);
	document.getElementById('ranged_dice').innerHTML = diceChoice(RAN);
	document.getElementById('magic_dice').innerHTML = diceChoice(MAG);
}

function diceChoice(stat)
{
	if(parseInt(stat) >= 4)
		return("1D20 + 80");
	else if(parseInt(stat) == 3)
		return("2D20 + 60");
	else if(parseInt(stat) == 2)
		return("3D20 + 40");
	else if(parseInt(stat) == 1)
		return("4D20 + 20");
	else
		return("5D20");
}

function calculateHeight(race, gender, height)
{
	if(height == null || height == "")
		return(0);
		
	base = 0;
	X = 0;
		
	switch(race)
	{
		case 0: //Human: Silmarite Kingdomer
			base = 100;
			if(gender == 0) // male
				X = 75;
			else //female
				X = 70;
			break;
		case 1: //Human: Belemarian Imperial
			base = 100;
			if(gender == 0) // male
				X = 75;
			else //female
				X = 67;		
			break;
		case 2: //Human: Careshite Imperial
			base = 100;
			if(gender == 0) // male
				X = 60;
			else //female
				X = 55;			
			break;
		case 3: //Human: Ethenorden Nomad
			base = 100;
			if(gender == 0) // male
				X = 75;
			else //female
				X = 67;			
			break;
		case 4: //Human: Of the Conquered Lands
			base = 100;
			if(gender == 0) // male
				X = 72;
			else //female
				X = 68;			
			break;
		case 5: //Human: Obaayn Desert Tribal
			base = 100;
			if(gender == 0) // male
				X = 58;
			else //female
				X = 52;		
			break;
		case 6: //Human: Of the Haku People
			base = 100;
			if(gender == 0) // male
				X = 58;
			else //female
				X = 52;
			break;
		case 7: //Human: Dharghenaas Aboriginal
			base = 100;
			if(gender == 0) // male
				X = 75;
			else //female
				X = 70;		
			break;
		case 8: //Human: City State dweller from Northern Aumethorion
			base = 100;
			if(gender == 0) // male
				X = 75;
			else //female
				X = 65;		
			break;
		case 9: //Human: Of the Ling People
			base = 100;
			if(gender == 0) // male
				X = 55;
			else //female
				X = 50;		
			break;
		case 10: //Human: Steppe Horse Nomad
			base = 100;
			if(gender == 0) // male
				X = 60;
			else //female
				X = 55;		
			break;
		case 11: //The Hidden: Forest Cannibal
			base = 100;
			if(gender == 0) // male
				X = 58;
			else //female
				X = 52;		
			break;
		case 12: //The Hidden: Mountain Cannibal
			base = 100;
			if(gender == 0) // male
				X = 65;
			else //female
				X = 60;		
			break;
		case 13: //Elf: The Fallen of Dharghenaas
			base = 110;
			if(gender == 0) // male
				X = 80;
			else //female
				X = 65;		
			break;
		case 14: //Elf: Imperialite Islander
			base = 115;
			if(gender == 0) // male
				X = 80;
			else //female
				X = 65;		
			break;
		case 15: //Half-Elf: Blessed of Sil'Dhuron
			base = 105;
			if(gender == 0) // male
				X = 77;
			else //female
				X = 66;		
			break;
		case 16: //Half-Elf: The Exiled
			base = 105;
			if(gender == 0) // male
				X = 77;
			else //female
				X = 66;		
			break;
		case 17: //Dwarf: Divine Shield of the City of Gods
			base = 80;
			if(gender == 0) // male
				X = 40;
			else //female
				X = 35;				
			break;
		case 18: //Dwarf: Warrior Clansman of the City of War
			base = 80;
			if(gender == 0) // male
				X = 40;
			else //female
				X = 35;		
			break;
			
	}
	//rase + (underrase * (0,5+(d100 / 100))		
	document.getElementById('height_centimeters').innerHTML = Math.round(parseInt(base) + (parseInt(X) * (0.5 + (parseInt(height)/100)))) + " centimeters";		
}
/*			KEY INDEX
	0		male
	1		female
*/
function calculateWeight(race, gender, weight, returnValue)
{
	if(weight == null || weight == "")
		return(0);
		
	X = 0;
	
	switch(race)
	{
		case 0: //Human: Silmarite Kingdomer
			if(gender == 0) // male
				X = 75;
			else //female
				X = 57;
			break;
		case 1: //Human: Belemarian Imperial
			if(gender == 0) // male
				X = 75;
			else //female
				X = 58;		
			break;
		case 2: //Human: Careshite Imperial
			if(gender == 0) // male
				X = 65;
			else //female
				X = 56;			
			break;
		case 3: //Human: Ethenorden Nomad
			if(gender == 0) // male
				X = 70;
			else //female
				X = 55;			
			break;
		case 4: //Human: Of the Conquered Lands
			if(gender == 0) // male
				X = 70;
			else //female
				X = 60;			
			break;
		case 5: //Human: Obaayn Desert Tribal
			if(gender == 0) // male
				X = 58;
			else //female
				X = 52;		
			break;
		case 6: //Human: Of the Haku People
			if(gender == 0) // male
				X = 58;
			else //female
				X = 52;			
			break;
		case 7: //Human: Dharghenaas Aboriginal
			if(gender == 0) // male
				X = 90;
			else //female
				X = 80;			
			break;
		case 8: //Human: City State dweller from Northern Aumethorion
			if(gender == 0) // male
				X = 58;
			else //female
				X = 52;		
			break;
		case 9: //Human: Of the Ling People
			if(gender == 0) // male
				X = 75;
			else //female
				X = 57;
			break;
		case 10: //Human: Steppe Horse Nomad
			if(gender == 0) // male
				X = 60;
			else //female
				X = 55;		
			break;
		case 11: //The Hidden: Forest Cannibal
			if(gender == 0) // male
				X = 60;
			else //female
				X = 50;
			break;
		case 12: //The Hidden: Mountain Cannibal
			if(gender == 0) // male
				X = 80;
			else //female
				X = 70;		
			break;
		case 13: //Elf: The Fallen of Dharghenaas
			if(gender == 0) // male
				X = 75;
			else //female
				X = 60;		
			break;
		case 14: //Elf: Imperialite Islander
			if(gender == 0) // male
				X = 80;
			else //female
				X = 65;		
			break;
		case 15: //Half-Elf: Blessed of Sil'Dhuron
			if(gender == 0) // male
				X = 75;
			else //female
				X = 59;		
			break;
		case 16: //Half-Elf: The Exiled
			if(gender == 0) // male
				X = 75;
			else //female
				X = 59;		
			break;
		case 17: //Dwarf: Divine Shield of the City of Gods
			if(gender == 0) // male
				X = 100;
			else //female
				X = 90;		
			break;
		case 18: //Dwarf: Warrior Clansman of the City of War
			if(gender == 0) // male
				X = 105;
			else //female
				X = 95;		
			break;
		default:
			alert("Racial selection out of bounds");
			
	}
	if(parseInt(returnValue) == 0)	
		document.getElementById('weight_kilos').innerHTML = Math.round(parseInt(X) * (0.5 + (parseInt(weight)/100))) + " kilos";	
	else
		return(Math.round(parseInt(X) * (0.5 + (parseInt(weight)/100))));
	//(rase * (0,5 + (d100/100)))	
}

function calculateDamageBonus(weight_kilo, muscle)
{
	total = parseInt(weight_kilo) + parseInt(muscle);
	damageExtra = 0;

	if(parseInt(total) > 220)
	{
			temp = total - 220;
			damageExtra = Math.round((parseFloat(temp) / 7.5));
	}
	if(parseInt(total) > 205)
	{
			damageExtra = "+1D10 + " + damageExtra;
	}
	else if(parseInt(total) > 190)
	{
			damageExtra = "+1D8";
	}
	else if(parseInt(total) > 160)
	{
				damageExtra = "+1D6";
	}
	else if(parseInt(total) > 140)
	{
			damageExtra = "+1D4";
	}
	else if(parseInt(total) > 125)
	{
			damageExtra = "+1D2";
	}
	else if(parseInt(total) > 90)
	{
			damageExtra = "0";
	}
	else if(parseInt(total) > 75)
	{
			damageExtra = "-1D2";
	}
	else if(parseInt(total) > 60)
	{
			damageExtra = "-1D4";
	}
	else
	{
			damageExtra = "-1D6";
	}
	document.getElementById('muscle_damage').innerHTML = "Damage: " + damageExtra;
}

function isLegalIncrease(valueChanged, valueParentBase)
{
	if(((valueChanged - valueParentBase) < 6) && ((valueChanged - valueParentBase) > -5))
	 return(1);
	return(0);
}

function isBlankField(idValue_field)
{
	if(document.getElementById(idValue_field).value == "")
	{
		return(1);
	}
	else
	{
		return(0);
	}
}

function calculateSibling(idValue_thisField, idValue_siblingField, idValue_parentField)
{
	document.getElementById(idValue_siblingField).value = (document.getElementById(idValue_parentField).value) - (document.getElementById(idValue_thisField).value - document.getElementById(idValue_parentField).value);
}

//
function setValue(newValue, parentValue, idValue_thisField, idValue_parentField, idValue_siblingField) 
{
//	alert("" + newValue + parentValue + idValue_thisField + idValue_parentField + idValue_siblingField);
	
	//We have to have a new value to set
	if(isBlankField(idValue_thisField))
		return (0);
	
	//If the parent is blank, we use the current	
	if(idValue_parentField == null)
		return(0);	
	
	if(isBlankField(idValue_parentField))
	{
		document.getElementById(idValue_parentField).value = newValue;
		parentValue = newValue;
	}
	
	limit = 0;
	
	if(!isLegalIncrease(newValue, parentValue))
	{
		if(parseInt(newValue) < parseInt(parentValue))
		{
			limit = parseInt(parentValue) - 5;
		}
		else
		{
			limit = parseInt(parentValue) + 5;
		}
		document.getElementById(idValue_thisField).value = limit
		//document.getElementById(idValue_siblingValue).value = (parentValue - (limit - document.getElementById(idValue_siblingField).value));
	}

	if(idValue_siblingField == null)
		return(0);

	calculateSibling(idValue_thisField, idValue_siblingField, idValue_parentField);

	//alert("" + newValue + parentValue + idValue_thisField + idValue_parentField + idValue_siblingField);
}

function setValueAppearance(newValue, parentValue, idValue_thisField, idValue_parentField, idValue_siblingField) 
{
//	alert("" + newValue + parentValue + idValue_thisField + idValue_parentField + idValue_siblingField);
	
	//We have to have a new value to set
	if(isBlankField(idValue_thisField))
		return (0);
	
	//If the parent is blank, we use the current	
	if(idValue_parentField == null)
		return(0);	
	
	if(isBlankField(idValue_parentField))
	{
		document.getElementById(idValue_parentField).value = newValue;
		parentValue = newValue;
	}
	
	limit = 0;
	
	if(!isLegalIncrease(newValue, parentValue))
	{
		if(parseInt(newValue) < parseInt(parentValue))
		{
			limit = parseInt(parentValue) - 20;
		}
		else
		{
			limit = parseInt(parentValue) + 20;
		}
		document.getElementById(idValue_thisField).value = limit
		//document.getElementById(idValue_siblingValue).value = (parentValue - (limit - document.getElementById(idValue_siblingField).value));
	}

	if(idValue_siblingField == null)
		return(0);

	calculateSibling(idValue_thisField, idValue_siblingField, idValue_parentField);

	//alert("" + newValue + parentValue + idValue_thisField + idValue_parentField + idValue_siblingField);
}

/*
<html>
<body>
<p id="myP">Sample Text inside a <b>p</b> element</p>
<button onclick="alert(myP.innerHTML);">InnerHTML</button>
<button onclick="alert(myP.innerText);">InnerText</button>
</body>
</html>
*/