// this file supports the AFIS header file

// preload rollover images
afispon = new Image()
afispon.src = "/afisbrand/images/afisproducts1b.gif";
afispoff = new Image()
afispoff.src = "/afisbrand/images/afisproducts1a.gif";
afisson = new Image()
afisson.src = "/afisbrand/images/afisservices1b.gif";
afissoff = new Image()
afissoff.src = "/afisbrand/images/afisservices1a.gif";
afisabouton = new Image()
afisabouton.src = "/afisbrand/images/afisabout1b.gif";
afisaboutoff = new Image()
afisaboutoff.src = "/afisbrand/images/afisabout1a.gif";



// initialize position variables
LeftX=0; BottomY=0; TopY=0; RightX=0;
var curMenu=document;

// function GetWidth()
// get the width of the current window
function GetWidth() {
  if (!document.all) {
    return window.innerWidth
  } else { 
    return document.body.clientWidth; 
  }
}


function GetHeight() {
  if (!document.all) {
     return window.innerHeight
  } else {
     return document.body.clientHeight;
  }
}

/* function menuDivPos 
 * positions the menu item (initially hidden) xPos from the right margin, you 
 * can also specify a new yPos which moves the div vertically with the starting 
 * position being the top of the window.  tLayer is the DIV to position.  Pass 
 * three args per item to this function.  To call this function use this syntax:  
 * menuDivPos('afrtsnav',290,59,'dvinav',190,59) - repositions 2 DIVs.
*/
function menuDivPos() {
var args = menuDivPos.arguments;
for (var i=0;i<(args.length-1);i+=3) {

  // setup the variables
  var tLayer = args[i];
  var xPos = args[i+1];
  var yPos = args[i+2];

  // check that the arguments were sent in the correct order, tLayer must be a text type
  if (typeof tLayer != "string" || typeof xPos != "number" || typeof yPos != "number") { alert("ERROR! Pass arguments to this function in the order of layer, horizontal position, vertical position.\r\reg menuDivPos\('" + tLayer + "', '" + xPos + "', '" + yPos + "'\), quote the first argument, do not quote the numbers!"); return;
  }

  // get the object reference
  dnav = MM_findObj(tLayer);

  // get the window width
  a = GetWidth();  if (a < 500) { a = 500; }

  // set the new positions
  if (document.getElementById) { 
    dnav.style.left = (xPos-5); 
    dnav.style.top = yPos; 
  } else if (dnav.style) { 
    dnav.style.pixelLeft = (xPos-5); 
    dnav.style.pixelTop = yPos; 
  } else { 
    dnav.moveTo((xPos-10),yPos) 
  }
}
}

// find the referenced object
function MM_findObj(n, d) { //v3.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(d.getElementById) { 
    x=d.getElementById(n); 
    return x; 
  }
  if(!(x=d[n])&&d.all) 
    x=d.all[n]; 
    for (var i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(var i=0;!x&&d.layers&&i<d.layers.length;i++)
      x=MM_findObj(n,d.layers[i].document); 
   return x;
}

function showHideLayers() { 
  var i,p,v,obj,args=showHideLayers.arguments;
  for (var 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; 
    }
  }
    // track current object location/size
  if (ns) {
  LeftX  = obj.left;
  RightX = LeftX + obj.clip.width;
  TopY  = obj.top;
  BottomY = obj.top + obj.clip.height;;
  }
  if (ie || ns6) {
  LeftX  = MakeNum(obj.left); 
  RightX = MakeNum(obj.width) + LeftX;
  TopY  = MakeNum(obj.top); 
  BottomY = MakeNum(obj.top) + MakeNum(obj.height);
  }
  curMenu = obj;
}

// take a value with the string 'px' after a number value, return the number
function MakeNum(v) { nm = v.substring(0, v.indexOf("px")); nm = Number(nm); return nm; } 

function toggleImage()  { // toggle icons and popups
var args = toggleImage.arguments
// imageName    - name of image to be toggled (from IMG tag NAME attribute)
// newImageName - name of image object to be toggled (from new Image() above)
for (var i=0;i<args.length-1;i+=2) {
   var imageName = args[i];
   var newImageName = args[i+1];
//alert("change images now " + imageName + " : " + newImageName)
   document.images[imageName].src = eval(newImageName + ".src");  // toggle icon
}
}


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);

// function hideAll() { showHideLayers('pro','','hide','serv','','hide','aboutAFIS','','hide'); }

function hideAll() { curMenu.visibility='hidden'; toggleImage('afisp','afispoff','afiss','afissoff','AFISabout','afisaboutoff'); }

function getRealLeft(imgElem) {
        xPos = eval(imgElem).offsetLeft;
        tempEl = eval(imgElem).offsetParent;
        while (tempEl != null) {
                xPos += tempEl.offsetLeft;
                tempEl = tempEl.offsetParent;
        }
       return xPos;
} 

// function FindNewDivPos() looks for the x,y coords of the images used as 
// anchors and respositions the popup menus to line up with each.
function FindNewDivPos() {
  if (ie || ns6) 
  { 
  img2x = getRealLeft(document.images["afisp"]); 
  img4x = getRealLeft(document.images["afiss"]); 
  img6x = getRealLeft(document.images["AFISabout"]); 
  } 
  else if (ns)
  { 
    img2x = document.afisp.x;
    img4x = document.afiss.x;
    img6x = document.AFISabout.x;
//  menuDivPos('pro',img2x,60,'serv',img4x-20,60,'aboutAFIS',img6x,60);
  }

  if (isMac && !ns6) 
  {
    // no reliable way to get the current image's position, so set the 
    // location based upon the window width
    a = GetWidth(); img2x = a-290; img4x = a-200; img6x = a-70;
  }
  menuDivPos('pro',img2x,60,'serv',img4x-20,60,'aboutAFIS',img6x,60);
}

function updateIt(e)
{
if (ns6 && isMac)
  {
    var x = e.clientLeft;
    var y = e.clientTop;
  }
else if (ie)
  {
    var x = window.event.clientX;
    var y = window.event.clientY;
  }
else if (ns)
  {
    var x = e.pageX;
    var y = e.pageY;
  }
else if (ns6)
  {
    var x = e.clientX;
    var y = e.clientY;
  }
    if (x > (RightX+20) || x < (LeftX-20)) hideAll();
    else if (y > (BottomY+40) || y < (TopY-20)) hideAll();
}

// end of file

