var is_ie = false;
var httpObj = null;

function getHTTPObj() {
  var reqObj;
	if (window.XMLHttpRequest) { // from Mozilla's Getting Started with AJAX page
		reqObj = new XMLHttpRequest();
		is_ie = false;
	}	else if (window.ActiveXObject) {
		reqObj = new ActiveXObject("Microsoft.XMLHTTP");
		is_ie = true;
	}
	return reqObj;
}

var httpObj = getHTTPObj();

function getNews() {
	httpObj.open('GET', 'news.html', true);
	httpObj.onreadystatechange = function() {
    if (httpObj.readyState == 4) {
      document.getElementById('news').innerHTML = httpObj.responseText;
    }
  }
	httpObj.send(null); 
}

function getContent(url) {
  if( !url ) {
    var url = getCookie('lasttab');
    if( !url ) {
      url = 'classes.html';
    }
  }
	httpObj.open('GET', url, true);
	httpObj.onreadystatechange = function() {
    if (httpObj.readyState == 4) {
      setTab(url);
      setCookie('lasttab', url, 365);
      document.getElementById('subcontent').innerHTML = httpObj.responseText;
    }
  }
	httpObj.send(null); 
}

function setTab(url) {
  var tabmenu = document.getElementById("menu2");
  tabs = tabmenu.getElementsByTagName("a");
  for( var i=0; i < tabs.length; i++ ) {
    if( tabs[i].title == url ) {
      tabs[i].setAttribute("class", "currtab");      
      tabs[i].setAttribute("className", "currtab");
    } else {
      tabs[i].setAttribute("class", "outtab");      
      tabs[i].setAttribute("className", "outtab");
    }
  }
}

var classInfo = new Array();
classInfo[0] = {name: "paladin", type: "Tank", desp: "Can dodge and get up to 5 attacks at lvl 90. They have powerful healing skills but must remain in good align. Considered the best class to go questing with. New features with shield weaponry." };
classInfo[1] = {name: "warrior", type: "Tank", desp: "Can dodge, can block, and the most damage dealing of all non-spell characters when fighting. Expensive repair bills on equipment and harder to find equipment for. Since they lack healing, it is often suggested to have a cleric as the 2nd pc." };
classInfo[2] = {name: "monk", type: "Tank", desp: "They dodge, block, and SNEAK! They are a thief like class without the backstab. They require more exp to level than any single class character. They have special attacks and are very effective against all enemies. They don't really become effective till around level 80, so be patient if you play a monk. Regen is ok, but they cannot heal." };
classInfo[3] = {name: "thief", type: "Tank", desp: "They dodge, they sneak, they dual wield. They really are easy to level, but do not many special skills other than the wicked backstab bonuses and multipliers. Once a backstab starts the battle goes, so you do not get to continue to backstab your enemy. They have their uses, can get through tunnels, and seem to be very good all around, but not that many are seen in the game." };
classInfo[4] = {name: "ranger", type: "Tank", desp: "They dodge, can stun opponents, and can make rations for heals. They have the same attacks as paladins, but also get dual wield. At higher levels (100) their rations are one of the best things on the mud. They also can charm many animals to kill things. Rangers make good characters, but lack as soloists. " };
classInfo[5] = {name: "cleric", type: "Spell Caster", desp: "They have great healing power as a single class. Also a decent hitter, but not a good tank. They have single class spells that make themselves powerful in time (something you learn as you play). A single class cleric gets a 3x heal bonus per cast per level. Almost all players make a cleric at one time or another, so you might as well start with one too. Cleric also can get into groups fairly easy. " };
classInfo[6] = {name: "mage", type: "Spell Caster", desp: "The most powerful spell caster in the game. The worst tank without aid of protection spells. They do massive spell damage at high levels. At lower levels they tend to be weak, but can use polymorph as a tank - some even dodge. They take 1/3 less overall experience to level than monks, and if you have huge mana, then you rock! You can use a spell called power word kill to destroy giant enemies. " };
classInfo[7] = {name: "psionist", type: "Spell Caster", desp: "Worthless in any group unless you are in the taxi service. A smart psionist can use their skills to drag thousands of enemies to them for an easy kill. Without a client your fingers will wear out trying this task. It wont take you long to learn how to use them or how others do. The best thing about Psionists is the ease of leveling others, and the piles of gold they command. " };
classInfo[8] = {name: "druid", type: "Spell Caster", desp: "It is not a tank, it is not a spell caster. The odd druid uses its forms to polymorph into tough beasties. However, you can play them without the need for any equipment. Some polymorphs can poison, paralyze, or get incredible regeneration. However, they are at best above average on all scales." };
classInfo[9] = {name: "multi", type: "Flexible", desp: "<p><b>What you DON'T get when you use more than one class on a single character.</b><p><p>Thief - Garotte, handspring, reflexes, trip, and better backstab multiplier<br />Mage - Power Word Kill, ring attack, mystic link, many other pure mage spells and polymorphs<br />Cleric - 3x heal bonus, spiritual armor, and group sanc<br />Warrior - block, various worn attack forms, hnd bonus at high levels, and dual wield</p><p>It is best to remember that what they lack in these areas, they make up for with any additional classes skills and spells you add. A Multiclass character is very useful in exploring new areas and grouping due to thier versitility. Multiclass are typcially the most popular of second PC used by players.</p>" };

function getClassInfo() {
  var uclass = document.getElementById('class').value;
  for( var i=0; i < classInfo.length; i++ ) {
    if( uclass == classInfo[i].name ) {
      var info = "<img src=\"images/" + classInfo[i].name + ".jpg\" alt=\"" +  classInfo[i].name + "\" align=\"right\" vspace=\"5\" hspace=\"5\">";
      info += "<b>Type: </b>" + classInfo[i].type + "<br />";
      info += "<b>Description:</b> " + classInfo[i].desp;
      document.getElementById('info').innerHTML = info;
      break;
    }
  }
}

var raceInfo = new Array();
raceInfo[0] = {name: "dwarves", str: "18/99", int: "18", wis: "18", dex: "17", con: "19", desp: "Shorter, less movement, infravision, more HP gain per tick.", special: "+3dam vs large opponents. Takes -2 damage from large opponents."};
raceInfo[1] = {name: "elves", str: "18/75", int: "19", wis: "18", dex: "19", con: "17", desp: "Taller, more movement, numerous racial hatreds, good at track.", special: "Regenerates 10-20 more mana (base) a tick."};
raceInfo[2] = {name: "humans", str: "18/100", int: "18", wis: "18", dex: "18", con: "18", desp: "Average...  Fewer racial hatreds than other races.", special: "None"};
raceInfo[3] = {name: "hobbits", str: "17", int: "18", wis: "18", dex: "20", con: "18", desp: "Shortest, least movement, more dexterity, weaker.", special: "Luck roll when dodging (+dodge)"};
raceInfo[4] = {name: "gnomes", str: "18/50", int: "19", wis: "17", dex: "18", con: "18", desp: "Shorter, less movement, more intelligence less wisdom.", special: "Detect Evil & 25% chance to recover from lost concentration."};
raceInfo[5] = {name: "halfgiant", str: "20", int: "16", wis: "16", dex: "17", con: "20", desp: "Tallest, most movement, more strength, less intelligence.", special: "Much more effective bashing."};
raceInfo[6] = {name: "halforc", str: "19", int: "16", wis: "17", dex: "17", con: "19", desp: "Strong, less intelligence, less widom. Infravision.", special: "Higher chance to get double damage or critical hits against opponent."};
raceInfo[7] = {name: "drow", str: "18/75", int: "19", wis: "18", dex: "19", con: "17", desp: "Evil Cousin of Elves. Infravision, high dexterity.", special: "Improved sight. True Sight + Infravision + Ability to see sneaking/hiding foes."};
raceInfo[8] = {name: "troll", str: "18/100", int: "18", wis: "16", dex: "17", con: "18", desp: "Incredibly high regeneration. Takes more damage from fire.", special: "The dumber they are, the more they can regenerate hit points."};

function getRaceInfo() {
  var race = document.getElementById('race').value;
  for( var i=0; i < raceInfo.length; i++ ) {
    if( race == raceInfo[i].name ) {
      var info = "<img src=\"images/" + raceInfo[i].name + ".gif\" alt=\"" +  raceInfo[i].name + "\" align=\"right\" vspace=\"5\" hspace=\"5\">";
      info += "<b>Max Attribute:</b> Str " + raceInfo[i].str;
      info += " Int " + raceInfo[i].int; 
      info += " Wis " + raceInfo[i].wis; 
      info += " Dex " + raceInfo[i].dex; 
      info += " Con " + raceInfo[i].con + "<br />";                   
      info += "<b>Description:</b> " + raceInfo[i].desp + "<br />";
      info += "<b>Special Ability:</b> " + raceInfo[i].special + "<br />";
      document.getElementById('info').innerHTML = info;
      break;
    }
  }
}



