/*
JAVASCRIPT LIBRARY FILE: preload and rollover effects
 
All material herein (c) Copyright 2003 Binary Minds, Inc.              
All Rights Reserved.
 
**Document Under Development**
Current Administrator: Tom
 
Changes (incl. date and name)
6/29/03 Tom: created
7/25/03 Tom: removed possibility of sending source of the over image.
 
Required Parameters: 
					FUNCTION: imgPreload
					1. Associative Array of preload images.
					  key - image name
					  value - image source
					  
					FUNCTION imgMouseOver   
					1: (String) Name of the image being replaced
					2: (String) Name of the replacing image OR (String) Source of the replacing image.
					If imgPreload is not used, second parameter must be set to image source.
					
					FUNCTION imgMouseOut
					1:(String) Name of the image being replaced
					
Optional Parameters: NONE

Usage:
------To preload images:------
Create an array with a key being a name of an image and value set to it's source. Array name is unimportant. Body tag onLoad must
contain a call to imgPreload(arrayName) function. 
i.e:
<head>
	<title>Preload Example</title>
<script language="JavaScript" src="preload_rollover.js"></script>
<script language="JavaScript">
var pageImages = new Array();
pageImages['next2']='nextOver.gif';
pageImages['prev2']='prevOn.gif';
</script>
</head>
<body onload="imgPreload(pageImages);">

------MouseOver effect:------
Example1: Second parameter of the imgMouseOver function is a NAME of the mouseover image
<a href="javascript:void(0)" onmouseover="imgMouseOver('next','next2')" onmouseout="imgMouseOut('next')">
	<img src="next.gif" name="next">
</a>
Example2: Second parameter of the imgMouseOver function is a SOURCE of the mouseover image 
<a href="javascript:void(0)" onmouseover="imgMouseOver('prev','prevOn.gif')" onmouseout="imgMouseOut('prev')">
   <img src="prev.gif" alt="" name="prev">
</a>   
*/

var preLoadArr = new Array();
var sSwappedSrc = new Array();
var err=0;

function imgPreload(arr){
 if (document.images){
     for (var i in arr){
      preLoadArr[i] = new Image;
      preLoadArr[i].src = arr[i];
     }
 }  
}

function imgMouseOver(sourceImgName,swapImg){ //argument1: name of the image1, argument2: name of the image2 or it's source  
 if(document.images && preLoadArr[swapImg] != null){
  sSwappedSrc[sourceImgName] = document.images[sourceImgName].src;
  document.images[sourceImgName].src = preLoadArr[swapImg].src;
 } 
} 

function imgMouseOut(sourceImgName){
 if(document.images[sourceImgName] != null && sSwappedSrc[sourceImgName] != null){
    document.images[sourceImgName].src = sSwappedSrc[sourceImgName];
 }
}

