/* Roll over links version 1.0 5/2/2001 by Eric Hayes, ehayes@teamh.com */

/*
Purpose
To provide emulation in Navigator 4.x for the a:hover CSS property for a series of links on the JHIIM family of sites.
These links are almost always present in column format so there is style support for left-aligning them. The top position is specified in the HTML by the user at design time.
This module also provides an image rollover facility for the triangle icons used on some lines.
*/

//Check if we're using IE or NN
var explorer = (navigator.appName.indexOf("Explorer") != -1);

//Starting positions for columns and size of indent for indented elements. Edit these to control the left alignment of the link columns.
var col1Start = 29;
var col2Start = 224;
var col3Start = 515;
var indentSize = 23;

//Set triangle images
var triangleOn = new Image();
triangleOn.src = "/reig/images/arrow_onblue_on.gif";
var triangleOff = new Image();
triangleOff.src = "/reig/images/arrow_onblue.gif";
var currentImage = new Image();

//This is a utility function for Navigator 4 to reload the page if the window is resized.
function reloadPage() {
if (innerWidth != origWidth || innerHeight != origHeight) {
for (var i=0; i<=document.layers.length-1; i++) {
document.layers[i].visibility = "hidden";
}//closes for loop
location.reload();
} //closes if
return true;
} //closes function

if (!explorer) {
origWidth = innerWidth;
origHeight = innerHeight;
onresize = reloadPage;
}

//Set global variables
var prevLink = new Object(); //Stores a reference to the previously written to layer object
var prevLinkText = ""; //Stores the code for the off state of the previously written to layer object
var hasReset = true; //Stores the state of the previous layer object (whether it has returned to the off state or not)

/*
This writes a <style> block to the page. In this block are the link styles and positioning information for the link columns.
The top position of each link line is user-specified directly in the HTML.
*/
document.write('<style>');
document.write('a.normallink {font-family: verdana, sans-serif; font-size: 9pt; text-decoration: none;}');
document.write('a.hilitelink {font-family: verdana, sans-serif; font-size: 9pt; text-decoration: underline;}');
document.write('.bodybold {width: 450px;}');
if (explorer) document.write('a:hover {text-decoration: underline;}');
document.write('.rolink {width: 400px; position: absolute; top: -2px; left: 13px;}');
document.write('.col1normal {font-weight: normal; position: absolute; left: ' + (col1Start + 3) + 'px;}');
document.write('.col1 {font-weight: bold; position: absolute; left: ' + col1Start + 'px;}');
document.write('.col1in {position: absolute; left: ' + (col1Start + indentSize) + 'px;}');
document.write('.col2 {font-weight: bold; position: absolute; left: ' + col2Start + 'px;}');
document.write('.col2in {position: absolute; left: ' + (col2Start + indentSize) + 'px;}');
document.write('.col2in2 {position: absolute; left: ' + (col2Start + (indentSize * 2)) + 'px;}'); //Specific to GSFP - adds a second indent to the second column
document.write('.col3 {font-weight: bold; position: absolute; left: ' + col3Start + 'px;}');
document.write('.col3in {position: absolute; left: ' + (col3Start + indentSize) + 'px;}');
document.write('</style>');

/*
Toggles the underline effect on and sets the triangle image on. For IE, only set the image, the a:hover style specified above controls the underlining. In Navigator, first check to see if the previous link has been reset to the off state. Navigator sometimes doesn't fire the mouseout event to make this happen. If it has not reset, force a reset with a call to writeLayer() specifying "true" to the resetTriangle parameter.

Then, compose the new HTML for the current link layer - that's stored in "rollOverText." Next, compose the HTML that will be restored to the layer when the user mouses out of it - that's stored in "prevLinkText." Next, retrieve a reference to the layer to which we want to write the new code and at the same time store that reference as the previous layer in "prevLink." Finally, toggle the current triangle image to the "on" state and call "writeLayer()" to actually place the code into the target layer.
*/

function linkOn(linkHref,linkText,seqRef) {

var layerRef = "hlink" + seqRef; //In the HTML the outer layer and the triangle image share the same name - "hlink" + some number

if (explorer) {
document.images[layerRef].src = triangleOn.src; //Set triangle image on.
currentImage = document.images[layerRef]; //Store reference to image for the linkOff() function.
} //closes if

else { //if Navigator
var rollOverText = "";
var currentLayer = new Object();

if (!hasReset) writeLayer(prevLink,prevLinkText,true);
hasReset = false;

rollOverText = '<a onmouseout="linkOff()" class="hilitelink" href="' + linkHref + '">' + linkText + '</a>';
prevLinkText = '<a onmouseover="linkOn(this.href,\'' + linkText + '\',\'' + seqRef + '\')" class="normallink" href="' + linkHref + '">' + linkText + '</a>';
currentLayer = prevLink = eval("document.layers[layerRef].document.layers[0].document.rolink" + seqRef + ".document");
currentImage = document.layers[layerRef].document.layers[0].document.images[layerRef];
currentImage.src = triangleOn.src;
writeLayer(currentLayer,rollOverText,false);
} //closes else
return true;
} //closes function

/*
Toggles the underline effect off and sets the triangle image off. In IE only the image is toggled - the underline is removed automatically based on the style sheet.
In Navigator all this function does is restore the previous HTML to the previous link layer. It then sets the "hasReset" variable to true. This is tested in the linkOn() function.
*/
function linkOff() {
if (explorer) {
currentImage.src = triangleOff.src;
} //closes explorer if
else {
writeLayer(prevLink,prevLinkText,true);
hasReset = true;
} //closes else
return true;
} //closes function

/*
Navigator only. You pass it a reference to a layer's document, the code to write to that document and whether or not to set the triangle to the off state.
If you pass in "true" as resetTriangle the triangle image embedded in the previous layer is set to off.
*/
function writeLayer(layerRef,codeToWrite,resetTriangle) {
layerRef.open();
layerRef.write(codeToWrite);
layerRef.close();
if (resetTriangle) currentImage.src = triangleOff.src;
return true;
} //closes function