
//// [MHDY] 10/20/2004
  // NWCA

/* Globals
--------------------------------------- */
var D      =document;
var regDl  =/dl/i;
var regDd  =/dd/i;


/* FUNCTIONS
--------------------------------------- */
 // Core
 // Array.push for IE mac
if(typeof Array.prototype.push == 'undefined'){
 Array.prototype.push=function(){
   b=this.length,a=arguments;
   for(var i=0; i<a.length; i++){
    this[b+i]=a[i];
   }
   return this.length
 }
}

 // Level Columns
function getObjHeight(A){
 var obj =D.getElementById(A);
 return (obj.offsetHeight)? obj.offsetHeight : null;
 /*
  NOTE:
  offsetHeight & clientHeight return the same value. New browsers should support both.
  */
}

function setObjHeight(A,NUM){
 D.getElementById(A).style.height= NUM+"px";
}

function levelColumnH(){
 var max;
  //Col 1 & 2
 var col1 =(arguments[0] && D.getElementById(arguments[0]))? getObjHeight(arguments[0]): null;
 var col2 =(arguments[1] && D.getElementById(arguments[1]))? getObjHeight(arguments[1]): null;
 if(col1 == null || col2 == null) return false;
 max =Math.max(col1,col2);
 if (col1!= max) setObjHeight(arguments[0],max);
 if (col2!= max) setObjHeight(arguments[1],max);
  //Col 3
 var c3adjust =0; // This is needed due to the use of margins or padding; Ideally, the element should have neither
 var col3 =(arguments[2] && D.getElementById(arguments[2]))? getObjHeight(arguments[2]): null;
 if(col3 == null) return false;
 max =Math.max(col2,col3);
 if (col2 != max){
   setObjHeight(arguments[0],max);
   setObjHeight(arguments[1],max);
 }
 if (col3 != max) setObjHeight(arguments[2],max - c3adjust);
 /* DEBUG */
 // alert(max+', '+col1+', '+col2+', '+col3);
 /* !DEBUG */
}


 // FORM METHOD
function inputClear(x){
 if (!D.getElementById(x)){return false;}

 var $login   =['0 16px','0 0'];
 var $pass    =['0 16px','-66px 0'];
 var $sets    =[$login,$pass];
 var $set     =(x =='loginUn')? 0: 1;
 var $obj     =D.getElementById(x);

 $obj.onfocus =function(){$obj.style.backgroundPosition =$sets[$set][0];}
 $obj.onblur  =function(){
   if(/^(\s*)$/g.test(this.value)){
     $obj.style.backgroundPosition =$sets[$set][1];
     this.value='';
   }
 }
}

 // Menus
 // Menu Assignment
submenu =function(V){
 if (document.getElementById && document.getElementById(V)){
   var $navRoot;
   var $node;

   $navRoot = document.getElementById(V);
//
// [CODE]
//   for (var i=0; $navRoot.childNodes[i]; i++){
// [!CODE]
// This technique works for most browsers, but
// causes IE Mac to throw an error at the end
// of the loop, Due to an undefined childNode[limit+1]
//
   for (var i=0; i < $navRoot.childNodes.length; i++){
	   $node =$navRoot.childNodes[i];
// Note: see comment above
// [CODE]
//   for (var g=0; $node.childNodes[g]; g++){
// ![CODE]
     for (var g=0; g < $node.childNodes.length; g++){
       if (regDl.exec($node.childNodes[g].nodeName)){
         $node.name =$navRoot.childNodes[i].childNodes[0].nodeValue;
         $node.link =$navRoot.childNodes[i].firstChild.attributes['href'].nodeValue;
         $node.id   =$node.attributes['id'].nodeValue;
         $node.onmouseover =menu1;
         $node.onmouseout  =menuTimeout;
       }
     }

   }
 }
}

 // Menu Generation
var CONTAINER ='container';
var GETBY     ='id'; /* 'tag' || 'id' */
var MENUNAME  ='newMenu';   // Arbitrary ID

var menu1 =function(){
 menuStoptime();
 menu0(); // clear old menus

 var $left =0;
 // $left +=(D.getElementById(CONTAINER).offsetLeft)? D.getElementById(CONTAINER).offsetLeft: 0; // This Container
 $left +=(D.getElementById(this.id).parentNode.offsetLeft)? D.getElementById(this.id).parentNode.offsetLeft: 0; // This Set
 $left +=(D.getElementById(this.id).offsetLeft)? D.getElementById(this.id).offsetLeft: 0; // This Element

 var $top =0;
 // $top +=(D.getElementById(CONTAINER).offsetTop)? D.getElementById(CONTAINER).offsetTop: 0;
 $top +=(D.getElementById(this.id).parentNode.offsetTop)? D.getElementById(this.id).parentNode.offsetTop: 0;
 $top +=(D.getElementById(this.id).offsetTop)? D.getElementById(this.id).offsetTop: 0;
 $top +=(D.getElementById(this.id).offsetHeight)? D.getElementById(this.id).offsetHeight: 0;

  // find sub links
 var $subLinks =[];
 var $subNames =[];
 for (var g=0; g < D.getElementById(this.id).childNodes.length; g++){
   if (D.getElementById(this.id).childNodes[g].nodeType == 1){
     for (var j=0; j < D.getElementById(this.id).childNodes[g].childNodes.length; j++){
       if (regDd.exec(D.getElementById(this.id).childNodes[g].childNodes[j].nodeName)){
        // D.getElementById(this.id).childNodes[g].childNodes[j].nodeName +' ' ; // DD
        // D.getElementById(this.id).childNodes[g].childNodes[j].nodeType +'\n' ; // 1
         $subLinks.push(D.getElementById(this.id).childNodes[g].childNodes[j].firstChild.attributes['href'].nodeValue);
         $subNames.push(D.getElementById(this.id).childNodes[g].childNodes[j].firstChild.firstChild.nodeValue);
       }
     }
   }
 }

 var menu =D.createElement('div');  // Menu: Create DIV
 menu.style.position ='absolute';   // Style
 menu.style.top    =$top +'px';
 menu.style.left   =$left +'px';
 menu.style.zIndex ='100';
 menu.setAttribute('id', MENUNAME); // Set Id for DIV

 var linkElm;
 for (var i=0; i < $subLinks.length; i++){
   linkElm =D.createElement('a');
   linkElm.setAttribute('class','subLink'); // IE PC doesn't see/apply this class. why??? ID used instead.
   linkElm.setAttribute('href',$subLinks[i]);
   linkElm.appendChild(D.createTextNode($subNames[i]));
   menu.appendChild(linkElm);
 }

 if (GETBY == "tag"){
   D.getElementsByTagName(CONTAINER)[0].appendChild(menu); // Append DIV to Containing DIV
 }else{
   D.getElementById(CONTAINER).appendChild(menu); // Append DIV to Containing DIV
 }
 D.getElementById(MENUNAME).onmouseover =menuStoptime;
 D.getElementById(MENUNAME).onmouseout  =menuTimeout;
}

 // Timers
var $timer;
var menuTimeout =function(){
 $timer =window.setTimeout('menu0()',500);
}
var menuStoptime =function(){
 window.clearTimeout($timer);
}
var menu0 =function(){
 if (D.getElementById(MENUNAME)){
   D.getElementById(MENUNAME).parentNode.removeChild(D.getElementById(MENUNAME));
 }
}

 // POP UP WINDOW
 // Attach Pop Up functions
function getElementbyClass(CLASSNAM){
 var $alltags =document.all? document.all : document.getElementsByTagName('*');
 for (var i=0; i<$alltags.length; i++){
   if ($alltags[i].className == CLASSNAM){
     classActionPop($alltags[i]);
   }
 }
}
 // Attach Pop Up functions
function classActionPop(x){
 x.onclick =function(){window.open(this.href,'new'); return false;}
 x.title   ='Pop Up: ' + x.title;
}

function fAssignTagA(){
 var strLoc = location.hash;
 if (strLoc.indexOf('#') != -1){
   var arLoc = strLoc.split('#');

   hiLightAnchor(arLoc[1]);

   var allATag = document.getElementsByTagName('A');
   for (var i=0; i < allATag.length; i++){
     if (allATag[i].getAttribute('href')){
       if(allATag[i].getAttribute('href').indexOf('#') != -1){
         allATag[i].ID = allATag[i].getAttribute('href').split('#')[1];
         allATag[i].onclick = fHiliteHash;
       }
     }
   }
 }
}
function fHiliteHash(){
  hiLightAnchor(this.ID);
}

 // ANCHOR TAG HI-LIGHTS ("#NAME" NOT "HREF")
var $hiLightHistory;
function hiLightAnchor(ID){
 if (D.getElementById(ID)){
   D.getElementById(ID).style.color ='#8C0';
   D.getElementById(ID).style.fontSize ='1.4em';
// D.getElementById(ID).style.fontWeight ='bold';
    /* Reset previous selection */
   if ($hiLightHistory!=null){
     D.getElementById($hiLightHistory).style.color ='#000';
     D.getElementById($hiLightHistory).style.fontSize ='1em';;
//   D.getElementById($hiLightHistory).style.fontWeight ='normal';
   }
   /* Set New Selection */
   $hiLightHistory =ID;
 }
}

// Onload Function
function loaded(){
 submenu('t0'); // apply sub menus to Tier 0
 submenu('t1'); // apply sub menus to Tier 1
 submenu('t0col1'); // apply sub menus to Tier 0 in the 1 column layout

 getElementbyClass('pop'); // apply the pop window class

 levelColumnH('columnLeft','content2Col');

 inputClear('loginUn');
 inputClear('loginPw');
}

//// EVENTS
// Onload Event
if (D.getElementById){
  window.onload =loaded;
}
