/* IMPORTANT: Put script after toolimg div or 
	 put toolimg 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 toolimg 
// Do you want img to move when mouse moves over link?
var imgFollowMouse= true;	
// Be sure to set imgWidth wide enough for widest image
var imgWidth= 0;
var offX= 15;	// how far from mouse to show img
var offY= 10; 
var imgFontFamily= "Verdana, arial, helvetica, sans-serif";
var imgFontSize= "8pt";
// set default text color and background color for toolimg here
// individual toolimgs can have their own (set in messages arrays)
// but don't have to
var imgFontColor= "#000000";
var imgBgColor= "#DDECFF"; 
var imgBorderColor= "#9AC1DA";
var imgBorderWidth= 0;
var imgBorderStyle= "ridge";
var imgPadding= 0;

// toolimg content goes here (image, description, optional bgColor, optional textcolor)
var messages = new Array();
// multi-dimensional arrays containing: 
// image and text for toolimg
// optional: bgColor and color to be sent to toolimg
messages[0] = new Array('s-btn.jpg','',"#FFFFFF");
messages[1] = new Array('../images/CustomizableScreen.gif','',"#FFFFFF");
messages[2] = new Array('../images/RTimeCharts.gif','',"#FFFFFF");
messages[3] = new Array('../images/ChartStudies.gif','',"#FFFFFF");
messages[4] = new Array('../images/DrawingTool.gif','',"#FFFFFF");
messages[5] = new Array('../images/TradeFromChart.gif','',"#FFFFFF");
messages[6] = new Array('../images/TradingPad.gif','',"#FFFFFF");
messages[7] = new Array('../images/OrderEntryWindow.gif','',"#FFFFFF");
messages[8] = new Array('images/iRunner.gif','',"#FFFFFF");
messages[9] = new Array('images/SRPlatform.gif','',"#FFFFFF");
messages[10] = new Array('../images/iRunner.gif','',"#FFFFFF");
messages[11] = new Array('../images/WinRunner.gif','',"#FFFFFF");
messages[12] = new Array('../images/tr_screen.jpg','',"#FFFFFF");

////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

// preload images that are to appear in toolimg
// 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 img in doToolimg function
// startStr goes before image, midStr goes between image and text
var startStr = '<table width="' + imgWidth + '"><tr><td align="center" width="100%"><img src="';
var midStr = '" border="0"></td></tr><tr><td valign="top">';
var endStr = '</td></tr></table>';

////////////////////////////////////////////////////////////
//  initImg	- initialization for toolimg.
//		Global variables for toolimg. 
//		Set styles
//		Set up mousemove capture if imgFollowMouse set true.
////////////////////////////////////////////////////////////
var toolimg, imgcss;
function initImg() {
	if (nodyn) return;
	toolimg = (ie4)? document.all['imgDiv']: (ie5||ns5)? document.getElementById('imgDiv'): null;
	imgcss = toolimg.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		imgcss.width = imgWidth+"px";
		imgcss.fontFamily = imgFontFamily;
		imgcss.fontSize = imgFontSize;
		imgcss.color = imgFontColor;
		imgcss.backgroundColor = imgBgColor;
		imgcss.borderColor = imgBorderColor;
		imgcss.borderWidth = imgBorderWidth+"px";
		imgcss.paddingTop = imgPadding+"px";
		
		imgcss.borderStyle = imgBorderStyle;
	}
	if (toolimg&&imgFollowMouse) {
		document.onmousemove = trackMouse;
	}
}

window.onload = initImg;

/////////////////////////////////////////////////
//  doToolimg function
//			Assembles content for toolimg and writes 
//			it to imgDiv
/////////////////////////////////////////////////
var t1,t2;	// for setTimeouts
var imgOn = false;	// check if over toolimg link
function doToolImg(evt,num) {
	if (!toolimg) return;
	//alert("hello");
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	imgOn = true;
	// set colors if included in messages array
	if (messages[num][2])	var curBgColor = messages[num][2];
	else curBgColor = imgBgColor;
	if (messages[num][3])	var curFontColor = messages[num][3];
	else curFontColor = imgFontColor;
	if (ie4||ie5||ns5) {
		var img = startStr + messages[num][0] + midStr + '<span style="font-family:' + imgFontFamily + '; font-size:' + imgFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		
		imgcss.backgroundColor = curBgColor;
		
	 	toolimg.innerHTML = img;
		//alert(img);
	}
	if (!imgFollowMouse) positionImg(evt);
	else t1=setTimeout("imgcss.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 (imgOn) positionImg(evt);
}

/////////////////////////////////////////////////////////////
//  positionImg function
//		If imgFollowMouse set false, so trackMouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position, 
//		offset amounts and toolimg width to position
//		toolimg within window.
/////////////////////////////////////////////////////////////
function positionImg(evt) {
	if (!imgFollowMouse) {
		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;
	}
	// toolimg width and height
	var tpWd = (ie4||ie5)? toolimg.clientWidth: toolimg.offsetWidth;
	var tpHt = (ie4||ie5)? toolimg.clientHeight: toolimg.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 img and window dimensions
	// and position the toolimg 
	if ((mouseX+offX+tpWd)>winWd) 
		imgcss.left = mouseX-(tpWd+offX)+"px";
	else imgcss.left = mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		imgcss.top = winHt-(tpHt+offY)+"px";
	else imgcss.top = mouseY+offY+"px";
	if (!imgFollowMouse) t1=setTimeout("imgcss.visibility='visible'",100);
}

function hideImg() {
	//alert("hello");
	if (!toolimg) {
		//alert("test");
		return;
	
	}
	//alert("test");
	t2=setTimeout("imgcss.visibility='hidden'",100);
	imgOn = false;
}

document.write('<div id="imgDiv" style="position:absolute; visibility:hidden; z-index:100"></div>')

