/***********************************************
* Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com)
* Copyright 2002-2007 by Sharon Paine
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* IMPORTANT: Put script after tooltip div or 
	 put tooltip div just before </BODY>. */

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;

// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }

///////////////////////  CUSTOMIZE HERE   ////////////////////
// settings for tooltip 
// Do you want tip to move when mouse moves over link?
var tipFollowMouse= true;	
// Be sure to set tipWidth wide enough for widest image
var tipWidth= 408;
var offX= 20;	// how far from mouse to show tip
var offY= 12; 
var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
var tipFontSize= "8pt";
// 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= "#000000";
var tipBgColor= "#DDECFF"; 
var tipBorderColor= "#000080";
var tipBorderWidth= 0;
var tipBorderStyle= "ridge";
var tipPadding= 0;

// tooltip content goes here (image, description, optional bgColor, optional textcolor)
var messages = new Array();
// multi-dimensional arrays containing: 
// image and text for tooltip
// optional: bgColor and color to be sent to tooltip
messages[0] = new Array('images/screenshot_trsearch.org.gif','Lots of custom objects made by level builders are hosted and reviewed here.');
messages[1] = new Array('images/screenshot_trle.net.gif','Biggest website with custom levels and an excellent review and walkthrough system. You can also upload and publish your own custom level here.');
messages[2] = new Array('images/screenshot_ngle.jpg','This Next Generation Level Editor and Game Engine is the door to a whole new Universe of level building.');
messages[3] = new Array('images/screenshot_bremse.jpg','Nice little tool that slows down your CPU and stops the Level Editor from spinning out of control.  Simple to use and you can even turn it off without having to exit the programme (Aus is Off - An is On).  I find a setting somewhere between 65 and 70, depending on the mood of my PC, does the job nicely.');
messages[4] = new Array('images/screenshot_cdaudiowadplayer.jpg','Cdaudio.wad player is a powerful editor for the cdaudio.wad file included with the Tomb Raider III Game. It also has some support for Tr4/TRc external wave files. Cdaudio.wad is a collection of WAV files embedded in one big file and used for soundtracks in the game. Cdaudio Tool let you extract individual Wavs from this file and add your own custom WAVs, so you can give new ambience to your custom levels. Full instructions included.');
messages[5] = new Array('images/screenshot_dxtre3d.jpg','Dxtre3d is an unofficial Tomb Raider Level Editor that will build new Tomb Raider level files in Phd, Tr2, Tr3, Tr4, and Trc formats.  The full package also includes a PDF manual, some demo projects, LNG editor for translate interface to foreign language, some textures files, and some LNG files. For more information and tutorials on this editor, and for downloads to other programmes which can be used with it, please visit Turbo Pascal&rsquo;s web site: http://www.dxtre3d.com');
messages[6] = new Array('images/screenshot_fexinspect2.jpg','Fexinspect allow to open and inspect compiled Tomb Raider levels files from Tomb Raiders 1 through 5.  If you need to understand how something was set up in the original games, you can find the information using this programme.  You can revise how objects are placed and are setup, how things are triggered and what options are used, etc.');
messages[7] = new Array('images/screenshot_meta.jpg','Metasequoia is a polygon modeller for 3DCG and game development. It provides you with an efficient modelling programme and is easy to learn. Even beginners to 3DCG should be able to pick up the rudiments and master the programme. It runs on Microsoft Windows only. This is the latest shareware version, but it doesn&rsquo;t permit you to export dxf files.<br><br>There is an older freeware version of Meta (R2.3b-2) which allows you to export dxf files, but it does not support Vista.');
messages[8] = new Array('images/screenshot_prjmerge.jpg','Fabulous little tool that is absolutely indispensable, especially in Team Projects.  With this tool you can merge 2 prj maps together.  In team projects this makes setting up level jumps an incredibly easy task as level builders can swap prj files with each other and simply merge them into their own maps.  Of course, always back up your files before attempting a merge, particularly if your level is already pushing limits.');
messages[9] = new Array('images/screenshot_rview.jpg','RVew is a program that allows you to open Tomb Raider levels and shows you each room fully textured. You can import/export the rooms in a DXF file format so you can edit them in a CAD program.  This version has been updated by Iceberg to run on XP.');
messages[10] = new Array('images/screenshot_screamer.gif','A tool that allows you to create a new sounds.txt and output new .sam and .sfx files (sound files) for your wad. You can use it to create a new sounds.txt file for a single object or for a complete wad. It will allow you to add custom samples to an object. It requires the J2RE 1.4 (Java 2 Runtime Environment) for your system.');
messages[11] = new Array('images/screenshot_SFXman01.gif','SFX Manager will fix sound bugs in wads. Requires the same runtimes as Wadmerger. For more information, see the Author&rsquo;s website:  http://pascal.larashome.com/Tools.htm');
messages[12] = new Array('images/screenshot_soundjack.jpg','Nice little tool which will extract the audio files from your TR3 game CDs and save them in WAV format for you. The programme will run fine on XP when set in compatibility mode for Windows 95. ');
messages[13] = new Array('images/screenshot_strpix.gif','Object editing and texturing tool of the "absolutely can&rsquo;t live without" type.');
messages[14] = new Array('images/screenshot_levelmanager.gif','The Tomb Raider Level Manager will install and play all your Tomb Raider custom levels at the click of a button. But this is only scratching the surface of its capabilities. It does require careful setup when first installing and running, particularly if you are a level builder, so make sure you read the instructions and follow the tutorials. Once you have this programme setup properly, you will never be without it again.<br><br>This version is in English, but there are other language formats available (Italian, Dutch, German, Chinese, French and Spanish). For more information on these, for installation instructions and tutorials, please visit Paolo&rsquo;s TR Level Manager web site:  http://www.trlevelmanager.it');
messages[15] = new Array('images/screenshot_tombripper.gif','A nice audio ripping tool which works fine with XP. Clicking on the file plays the track and you can save them. Very handy. The download includes the VB6 runtimes in case you need them. ');
messages[16] = new Array('images/screenshot_tr2wad.jpg','TR2wad will rip objects, textures and sound samples from TR4 files. Nice tool that will work fine on XP running in Win98 compatibility mode.');
messages[17] = new Array('images/screenshot_tbuilderv2.4r1.gif','Brilliant tool that will take care of all your texture set building needs and a lot more. This latest version has had the number of vertical pages increased from 32 to 64 to handle more 128x128 texture space when using the NGLE.');
messages[18] = new Array('images/screenshot_TR2Prj.gif','This is the latest, XP compatible, version of this brilliant little tool by Aktrekker. The programme will copy rooms and textures from the DATA files of Tomb Raider games and save them into a Prj file. It doesn&rsquo;t give you a perfect copy in every detail, obviously, but it will give you the basic geometry. ');
messages[19] = new Array('images/screenshot_trcustomscreens.gif','This nice little programme will read the *.PAK logos in the TR4 and TR5 cdroms, or the level screens packaged inside the SCREEN.STR in the TR5 cdrom. It will even open your *.raw files and save them in the correct format.');
messages[20] = new Array('images/screenshot_trfix1.jpg','Another indispensable tool from the amazing Aktrekker. If your PRJ file is giving you serious problems or won&rsquo;t even open, this may very well fix it for you. Worked for me and saved a broken level and hours of frustration. Works on XP too. There are a few issues with it, like phantom triggers being scattered around the level (which will disappear when you output the WAD) but as a last resort to save what would otherwise be a ruined level, this can be a real life saver. Instructions on how to use this tool included by Aktrekker in the download.');
messages[21] = new Array('images/screenshot_wadmerger.jpg','WADMerger is a tool to edit wad files. You can copy objects with it from other wad files and tr levels. Using the build in ai and animation editor you can create new enemies or extract enemies from other tr games. You can also change sprites to change the rope texture or water bubbles. Needs VB6 Runtimes installed.<br><br>Notice: this is the beta release, some new features are still unfinished or not documentated.');
messages[22] = new Array('images/screenshot_trep.gif','TREP is a small open-source  utility which modifies Tomb Raider 4 engine (tomb4.exe file) used for playing custom levels built with TRLE and DXTre3d. This utility allows you to change various hardcoded parameters, modify object and trigger behaviour, add new gameplay features, create your own custom flipeffects, timed events and patches and then share them with all TR community.<br><br>Now TREP also allows you to modify major TR4 engine parameters on the fly, using add-on script file, as well as create your own script entries of any type for per-level parameter modifying. All in all, with TREP you can do many things which were not possible with default, unmodified TR4 engine.');

////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

// preload images that are to appear in tooltip
// from arrays above
if (document.images) {
	var theImgs = new Array();
	for (var i=0; i<messages.length; i++) {
  	theImgs[i] = new Image();
		theImgs[i].src = messages[i][0];
  }
}

// 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>';

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip. 
//		Set styles
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
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;

/////////////////////////////////////////////////
//  doTooltip function
//			Assembles content for tooltip and writes 
//			it to tipDiv
/////////////////////////////////////////////////
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][2])	var curBgColor = messages[num][2];
	else curBgColor = tipBgColor;
	if (messages[num][3])	var curFontColor = messages[num][3];
	else curFontColor = tipFontColor;
	if (ie4||ie5||ns5) {
		var tip = '<table cellspacing="5" class="tooltip" width="' + tipWidth + '"><tr><td valign="top"><span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span></td></tr><tr><td align="center" width="100%"><img src="' + messages[num][0] + '" border="0"></td></tr></table>';
		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);
}

/////////////////////////////////////////////////////////////
//  positionTip function
//		If tipFollowMouse set false, so trackMouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position, 
//		offset amounts and tooltip width to position
//		tooltip within window.
/////////////////////////////////////////////////////////////
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>')