﻿ieHover = function() {


     var x = document.getElementById("nav").getElementsByTagName("DIV");


     for ( var i = 0; i < x.length; i++ ) {


          if ( x[i].className == 'hot' ) {


               x[i].onmouseover = function() { this.className += " ieHover"; }


               x[i].onmouseout = function() {


                    this.className = this.className.replace( new RegExp( " ieHover\\b" ), ""); 


               }


          }


      } 





     var y = document.getElementById("homePgImgs").getElementsByTagName("DIV");


     for ( var j = 0; j < y.length; j++ ) {


               y[j].onmouseover = function() { 


                    if ( !this.className.match(/frame/)) {


                         this.className += " ieHover"; 


                    }


               }


               y[j].onmouseout = function() {


                    this.className = this.className.replace( new RegExp( " ieHover\\b" ), ""); 


               }


      } 


}


if ( window.attachEvent ) window.attachEvent("onload", ieHover );








function getAbsPos(elt,which) {


  iPos = 0;


  while (elt != null) {


    iPos += elt["offset" + which];


    elt = elt.offsetParent;


    }


  return iPos;


}





function getAbsX(elt) { return (elt.x) ? elt.x : getAbsPos(elt,"Left"); }


function getAbsY(elt) { return (elt.y) ? elt.y : getAbsPos(elt,"Top"); }





function showSubNav( mainId, subId ) {


  // get mainId's position on the page


  // change the border style for mainId if not on the page you are rolling over


  if ( document.getElementById( mainId ).className !=  mainId + "On" ) {


     document.getElementById( mainId ).className = mainId + 'Roll';


   }


  // lower the z-index of the item to the right of mainId


  


  // position the sub menu


  var subNav = document.getElementById( subId );


  subNav.style.left = '-1px';


  subNav.style.top = '19px';


  subNav.style.display = 'block';


}





function hideSubNav( mainId, subId, prevState ) {


  // return to previous state


  document.getElementById( mainId ).className = ( mainId + prevState );


  // hide the submenu


  document.getElementById( subId ).style.display = 'none';


}


 


// Given an element with both 'id' and 'class' attributes,


// change the 'class' of the element


// id - the id attribute of the element to change


// newClass - the name of the class to apply to the element


function changeClass( id, newClass ) {


  document.getElementById( id ).className = newClass;


}





function addArrows( anID, frameNo, aDirection ) {


// get the id of enclosing element


  x = document.getElementById( anID );


  


// figure out what the next frame is so that the arrows' onclick can be set right.


  var nextFrame = frameNo;


  if ( nextFrame == 5 ) {


    nextFrame = 99;


  } else { 


    nextFrame++;


  }


  // figure out what the previous frame is


  var prevFrame = frameNo;


  if ( prevFrame == 0 ) {


    prevFrame = 99;


  } else {


    prevFrame = prevFrame - 1;


  }


 


  // create two <a> elements


  anchorLt = document.createElement( 'a' );


  anchorRt = document.createElement( 'a' );


  // attach the href


  anchorLt.setAttribute( 'href', '#' );


  anchorRt.setAttribute( 'href', '#' );  


  


  // edit the left arrow image tag


  firstImg = document.getElementById( 'goLt' );


  if ( aDirection == 'wentLeft' ) {


     firstImg.setAttribute( 'src', ( 'images/' + frameNo + 'frameGoLt_016x021_r.gif' ) );


  } else {


     firstImg.setAttribute( 'src', ( 'images/' + frameNo + 'frameGoLt_016x021.gif' ) );


  }


  firstImg.setAttribute( 'alt', 'go left to previous frame' );


  firstImg.style.display = ( 'block' );


  firstImg.onmouseover = function() { this.src='images/' + frameNo + 'frameGoLt_016x021_r.gif';}; 


  firstImg.onmouseout = function() { this.src='images/' + frameNo + 'frameGoLt_016x021.gif';};





// edit the right arrow image tag


  secondImg = document.getElementById('goRt');


  if ( aDirection == 'wentRight' ) {


     secondImg.setAttribute( 'src', ( 'images/' + frameNo + 'frameGoRt_016x021_r.gif' ) );


  } else {


     secondImg.setAttribute( 'src', ( 'images/' + frameNo + 'frameGoRt_016x021.gif' ) );


  }


  secondImg.setAttribute( 'alt', 'go right to next frame' );


  secondImg.style.display = ( 'block' );


  secondImg.onmouseover = function() { this.src='images/' + frameNo + 'frameGoRt_016x021_r.gif';}; 


  secondImg.onmouseout = function() { this.src='images/' + frameNo + 'frameGoRt_016x021.gif';};





// append the new <a> tags to the tree


  x.appendChild( anchorLt );


  x.appendChild( anchorRt );





//  append the images to the new <a> tags


  anchorLt.appendChild( firstImg );


  anchorRt.appendChild( secondImg );


  if ( prevFrame == 99 ) {


     if ( document.title == 'IMMI : Home' ) { //"home" refers to home.html. index.html's title is "home " -note the space. 


       anchorLt.onclick = function() { window.location.href = "index.html"; };


     } else { 


       anchorLt.onclick = function() { window.location.href = "home.html"; };


     }


  } else anchorLt.onclick = function() { changeFrame( 'homePgImgs', prevFrame, 'wentLeft' ); };








  if ( nextFrame == 99 ) {


    if ( document.title == 'IMMI : Home' ) {


      anchorRt.onclick = function() { window.location.href = "index.html"; };


    } else {


      anchorRt.onclick = function() { window.location.href = "home.html"; };


    }


  } else anchorRt.onclick = function() { changeFrame( 'homePgImgs', nextFrame, 'wentRight' ); };


}





// Change the state of the images on the home page from initial so something else


// frameNo - the number of the frame to change to


//           - the page is loaded in frame 0 (six slices)


//             - go to frame 1 by clicking "home" when any frame but frame 0 is loaded


//               or if you are in frame 6, by clicking the right arrow


//               or if you are in frame 2, by clicking the left arrow


           


//           - go to frame 1 by clicking leftmost sliver


//             or by clicking anywhere in the orange bar





//           - go to frame 2 by clicking the second sliver


//             or if you are in frame 1, by clicking the right arrow


//             of if you are in frame 3, by clicking the left arrow





//           - and so on...


// Remove <a> tags.


// Add arrows.


// Activate Home button.


function changeFrame( id, frameNo, dir ) {


  // effectively all this does is swap out the background image for the seven 


  // elements that make up the slide show area


  document.getElementById( 'sliver1' ).className = 'firstImg' + frameNo + 'frame';


  document.getElementById( 'sliver2' ).className = 'secondImg' + frameNo + 'frame';


  document.getElementById( 'sliver3' ).className = 'thirdImg' + frameNo + 'frame';


  document.getElementById( 'sliver4' ).className = 'fourthImg' + frameNo + 'frame';


  document.getElementById( 'sliver5' ).className = 'fifthImg' + frameNo + 'frame';


  document.getElementById( 'sliver6' ).className = 'sixthImg' + frameNo + 'frame';


  document.getElementById( 'tagLine' ).className = 'tagLine' + frameNo + 'frame';


  


  // remove <a> tags - we don't want the slivers clickable in any state except the initial load state.


  // x will be a list of divs


  var x = document.getElementById( id ).getElementsByTagName("DIV");


  // y is a list of all the <a> elements in each <div> in the list x


  var y;


  var z;


  for ( var i = 0; i < x.length; i++ ) {


     y = x[i].getElementsByTagName("A");


     for ( var j = 0; j < y.length; j++ ) {


          z = y[j].getElementsByTagName("IMG");


          for ( var k = 0; k < z.length; k++ ) {


               //attach the images


               x[i].appendChild( z[k] );


          }


          //remove the anchors


          x[i].removeChild( y[j] );


     }


  }


  // add in arrow for frames


  // first get the ID we really need


  addArrows( "tagLine" , frameNo, dir ); 





// Change class of the "Home" button and add an <a>.


  var h = document.getElementById( "home" );


  var hl = document.getElementById("homeLink");


  anchorHome = document.createElement( 'a' );


  // set the attributes 


  anchorHome.setAttribute( 'href', 'home.html' );


  // attach the href


  anchorHome.appendChild( hl );


  h.appendChild( anchorHome ); 


  hl.onclick = function() { window.location.href = "home.html"; };


  h.className = 'homeOn';


  h.onmouseover = function() { this.className='homeOn'; }; 


  h.onmouseout = function() { this.className='home'; }; 


}





// Popup window script


function popWin(url) {


     newwindow = window.open( url,'name','height=800,width=900,scrollbars=yes' );


     if ( window.focus ) {


          newwindow.focus()


     }


     return false;


}





function popFullWin(url) {


     newwindow = window.open( url,'name','height=800,width=900,resizable=yes,scrollbars=yes,status=yes');


     if ( window.focus ) {


          newwindow.focus()


     }


     return false;


}





