var aImageSeq = Array ( ) ;

function ImageSeq ( sName, nCurr, nWidth, nHeight, nX, nY )
{
  this.sName   = sName   ;
  this.nCurr   = nCurr   ;  
  this.nWidth  = nWidth  ;
  this.nHeight = nHeight ;
  this.nX      = nX      ;
  this.nY      = nY      ;
  this.aImages = new Array ( ) ;
}

function SeqImage ( sFileName, nWidth, nHeight, sTitle )
{
  this.sFileName = sFileName ;
  this.nWidth    = nWidth    ;
  this.nHeight   = nHeight   ;
  this.sTitle    = sTitle    ;

  this.image     = new Image ( ) ; 

  this.image.src = this.sFileName ;
}

function initSequenceImage ( sName, nCurr, nMaxWidth, nMaxHeight, nX, nY, sFileName, nWidth, nHeight, sTitle )
{
  var imageSeq = null ;

  for ( var i = 0 ; i < aImageSeq.length ; i++ )
  {
    if ( aImageSeq [ i ].sName == sName )
    {
      imageSeq = aImageSeq [ i ] ;
    }
  }

  if ( imageSeq == null )
  {
    imageSeq = new ImageSeq ( sName, nCurr, nMaxWidth, nMaxHeight, nX, nY ) ;
    
    aImageSeq.push ( imageSeq ) ;
  }

  var seqImage = new SeqImage ( sFileName, nWidth, nHeight, sTitle ) ;

  imageSeq.aImages.push ( seqImage ) ;
}

function switchSeqImages ( )
{
  for ( var i = 0 ; i < aImageSeq.length ; i++ )
  {
    var imageSeq = aImageSeq [ i ] ;

    var img = document.getElementById ( imageSeq.sName ) ;

    if ( img )
    {
      if ( imageSeq.nCurr == ( imageSeq.aImages.length - 1 ) )
      {
        imageSeq.nCurr = 0 ;
      }
      else
      {
        imageSeq.nCurr++   ;
      }
      
      var image = imageSeq.aImages [ imageSeq.nCurr ] ; 

      img.src          = image.image.src      ;
      img.style.border = "0"                  ; 
      img.style.width  = image.nWidth  + "px" ;
      img.style.height = image.nHeight + "px" ;
      img.title        = image.sTitle         ;
      img.alt          = image.sTitle         ;
    }
  }
}
