{ var imageList = new Array();}




//-----------------------------------------------------------------------------
//
function swapMe(iName,iDirection,iButton,echo)
{
 var myIndex = (typeof(iButton) != "undefined") ? iButton : iName 
     myIndex = myIndex.toLowerCase() + iDirection.toLowerCase();
 
 if(typeof(imageList[myIndex]) != "undefined")
 { 
  if(typeof(echo) != "undefined")
   alert(iName +" >> " +myIndex)
 
  document [iName].src = imageList[myIndex].src 
 }
 
 else
 {
  var msg1 = "JavaScript Runtime Error ~fImageMgr.js: swapMe(...)",
      msg2 = "\nelement '" +myIndex +"' does not exist in imageList[].";
  
  alert(msg1+msg2)
 }
}
//-----------------------------------------------------------------------------





//-----------------------------------------------------------------------------
function cacheImage(thatFolder,thatImage,thatMask,thatFlag,thatName,echo)
{
 var myFlags = new Array();
     myFlags = thatFlag.split(',');
	 
 var myEvent,
     myImage,
	 myFolder;

 var myName = (typeof(thatName) == "undefined") ? thatImage : thatName;
 
 for(var x=0; x<myFlags.length; x++)
 {
  // -i (inactive) = Off
  // -p (pressed)  = Pre
  // -o (over)     = Ovr
  // -s (inactive) = Sel (initial state was selected instead of inactive.)
  // -x (disabled) = Dis
  
  myEvent  = (myFlags[x] == "i") 
   ? "Off" : (myFlags[x] == "o") 
   ? "Ovr" : (myFlags[x] == "p") 
   ? "Pre" : (myFlags[x] == "s")    
   ? "Sel" : (myFlags[x] == "a")
   ? "Act" : "Dis";
  
  
  myImage  = myName.toLowerCase() +myEvent.toLowerCase();
  
  mySource = thatMask.replace(/{name}/,thatImage);
  mySource = mySource.replace(/{flag}/,myFlags[x]);
  
  // make sure the folder has a trailing slashmark
  myFolder = (thatFolder.substr(thatFolder.length-1,1)!= "/") ? thatFolder +"/" : thatFolder;
 
  imageList[myImage] = new Image;
  imageList[myImage].src = myFolder +mySource
  
  if(typeof(echo) != "undefined")
   alert(myImage +" (=) " +imageList[myImage].src)
 }
}
//-----------------------------------------------------------------------------





//-----------------------------------------------------------------------------
//
function rollMe(iName,iDirection,iText)
{
 if(iName.toLowerCase() != currentIcon.toLowerCase())
 {
  swapMe(iName,iDirection)
 }

 /* 
 if(typeof(iText) != "undefined")
 { window.status = (iDirection == 'ovr') ?iText : ''; }
 */
}
