    function openclose(base)
    {
      if (document.all) {
        folder = document.all[base];
        sub = document.all[base + "_sub"];
      } else if (document.layers) {
        folder = getObjNN4(document,base);
	sub = getObjNN4(document,base = "_sub");
      } else {
        folder = document.getElementById(base);
        sub = document.getElementById(base + "_sub");
      }
      if (sub.className=="folderclosed") {
        if (folder.className=="subfolder") {
	  folder.className = "subfolderexp";
        } else {
          folder.className = "folderexp";
        }
        sub.className = "folderopen";
      } else {
        if (folder.className=="subfolderexp") {
          folder.className = "subfolder";
        } else {
          folder.className = "folder";
        }
        sub.className = "folderclosed";
      }
    }

    /* For Netscape 4 */
    function getimage(name)
    {
      var x = document.images;
      for (var i=0;i<x.length;i++) {
        if (x[i].id == name)
          return i;
      }
      return -1;
    }

    var no_images = 6;  // 1--36
    var image_dir = "/images/newhomeimages/";
    var imageprefix = "home";
    var imagesuffix = ".jpg";
    var images = new Array();
    var alt = new Array();


    function preload_images()
    {
      for (i=1; i<=no_images; i++) {
        images[i-1] = new Image();
        images[i-1].src = image_dir + imageprefix + i + imagesuffix;
      }
    }

    alt[0] = "The Tanlaw Mill";
    alt[1] = "The Clore Laboratory";
    alt[2] = "Beloff House";
	alt[3] = "Hunter Street campus";
	alt[4] = "The Mill race";
    alt[5] = "Snowmen behind the Anthony de Rothschild Building";


var images_to_rotate = 0;
    var max_rotation = 0;
    var map = new Array();
    map[0] = new Array(0);
    map[1] = new Array(1);
    map[2] = new Array(2);
    map[3] = new Array(3);
    map[4] = new Array(4);
    map[5] = new Array(5);
	
    var swap_counter = 0;
    
    function swap_wrapper()
    {
      swap_counter++;
      if (swap_counter==3) {
        swap_counter = 0;
        swap_img();
      }
    }

    function swap_img()
    {
       var i,r;
       for (i=1;i<=images_to_rotate;i++) {
         r = parseInt(Math.random()*max_rotation);
	 if (document.all) {
           img = document.all["mainimage" + i];
         } else if (document.layers) {
           img = getimage("mainimage" + i)
         } else {
           img = document.getElementById("mainimage" + i);
         }
	 if (document.layers) {
           document.images[img].src = images[map[i-1][r]-1].src;
           document.images[img].alt = alt[map[i-1][r]-1];
         } else {
   	   img.src = images[map[i-1][r]-1].src;
           img.alt = alt[map[i-1][r]-1];
         }
       }
    }
    
    function gotourl()
    {
       if (document.quicklinks.quickselect.value!="") {
         window.location.href = document.quicklinks.quickselect.value;
       }
       return false;
    }


function determineWidth()
{
  var img,newimg;
  var width;
  var ns4;
  var agent = navigator.userAgent;
  if (document.layers) {
    ns4 = 1;
  } else {
    ns4 = 0;
  }
  if (ns4) {
    width = window.innerwidth;
  } else if (!document.body) {
    width = "undef";
  } else {
    width = document.body.offsetWidth;
  }
  return width;
}

function init_images()
{
  if (determineWidth()>800) { 
    image_dir = image_dir + "large/";
    swap_counter = 2;
  }
  preload_images();
  aid = setInterval('swap_wrapper()',5000);
}
