divided javascript to battle and spellbook areas