/*

THIS CODE CAN BE USED WITH IMAGES, TEXT, OR BOTH

You must include this page with any webpage that uses the menu like so:
<script language="JavaScript" type="text/JavaScript" src="navigation.js"></script>

***********To use with images***************

You must link two images representing "on" and "off"
Image names default to "imagename + .gif" (off) and "imagename + _f2.gif" (on)
The path defaults to "/images/"
Each image must have a "name" property and code like so;

<a onMouseOver="hideMenu(); popup('news'); overmenu=1" 
            onMouseOut=" menutimeout('news');overmenu=0" 
            href="#"><img src="images/icons/html.gif"  border="0" name="news"></a> 
			
You must also list out the names of the images in the javascript at the top of your page
Like so:

function imageLinks(){
toc_new('news');
//toc_new('calendar');
//toc_new('contacts');
}

************To use with text****************

You must nest the text in a div tag with an "id" property and code like so:

<DIV Id="news" style="Z-INDEX: 1000; POSITION: absolute; WIDTH: 50px; HEIGHT: 10px; LEFT: 72px; TOP: 10px"><a onMouseOver="hideMenu(); popup('news'); overmenu=1" 
            onMouseOut=" menutimeout('news');overmenu=0" 
            href="#">news</a></DIV>
			
************Sample menu layer code**********

<div id="newslayer" onMouseOver=overmenu=1; style="Z-INDEX: 102; LEFT: 10px; VISIBILITY: hidden; POSITION: absolute; TOP: 30px" onMouseOut="overmenu=0; menutimeout('news')" > 
        
  <table width="200" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFCC99">
    <tr> 
            
      <td colspan="3"> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
                  <td colspan="3" height="0"> 
                    <p><img src="/headergraphics/greenbar.jpg" width="5" height="5"></p>
                  </td>
                </tr>
                <tr> 
                  <td width="15">&nbsp;</td>
                  <td> 
                    <p><a href="/contacts/accountteam.asp" class="navtext">Account 
                      Team</a><br>
                      <a href="/contacts/partners.asp" class="navtext">Partners</a><br>
                      <a href="/contacts/nebtowns/index.asp" class="navtext">Town 
                      Index</a></p>
                  </td>
                  <td width="20">&nbsp;</td>
                </tr>
              </table>
            </td>
          </tr>
          <tr> 
            <td> 
              <div align="right"></div>
            </td>
            
      <td>&nbsp;</td>
      <td>&nbsp;</td>
          </tr>
        </table>
      </div>

*/ 
  
   NS4 = (document.layers);
   NS6 =  ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 5))
   IE4 = (document.all);
   MAC45 = (navigator.appVersion.indexOf("MSIE 4.5") != -1)
  ver4 = (NS4 || IE4);   
 isMac = (navigator.appVersion.indexOf("Mac") != -1);
 menuHeight=-18;
 menuOffset=2;
var overmenu = false;
var openmenu = null;
var overcheck = null;
 
//added for select form object support
  function P7_hideSelect(a){ //v1.0 by PVII
  var g,h=(a==1)?"hidden":"visible";
  if(document.getElementsByTagName){
  g=document.getElementsByTagName("select");
  if(g){for(var i=0;i<g.length;i++){
  g[i].style.visibility=h;}}}
  }
//
function FindLeftEdge(img) {
// Find Position of Image File
        xPos = img.offsetLeft;
        tempEl = img.offsetParent;
        while (tempEl != null) {
                xPos += tempEl.offsetLeft;
                tempEl = tempEl.offsetParent;
        }
        return xPos;
}

function FindTopEdge(img) {
// Find Position of Image File
        yPos = img.offsetTop;
        tempEl = img.offsetParent;
        while (tempEl != null) {
                yPos += tempEl.offsetTop;
                tempEl = tempEl.offsetParent;
        }
        if (MAC45) yPos=menuOffset;
        return yPos;
        }

function findloc (imgname)
// Find Position of Image File
{
	if (NS6)
		var holdingImage=document.getElementById(imgname)
	else if (NS4)
		var holdingImage=eval("document.layers."+imgname)
	else
		var holdingImage=eval(imgname);
var canvasLeft = (NS4 && !NS6) ? holdingImage.x : FindLeftEdge(holdingImage)+2;
var canvasTop = (NS4 && !NS6) ? holdingImage.y : FindTopEdge(holdingImage);
var canvasWidth = holdingImage.width;
var canvasHeight = holdingImage.height;
return ([canvasLeft,canvasTop]);
}

function showMenu(imgname) 
// Show Menu Layer
{
        if (NS6) 
                menu=document.getElementById(imgname+"layer")
        else if (NS4)
                menu=eval("document.layers."+imgname+"layer")
        else
                menu=eval(imgname+"layer");

        if (NS4) menu.visibility = "show"
        else menu.style.visibility = "visible"
        openmenu=imgname;
		if(tocItem[openmenu]) swap_img(openmenu);
}

function hideMenu() 
// Hide Menu Layer
{
if (openmenu != null)
        {
        if (NS6) 
                menu=document.getElementById(openmenu+"layer")
        else if (NS4)
                menu=eval("document.layers."+openmenu+"layer")
        else
                menu=eval(openmenu+"layer");
            if (NS4) menu.visibility = "hide"
            else menu.style.visibility = "hidden"
			//alert(openmenu);
             if(tocItem[openmenu]) unswap_img(openmenu);
        }
}

function popup (imgname)
// Pop Up Menu
{
        if (NS6) 
                menu=document.getElementById(imgname+"layer")
        else if (NS4)
                menu=eval("document.layers."+imgname+"layer")
        else
                menu=eval(imgname+"layer");
if (NS4)
{
        menu.top = findloc(imgname)[1]-1-menuHeight;
		menu.left = findloc(imgname)[0]-menuOffset;
}
else if (NS6)
{
        menu.style.top = findloc(imgname)[1]-1-menuHeight;
        menu.style.left = findloc(imgname)[0]-menuOffset;
}
else
{
        menu.style.pixelTop = findloc(imgname)[1]-1-menuHeight;
		menu.style.pixelLeft = findloc(imgname)[0]-menuOffset;
		
		/*check to see if the menu is going to go off the screen and adjust
		Code may need improvement here*/
		if(menu.style.pixelLeft > 240)
        menu.style.pixelLeft = findloc(imgname)[0]-20;
}
showMenu(imgname);
}

function checkmenu (openmenu,check)
// Check to see if menu is open but not used, if so it is closed
{
if ((overmenu == 0) && (check == overcheck))
{
        if (NS6) 
                menu=document.getElementById(openmenu+"layer")
        else if (NS4)
                menu=eval("document.layers."+openmenu+"layer")
        else
                menu=eval(openmenu+"layer");
            if (NS4) menu.visibility = "hide"
            else menu.style.visibility = "hidden"
			//alert(tocItem[openmenu])
			 if(tocItem[openmenu]) unswap_img(openmenu);
                //unswap_img(openmenu);
}
}

function menutimeout (openmenu)
// half second timeout after mouse moves away from image or subnav in IE 
{
if (IE4){
overcheck=overcheck+1;
setTimeout("checkmenu(openmenu,"+overcheck+")",500);
}
}

function tocItem (name) {
this.on = new Image();
this.on.src = "/images/" + name + "_f2.gif"
this.off = new Image();
this.off.src = "/images/" + name + ".gif"
}

function toc_new (name) {
tocItem[name] = new tocItem(name);
}

function swap_img (imgName, openmenu)
// Swap out image for mouseover event
{
if (document.images) {
//alert(imgName)
	if ((openmenu == null) || (IE4) || (NS6)){
		document[imgName].src = tocItem[imgName].on.src;
	}else{
       image= eval("document.layers."+openmenu+"layer.document.images['"+imgName+"']");
       image.src = tocItem[imgName].on.src;

    }
}
}

function unswap_img (imgName, openmenu)
// Return to original image
{
if (document.images) {
	if ((openmenu == null) || (IE4) || (NS6)){
   		 document[imgName].src = tocItem[imgName].off.src
	}else{
        image= eval("document.layers."+openmenu+"layer.document.images['"+imgName+"']");
        image.src = tocItem[imgName].off.src;
    }
}
}

if (document.images != null) {

}

