function MyImg()
{
  this.AddImg = AddImg;
  this.NextImg = NextImg;
  this.LastImg = LastImg;
  this.CurImg = CurImg;
  this.GetNme = GetNme;
  this.timerlst = 0;

  var nImg = 0; 
  var maxImg = 0;
  var name = "";
  var imgs = new Array();

  function AddImg(path,img)
  {
    if (name == "" )	{name = img;}
    imgs[maxImg] = new Image();
    imgs[maxImg].src = path+img;
    maxImg++;
  }

  function NextImg()
  {
    if (maxImg>1) {
      nImg = (nImg +1) % maxImg;
    }
    return( imgs[nImg].src );
  }

  function LastImg()
  {
    if (maxImg>1) {
      nImg = nImg -1;
      if (nImg < 0) nImg = maxImg-1;
    }
    return( imgs[nImg].src );
  }

  function CurImg()
  {
    return( imgs[nImg].src );
  }

  function GetNme()
  {
    return( name );
  }
}

var nnImg = -1;
var imglst = new Array();
var timerlst = new Array();


function initIMG( path, img, tmr ) {
  nnImg++;
  imglst[nnImg] = new MyImg();
  imglst[nnImg].AddImg( path,img );
  if ( tmr ) {
    doIMG( nnImg );
  }

}

function addIMG( path, img1 ) {
  imglst[nnImg].AddImg( path,img1 );
}

function doIMG( nImg ) {
  upIMG( nImg );
  imglst[nImg].timerlst = window.setTimeout( "doIMG( '"+nImg+"' );", 2000 );
}

function stopIMG( nImg ) {
  window.clearTimeout( imglst[nImg].timerlst );
  imglst[nImg].timerlst = 0;
}

function doIMGs( imgz, nImg ) {
  if ( imglst[nImg].timerlst == 0 ) {
    upIMG( nImg );
    imglst[nImg].timerlst = window.setTimeout( "doIMG( '"+nImg+"' );", 2000 );
    imgz.src = "gifs/marrows.gif";
  } else {
    window.clearTimeout( imglst[nImg].timerlst );
    imglst[nImg].timerlst = 0;
    imgz.src = "gifs/marrowp.gif";
  }
}

function downIMG( nImg ) {
  nm = imglst[nImg].GetNme();
  if (document[nm].complete) {
    document[nm].src = imglst[nImg].LastImg();
  }
}

function upIMG( nImg ) {
  nm = imglst[nImg].GetNme();
  if (document[nm].complete) {
    document[nm].src = imglst[nImg].NextImg();
//      blendimage(nm+"bk", nm, imglst[nImg].NextImg(), 400);
  }
}

function bigIMG( nImg ) {
  nm = imglst[nImg].CurImg();
  i = nm.lastIndexOf(".");
  nm = nm.substr(0,i)+"x"+nm.substr(i);
  return( nm );
}

function downAllIMG() {
  for ( i = 0; i <= nnImg; i++ ) {
    nm = imglst[i].GetNme();
    document[nm].src = imglst[i].LastImg();
  }
}

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var obj = document.getElementById(id).style; 
    obj.opacity = (opacity / 100); 
    obj.MozOpacity = (opacity / 100); 
    obj.KhtmlOpacity = (opacity / 100); 
    obj.filter = "alpha(opacity=" + opacity + ")"; 
}

//blend two images
function blendimage(divid, imageid, imagefile, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //set the current image as background 
   document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
     
    //make new image transparent 
    changeOpac(0, imageid); 
     
    //set new image 
    document.getElementById(imageid).src = imagefile; 

    //fade in new image - numerous timeouts 
    for(i = 0; i <= 100; i++) { 
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    } 
    setTimeout("document.getElementById('"+divid+"').style.backgroundImage = 'none';",(timer * speed)); 
} 

