       dojo.require("dojo.fx");

       function simplemenu(num) {
        if (num != 0) {
        var starterdiv = "startit" + num;
        dojo.addClass(starterdiv,'simplestarter2');
        }   
       }

       function simplemenuout(num) {
        if (num != 0) {
        var starterdiv = "startit" + num;
        dojo.removeClass(starterdiv,'simplestarter2');
        }   
       }

       function indexmenu(num) {
        if (num != 0) {
        var starterdiv = "startit" + num;
        var imgsrc = "images/indeximage" + num + ".jpg";
        var imgname = dojo.byId('indeximage');
	dojo.addClass(starterdiv,'simplestarter2');
        imgname.src=imgsrc;
        }   
       }

       function indexmenuout(num) {
        if (num != 0) {
        var starterdiv = "startit" + num;
        var imgsrc = "images/indeximage0.jpg";
        var imgname = dojo.byId('indeximage');
        dojo.removeClass(starterdiv,'simplestarter2');
        imgname.src=imgsrc;
        }   
       }

       function indexanimation() {
        var imgsrc = "images/facts-animation.gif";
        var imgname = dojo.byId('indeximage');
        imgname.src=imgsrc;
       }

       function indexmapchange(num) {
        if (num != 0) {
        var imgsrc = "images/indeximage" + num + ".jpg";
        var imgname = dojo.byId('indeximage');
        imgname.src=imgsrc;
        }
       }

       function indexmapout(num) {
        if (num != 0) {
        var imgsrc = "images/indeximage0.jpg";
        var imgname = dojo.byId('indeximage');
        imgname.src=imgsrc;
        }   
       }

function dopop(page)
{
width = screen.width;
height = screen.height;
if (width > 819 && height > 699)
{
width = 820;
height = 700;
}
popstring = 'width='+width+',height='+height+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no';
window.open(page,'microsite',popstring);
}


       function funky(here,num,total) {
        if (num != 0) {
        var starterdiv = "startit" + num;
        var herediv = "startit" + here;
        var holderdiv = "holder" + num;
        for(var count = 1; count <= total; count++)
        {
         if(count != num) 
          {
          clearslide(count);
          }
         else
          {
          // Make the Current location red, unless that's the one we're sliding
          if(here != num && here != 0){dojo.addClass(herediv,'here');} else { if(here != 0) {dojo.removeClass(herediv,'here');}}
          } 
        }
        dojo.addClass(starterdiv,'starter2');
        dojo.addClass(holderdiv,'zed');
        var current = 2; 
        doclassani(current,num);   
        }   
       }

       function doclassani(current,num)
       {
        var animatediv = "aniback" + num;
        var pos = "ani" + current;
        var wipediv = "wiper" + num;
        var starterdiv = "startit" + num;
        var holderdiv = "holder" + num;
        dojo.addClass(animatediv,pos);
// Ensure that the Z indices are correct, and the arrow always appears
        dojo.addClass(starterdiv,'starter2');
        dojo.addClass(holderdiv,'zed');
        if(current < 22)
        {
//        current++;
// Faster version
        current = current + 2;
        var func = "doclassani("+current+","+num+")";
        t = setTimeout(func,1);
       return false;
        }
        else
       {
// Extra code for the faster version
       dojo.addClass(animatediv,'ani21');
// End of extra code
       var wipefunc = "wipe("+num+")";

       for(var count = 1; count <= total; count++)
       {
        if(count != num)
         {
         clearslide(count);
         }
       }
       dojo.addClass(wipediv,'wipeclass2');
       t = setTimeout(wipefunc,5);
// Ensure that the Z indices are correct, and the arrow always appears
       dojo.addClass(starterdiv,'starter2');
       dojo.addClass(holderdiv,'zed');
       return false;
       }
       }
      
       function wipe(num)
       {
       var wipediv = "wiper"+num;
                 dojo.fx.wipeIn({
                                node: wipediv,
                                duration: 300
                                }).play();
       
       }
 
       function wipeout(total)
       {
       var wipediv = "";
       for(var count = 1; count <= total; count++)
       {
       wipediv = "wiper"+count;
       dojo.addClass(wipediv,'wipeclass1');
       }

       }

       function clearslide(num)
       {
       var wipediv = "";
       var animatediv = "";
       var pos = "";
       var holderdiv = "holder" + num;
       wipediv = "wiper"+num;
       dojo.removeClass(wipediv,'wipeclass2');
       var starterdiv = "startit" + num;
       dojo.removeClass(starterdiv,'starter2');
       for(var count = 2; count < 22; count++)
       {
        animatediv = "aniback" + num;
        pos = "ani" + count;
        dojo.removeClass(animatediv,pos);
       }
        dojo.removeClass(holderdiv,'zed');

       }

       function overlay(num)
       {
        for(var count = 1; count < 8; count++)
         {
          if (count != num) {underlay(count);} 
         }
        var imgdiv = page + 'img' + num;
        var newimgdiv = imgdiv + 'back';
        dojo.addClass(imgdiv,newimgdiv);
       }

       function underlay(num)
       {
        var imgdiv = page + 'img' + num;
        var newimgdiv = imgdiv + 'back';
        dojo.removeClass(imgdiv,newimgdiv);
       }

       function doUnderlay()
       {
        for(var count = 1; count < 8; count++)
         {
          underlay(count);
         }
       }

function doOverlay(e) {
     e = e || window.event;
     var cursor = {x:0, y:0};
//     var cursor = {x:0};
     if (e.pageX || e.pageY) {
         cursor.x = e.pageX;
         cursor.y = e.pageY;
     }
     else {
         cursor.x = e.clientX +
             (document.documentElement.scrollLeft ||
             document.body.scrollLeft) -
             document.documentElement.clientLeft;
         cursor.y = e.clientY +
             (document.documentElement.scrollTop ||
             document.body.scrollTop) -
             document.documentElement.clientTop;
     }
     findme = dojo.byId("nav");
//     navleftpos = findPos(findme);
     navpos = findPos(findme);
//     xoffset = cursor.x - navleftpos;
     xoffset = cursor.x - navpos[0];
     yoffset = cursor.y - navpos[1];
// Now work out which overlay to trigger, based on page and xoffset
    var img = 0;
       if (xoffset > 79 && xoffset < 156 && yoffset < 93) {img = 1;}
       else if (xoffset > 159 && xoffset < 278 && yoffset < 93) {img = 2;}
       else if (xoffset > 282 && xoffset < 403 && yoffset < 93) {img = 3;}
       else if (xoffset > 406 && xoffset < 479 && yoffset < 93) {img = 4;}
       else if (xoffset > 482 && xoffset < 567 && yoffset < 93) {img = 5;}
       else if (xoffset > 569 && xoffset < 688 && yoffset < 93) {img = 6;}
       else if (xoffset > 692 && xoffset < 771 && yoffset < 93) {img = 7;}
/*
// This switch statement allows different shapes of image grid on each page - not needed at present
    switch (page) {
     case "lifestyle":
       if (xoffset > 79 && xoffset < 156 && yoffset < 93) {img = 1;}
       else if (xoffset > 159 && xoffset < 278 && yoffset < 93) {img = 2;}
       else if (xoffset > 282 && xoffset < 403 && yoffset < 93) {img = 3;}
       else if (xoffset > 406 && xoffset < 479 && yoffset < 93) {img = 4;}
       else if (xoffset > 482 && xoffset < 567 && yoffset < 93) {img = 5;}
       else if (xoffset > 569 && xoffset < 688 && yoffset < 93) {img = 6;}
       else if (xoffset > 692 && xoffset < 771 && yoffset < 93) {img = 7;}
      break;
     case "academics":
       if (xoffset > 79 && xoffset < 156 && yoffset < 93) {img = 1;}
       else if (xoffset > 159 && xoffset < 278 && yoffset < 93) {img = 2;}
       else if (xoffset > 282 && xoffset < 403 && yoffset < 93) {img = 3;}
       else if (xoffset > 406 && xoffset < 479 && yoffset < 93) {img = 4;}
       else if (xoffset > 482 && xoffset < 567 && yoffset < 93) {img = 5;}
       else if (xoffset > 569 && xoffset < 688 && yoffset < 93) {img = 6;}
       else if (xoffset > 692 && xoffset < 771 && yoffset < 93) {img = 7;}
      break;
     case "parents":
       if (xoffset > 79 && xoffset < 156 && yoffset < 93) {img = 1;}
       else if (xoffset > 159 && xoffset < 278 && yoffset < 93) {img = 2;}
       else if (xoffset > 282 && xoffset < 403 && yoffset < 93) {img = 3;}
       else if (xoffset > 406 && xoffset < 479 && yoffset < 93) {img = 4;}
       else if (xoffset > 482 && xoffset < 567 && yoffset < 93) {img = 5;}
       else if (xoffset > 569 && xoffset < 688 && yoffset < 93) {img = 6;}
       else if (xoffset > 692 && xoffset < 771 && yoffset < 93) {img = 7;}
      break;
     case "admissions":
       if (xoffset > 79 && xoffset < 156 && yoffset < 93) {img = 1;}
       else if (xoffset > 159 && xoffset < 278 && yoffset < 93) {img = 2;}
       else if (xoffset > 282 && xoffset < 403 && yoffset < 93) {img = 3;}
       else if (xoffset > 406 && xoffset < 479 && yoffset < 93) {img = 4;}
       else if (xoffset > 482 && xoffset < 567 && yoffset < 93) {img = 5;}
       else if (xoffset > 569 && xoffset < 688 && yoffset < 93) {img = 6;}
       else if (xoffset > 692 && xoffset < 771 && yoffset < 93) {img = 7;}
      break;
     case "alumni":
       if (xoffset > 79 && xoffset < 156 && yoffset < 93) {img = 1;}
       else if (xoffset > 159 && xoffset < 278 && yoffset < 93) {img = 2;}
       else if (xoffset > 282 && xoffset < 403 && yoffset < 93) {img = 3;}
       else if (xoffset > 406 && xoffset < 479 && yoffset < 93) {img = 4;}
       else if (xoffset > 482 && xoffset < 567 && yoffset < 93) {img = 5;}
       else if (xoffset > 569 && xoffset < 688 && yoffset < 93) {img = 6;}
       else if (xoffset > 692 && xoffset < 771 && yoffset < 93) {img = 7;}
      break;
     case "history":
       if (xoffset > 79 && xoffset < 156 && yoffset < 93) {img = 1;}
       else if (xoffset > 159 && xoffset < 278 && yoffset < 93) {img = 2;}
       else if (xoffset > 282 && xoffset < 403 && yoffset < 93) {img = 3;}
       else if (xoffset > 406 && xoffset < 479 && yoffset < 93) {img = 4;}
       else if (xoffset > 482 && xoffset < 567 && yoffset < 93) {img = 5;}
       else if (xoffset > 569 && xoffset < 688 && yoffset < 93) {img = 6;}
       else if (xoffset > 692 && xoffset < 771 && yoffset < 93) {img = 7;}
      break;
    }
*/
    if (img != 0) { overlay(img);} 
    return false;
}

function findPos(obj) {
	var curleft = curtop = 0;
//	var curleft = 0;
        if (obj.offsetParent) {
        do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
        return [curleft,curtop];
//        return curleft;
       }
       }

function preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
