var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;

var origWidth, origHeight;

if (nodyn) { event = "nope" }

var tipFollowMouse= true;	
var tipWidth= 550;
var offX= 20;	// how far from mouse to show tip
var offY= 12; 
var tipFontFamily= "Trebuchet MS";
var tipFontSize= "10.5pt";
// set default text color and background color for tooltip here
// individual tooltips can have their own (set in messages arrays) but don't have to
var tipFontColor= "#f8ff36";
var tipBgColor= "#7a1c1f"; 
var tipBorderColor= "#000080";
var tipBorderWidth= 4;
var tipBorderStyle= "ridge";
var tipPadding= 4;

// tooltip content goes here (image, description, optional bgColor, optional textcolor)
var messages = new Array();
messages[0] = new Array('You can connect at "play.theforsakenlands.org" (which is IP 216.136.9.8) and port number "1848".');
messages[1] = new Array('A client is the software that you will use to connect to and interact with the game. There are many clients that are available, all varying in complexity and style. Most people generally find a client they find easy to use that has a range of functional capabilities as well (Aliases/Macros/Triggers/Logging). I would recommend MUSHclient to start out with. It is simple to start with originally, and also has more advanced features (and programmability) that can be utilized in time.');
messages[2] = new Array('Roleplay is when you, as a player, try to immerse yourself in the world in which your character is living. Think like your character would think, act like your character would act, and in general behave as though you were your character instead of you. Roleplay will be much more rewarding and enjoyable if you think up something different rather than just reflecting your own personality through your character. Forsaken Lands is a "Roleplay Enforced" game. That means that at all times you need to maintain roleplay to a modicum degree. You are required to stay "In Character" at all times within the game unless you are told otherwise by an Immortal. However much you want to roleplay beyond that is up to you. My advice would be to involve yourself in your character: your experience will be more fun that way.');
messages[3] = new Array('Player-Killing (PK for short) is a core aspect of the game. While FL is not designed to be a "hack-and-slash" MUD, it is meant to be a dangerous world where you need to remain vigilant to survive. Essentially, characters in the game are allowed to kill other characters within the game in addition to mobs and creatures. PK is not meant to be random, and there needs to be a viable roleplay reason to explain why one character would kill another.');
messages[4] = new Array('There is no "best" or "strongest" race/class combination for your character. Any combination you choose will have both strengths and weaknesses. Certain races/classes have other bane races/classes that they are supposed to have a hard time against. Conversely, they also have other race/classes that they will have the advantage against.');
messages[5] = new Array('The best place to get questions answered in detail is on the Forums. However, within the game you can use the Newbie Channel, in-game help files ("help ____"), or ask another player.');
messages[6] = new Array('When you roll for stats at creation, you should start by getting a decent roll. What is a decent roll? Well, to start out, I would aim for a number no less than 48. The first thing you will want to do after that is add as many points to Constitution (CON) as you can. The CON stat will determine how many Health Points (HP) you gain when you raise a level. After that, you should try to get 18 in INT and WIS respectively, as these will determine how much mana you gain each level. I would then split the remaining points between STR and DEX. These two stats are important, but they don\'t directly influence gain, and you can max them later.');
messages[7] = new Array('You can do that using the "score" command.');
messages[8] = new Array('You can communicate with other characters in the game using a variety of methods. The most common ones are "say" and "tell". There is also a Newbie Channel that can be accessed while you are below 15 (if you want to continue to use it, you can request to do so. It is the only "OOC" channel inThere is also a note system within FL that is essentially a postal system.');
messages[9] = new Array('If you are below level 10, you can use the recall command to return yourself to your home temple. If you are above level 10, your best course of action is to ask someone for help using tells. Once you reach level 25 or so, it is also a good idea to keep a few recall potions with you, so you can quaff them to return to your temple if you get lost. Ask around to find out where to get them.');
messages[10] = new Array('You don\'t need to "get" skills and spells per se. Each class has a standard base set of skills that will become available to them as they gain levels. Sometimes you are offered the option of selecting between different skills. You can see what skills/spells you have using the "skill" and "spell" commands.');
messages[11] = new Array('In order to use skills/spells, you will first need to practice them. Once you have practiced them (you will want to put 2-3 practices into each until it says "You are learned at X") you are ready to use them. In order to see their purpose and the syntax for using them, check the help files in game. (Type "help <skill/spell name>")');
messages[12] = new Array('There are a ton of variables that determine your accuracy, and how much damage you make when you hit something. However, two key components are Hitroll and Damroll.');
messages[13] = new Array('The Immortals are the staff members that run the game. They are responsible for general upkeep, building new areas, updating and adding to the code, and interacting with the players. Each cabal is also lead by an immortal. There are varying levels within the immortal hierarchy (52-60), with the higher level immortals generally being more experienced. The Immortals also roleplay as gods within the game, so if you interact with one stay "In Character" (maintain roleplay) unless otherwise directed. The staff members are volunteers and you should always show them respect for the time and service they provide.');
messages[14] = new Array('A Cabal is an organization of individuals which has a specific goal, agenda, and exotic powers granted to them by the Immortals. They offer a chance for deeper, more advanced role-play, new friends, opportunity to ascend in cabal ranks and gain respect, power, and loyalty of their members. The Cabals of Forsaken Lands are, for the most part, player controlled, from inducting new members, to forming alliances or declaring vendettas against other cabals. Your chances for induction and future possibilities in them, are dictated solely by your relationship with its members and their opinion of you.');
messages[15] = new Array('Before anyone can join a cabal, they must be a member of the clan tied to that cabal. Each cabal also has a clan from which it draws new members. The clanhalls are located throughout Aabahran, many of them in the major cities. If you ask around in game they won\'t be hard to locate. You must first join the clan. Once you have advanced to a degree within the clan, you will be given the opportunity to apply to the cabal. The clanmaster will give out clan quests which will reward you with Clan Points if you succeed. Accumulating these (ie doing the quests) are a good way to advance. In addition, you should talk with your fellow clanmembers, and make sure you abide by the clans principles and goal.');
messages[16] = new Array('There are certain tasks that can be done within the game that will challenge your character and, if you succeed, offer rewards. At the lower levels, you can get quests from your guild master. As you gain ranks, certain mobs or creatures will offer you rewards if you will complete tasks or favors for them. Keep in mind that not all quests are meant to be done alone, and be wary of tackling more than you can handle.');

// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
var startStr = '<table width="' + tipWidth + '"><tr><td align="center" width="100%"><img src="';
var midStr = '" border="0"></td></tr><tr><td valign="top">';
var endStr = '</td></tr></table>';
var tooltip, tipcss;
function initTip() {
	if (nodyn) return;
	tooltip = (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = tooltip.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tipcss.width = tipWidth+"px";
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
	}
	if (tooltip&&tipFollowMouse) {
		document.onmousemove = trackMouse;
	}
}
window.onload = initTip;
var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
function doTooltip(evt,num) {
	if (!tooltip) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	// set colors if included in messages array
	if (messages[num][1])	var curBgColor = messages[num][1];
	else curBgColor = tipBgColor;
	if (messages[num][2])	var curFontColor = messages[num][2];
	else curFontColor = tipFontColor;
	if (ie4||ie5||ns5) {
		var tip = '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][0] + '</span>'; //+ endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}
var mouseX, mouseY;
function trackMouse(evt) {
	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
	mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	if (tipOn) positionTip(evt);
}
function positionTip(evt) {
	if (!tipFollowMouse) {
		standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
		mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	}
	// tooltip width and height
	var tpWd = (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	// document area in view (subtract scrollbar width for ns)
	var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
	var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
	// check mouse position against tip and window dimensions
	// and position the tooltip 
	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = mouseX-(tpWd+offX)+"px";
	else tipcss.left = mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = winHt-(tpHt+offY)+"px";
	else tipcss.top = mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}
function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}

document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>')
