/*******************************************************************
*
* File    : rollover.js
*
* Created : 1999/10/10
*
* Author  : Roy Whittle  (Roy@Whittle.com) www.Roy.Whittle.com
*
* Purpose : To create simple 'onMouse' rollovers
*
* History
* Date         Version        Description
* 1999/10/10   1.0            First Version. Written to simplify
*                             Cached Image RollOvers
* 1999/10/26   1.1            Added msClk to allow a different image
*                             to be used on click.
*******************************************************************/
var Roll  = new Array();
var Group = new Array();
var ipath = "images/"
//var ipath = "roy7_"
/***********************************************************
* Function   : CreateImageRollover
*
* Parameters : on_name  - the name of the image to use onMouseOver
*              off_name - the name of the image when mouse not over
* 
* Description : Creates an object that can hold the on/off images
*
***********************************************************/
function CreateImageRollover(on_name, off_name, click_name, group_name)
{
	if(document.images)
	{
		this.on_image        = new Image();
		this.on_image.src    = on_name;
		this.off_image       = new Image();
		this.off_image.src   = off_name;
		this.click_image     = new Image();
		this.click_image.src = click_name;
		this.group           = group_name;

		if(!Group[group_name])
			Group[group_name] = "none";
	}
	
}
/***********************************************************
* Function   : RollOver
*
* Parameters : name     - the name of an image in the document
*              on_name  - the name of the image to use onMouseOver
*              off_name - the name of the image when mouse not over
* 
* Description : Creates an object that can hold the on/off images
*
***********************************************************/
function RollOver(name, on_name, off_name, click_name, group)
{
	Roll[ name ] = new CreateImageRollover(on_name, off_name, click_name, group);
}

/***********************************************************
* Function   : RollOverGif/Jpg
*
* Parameters : name     - the name of an image in the document
*
* Description : Creates an object that can hold the on/off images
*
* If you name all your images 
* "images/name_on.gif"  
* "images/name_off.gif" 
* you can use this function instead. 
*
***********************************************************/
function RollOverGif(name, group)
{
	RollOver(name, 	ipath + name + "_on.gif", 
				ipath + name + "_off.gif",
				ipath + name + "_clk.gif",
				group);
}
function RollOverJpg(name)
{
	RollOver(name, 	ipath + name + "_on.jpg", 
				ipath + name + "_off.jpg",
				ipath + name + "_clk.jpg",
				group);
}

/*****************************************************************
*
* Function   : msOvr
*
* Parameters : name - name of the image to turn on onMouseOver
*
* Description: Swaps the current image to the "on" image
*
*****************************************************************/
function msOvr(name)
{
	if(document.images)
		if(document.images[name] && Roll[name])
		{
			if(	!Roll[name].group
			 ||	!Group[ Roll[name].group ]
			 || 	Group[ Roll[name].group ] != name)
				document.images[name].src=Roll[name].on_image.src;

		}
}
/*****************************************************************
*
* Function   : msOut
*
* Parameters : name - the name of the image to turn "off"
*
* Description: Swaps the current image to the "off" image
*
*****************************************************************/
function msOut(name)
{
	if(document.images)
		if(document.images[name] && Roll[name])
		{
			if(	!Roll[name].group
			 ||	!Group[ Roll[name].group ]
			 || 	Group[ Roll[name].group ] != name)
				document.images[name].src=Roll[name].off_image.src;

		}
}
/*****************************************************************
*
* Function   : msClk
*
* Parameters : name - the name of the image to turn "off"
*
* Description: Swaps the current image to the "off" image
*
*****************************************************************/
function msClk(name)
{
	if(document.images)
		if(document.images[name] && Roll[name])
		{
			if(	Roll[name].group )
			{
				var g = Roll[name].group;
				if(	Group[ g ]
			 	&&	Group[ g ] != "none")
				document.images[ Group[ g ] ].src=Roll[ Group[ g ] ].off_image.src;

				document.images[name].src=Roll[name].click_image.src;
				Group[ Roll[name].group ] = name;			
			}
		}
}
function reset(g)
{
	if(	Group[ g ]
 	&&	Group[ g ] != "none")
	{
		document.images[ Group[ g ] ].src=Roll[ Group[ g ] ].off_image.src;
		Group[ g ] = "none";
	}
}
/*****************************************************************
*
* Function   : msOvr2
*
* Parameters : name - name of the image to turn on onMouseOver
*              roll_name - the name of the image to use
*
* Description: Swaps the current image to the "on" image
*
*****************************************************************/
function msOvr2(img_name, roll_name)
{
	if(document.images)
		if(document.images[img_name] && Roll[roll_name])
			document.images[img_name].src=Roll[roll_name].on_image.src;
}
/*****************************************************************
*
* Function   : msOut2
*
* Parameters : name - the name of the image to turn "off"
*              roll_name - the name of the image to use
*
* Description: Swaps the current image to the "off" image
*
*****************************************************************/
function msOut2(img_name, roll_name)
{
	if(document.images)
		if(document.images[img_name] && Roll[roll_name])
			document.images[img_name].src=Roll[roll_name].off_image.src;
}
/*****************************************************************
*
* Function   : msOvrFrame
*
* Parameters : frame_name - the name of the frame containing the image
*              image_name - name of the image to turn on onMouseOver
*              roll_name - the name of the rollover to use
*
* Description: Swaps the current image to the "on" image
*
*****************************************************************/
function msOvrFrame(frame_name, img_name, roll_name)
{
	if(document.images)
		if(top.frames[frame_name]
		 && top.frames[frame_name].document.images[img_name] 
		 && Roll[roll_name])
			top.frames[frame_name].document.images[img_name].src=
				Roll[roll_name].on_image.src;
}
/*****************************************************************
*
* Function   : msOutFrame
*
* Parameters : frame_name - the name of the frame containing the image
*              image_name - name of the image to turn off onMouseOut
*              roll_name - the name of the rollover to use
*
* Description: Swaps the current image to the "on" image
*
*****************************************************************/
function msOutFrame(frame_name, img_name, roll_name)
{
	if(document.images)
		if(top.frames[frame_name]
		 && top.frames[frame_name].document.images[img_name] 
		 && Roll[roll_name])
			top.frames[frame_name].document.images[img_name].src=
				Roll[roll_name].off_image.src;
}
/*****************************************************************
*
* Function   : msOvrFrame2
*
* Parameters : frame_name - the name of the frame containing the image
*              image_name - name of the image to turn on onMouseOver
*              roll_name - the name of the rollover IN THE OTHER FRAME to use
*
* Description: Swaps the current image to the "on" image
*
*****************************************************************/
function msOvrFrame2(frame_name, img_name, roll_name)
{
	if(document.images)
		if(top.frames[frame_name]
		 && top.frames[frame_name].document.images[img_name] 
		 && top.frames[frame_name].Roll
		 && top.frames[frame_name].Roll[roll_name])
			top.frames[frame_name].document.images[img_name].src=
				top.frames[frame_name].Roll[roll_name].on_image.src;
}
/*****************************************************************
*
* Function   : msOutFrame2
*
* Parameters : frame_name - the name of the frame containing the image
*              image_name - name of the image to turn off onMouseOut
*              roll_name - the name of the rollover IN THE OTHER FRAME to use
*
* Description: Swaps the current image to the "on" image
*
*****************************************************************/
function msOutFrame2(frame_name, img_name, roll_name)
{
	if(document.images)
		if(top.frames[frame_name]
		 && top.frames[frame_name].document.images[img_name] 
		 && top.frames[frame_name].Roll
		 && top.frames[frame_name].Roll[roll_name])
			top.frames[frame_name].document.images[img_name].src=
				top.frames[frame_name].Roll[roll_name].off_image.src;
}

