//
// Dreamweaver functions (MM = Macromedia)
//

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_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];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


//
// Customized functions for FEE site
//
//  The FEE site design requires not just "mouse over" image swapping,
//    but "mouse down" swapping as well. Plus, the current page's navigation
//    button, which is normally highlighted, must go back to the unhighlighted
//    state while another button is highlighted.
//
//  Note: 6/4/02 Mouse Down/Up swapping removed as the onMouseDown/Up events are
//   buggy in several browsers
//

// Two variables must be defined on each page where these functions are used:
//
//   var currentpage;     // name of current page ("overview", "deadlines", "procedures", "login", "faq", "contact", or "")
//   var imagepath;       // relative path to the navigation images, ("img/nav", "../img/nav", etc.)

// These variables keep track of which button is currently moused over, and which state it's in

var currentbutton = "";          // which button is moused over, if any
var currentbuttondown = false;   // true if button in "down" state

// handle onMouseOver
//   - sets current page's button to normal state
//   - sets specified button to mouseover state
//
function do_mouseover(button) {
  if (button != currentpage) {
    do_currentpage_swap();
    do_image_swap(button, "_hi");
    currentbutton = button;
    currentbuttondown = false;
  }
}

function do_mouseout(button) {
  if (button != currentpage) {
    delayed_currentpage_restore();
    do_image_swap(button, "");
    currentbutton = "";
    currentbuttondown = false;
  }
}
// NO LONGER USED
//function do_mousedown(button) {
//  if (button == currentbutton) {
//    do_image_swap(button, "_down");
//    currentbuttondown = true;
//  }
//}
//
//function do_mouseup(button) {
//  if (button == currentbutton && currentbuttondown == true) {
//    do_image_swap(button, "_hi");
//    currentbuttondown = false;
//  }
//}

//
// The following functions swap and restore the current page's button
//

var timerid = null;

//
// swap current page button to unhighlighted state
//
function do_currentpage_swap() {
  if (currentpage) {
    if (timerid != null) // if waiting for restore, cancel restore
      cancel_currentpage_restore();
    else                 // otherwise, perform swap
      do_image_swap(currentpage, "");
  }
}

//
// start timer for delayed restoration of current page button
//
function delayed_currentpage_restore() {
  timerid = setTimeout("do_currentpage_restore()", 100); // last arg is delay in milliseconds
}

//
// cancel delayed restoration of current page button
//
function cancel_currentpage_restore() {
  if (timerid != null) {
    clearTimeout (timerid);
    timerid = null;
  }
}

//
// perform restoration of current page button to highlighted state
//
function do_currentpage_restore() {
  if (currentpage) {
    do_image_swap(currentpage, "_hi");
  }
  timerid = null;
}

//
// Utility function to perform image swapping
//  name is the image name and the first part of the image filename
//  state is the filename prefix (i.e. "_hi", "_down")
//

function do_image_swap(imgname, state) {
  // find image object
  var obj = MM_findObj(imgname);
  if (obj) {
    // create image sources
    var src = imagepath + "/" + imgname + state + ".gif";
    // swap the images
    obj.src = src;
  }
}
