function MyPreloadImages()
{
  var aDoc = document;
  if (aDoc.images)
  {
    if (!aDoc.m_Picture) aDoc.m_Picture = new Array();
    var srcIndex, dstIndex = aDoc.m_Picture.length, argList = MyPreloadImages.arguments;
    for(srcIndex = 0; srcIndex < argList.length; srcIndex++)
    {
      if (argList[srcIndex].indexOf("#") != 0)
      {
        aDoc.m_Picture[dstIndex] = new Image;
        aDoc.m_Picture[dstIndex++].src = argList[srcIndex];
      }
    }
  }
}
				
function MySwapImageRestore()
{
  var srcIndex, imageObject, swapImage=document.m_SwapImage;
  for(srcIndex=0; swapImage && srcIndex<swapImage.length && (imageObject=swapImage[srcIndex]) && imageObject.oSrc; srcIndex++)
  {
    imageObject.src = imageObject.oSrc;
  }
}

function MyFindObj(iObjectName, iDocument)
{
  var stringPtr, anIndex, anObject;
  if (!iDocument) iDocument=document;
  if ((stringPtr = iObjectName.indexOf("?")) > 0 && parent.frames.length)
  {
    iDocument = parent.frames[iObjectName.substring(stringPtr+1)].document;
    iObjectName = iObjectName.substring(0,stringPtr);
  }
  if (!(anObject=iDocument[iObjectName]) && iDocument.all)
  {
    anObject = iDocument.all[iObjectName];
  }
  for (anIndex=0; !anObject && anIndex < iDocument.forms.length; anIndex++)
  {
    anObject = iDocument.forms[anIndex][iObjectName];
  }
  for(anIndex=0; !anObject && iDocument.layers && anIndex < iDocument.layers.length; anIndex++)
  {
    anObject = MyFindObj(iObjectName, iDocument.layers[anIndex].document);
  }
  if (!anObject && iDocument.getElementById)
  {
    anObject=iDocument.getElementById(iObjectName);
  }
  return anObject;
}

function MySwapImage()
{
  var argIndex, imageIndex=0, imageObject, argList=MySwapImage.arguments;
  document.m_SwapImage = new Array;
  for(argIndex=0; argIndex < (argList.length-1); argIndex += 2)
  {
    if ((imageObject = MyFindObj(argList[argIndex])) != null)
    {
      document.m_SwapImage[imageIndex++] = imageObject;
      if(!imageObject.oSrc) imageObject.oSrc = imageObject.src;
      imageObject.src = argList[argIndex+1];
    }
  }
}

function ClearImageBarHighlight(thisObj)
{
  thisObj.parentNode.style.backgroundImage = "url('images/imagebar.gif')";
}

function SetActiveTile(thisObj, imageNum)
{
  thisObj.parentNode.style.backgroundImage = "url('images/imagebarlit.gif')";
  
  var imageFile = "images/original" + imageNum + ".gif";
  var backgroundImage = "url('" + imageFile + "')";

  document.getElementById("originalImage").src = imageFile;
  document.getElementById("tiledOriginal").style.backgroundImage = backgroundImage;

  imageFile = "images/tile" + imageNum + ".gif";
  backgroundImage = "url('" + imageFile + "')";
  
  document.getElementById("seamlessTileImage").src = imageFile;
  document.getElementById("tiledSeamless").style.backgroundImage = backgroundImage;
}

