// holtp-16.js  -  5'09-11-09
// This is the HOLd toolTiP.JavaScript file.

// Goes at bottom of BANER.HTM  (does not use Section 3 universal messages)
//               and X1MAI.HTM  (  does   use Section 3 universal messages)

// It actually includes only 1 script:

//   Script #1  - - - - - -  not included in this file  - - - - - -
//   Script #2  (  also   holtp.js)  which means "HOLd toolTiP"
//   Script #3  - - - - - -  not included in this file  - - - - - -
//   Script #4  - - - - - -  not included in this file  - - - - - -
//   Script #5  - - - - - -  not included in this file  - - - - - -

// *****  If you ever alter this file at all, please see SCRIPTS.NTE 
//        & make sure that STDFT, NOHOT, & HOLTP are all synchronized.

//////////////////////////////////////////////////////////////////////

// Script #2  (also individually as holtp.js)  meaning "HOLd toolTiP"
// It sets up the holdtip boxes and initially assigns text-content
//   for the first 11 messages  (#s 0-10).  It requires an additional
//   script of "Section 3" messages in each ??mai.htm file

/////  Section 1 of 7  -  copyright  /////////////////////////////////

// This code is from Dynamic Web Coding www.dyn-web.com 
// Copyright 2002 by Sharon Paine Permission granted to use this code as long as this entire notice is included.
// Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/

/////  Section 2 of 7  -  vars  //////////////////////////////////////

var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;
var origWidth, origHeight;
var tipFollowMouse      = true; 
var tipWidth            = 160;  // 160 was Sharon's original pixel width
var curTipWidth         = tipWidth // in case no tipWidth set in array 
var offX                = 12;   // how far from mouse to show tip
var offY                = 12; 
var tipFontFamily       = "Verdana, arial, helvetica, sans-serif";
var tipFontSize         = "8pt";
var tipFontColor        = "#000000"; // black
	     // For possible background color
	     //             DDECFF = a pale blue
	     //             A0A0A0 = a too-dark grey
	     //             FFFFDD = very pale yellow  (acceptable, but)
	     //             FFFFCC = pale yellow  (excellent!)
	     //             EEFFEE = pale green   (great!)
	     //   Maybe use the very pale yellow as the standard for the
	     //     footnotes (without graphics), but use the (darker)
	     //     pale yellow as a background for picture captions.
	     //   I think that'll work.  --  We'll see.
	     //   0'11-28-04 (ver -06) changed default bgColor
	     //     from very pale yellow to pale green
var tipBgColor          = "#EEFFEE";  // pale green
var origBgColor         = tipBgColor; // in case no bgColor set in array
	     // For possible border color
	     //             0000FF = blue  (no, this is a link indicator)
	     //             00CC00 = pale green  (too light)
	     //             008000 = green  (excellent!)
var tipBorderColor      = "#008000";
var origBorderColor     = tipBorderColor; // if no BorderColor set in array
var tipBorderWidth      = 3;
var tipBorderStyle      = "solid";
var tipPadding          = 1;
var t1,t2;              // for setTimeouts
var tipOn = false;      // check if over tooltip link
var tooltip, tipcss;
var mouseX, mouseY;
var startStr =   '<table width="' + curTipWidth +'"><tr><td align="center" width="100%"><img src="';
var startStr13 = '<table width="';
var startStr23 = '<tr><td align="center" width="100%"><img src="';
var startStr33 = '" border="0"></td></tr>';
var midStr = '<tr><td valign="top">';
var endStr = '</td></tr></table>';
var messages = new Array();

/////  Section 3 of 7  -  messages array data  ///////////////////////

//       There are 8 of them (#0-7)
//         7 styles:  xin, maj, lnk, geo, def, acr, pic
//                     1    0    1    6    0    0    0

//BOY
messages[0] = new Array("", // geo
'<center>Home of the Boyertown<br>Museum of Historic Vehicles<br>&#149;&#149;&#149;<br>35 miles NW of Philadelphia</center>',
"197"); // med width

//RTC
messages[1] = new Array("", // lnk
'<center>&nbsp;Returns to Contents&nbsp;<br>Table for this page<center>',
"170","DDECFF","black","blue"); // med width

//PEN1 (part 1 of mess#3)
messages[2] = new Array("", // geo
"<center>Part 1 of 2</center><br>&nbsp;<b>Pennsylvania</b> is a medium-sized, heavily<br>&nbsp;&nbsp;&nbsp;&nbsp;populated, state in the northeastern<br>&nbsp;&nbsp;&nbsp;&nbsp;region of the United States of America.<br><br>&nbsp;Among its major industries are agriculture,<br>&nbsp;&nbsp;&nbsp;&nbsp;tourism, production of steel, machinery,<br>&nbsp;&nbsp;&nbsp;&nbsp;chemicals, computer components, cars,<br>&nbsp;&nbsp;&nbsp;&nbsp;crayons, and Hershey's chocolate.<br><br>&nbsp;It is neighbored by 6 other similar states:<br>&nbsp;&nbsp;&nbsp;&nbsp;New York, New Jersey, Delaware,<br>&nbsp;&nbsp;&nbsp;&nbsp;Maryland, West Virginia, and Ohio.<br><br>&nbsp;<b>Pennsylvania</b>'s name means &quot;<font id=vb>Penn's<br>&nbsp;&nbsp;&nbsp;&nbsp;woods</font>&quot;, as the 45,333 square miles of<br>&nbsp;&nbsp;&nbsp;&nbsp;heavily forested land was granted to<br>&nbsp;&nbsp;&nbsp;&nbsp;<font id=vb>William Penn</font> (1644-1718) by King<br>&nbsp;&nbsp;&nbsp;&nbsp;Charles II of England, in <font id=ab>1681</font>.<br><br><center>(move mouse right for Part 2)</center>",
"260"); // wide

//PEN2 (part 2 of mess#2)
messages[3] = new Array("", // geo
'<center>(move mouse left for Part 1)<br><br>This is Part 2 of 2</center><br>&nbsp;No other state in America holds so many<br>&nbsp;&nbsp;&nbsp;&nbsp;historic sites as <b>Pennsylvania</b> &nbsp;&ndash;&nbsp; plus,<br>&nbsp;&nbsp;&nbsp;&nbsp;it has 260 universities and colleges, and<br>&nbsp;&nbsp;&nbsp;&nbsp;is the birthplace of Perry Como, Jimmy<br>&nbsp;&nbsp;&nbsp;&nbsp;Stewart, Gene Kelly, Mister Rogers, the<br>&nbsp;&nbsp;&nbsp;&nbsp;Dorsey brothers, and Punxsutawney Phil.<br><br>&nbsp;The capital of <b>Pennsylvania</b> is Harrisburg,<br>&nbsp;&nbsp;&nbsp;&nbsp;a town of about 48,000, situated along<br>&nbsp;&nbsp;&nbsp;&nbsp;the Susquehanna River&nbsp;<br><br>&nbsp;&#149;&nbsp;&nbsp;157 miles west of New York City&nbsp;<br>&nbsp;&#149;<img src="transspc.gif" width=15 height=2>95 miles north of Washington DC&nbsp;<br>&nbsp;&#149;&nbsp;&nbsp;164 miles east of Pittsburgh PA&nbsp;<br>&nbsp;&#149;<img src="transspc.gif" width=15 height=2>94 miles WNW of Philadelphia PA&nbsp;<br>&nbsp;&#149;<img src="transspc.gif" width=15 height=2>66 miles west of <font id=vb>Boyertown Museum</font><br><br><center>(move mouse left for Part 1)</center>',
"260"); // wide

//BER
messages[4] = new Array("", // geo
"<center><b>Berks County</b>, founded in <font id=ab>1752</font>, is the 9th most populous of the 67 counties in the state of <font id=vb>Pennsylvania</font>.&nbsp;&nbsp; The <font id=ab>2000</font> census put the population of the 864 square miles of <b>Berks County</b> at 373,638 &nbsp;&ndash;&nbsp; up 11% from <font id=ab>1990</font>.<br>&#149;&#149;&#149;<br>Of the 8 counties in <font id=vb>Pennsylvania</font> with a greater population, three of them border <b>Berks</b> to the south and east:&nbsp; Lancaster, Chester, and Montgomery Counties.<br>Other bordering counties are<br>Lebanon, Schuylkill, & Lehigh.<br>&#149;&#149;&#149;<br>The <b>Berks County</b> seat is <font id=vb>Reading</font> (pronounced &quot;Redding&quot;), a city of about 81,000 people, probably best known as<br>the home of the Reading Railroad, which,<br>in the <font id=ab>1870's</font>, was the largest corporation<br>in the world, and since <font id=ab>1933</font>, has been immortalized on the &quot;Monopoly&quot; board.<br>&#149;&#149;&#149;<br><font id=vb>Reading</font>, <font id=vb>Pennsylvania</font>, is located<br>48 miles WNW of Philadelphia, and<br>15 miles west of the Boyertown Museum.</center>",
"270"); // max width

//REA
messages[5] = new Array("", // geo
'<center><b>Reading</b>&nbsp; (pronounced "Redding")<br>is a city of about 81,000 people,<br>probably best known as the home of<br>the <font id=vb>Reading Railroad</font>, which, in the<br><font id=ab>1870&#39;s</font>, was the largest corporation in<br>the world, and since <font id=ab>1933</font>, has been<br>immortalized on the &quot;Monopoly&quot; board.<br>&#149;&#149;&#149;<br><b>Reading</b>, <font id=vb>Pennsylvania</font>, was named in<br><font id=ab>1748</font>, by Thomas & Richard Penn (sons of<br>Pennsylvania founder, William Penn) after<br>their ancestral home of <b>Reading</b>, England,<br>which was founded in the eighth century,<br>40 miles due west of London, and today<br>has a population of about 144,000.&nbsp; &#149;&#149;&#149;&nbsp;<br><b>Reading</b>, England&#39;s, most famous current<br>resident is actress Jacqueline Bisset.<br>A past resident was author Oscar Wilde.<br>Actress Kate Winslet was born there<br>on Sunday, October 5th, <font id=ab>1975</font>.<br>&#149;&#149;&#149;<br><b>Reading</b>, <font id=vb>Pennsylvania</font>, is located<br>48 miles WNW of Philadelphia, and<br>15 miles west of the Boyertown Museum.</center>',
"264"); // wide

//PHI
messages[6] = new Array("", // geo
'<center>"<font id=vb>Philly</font>" is the nickname of the<br>Pennsylvania town of <b>Philadelphia</b>, a<br>Greek word which means, "<font id=vb>brotherly love</font>."<br>&#149;&#149;&#149;<br>The community was named by William<br>Penn, in <font id=ab>1682</font>, after the <b>Philadelphia</b> in<br>the Lydia region of Asia Minor, which was<br>mentioned twice in the Bible, in the beginning<br>of the book of Revelation.&nbsp;&nbsp; The village of<br>Alasehir, Turkey, stands on that site now.<br>&#149;&#149;&#149;<br><b>Philadelphia</b> PA, the <font id=vb>USA&#39;s first capital</font>,<br>is now its fifth largest city &nbsp;&mdash;&nbsp; behind only<br>Houston, Chicago, Los Angeles, & New York.<br>&#149;&#149;&#149;<br><b>Philadelphia</b>, <font id=vb>Pennsylvania</font> is located<br>in the northeastern region of the<br><font id=v><i>United States of America</i></font><br>in the southeastern corner of the<br>state of Pennsylvania<br>78 miles SW of New York City<img src="transspc.gif" width=27 height=2><br>126 miles NE of Washington DC<img src="transspc.gif" width=30 height=2><br>258 miles east of Pittsburgh PA<img src="transspc.gif" width=34 height=2><br><img src="transspc.gif" width=22 height=2>35 miles SE of the Boyertown Museum</center>',
"272"); // max width

//KEN
messages[7] = new Array("", // xin
'<center>Executive Director of the <b>Boyertown<br>Museum of Historic Vehicles</b>,<br>which has sponsored and produced<br>the annual <font id=vb>Duryea Day</font>, ever since<br>the Labor Day Weekend of <font id=ab>1966</font></center>',
"234"); // med width

messages[8] = new Array();
messages[9] = new Array();
messages[10] = new Array();

/*   These (#s 0-10) are just the universal messages.  An individual
       additional script of "Section 3" messages, in each file which
       calls this script, is further required, beginning with #11.  */

/////  Section 4 of 7  -  3 if statements  ///////////////////////////

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];
  }
}

if (ns4) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

if (nodyn) { event = "nope" }
	  
/////  Section 5 of 7  -  5 functions  ///////////////////////////////

function doTooltip(evt,num) {

	if (!tooltip) return;
	if (t1) clearTimeout(t1);       if (t2) clearTimeout(t2);
	tipOn = true;
	
	// set tipwidth if included in messages array
	
	if (messages[num][2])   var curTipWidth = messages[num][2];
	else curTipWidth = tipWidth;

	// set colors if included in messages array
	
	if (messages[num][3])   var curBgColor = messages[num][3];
	else curBgColor = tipBgColor;
	
	if (messages[num][4])   var curFontColor = messages[num][4];
	else curFontColor = tipFontColor;
	
	if (messages[num][5])   var curBorderColor = messages[num][5];
	else curBorderColor = tipBorderColor;

	if (ns4) {
		var tip = '<table bgcolor="' + tipBorderColor + '" width="' + curTipWidth + '" cellspacing="0" cellpadding="' + tipBorderWidth + '" border="0"><tr><td><table bgcolor="' + curBgColor + '" width="100%" cellspacing="0" cellpadding="' + tipPadding + '" border="0"><tr><td>' + startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr + '</td></tr></table></td></tr></table>';
		tooltip.write(tip);
		tooltip.close();
	} else if (ie4||ie5||ns5) {
		if (!messages[num][0]) var tip = startStr13 + curTipWidth +'">' +                                              midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		else                   var tip = startStr13 + curTipWidth +'">' + startStr23 + messages[num][0] + startStr33 + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
		tipcss.borderColor = curBorderColor;
		tooltip.innerHTML = tip;
	}

	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}

function initTip() {
	if (nodyn) return;
	tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = (ns4)? document.tipDiv: tooltip.style;
	if (ie4||ie5||ns5) {    // ns4 would lose all this on rewrites
		tipcss.width = curTipWidth+"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;
	}

// THE FOLLOWING "IF" STATEMENT IN THIS FUNCTION (initTip)
//   CONFLICTS WITH THE "IF" STATEMENT IN THE (MoveHandlerIE)
//   FUNCTION IN THE "BOUNCE01.JS" JAVASCRIPT, CAUSING
//   THE BOUNCE SCRIPT NOT TO RUN PROPERLY. 
//   THE 7 BALLS APPEAR, BUT DO NOT FOLLOW THE MOUSE.

	if (tooltip&&tipFollowMouse) {
		if (ns4) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = trackMouse;
	}
}

function trackMouse(evt) {
	mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;  // script fails if this is NOT "Left"
	mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	if (tipOn) positionTip(evt);
}

function positionTip(evt) {
	if (!tipFollowMouse) {
		mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft; // Left/Right -- seems makes no difference
		mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	}

	// tooltip width and height
	var tpWd = (ns4)? tooltip.width: (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ns4)? tooltip.height: (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;

	// document area in view (subtract scrollbar width for ns)  
	
	var winWd = (ns4||ns5)? window.innerWidth-20+window.pageXOffset: document.body.clientWidth+document.body.scrollLeft; // Left is better
	var winHt = (ns4||ns5)? window.innerHeight-20+window.pageYOffset: document.body.clientHeight+document.body.scrollTop;

	// check mouse position against tip and window dimensions

	// and position the tooltip 
	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = (ns4)? mouseX-(tpWd+offX): mouseX-(tpWd+offX)+"px";
	else tipcss.left = (ns4)? mouseX+offX: mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = (ns4)? winHt-(tpHt+offY): winHt-(tpHt+offY)+"px";
	else tipcss.top = (ns4)? mouseY+offY: mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}

/////  Section 6 of 7  -  miscellaneous  /////////////////////////////

window.onload = initTip;

/////  Section 7 of 7  -  write one line  ////////////////////////////

document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>');

/////  End of all 7 sections of Script #2  (HoldTip)  ////////////////

//  end of all 1 scripts  ////////////////////////////////////////////
