<!--
/************************ General Purpose Functions *************************/
now = new Date ();

function callback (obj, func, args, store, rem, call) {
  for (var i = 0; i < args.length; i++, rem--)
    store[store.length] = args[i];

  // Javascript can take more arguments than required
  // Hence rem could be negative. 
  // To debug this had been a major exercise in frustration.
  if (call && rem <= 0)
    return func.apply (obj, store);
  
  return function () {
    return callback (obj, func, arguments, store, rem, true);
  }
}

function wrap () {
  if (arguments.length < 2 
      || typeof (arguments[0]) != "object"
      || typeof (arguments[1]) != "function")
    return undefined;
  
  var obj = arguments[0];
  var func = arguments[1];
  var rem = func.length;
  var args = []; 
  if (arguments.length > 2) {
    args = new Array (arguments.length - 2);
    for (var i = 0; i < args.length; i++)
      args[i] = arguments[i + 2];
  }
  
  return callback (obj, func, args, [], rem, false); 
}

/************************* Page Specific Functions ***************************/

function Imgroll (imgname, timeout) {
  this.imgname = imgname; // id of image for slideshow
  this.getsrc = 0; // function that returns the URI given a number
  this.getlen = 0; // function returns the total #images
  // this.fncb = 0; // callback function set for timeout
  this.timeout = timeout; // time after which fncb should be called
  this.cbid = 0; this.count = 0; // count is current image number
  this.unsetcb = function (cbid) {
    if (cbid) {
      clearTimeout (cbid);
    }
    return 0;
  }
  this.setdispimg = function () {
    this.cbid = this.unsetcb (this.cbid);
    document[imgname].src = this.getsrc (this.count++);
    if (this.count == this.getlen ()) {
      this.count = 0;
    }
    this.cbid = setTimeout (wrap (this, this.setdispimg), this.timeout);
  }
}

function Imgroll_1 (imgname, fncb, timeout) {
  Imgroll.call (this, imgname, fncb, timeout);
  this.images = new Array (); // contains URI of images
  this.getsrc = function (i) {
    return this.images[i];
  }
  this.getlen = function () {
    return this.images.length;
  }
}

function startbody ()
{
  if (document.images) {
    var di = new Imgroll_1 ("dispimg", 2000);
    di.images = ["/reddy/dispimg/kings-garden.jpg", 
		 "/reddy/dispimg/kings-garden1.jpg"];
    di.setdispimg ();
  }
}

function endbody ()
{
  di.unsetcb (di.cbid);
  delete di;
  delete now;
}

-->
