/*************************************************************************
* Yale University School of Medicine, New Haven, Connecticut, USA        *        
* All contents copyright (C) 1997 Yale University. All rights reserved.  *
* Yale Center for Advanced Instructional Media  carl.jaffe@yale.edu      *
* patrick.lynch@yale.edu  phillip.simon@yale.edu   sean.jackson@yale.edu *
* Yale CAIM, 47 College Street Suite 224, New Haven, CT 06510, USA       *
* URL:http://info.med.yale.edu/caim/                                     *
*************************************************************************/

/*********************************************************
*              HHMI SPECIFIC CODE                        *
*********************************************************/                

/***********************************************************
 **********************************************************
*        HHMI DIRT (Dynamic image rollover thingy)         *
*        Speciffically modified for HHMI                   *
*            08/27/98 Sebastian Rossi                      *
 **********************************************************
***********************************************************/


/***********************************************************
*getImage(image_name): Returns the document.images[] index *
*	for the image with thegiven name. Works around image   *
*	reproduction bug in Netscape 3.0                       *
***********************************************************/
function getImage(image_name)
{
	var lastfind = -1;
	for(var i =0; i < document.images.length;i++)
	{
		if (document.images[i].name == image_name)
			lastfind = i;
	}
	return lastfind;
}

/**********************************************************
*getNum(imageName): Returns the index of imageName from   *
*				    the global array namArray. If         *
*					imageName is not found returns -1     *
**********************************************************/
function getNum(imageName)
{
	for (i=0; i < numImages; i++)
	{
		if (nameArray[i] == imageName)
			break;
	}

	if (i == numImages)
	{
		i = -1;	
	}
	return i;
}

/**********************************************************
*dimimage(imageName): swaps the src of the image named    *
*                     imageName to the src stored in      *
*                     dimArray[] and changes window.status*
*                     to the corresponding blurb if they  *
*					  both exist.                         * 
**********************************************************/
function dimImage(imageName)
{
	bNum = getNum(imageName);
	if (bNum == -1)
	{
		alert("Error: This image has not been initialized");
		return;
	}
	document.images[(getImage(imageName))].src = dimArray[bNum].src;
    window.status = blurbArray[bNum];
}

/**********************************************************
*undimimage(imageName): swaps the src of the image named  *
*                       imageName to the src stored in    *
*                       normalArray[] if it exits.        *
**********************************************************/
function undimImage(imageName)
{
	bNum = getNum(imageName);
	if (bNum == -1)
	{
		return;
	}
	document.images[(getImage(imageName))].src = normalArray[bNum].src;
	window.status = "";
}

/**********************************************************
*initImages(imageString)                                  *
**********************************************************/
function initImages(imageString)
{
	//Exit Button
		nameArray[0] = "exit" 
		normalArray[0] = new Image
		normalArray[0].src = "http://info.med.yale.edu/caim/hhmi/resources/buttons/exit1.gif"
		dimArray[0] = new Image
		dimArray[0].src = "http://info.med.yale.edu/caim/hhmi/resources/buttons/exit2.gif"
		blurbArray[0] = "Use this button to exit the program."


	//Help Button
		nameArray[1] = "help" 
		normalArray[1] = new Image
		normalArray[1].src = "http://info.med.yale.edu/caim/hhmi/resources/buttons/help1.gif"
		dimArray[1] = new Image
		dimArray[1].src = "http://info.med.yale.edu/caim/hhmi/resources/buttons/help2.gif"
		blurbArray[1] = "Click here to send a request for help via email."

	//Prev Button
		nameArray[2] = "prev" 
		normalArray[2] = new Image
		normalArray[2].src = "http://info.med.yale.edu/caim/hhmi/resources/buttons/prev1.gif"
		dimArray[2] = new Image
		dimArray[2].src = "http://info.med.yale.edu/caim/hhmi/resources/buttons/prev2.gif"
		blurbArray[2] = "Click here to move to the previous page."

	//Next Button
		nameArray[3] = "next" 
		normalArray[3] = new Image
		normalArray[3].src = "http://info.med.yale.edu/caim/hhmi/resources/buttons/next1.gif"
		dimArray[3] = new Image
		dimArray[3].src = "http://info.med.yale.edu/caim/hhmi/resources/buttons/next2.gif"
		blurbArray[3] = "Click here to move to the next page."

	//ToTop Button
		nameArray[4] = "totop" 
		normalArray[4] = new Image
		normalArray[4].src = "http://info.med.yale.edu/caim/hhmi/resources/buttons/totop.gif"
		dimArray[4] = new Image
		dimArray[4].src = "http://info.med.yale.edu/caim/hhmi/resources/buttons/totop2.gif"
		blurbArray[4] = "Click here to move to the top of the page."

	//Close Button
		nameArray[5] = "close"
		normalArray[5] = new Image
		normalArray[5].src = "http://info.med.yale.edu/caim/hhmi/resources/buttons/close.gif"
		dimArray[5] = new Image
		dimArray[5].src = "http://info.med.yale.edu/caim/hhmi/resources/buttons/close2.gif"
		blurbArray[5] = "Close window."

}

var numImages = 6;
var normalArray = new Array();
var dimArray = new Array();
var blurbArray = new Array();
var nameArray = new Array();

initImages();
