var empty = new Array(0, 0, 0, 0, 0, 0, 0, 0), classes = { 'Lord (M)': new Array(18, 6, 0, 5, 7, 7, 0, 5), 'Great Lord (M)': new Array(23, 10, 0, 7, 9, 10, 3, 6), 'Tactician': new Array(16, 4, 3, 5, 5, 5, 3, 5), 'Grandmaster': new Array(20, 7, 6, 7, 7, 7, 5, 6), 'Cavalier': new Array(18, 6, 0, 5, 6, 7, 0, 7), 'Paladin': new Array(25, 9, 1, 7, 8, 10, 6, 8), 'Great Knight': new Array(26, 11, 0, 6, 5, 14, 1, 7), 'Knight': new Array(18, 8, 0, 4, 2, 11, 0, 4), 'General': new Array(28, 12, 0, 7, 4, 15, 3, 5), 'Myrmidon': new Array(16, 4, 1, 9, 10, 4, 1, 5), 'Swordmaster': new Array(20, 7, 2, 11, 13, 6, 4, 6), 'Mercenary': new Array(18, 5, 0, 8, 7, 5, 0, 5), 'Hero': new Array(22, 8, 1, 11, 10, 8, 3, 6), 'Fighter': new Array(20, 8, 0, 5, 5, 4, 0, 5), 'Warrior': new Array(28, 12, 0, 8, 7, 7, 3, 6), 'Barbarian': new Array(22, 8, 0, 3, 8, 3, 0, 5), 'Berserker': new Array(30, 13, 0, 5, 11, 5, 1, 6), 'Archer': new Array(16, 5, 0, 8, 6, 5, 0, 5), 'Sniper': new Array(20, 7, 1, 12, 9, 10, 3, 6), 'Bow Knight': new Array(24, 8, 0, 10, 10, 6, 2, 8), 'Thief': new Array(16, 3, 0, 6, 8, 2, 0, 5), 'Assassin': new Array(21, 8, 0, 13, 12, 5, 1, 6), 'Trickster': new Array(19, 4, 4, 10, 11, 3, 5, 6), 'Pegasus Knight': new Array(16, 4, 2, 7, 8, 4, 6, 7), 'Falcon Knight': new Array(20, 6, 3, 10, 11, 6, 9, 8), 'Dark Flier': new Array(19, 5, 6, 8, 10, 5, 9, 8), 'Wyvern Rider': new Array(19, 7, 0, 6, 5, 8, 0, 7), 'Wyvern Lord': new Array(24, 11, 0, 8, 7, 11, 3, 8), 'Griffon Rider': new Array(22, 9, 0, 10, 9, 8, 3, 8), 'Mage': new Array(16, 0, 4, 3, 4, 2, 3, 5), 'Sage': new Array(20, 1, 7, 5, 7, 4, 5, 6), 'Dark Mage': new Array(18, 1, 3, 2, 3, 4, 4, 5), 'Sorcerer': new Array(23, 2, 6, 4, 4, 7, 7, 6), 'Dark Knight': new Array(25, 4, 5, 6, 5, 9, 5, 8), 'Priest': new Array(16, 0, 3, 2, 4, 1, 6, 5), 'War Monk': new Array(24, 5, 5, 4, 6, 6, 6, 6), 'Cleric': new Array(16, 0, 3, 2, 4, 1, 6, 5), 'War Cleric': new Array(24, 5, 5, 4, 6, 6, 6, 6), 'Troubadour': new Array(16, 0, 3, 2, 5, 1, 5, 7), 'Valkyrie': new Array(19, 0, 5, 4, 8, 3, 8, 8), 'Villager': new Array(16, 1, 0, 1, 1, 1, 0, 5), 'Dancer': new Array(16, 1, 1, 5, 8, 3, 1, 5), 'Taguel': new Array(18, 2, 0, 4, 5, 3, 2, 6), 'Manakete': new Array(18, 2, 0, 1, 1, 2, 2, 6), 'Lord (F)': new Array(16, 5, 1, 6, 8, 6, 1, 5), 'Great Lord (F)': new Array(20, 8, 1, 9, 11, 8, 4, 6), 'Lodestar': new Array(21, 9, 1, 10, 10, 8, 4, 6), 'Dread Fighter': new Array(22, 8, 4, 7, 9, 7, 10, 6), 'Bride': new Array(21, 7, 6, 11, 10, 7, 6, 6), 'Conqueror': new Array(24, 10, 3, 9, 8, 12, 5, 8) }; function calculateStats(firstClassName, secondClassName) { var firstClass = classes[firstClassName], secondClass = classes[secondClassName], sum = new Array(), //Holds the modified growths temp, //Because we need to store things to work with all those functions x = 0; for (x = 0; x < firstClass.length; x++) { if (firstClass[x] === '?' || secondClass[x] === '?') { sum[x] = '?'; } else { sum[x] = secondClass[x] - firstClass[x]; //Add character growth + class growth manipulated with this multidimensional array } temp = document.getElementById('ClassChange' + x.toString()); //Set temp to hold an id through some string manipulation //If charName is 'liz' and x is currently 2, the id referred to will be 'liz2' temp.childNodes[0].nodeValue = sum[x]; //Pass the sum over to the id } return sum; } function init() { var collection, item, i = 0; var reclass = function() { var first = document.getElementById('ClassChange_dropdown_first'), firstName = first.options[first.selectedIndex].value, second = document.getElementById('ClassChange_dropdown_second'), secondName = second.options[second.selectedIndex].value; calculateStats(firstName, secondName); }; for (i = 0, collection = document.getElementsByClassName('ClassChangeDropdown'); i < collection.length; i++) { item = collection[i] item.addEventListener('change', reclass, false); } } setTimeout(function() { init(); }, 0);