// Global Variables

var menu;
var wiping = false;
var wipetime;
var wipeel;
var into;
var linkupcolor = "darkblue";
var linkdowncolor = "brown";
var linkovercolor = "darkred";
var linkdownovercolor = "crimson";

// Function definitions


function setMenu() {
  for (var i=0; i<document.links.length; i++) {
	var thelink = document.links[i];
    if (thelink.href==document.location.href || (thelink.id?(thelink.id==menu):false)) var thislink = thelink;
	if (thelink.children[0]) {
	    if ((thelink.children[0].tagName=="IMG" && thelink.children[0].name) || (thelink.children[0].tagName!="IMG")) {
	      setMenuItem(thelink);
		  }
        }
	else setMenuItem(thelink);
	}
  if (thislink) deactivate(thislink);
  interval = setInterval("if (imagesLoaded()) uncover()",100);
  startPulsate();
  return true;
}

function uncover() {
  document.all.Layer1.style.visibility="hidden";
  clearInterval(interval);
}

function imagesLoaded() {
  var img = document.images;
  var ans = true;
  for (var i=0; i<img.length; i++) {
    if (!img[i].complete) {ans = false; break;}
	}
  return ans;
}

function setMenuItem(linkitem,state) {
  if (!state) state="up";
  with (linkitem) {
     setMenuLink(linkitem,state);
     onmouseover = menuHandler;
	 onmouseout =  menuHandler;
	 onclick =  menuHandler;
     if (linkitem.popupmenu) {
		if (document.all) {
		  var popuplayer = document.all[linkitem.popupmenu];
		}
		else {
		  var popuplayer = eval("document." + linkitem.popupmenu);
		}		
		with (popuplayer) {
		  popuplayer.parentmenu = linkitem.id;
		  onmouseout = menuHandler;
		  className = "submenu";
		  }
		}
	 }
}

function initButton(theimg,state) {
  if (!state) state="up";
  var theimgfile = theimg.src.substring(0,theimg.src.length-4);
  MM_preloadImages(theimgfile+'_f2.gif', theimgfile+'_f3.gif');
  setButton(theimg,state,theimgfile+"_f2.gif",theimgfile+"_f3.gif");
}

function setLink(l,state) {
  if (!state) state = "up";
  if (!l.state) {
      l.state = state;
	  var a = arguments;
	  if (a.length > 2) {
	    l.up = a[2];
		if (a.length >3) {
		  l.over = a[3];
		  if (a.length > 4) {
		    l.down = a[4];
			if (a.length > 5) {
			  l.downover = a[5];
			  }
			else l.downover = a[3];
			}
		  else l.down = linkdowncolor;
		  }
		else l.over = linkovercolor;
		}
	  else {
	    l.up = linkupcolor;
		l.over = linkovercolor;
		l.down = linkdowncolor;
		l.downover = linkdownovercolor;
		}
	  }
		
  if (state=="over" && l.state=="up") {l.style.color = l.over; l.style.textDecoration = "underline";}
  else if (state=="over" && l.state=="down") {l.style.color = l.downover; l.style.textDecoration = "underline";}
  else if (state=="up" || state=="down") {
    l.state = state;
	l.style.color = eval("l."+state);
	l.style.textDecoration = "none";
    }
  else alert("Invalid state in setLink");
}

function setMenuLink(l,state) {
  if (!state) {
    x = l;
    if (l.children[0]) {if (l.children[0].tagName=="IMG") x = l.children[0]};
    if (!x.state) state = "up";
	else state = x.state;
	}
  if (l.children[0]) {
    if (l.children[0].tagName=="IMG" && !l.state) initButton(l.children[0],state);
	else if (l.children[0].tagName=="IMG") setButton(l.children[0],state);
	else setLink(l,state);
	}
  else setLink(l,state);
  if ((state=="over" || state=="downover") && l.status) window.status = l.status;
  else if (state=="up" || state=="down") window.status = "";  
}

function setButton(theimg, state) {
  if (!theimg.state) {
      if (!state) state = "up";
      theimg.state = state;
	  theimg.up = theimg.src;
	  var a = arguments;
	  if (a.length < 3) {alert("Error in setButton...no image names"); return false;}
	  else {
		theimg.over = a[2];
		if (a.length > 3) {
		  theimg.down = a[3];
		  theimg.downover = (a.length==5)?a[4]:a[2];
		  }
		else {
		  theimg.down = a[2];
		  theimg.downover = theimg.up;
		  }
		}
      }
  if (!state) state=theimg.state;
  if (state=="over" && theimg.state=="up") theimg.src = theimg.over;
  else if (state=="over" && theimg.state=="down") theimg.src = theimg.downover;
  else if (state=="up" || state=="down") {
    theimg.state = state;
	theimg.src = eval("theimg."+state);
    }
  else alert("Invalid state in SetButton");
}

function deactivate(thelink) {
  setMenuLink(thelink,"down");
  var m=thelink;
  for (var l=getLayer(m); l.parentmenu; l=getLayer(m)) {
    m = document.all[l.parentmenu];
	setMenuLink(m,"down");
	}
  if (thelink.popupmenu) thelink.onclick = function () {event.returnValue = false};
  else {
    with (thelink) {
	  outerHTML = innerHTML;
      }
	}
}

function menuHandler() {
 switch (this.tagName) {
  case "A":
    if (menuSelect(this)) Menu_On(this);
	else if (menuUnSelect(this)) {
	   if (!this.popupmenu) Menu_Off(this);
	   else if (!submenuSelect(this)) Menu_Off(this);
	   }
	else if (event.type=="click") {
	   MenuTree_Off(this);
	   }
    break;
	 
  case "DIV":
	if ((menuUnSelect(this)) && (!parentSelect(this))) MenuTree_Off(this);
    break;
  }
  return true;
}

function menuSelect(m) {
  return (event.type=="mouseover") && (!m.contains(event.fromElement));
}

function menuUnSelect(m) {
  return (event.type=="mouseout") && (!m.contains(event.toElement));
}

function submenuSelect(m) {
  return document.all[m.popupmenu].contains(event.toElement);
}

function parentSelect(m) {
  return document.all[m.parentmenu].contains(event.toElement);
}

function getLayer(m) {
  var l = m.parentElement;
  while (l.tagName != "DIV") l = l.parentElement;
  return l;
}

function MenuTree_Off(m) {
  var l=m;
  if (m.tagName=="A") {
      Menu_Off(m)
      l = getLayer(m);
	  }
  if (l.parentmenu) MenuTree_Off(document.all[l.parentmenu]);
}

function Menu_On(linkitem) {
 with (linkitem) {
  if (wiping) stopWipe();
  setMenuLink(linkitem,"over");
  if (linkitem.popupmenu) {
       if (document.all[popupmenu].style.visibility=="hidden") wipe('clipRight',document.all[popupmenu]);
	   }
  }   
  return true;
}

function Menu_Off(linkitem) {
  if (wiping) stopWipe();
  setMenuLink(linkitem);
  if (linkitem.popupmenu) document.all[linkitem.popupmenu].style.visibility="hidden";
  return true;
}


         function wipe(direction,el) {
            /* The third argument is optional and specifies whether a
               wipe-in or wipe-out occurs. The default is a 
               wipe-in. */
            into = true;
            if (arguments[2] != null)
               into = arguments[2];

            if (null == el.init) {
               // Initialize effect.
               // All wipe information is stored in the element.
  			   wiping = true;
			   wipeel = el;
               el.init = true;
               el.clipTop = 0;
               el.clipRight = 0; 
               el.clipBottom = 0; 
               el.clipLeft = 0
               el.inc = 20;
			   
               // Set up wipe in.
               if (into) {
                  switch (direction) {
                  case "clipBottom":
                     el.clipRight = "100%";
                     el.size = el.offsetHeight;
                     break;
                  case "clipRight":
                     el.clipBottom = "100%";
                     el.size = el.offsetWidth;
                     break;
                  case "clipTop":
                     el.clipBottom = "100%";
                     el.clipRight = "100%";
                     el.clipTop = el.offsetHeight;
                     el.inc *= -1;
                     el.size = 0;
                     break;
                  case "clipLeft":
                     el.clipBottom = "100%";
                     el.clipRight = "100%";
                     el.clipLeft = el.offsetWidth;
                     el.inc *= -1;
                     el.size = 0;
                     break;
                  }
				  el.style.visibility = "visible";
				  }
               else       // Set up wipe-out.
                  switch (direction) {
                  case "clipBottom":
                     el.clipRight = "100%";
                     el.clipBottom = el.offsetHeight;
                     el.size = 0;
                     el.inc *= -1;
                     break;
                  case "clipRight":
                     el.clipBottom = "100%";
                     el.clipRight = el.offsetWidth;
                     el.size = 0;
                     el.inc *= -1;
                     break;
                  case "clipTop":
                     el.clipBottom = "100%";
                     el.clipRight = "100%";
                     el.clipHeight = el.offsetHeight;
                     el.size = el.offsetHeight;
                     break;
                  case "clipLeft":
                     el.clipBottom = "100%";
                     el.clipRight = "100%";
                     el.clipLeft = 0;
                     el.size = el.offsetWidth;
                     break;
                  }
            }
            // Increment clip.
            el[direction] += el.inc;
            // Set clip.
            el.style.clip = "rect(" + el.clipTop + " " +
               el.clipRight + " " + el.clipBottom + " " +
               el.clipLeft + ")";
			if (((el.size >= el[direction]) && (el.inc > 0)) || ((el[direction] >= 0) && (el.inc < 0))) {
 			   wipetime = setTimeout("wipe('"+direction+"', document.all."+el.id+", "+into+")", 10);
			   }
			else stopWipe();
         }

function stopWipe() {
  wiping = false;
  wipeel.init = null;
  if (!into) wipeel.style.visibility = "hidden";
  wipeel = null;
  clearTimeout(wipetime);
  wipetime = null;
}

function startPulsate() {
  pEls = document.all["pulsate"];
  if (pEls==null) return false;
  else {
    setInterval("pulsate()",1000);
	}
}

function pulsate() {
   if (!pEls.length) {
      if (pEls.style.color==linkupcolor) pEls.style.color = linkovercolor;
	  else pEls.style.color =linkupcolor;
     }
   else {
     for (var i=0; i<pEls.length; i++) {
	   if (pEls[i].style.color==linkupcolor) pEls[i].style.color = linkovercolor;
	   else pEls[i].style.color = linkupcolor;
	   }
	 }
}

function MM_reloadPage(init) {  
  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);

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_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_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

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_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}