// JavaScript Document

var menuBars=new Array();
var menuPtr=0;

function doSearch()
{
    //window.location = imagePath+"search/search.asp?SearchField="+escape(document.getElementById('searchField').value);
	//Redirected search results to Google Mini - JJR
	window.location = "http://search.smdc.org/search?q="+escape(document.getElementById('searchField').value)+"&site=default_collection&client=default_frontend&proxystylesheet=default_frontend&output=xml_no_dtd&x=14&y=12";
}

function doContactUs()
{
    window.location = imagePath+"contactus/contactus.asp";
}

function gotoLink2(theForm)
{
    window.open(document.getElementById('groupscombo').value);
}

function gotoLink4(theForm)
{
    window.open(document.getElementById('cmecombo').value);
}

function gotoLink3(theForm)
{
    window.open(document.getElementById('classescombo').value);
}

function AJAXRequest(sendData, returnFunction, url)
{
   //alert(returnFunction+"_"+url);
   var AJAXWrapper = (function ()
   {
      var rFunc; // the return function.
      var sData; // data we're sending. 
      var xhrq; // XMLHTTPRequest object.
      var xURL;
      var errorCode;
      var errorMsg;

      var readyStates = { 'uninitialized' : 0, 'loading' : 1, 'loaded' : 2, 'interactive' : 3, 'complete' : 4 } ;
      var statusCodes = { 'OK' : 200, 'Not Found' : 404 } ;
      function XMLHandler()
      {

	     //alert( xhrq.status +" _ "+xhrq.readyState+" _ "+  xhrq.responseXML+" _ "+xhrq.responseText );   
         if (xhrq.readyState == readyStates.complete)

            if (xhrq.status == statusCodes.OK )
            {
				//alert( xhrq.status +" _ "+xhrq.readyState+" _ "+  xhrq.responseXML+" _ "+xhrq.responseText );  
               rFunc(xhrq.responseXML, xhrq.responseText);
            }
            else
					alert (xhrq.statusText);
      //             logTransaction ('AJAXRequest', ['error', 'status failed'], ['status', xhrq.statusText]);
         
      }

      function init(dataToSend, returnFunc, inURL)
      {
         rFunc = returnFunc;
         if (dataToSend != null)
            sData = new String(dataToSend.xml);         // make a new copy.
         else
            sData = null;
         xURL = new String(inURL);
         errorCode = 0;
         errorMsg = "";

         // make xmlhttprequest -- branch for IE & one for other browsers.
         xhrq = false;
         if (window.XMLHttpRequest)
         {
            try
            {
              xhrq = new XMLHttpRequest();
//              xhrq.overrideMimeType('text/xml');
            }
            catch (e)
            {
               xhrq = false;
            }
         }
         else if (window.ActiveXObject)
         {
            try
            {
				xhrq = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
               xhrq = false;
            }
         }

         if (xhrq)
         {
            var sendMethod;
            if (dataToSend != null) 
				sendMethod = "POST"; 
			else 
				sendMethod = "GET";
     		//logTransaction('AJAXRequest', ['xmlout', sData]);
            xhrq.onreadystatechange = XMLHandler;
            xhrq.open(sendMethod, inURL, true);
			if (dataToSend != null)
            {
               xhrq.setRequestHeader('Content-Type', 'text/xml');
               xhrq.send(dataToSend);
            }
            else
               xhrq.send(null);
         }
         else
         {
            errorCode = - 1;
            errorMsg = "No XMLHttpRequest object available in browser.";
         }
      }
	 return { 'init' : init, 'XMLHandler' : XMLHandler } ;
   })();
   
   this.readyStates = {'uninitialized' : 0, 'loading' : 1, 'loaded' : 2, 'interactive' : 3, 'complete' : 4 };
   this.statusCodes = { 'OK' : 200, 'Not Found' : 404 } ;
   AJAXWrapper.init(sendData, returnFunction, url);
}

var imagePath = "images/";
// JavaScript Document
function makeBlueBar()
{
   // upon sizing, we need to redimension first and last children.
   var xsize = 210;
   var newRect = makeDiv(xsize, 26);
   var innerRect = makeDiv(xsize - 11, 26);
   newRect.rectStyle = 'blueBar';
   innerRect.style.left = '11px';
   innerRect.style.top = '0px';
   innerRect.style.fontSize = '12px';

   innerRect.style.textAlign = 'left';
   innerRect.style.fontWeight = 'bold';
   innerRect.style.paddingTop = '4px';
   innerRect.zIndex = 3;
   innerRect.style.backgroundColor = '#0e7b95';
   innerRect.style.height = '16px';

   innerRect.style.backgroundRepeat = 'repeat-x';

   newRect.appendChild(innerRect);

   var topLeft = makeDiv(11, 13);
   topLeft.style.backgroundImage = 'url(' + imagePath + "topLeftDarkBlue.png" + ')';
   topLeft.style.backgroundRepeat = 'no-repeat';
   topLeft.style.top = '0px';
   topLeft.style.left = '0px';
   newRect.appendChild(topLeft);

   var topMid = makeDiv(xsize - 11, 13);
   topMid.style.left = '12px';
   topMid.style.top = '0px';
   topMid.style.zIndex = - 1;
   topMid.style.backgroundImage = 'url(' + imagePath + 'rightMiddleDarkBlue1by15.png' + ')';
   newRect.appendChild(topMid);

   var middleLeft = makeDiv(11, 1);
   middleLeft.style.backgroundImage = 'url(' + imagePath + "middleLeftDarkBlue.png" + ')';
   middleLeft.style.backgroundRepeat = 'repeat-y';
   middleLeft.style.top = '13px';
   middleLeft.style.left = '0px';
   newRect.appendChild(middleLeft);

   var bottomLeft = makeDiv(11, 12);
   bottomLeft.style.backgroundImage = 'url(' + imagePath + "bottomLeftDarkBlue.png" + ')';
   bottomLeft.style.backgroundRepeat = 'no-repeat';
   bottomLeft.style.bottom = '0px';
   bottomLeft.style.left = '0px';
   newRect.appendChild(bottomLeft);

   var bottomRight = makeDiv(xsize - 11, 30);
   bottomRight.style.backgroundImage = 'url(' + imagePath + 'rightBottomDarkBlue1by14.png' + ')';
   //   bottomRight.style.bottom = '0px';
   bottomRight.style.zIndex = - 1;
   bottomRight.style.top = '12px';
   //    bottomRight.style.bottom = '0px';
   bottomRight.style.left = '11px';
   bottomRight.style.backgroundRepeat = 'repeat-x';
   newRect.appendChild(bottomRight);
   newRect.newBarLoc = 22;
   return(newRect);

}

//  ---------------------------------------

function makeRoundRect(xsize, ysize, radius, c, noRight)
{

    var newRect = makeDiv(xsize, ysize);
    var bottomAreaTop = ysize - radius;
    var innerRect;
    var ndivSize;

    if (noRight) 
   		ndivSize = xsize - radius;
    else 
		ndivSize = xsize - (2 * radius);
   
    innerRect = makeDiv(ndivSize, ysize);

   var i, y, ndiv, x;
   var rsquared = radius * radius;
   innerRect.style.left = radius + 'px';
   innerRect.style.top = '0px';
   innerRect.style.backgroundColor = c;
   newRect.appendChild(innerRect);

   ndiv = makeDiv(radius, ysize - (2 * radius));
   ndiv.style.top = radius + 'px';
   ndiv.style.left =  '0px';
   ndiv.style.backgroundColor = c;
   newRect.appendChild(ndiv);

   if ( ! noRight)
   {
      ndiv = makeDiv(radius, ysize - (2 * radius));
      ndiv.style.top = radius + 'px';
      ndiv.style.right =  '0px';
      ndiv.style.backgroundColor = c;
      newRect.appendChild(ndiv);
   }
   x = 0;
   for (i = ( - radius);i < 0;i ++ )
   {
      y = Math.floor(Math.sqrt(rsquared - (i * i)));
      ndiv = makeDiv(1, y);
      ndiv.style.backgroundColor = c;
      ndiv.style.left = x + 'px';
      //      ndiv.style.top = bottomAreaTop + 'px';
      ndiv.style.bottom = (radius - y) + 'px';
      newRect.appendChild(ndiv);

      ndiv = makeDiv(1, y);
      ndiv.style.backgroundColor = c;
      ndiv.style.left = x + 'px';
      ndiv.style.top = (radius - y) + 'px';
      newRect.appendChild(ndiv);

      if ( ! noRight)
      {
         ndiv = makeDiv(1, y);
         ndiv.style.backgroundColor = c;
         ndiv.style.left = (xsize - x) - 1 + 'px';
         ndiv.style.top = bottomAreaTop + 'px';
         newRect.appendChild(ndiv);

         ndiv = makeDiv(1, y);
         ndiv.style.backgroundColor = c;
         ndiv.style.left = (xsize - x) - 1 + 'px';
         ndiv.style.top = (radius - y) + 'px';
         newRect.appendChild(ndiv);
      }

      x ++ ;
   }

   return(newRect);

}

//  ---------------------------------------

function makeRoundRectNoBottom(xsize, ysize, radius, c, noRight, noLeft)
{

   	var newRect = makeDiv(xsize, ysize);
   	var bottomAreaTop = ysize - radius;
   	var innerRect;
   	var ndivSize;

   	if (noRight || noLeft) 
   		ndivSize = xsize - radius;
   	else 
   		ndivSize = xsize - (2 * radius);
		
   	innerRect =  makeDiv(ndivSize, ysize);

   	var i, y, ndiv, x;
   	var rsquared = radius * radius;

   	if (noLeft) 
		innerRect.style.left = '0px';
   	else
   		innerRect.style.left = radius + 'px';

   	innerRect.style.top = '0px';
   	innerRect.style.backgroundColor = c;
   	newRect.appendChild(innerRect);

   	ndiv = makeDiv(radius, ysize - radius);
   	ndiv.style.top = radius + 'px';
   	ndiv.style.left =  '0px';
   	ndiv.style.backgroundColor = c;
   	newRect.appendChild(ndiv);

   	if ( ! noRight)
   	{
      	ndiv = makeDiv(radius, ysize - radius);
      	ndiv.style.top = radius + 'px';
      	ndiv.style.right =  '0px';
      	ndiv.style.backgroundColor = c;
      	newRect.appendChild(ndiv);
   	}
   	x = 0;
   	for (i = ( - radius);i < 0;i ++ )
   	{
      	y = Math.floor(Math.sqrt(rsquared - (i * i)));

      if ( ! noLeft)
      {
         ndiv = makeDiv(1, y);
         ndiv.style.backgroundColor = c;
         ndiv.style.left = x + 'px';
         ndiv.style.top = (radius - y) + 'px';
         newRect.appendChild(ndiv);
      }

      if ( ! noRight)
      {
         ndiv = makeDiv(1, y);
         ndiv.style.backgroundColor = c;
         ndiv.style.left = (xsize - x) - 1 + 'px';
         ndiv.style.top = (radius - y) + 'px';
         newRect.appendChild(ndiv);
      }

      x ++ ;
   }

   return(newRect);

}

//  ---------------------------------------
function getRectArea(rectangle)
{
   return (rectangle.firstChild);
}

//  ---------------------------------------
function getPixels()
{
   return (parseInt(this.match(/\d*/)));
}

// -------------------------------------
function makeDiv(xsize, ysize)
{
   var newDiv = document.createElement('div');
   newDiv.style.position = 'absolute';
   newDiv.style.overflow = 'hidden';
   newDiv.style.width = xsize + 'px';
   newDiv.style.height = ysize + 'px';
   return (newDiv);
}

//  ---------------------------------------
var currHeight=10 ,currPicture=0,nMenuItems=0;
var totalHeight=currHeight;
var topSpotDone=false, spotDone=false;
var currPath, pathParts;

var spacing = 4;
var lnavColors = new Array('#7EC6B9', '#13859e', '#54AEAD', '#000000', '#ffffff');
var lnavRadius = 9;
var indent = 10;

function addBar(lev, color)
{

   	var newBar;

   	if (this.lev == 1)
   		newBar = makeBlueBar();
   	else
   		newBar = makeRoundRect(218 - (this.lev * indent), barHeight, lnavRadius, lnavColors[this.lev], true);

   	if (newBar.rectStyle == 'blueBar') 
   		newBar.newBarLoc = spacing + 6;
   	else    
   		newBar.newBarLoc = spacing;
   	newBar.style.top = this.newBarLoc + 'px';
   	if (this.rectStyle == 'blueBar') 
		newBar.style.top=(this.newBarLoc+6)+'px';
   
   	newBar.style.left = indent + 'px';
   	newBar.addBar = addBar;
   	newBar.bars = 0;
	this.bars++;
   	if ((this.bars != 1) && (this.lev==2)) newBar.style.top = (newBar.style.top.getPixels()-10)+'px';
//   if ((this.lev==2)) newBar.style.top = (newBar.style.top.getPixels()-(this.bars*10))+'px';

   newBar.lev = this.lev + 1;

   newBar.expandBar = expandBar;
   this.appendChild(newBar);
   var currDiv = this;
   // 	this.newBarLoc += spacing + barHeight;
   var newDelta = barHeight;
   // this.newBarLoc += barHeight + spacing;
   var depth = 0;

   while (currDiv.lev >= 1)
   {
      if (currDiv.rectStyle == 'blueBar')
      currDiv.newBarLoc = currDiv.childNodes[5].style.height.getPixels() +  currDiv.childNodes[5].style.top.getPixels() + spacing + 6 ;
      else
      currDiv.newBarLoc = currDiv.lastChild.style.height.getPixels() + currDiv.lastChild.style.top.getPixels() + spacing;
      currDiv.style.height = (currDiv.newBarLoc)  + 'px';
      if (currDiv.rectStyle == 'blueBar')
      currDiv.firstChild.style.height = (currDiv.newBarLoc) - 14 + 'px';
      else
      currDiv.firstChild.style.height = (currDiv.newBarLoc) + 'px';
      if (currDiv.rectStyle == 'blueBar')
      {
         currDiv.childNodes[3].style.height = (currDiv.newBarLoc)  - 14 + 'px';
         currDiv.childNodes[5].style.top = (currDiv.newBarLoc)  - 14 + 'px';
      }
      else
      currDiv.childNodes[1].style.height = (currDiv.newBarLoc) - (2 * lnavRadius) + 'px';

      depth ++ ;

      currDiv = currDiv.parentNode;

   }

   this.bars ++ ;
   // 	this.newBarLoc = 36 + this.newBarLoc;

   return (newBar);
}

//  ---------------------------------------

function expandBar (howMuch)
{
   this.newBarLoc += howMuch;
   // 	this.style.height = this.style.height.getPixels() + howMuch;

   var currDiv = this;
   while (currDiv.lev >= 1)
   {
      if (currDiv != this)

      if (currDiv.rectStyle == 'blueBar')
      currDiv.newBarLoc = currDiv.childNodes[5].style.height.getPixels() +  currDiv.childNodes[5].style.top.getPixels() + spacing -6;
      else
      currDiv.newBarLoc = currDiv.lastChild.style.height.getPixels() + currDiv.lastChild.style.top.getPixels() + spacing;


      currDiv.style.height = (currDiv.newBarLoc)  + 'px';
      if (currDiv.rectStyle == 'blueBar')
      currDiv.firstChild.style.height = (currDiv.newBarLoc) - 14 + 'px';
      else      currDiv.firstChild.style.height = (currDiv.newBarLoc) + 'px';

      if (currDiv.rectStyle == 'blueBar')
      {
         currDiv.childNodes[3].style.height = (currDiv.newBarLoc)  - 14 + 'px';
         currDiv.childNodes[5].style.top = (currDiv.newBarLoc)  - 14 + 'px';
      }
      else
      currDiv.childNodes[1].style.height = (currDiv.newBarLoc) - (2 * lnavRadius)  + 'px';

      // 		currDiv.childNodes[2].style.top = (currDiv.newBarLoc) + 11 + 'px';

      currDiv = currDiv.parentNode;

   }
}

//  ---------------------------------------

function setBar (howMuch)
{
   this.newBarLoc = howMuch;
   // 	this.style.height = this.style.height.getPixels() + howMuch + 'px';

   var currDiv = this;
   while (currDiv.lev >= 1)
   {
      if (currDiv != this)
      currDiv.newBarLoc = currDiv.lastChild.style.height.getPixels() + currDiv.lastChild.style.top.getPixels() + spacing;
      currDiv.style.height = (currDiv.newBarLoc)  + 'px';
      currDiv.firstChild.style.height = (currDiv.newBarLoc) - (2 * lnavRadius) + 'px';
      // 		currDiv.childNodes[2].style.top = (currDiv.newBarLoc) + 11 + 'px';
      currDiv = currDiv.parentNode;
   }
}

//  ---------------------------------------

var barHeight = 24;
var noteCardRadius = 15;
var thisPageName;

function init()
{
   	var xmlspec;

    //fix links.
	
   	var currPath = new String(window.location);
   
    currPath=currPath.replace('/smmc/','/');
	
   	var pathArray = currPath.split('/');
	
	var currDirectory = new String(pathArray[pathArray.length - 2]);
	
	if (currDirectory == "childrenshospital")
	{
		document.getElementById('header1').className="";
		document.getElementById('header2').className="";
	}
	
   	xmlspec = pathArray[pathArray.length - 2] + '.xml';
	
   	var xptr = pathArray.length - 1;
    
   	var pA=pathArray.length-4;
   	var iPath="";
   	while (pA-- >0)
    	iPath="../"+iPath;

   	//set up topnav
   	var el;
	var footerHTML='<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td width="50%" align="left"><a href="'+iPath+'webprivacy/webprivacy.htm" style="color:#108184"><font color="#108184">Privacy Statement</font></a>&nbsp;|&nbsp;<a href="'+iPath+'termsofusage/termsofusage.htm" style="color:#108184"><font color="#108184">Terms of Usage</font></a></td><td width="50%" align="right">407 East 3rd Street, Duluth, MN 55805 &bull; 218&ndash;786&ndash;4000</td></tr></table>';

	if (document.getElementById("footer"))	
		document.getElementById('footer').innerHTML=footerHTML;
   
   	var zn=document.getElementById('navItems');

   	el=document.getElementsByTagName('a');
   	for (var ix=0;ix<el.length;ix++)
   	{
    	if (el[ix].className == 'ouraffiliates')
		{
        	el[ix].href = 'http://www.smdc.org/ouraffiliates/ouraffiliates.htm';
			el[ix].target='_blank';
		}
    	if (el[ix].className=='patientresources')
		{
        	el[ix].href = 'http://www.stmarysduluth.org/patienthandbook/patienthandbook.htm';
			
		}
    	if (el[ix].className=='employment')
        {
        	el[ix].href = 'http://www.smdc.org/employment/employment.htm';
			el[ix].target='_blank';
        }
    	if (el[ix].className =='volunteering')
		{
        	el[ix].href='http://www.smdc.org/volunteering/volunteering.htm'; 
			el[ix].target='_blank';
		}
    	if (el[ix].className =='foundationgiving')
		{
        	el[ix].href='http://www.smdc.org/foundationjoint/jointfoundations.htm';
			el[ix].target='_blank';
		}   
    }
	
   	el=document.getElementById('header');
	
    var istr=new String(el.innerHTML);
    istr=istr.replace('/smmc/',iPath);
    el.innerHTML=istr;
    
   	imagePath="";
   	thisPageName = new String(pathArray[xptr]);
   	if (thisPageName == '') 
   	{ 
   		thisPageName = new String('default.htm'); 
		xmlspec='smmc.xml';
	}
   	thisPageName=thisPageName.toLowerCase();
	
	// 12/7/2007 change for Childres Hospital
	el=document.getElementById('header1');
	
	if (currDirectory == "childrenshospital") 
	{
		document.getElementById('header1').className="headerdulchild";
		document.getElementById('header2').className="header2dulchild";
	}

//   var t = new AJAXRequest(null, init2, xmlspec);
    doLeftNav();
}

//  ---------------------------------------

var topSpot=false,spot=false;
var tabs, ntabs, tabDivs;

function init2(theXML, theText)
{
   // alert(theXML.documentElement.firstChild.tagName);

    var currLevs = new Array();
    var r;
    var lnav;
    var lnavColor = '#7EC6B9';

    var lnavLev1 = '#13859e';
    var lnavLev2 = '#54AEAD';
    var lnavHeight = 24;
    var currLines = 0;
    String.prototype.getPixels = getPixels;
    var pages = theXML.documentElement.childNodes;

    lnav = makeRoundRect(218, lnavHeight, 11, lnavColor, true);
    lnav.lev = 1;
    lnav.newBarLoc = spacing + 4;
    lnav.addBar = addBar;
    lnav.expandBar = expandBar;
    lnav.bars = 0;
    lnav.style.left = '12px';
    lnav.style.top = '12px';
    document.getElementById('leftNav').appendChild(lnav);
    currLevs[0] = lnav
    var nbar;
    var tArea;
    var currLev = 0;
    var pageLists = new Array();
    pageLists[0] = pages;
    var pageListPtr = 0;

    var cPageName;

   	if (thisPageName == 'default.htm' || thisPageName == 'smmc')
   	{
		doCenterRect();
      	// make notecard.
      	enableTabs();
      	var getNoteCard = new AJAXRequest(null, drawNoteCard, "qualityfirst.htm");
      	// fire async request for notecard data.
   	}
   	else
   	{		
		doTopNav();

		//set centercontent height.
    	var cc=document.getElementById('centerContent');

    if (parseInt(cc.offsetHeight) < parseInt(lnav.offsetHeight) )
        {  cc.style.height= (lnav.offsetHeight-80)+'px'; cc.style.position='relative';}

      // look at the XML & set up subheader & header.

      document.getElementById("subHead").innerHTML = theXML.documentElement.getAttribute("parent");
      document.getElementById("mainHeadline").innerHTML = theXML.documentElement.getAttribute("site");
      //do crumb bar.
      var crumb=document.getElementById("crumb");
      //find page.
      var allPages=theXML.getElementsByTagName("page");
      var foundIdx=-1;
      for (var ix=0;ix<allPages.length;ix++)
        if (allPages[ix].getAttribute("url")==thisPageName) { foundIdx=ix;break;}
      if (foundIdx == -1)
        alert ("Page not found.  No navigation will be displayed.");
      else
        {
            var currNode = allPages[foundIdx];
            var crumbText = allPages[foundIdx].getAttribute("title");
            var newText;
            while (currNode.tagName != "sitemap")
            {
                currNode=currNode.parentNode;
                if (currNode.tagName == 'sitemap')
                {
                newText = '<a href="'+currNode.getAttribute("url")+'">'+currNode.getAttribute("site")+'</a>';
                crumbText = newText+"&nbsp;|&nbsp;"+crumbText;
                }
                else
                { 
                newText = '<a href="'+currNode.getAttribute("url")+'">'+currNode.getAttribute("title")+'</a>';
                crumbText = newText+"&nbsp;|&nbsp;"+crumbText;
                }
            }    
            crumbText = '<a href="/smmc/default.htm">St. Mary\'s Home</a> | ' + crumbText;
            crumb.innerHTML = crumbText;
        }
   }

   	if ((spot) && (!topSpot))
   	{
		var cSpotRun = new AJAXRequest(null,doSpotlight,spot);
   	}
   	else if (topSpot)
   	{
	   	alert('topspot');
    	var cTS=new AJAXRequest(null,doTopSpotlight,topSpot);
    }
}

var topSpotDone=false;
var spotDone = false;

function getTopSpotlight(spotlighturl)
{
   var topSpotReq = new AJAXRequest(null,doTopSpotlight,spotlighturl);
}

function getSpotlight(spotlighturl)
{
   var spotReq = new AJAXRequest(null,doSpotlight,spotlighturl);
}

function doTopSpotlight(theXML, theText)
{
	var root1=theText;
	var elem=document.getElementById("farRightTable");
	elem.style.verticalAlign='top';
	elem.innerHTML=root1;
	topSpotDone=true;
}

function doSpotlight(theXML, theText)
{
	var root1=theText;
	var elem=document.getElementById("farRightTable");
	elem.style.verticalAlign='top';
	if (topSpotDone)
		elem.innerHTML += root1;
	else
		elem.innerHTML = root1;
	spotDone=true;
}

var depth=0;
var topNavDone=false;
var rightArrowImage=0;
var bluebarElem=0;
var newDivs=0;
var lightBlueDiv;

//  ---------------------------------------

var notecardDivs;
var tabs;

function doCenterRect()
{

   r = makeRoundRect(486, 208, 9, '#99c4b9', false);
   r.style.left = '9px';
   r.style.top = '7px';
   r.style.zIndex = 2;

   document.getElementById('topRightDiv').appendChild(r);
   r = makeRoundRect(478, 200, 9, 'white', false);
   r.style.left = '13px';
   r.style.top = '11px';
   r.style.zIndex = 3;
   var tArea = getRectArea(r);
   tArea.style.paddingTop = '4px';
   var middleBox = document.getElementById('middleBox');

   tArea.innerHTML = middleBox.innerHTML;

   document.getElementById('topRightDiv').appendChild(r);
}

//  ---------------------------------------

function doTopNav()
{

    var tNavDiv = document.getElementById("topNavBar");
    var tNavElements = new Array (
    {name : 'Find a Patient', url : 'findapatient/findapatient.htm'},
    {name : 'Patient Guide', url : 'patienthandbook/patienthandbook.htm'},
    {name : 'Our Medical Staff', url : 'medicalstaff/medicalstaff.htm'},
    {name : 'Specialty Services', url : 'specialtyservices/specialtyservices.htm'},
    {name : 'Other Services', url : 'otherservices/otherservices.htm'},
    {name : 'About Us', url : 'aboutus/aboutus.htm'}
    /*{name : 'Newsroom', url : 'newsroom/newsroom.htm'}*/
    );

    // parse url to see where we are...

    var locStr = new String(window.location.pathname);
    if ((locStr.substr(locStr.length-1),1)=='/') 
		locStr+='default.htm';
    locStr=locStr.replace('/smmc/','/');
    var locPieces = locStr.split('/');

   // 0th elem = http :
   // 1st elem = empty string
   // 2nd elem = server name
   // 3rd elem = site name
   // nesting depth = length - 5

	var nDepth = locPieces.length - 2;

	pathPrefix = "";
	for (var idx = 0;idx < nDepth;idx ++ )
		pathPrefix += "../";

	// make top links
	var tNavHTML = '<table cellspacing="0" width="100%" style="height:28px;" cellpadding="0" border="0" align="center"><tr>';
	for (var idx = 0;idx < tNavElements.length;idx ++ )
	{
		if (idx > 0) 
			tNavHTML += "<td width=" + '"5"' + ">|</td>";
		tNavHTML += '<td valign="middle" align="center" onmouseover="this.style.backgroundColor=' + "'#A7e7b3';" +
		'" onmouseout="this.style.backgroundColor=' + "'';" + '" onclick="window.location=' +
		"'" + pathPrefix+tNavElements[idx].url+"';" + '">';
		tNavHTML += tNavElements[idx].name + "</td>";
	}
	tNavHTML += "</tr></table>";
	tNavDiv.innerHTML = tNavHTML;

}

//  ---------------------------------------

function enableTabs()
{
   tabs = new Object(
   {
      'tabSelected' : - 1, 'tabCount' : 0
   }
   );
   tabs.tabArray = new Array();
   tabs.linkArray = new Array();
   var tabDiv = document.getElementById("tabs");
   var divs = tabDiv.getElementsByTagName("div");
   var idx;
   var tabCount = 0;
   // we populate the tab object with a list of tabs.
   for (idx = 0; idx < divs.length; idx ++ )
   {
      if (divs[idx].className == 'tabText')
      {
         tabs.tabArray[tabCount ++ ] = divs[idx];
      }
      if (divs[idx].className == 'tabSelectedText')
      {
         tabs.tabArray[tabCount] = divs[idx];
         tabs.tabSelected = tabCount ++ ;
      }
   }
   tabs.tabCount = tabCount;

   tabs.linkArray[2] = 'qualityfirst.htm';
   tabs.linkArray[1] = 'clinicaltrials.htm';
   tabs.linkArray[0] = 'mvl.htm';

   //        newDiv.attachEvent('onclick', gosomewhere);

   for (idx = 0; idx < tabs.tabArray.length; idx ++ )
   {
      if (window.ActiveXObject)
      {
         tabs.tabArray[idx].attachEvent('onclick', refreshTabs);
         tabs.tabArray[idx].mydata = idx;
      }
      else
      {
         tabs.tabArray[idx].addEventListener('click', refreshTabs, false);
         tabs.tabArray[idx].mydata = idx;
      }
   }

   // attach event handlers
   // alert (tabs.tabSelected);
   // alert (tabs.tabArray.length);
   // alert (tabs.tabArray[tabs.tabSelected].innerHTML);

}

//  ---------------------------------------

function refreshTabs(eva)
{
   var e_out;
   cancelBubble = true;

   var ie_var = "srcElement";
   var moz_var = "target";
   var prop_var = "mydata";
   // "target" for Mozilla, Netscape, Firefox et al. ; "srcElement" for IE
   eva[moz_var] ? e_out = eva[moz_var][prop_var] : e_out = eva[ie_var][prop_var];

   var clinicImg = document.getElementById('ClinicalTrialsImg');
   var MVLImg = document.getElementById('MVLImg');
   var qualityImg = document.getElementById('QualityImg');

   var clinic = document.getElementById('ClinicalTrials');
   var forMVL = document.getElementById('MVL');
   var quality = document.getElementById('Quality');

    switch (e_out)
    {
      	case 0 :
         	// 'Clinical Trials' :
         	nLink = 'clinicaltrials.htm';
         	clinic.className = "tabSelectedText";
         	clinicImg.rows[0].cells[0].style.backgroundImage = "url('Images/folderTabMiddleSelected.gif')";
         	clinicImg.rows[0].cells[1].style.backgroundImage = "url('Images/folderTabMiddleSelected.gif')";
         	clinicImg.rows[0].cells[2].style.backgroundImage = "url('Images/folderTabRightSelected.gif')";
		 
		    forMVL.className = "tabText";
            MVLImg.rows[0].cells[0].style.backgroundImage = "url('Images/folderTabLeftSquare.gif')";
            MVLImg.rows[0].cells[1].style.backgroundImage = "url('Images/folderTabMiddle.gif')";
            MVLImg.rows[0].cells[2].style.backgroundImage = "url('Images/folderTabRight.gif')";

         	quality.className = "tabText";
         	qualityImg.rows[0].cells[0].style.backgroundImage = "url('Images/folderTabLeft.gif')";
         	qualityImg.rows[0].cells[1].style.backgroundImage = "url('Images/folderTabMiddle.gif')";
         	break;
		 
		case 1 :
         	// 'Quality' :
         	nLink = 'qualityfirst.htm';
         	clinic.className = "tabText";
         	clinicImg.rows[0].cells[0].style.backgroundImage = "url('Images/folderTabLeftSquare.gif')";
         	clinicImg.rows[0].cells[1].style.backgroundImage = "url('Images/folderTabMiddle.gif')";
         	clinicImg.rows[0].cells[2].style.backgroundImage = "url('Images/folderTabRight.gif')";
		 
		   	forMVL.className = "tabText";
           	MVLImg.rows[0].cells[0].style.backgroundImage = "url('Images/folderTabMiddle.gif')";
            MVLImg.rows[0].cells[1].style.backgroundImage = "url('Images/folderTabMiddle.gif')";
           	MVLImg.rows[0].cells[2].style.backgroundImage = "url('Images/folderTabRight.gif')";
       
         	quality.className = "tabSelectedText";
         	qualityImg.rows[0].cells[0].style.backgroundImage = "url('Images/folderTabLeftSelected.gif')";
         	qualityImg.rows[0].cells[1].style.backgroundImage = "url('Images/folderTabMiddleSelected.gif')";
         	break;
			
      case 2 :
         // 'MVL' :
       
         {
            nLink = 'mvl.htm';
            clinic.className = "tabText";
            clinicImg.rows[0].cells[0].style.backgroundImage = "url('Images/folderTabLeftSquare.gif')";
            clinicImg.rows[0].cells[1].style.backgroundImage = "url('Images/folderTabMiddle.gif')";
            clinicImg.rows[0].cells[2].style.backgroundImage = "url('Images/folderTabRight.gif')";

            forMVL.className = "tabSelectedText";
           	MVLImg.rows[0].cells[0].style.backgroundImage = "url('Images/folderTabMiddleSelected.gif')";
            MVLImg.rows[0].cells[1].style.backgroundImage = "url('Images/folderTabMiddleSelected.gif')";
          	MVLImg.rows[0].cells[2].style.backgroundImage = "url('Images/folderTabRightSelected.gif')";

            quality.className = "tabText";
            qualityImg.rows[0].cells[0].style.backgroundImage = "url('Images/folderTabLeft.gif')";
            qualityImg.rows[0].cells[1].style.backgroundImage = "url('Images/folderTabMiddle.gif')";
         }
        
         break;

   }
   var getNoteCard = new AJAXRequest(null, drawNoteCard, nLink);
   return;
}

//  ---------------------------------------

function drawNoteCard(theXML, theText)
{
    // now, we can create an XML document from the text of the HTML -- find the body tag and pull it out, along with everything in
    // between.  Reparse as XML, and insert into document !
    var bodyStart, bodyEnd;

    bodyStart = theText.indexOf('>', theText.indexOf('<body') + 5) + 1;
    bodyEnd = theText.indexOf('body>', bodyStart) - 2;
    var nBody = "";
    // base64.decode(XMLHeaderB64);
    nBody += theText.substr(bodyStart, (bodyEnd - bodyStart));
    // var nXML = new ActiveXObject("MSXML2.DOMDocument.4.0");
    // nXML.async = false;

    //    nXML.loadXML(nBody);
    //  alert (nXML.documentElement.tagName);
    // find notecardWrapper div.

    var noteCardDiv = document.getElementById("notecardWrapper");
    noteCardDiv.innerHTML = nBody;

    //alert (nBody);
    //alert (theXML.documentElement.tagName);
}

//  ---------------------------------------

function trimStr(string)
{
    return (string.substr(0, string.length - 4));
}

//  ---------------------------------------
var menuAddFlag=false;

function selector(ev)
{
    if (window.ActiveXObject)
    	ev = ev.srcElement;
   	else
   		ev = ev.target;
   	while (ev.parentNode.id != 'noteTabs')
   		ev = ev.parentNode;

   	for (var x = 0;x < 3;x ++ )
   	{
      	if (notecardDivs[x] == ev)
      	{
         	if (document.getElementById('notecardArea').innerHTML != tabDivs[x])
         	{
            	notecardDivs[x].childNodes[0].style.color = '#8ab7c1';
            	notecardDivs[x].childNodes[1].childNodes[0].style.backgroundImage = notecardDivs[x].childNodes[1].childNodes[0].style.backgroundImage.replace(".gif", "Selected.gif");
            	notecardDivs[x].childNodes[1].childNodes[1].style.backgroundImage = notecardDivs[x].childNodes[1].childNodes[1].style.backgroundImage.replace(".gif", "Selected.gif");
            	notecardDivs[x].childNodes[1].childNodes[2].style.backgroundImage = notecardDivs[x].childNodes[1].childNodes[2].style.backgroundImage.replace(".gif", "Selected.gif");
            	document.getElementById('notecardArea').innerHTML = tabDivs[x];
         	}
      	}
      	else
      	{
         	notecardDivs[x].childNodes[0].style.color = '#ffffff';
         	notecardDivs[x].childNodes[1].childNodes[0].style.backgroundImage = notecardDivs[x].childNodes[1].childNodes[0].style.backgroundImage.replace("Selected.gif", ".gif");
         	notecardDivs[x].childNodes[1].childNodes[1].style.backgroundImage = notecardDivs[x].childNodes[1].childNodes[1].style.backgroundImage.replace("Selected.gif", ".gif");
         	notecardDivs[x].childNodes[1].childNodes[2].style.backgroundImage = notecardDivs[x].childNodes[1].childNodes[2].style.backgroundImage.replace("Selected.gif", ".gif");
      	}
   	}
}

//  ---------------------------------------

//  ---------------------------------------

function doSelect(ev)
{
   	if (window.ActiveXObject)
   	ev = ev.srcElement;

   	while (ev.typeName != 'tab') ev = ev.parentNode;

   	for (var idx = 0;idx < tabs.length;idx ++ )
   	{
      	if (ev == tabs[idx])
      	{
         	document.getElementById('notecardArea').innerHTML = tabDivs[idx];
         	changeColor(ev, '#ffffff', '#88b5c1');
      	}
      	else
      		changeColor(tabs[idx], '#88b5c1', '#ffffff');
   	}
}

//  ---------------------------------------

function changeColor(elem, nCol, iCol)
{
   	if (elem.childNodes.length > 1)
   	{
      	for (var idx = 0;idx < elem.childNodes.length; idx ++ )
      		elem.childNodes[idx].style.backgroundColor = nCol;
      	elem.firstChild.style.color = iCol;
   	}
   	else
   	{
      	elem.style.color = iCol;
      	elem.style.backgroundColor = nCol;
   	}
   	//elem.style.backgroundColor = nCol;
}

//  ---------------------------------------
function ncard(theXML, theText)
{
   	document.getElementById('notecardArea').innerHTML = theText;
   	tabDivs[0] = theText;
}

//  ---------------------------------------
function ncard1(theXML, theText)
{
   	tabDivs[1] = theText;
}

//  ---------------------------------------
function ncard2(theXML, theText)
{
   	tabDivs[2] = theText;
}

//recently added stuff.
function highlightTopLeftNav(elem1)
{  
	elem1.style.color='#91d7f5';
	elem1.style.cursor='default';
	var img=elem1.childNodes[0];

	//var imageRow = document.getElementById("insideLeftNav");
	//var img=imageRow.rows[0].cells[imageIndex].childNodes[0];
	img.style.visibility='hidden';
	img=img.nextSibling;
	img.style.visibility='visible';
}

function highlightTopTopRight(elem1)
{
	elem1.style.color='#155389';
	elem1.style.fontWeight='bold';
	elem1.style.cursor='default';
}

function unhighlightTopTopRight(elem1)
{
	elem1.style.color='#ffffff';
	elem1.style.fontWeight='normal';
}

function unhighlightTopLeftNav(elem1)
{
	elem1.style.color='#ffffff';
	elem1.style.cursor='default';
	var img=elem1.childNodes[0];
	//var imageRow = document.getElementById("insideLeftNav");
	//var img=imageRow.rows[0].cells[imageIndex].childNodes[0];
	img.style.visibility='visible';
	img=img.nextSibling;
	img.style.visibility='hidden';
}

//simple 
function makeCornerDiv(radius, colorVal, width, height, elem)
{	
	var r;
	var newDiv = document.createElement("div");
	var newCorner=document.createElement("div");
	var botCorner=document.createElement("div");
	var rightArea=document.createElement("div");
	var leftSpace = document.createElement("div");
	var textArea = document.createElement("div");
	var x,y;
	if (height & 1) height++;
	if (radius & 1) radius++;
	r=radius*radius;
	
	newDiv.style.position='absolute';
	newDiv.style.width=width + 'px';
	newDiv.style.height= height + 'px';
	leftSpace.style.position='absolute';
	leftSpace.style.width= radius + 'px';
	leftSpace.style.height= (height-(2*radius))+'px';
	leftSpace.style.overflow='hidden';
	leftSpace.style.left = '1px';
	leftSpace.style.top = radius + 'px';
	leftSpace.style.backgroundColor = colorVal;
	leftSpace.setAttribute('name','leftSpace');
	rightArea.style.position='absolute';
	rightArea.style.width= (width-radius) + 'px';
	rightArea.style.height=newDiv.style.height;
	rightArea.style.left = radius + 'px';
	rightArea.style.top='0px';
	rightArea.style.backgroundColor = colorVal;
	rightArea.setAttribute('name','rightArea');
	textArea.style.position='absolute';
	textArea.style.width=((width-(radius/2))-3) + 'px';
	textArea.style.left = ((radius/2)+3) + 'px';
	textArea.style.top = (radius/2) + 'px';
	textArea.style.height = (height-radius) + 'px';
	textArea.style.textAlign = 'left';
	textArea.style.zIndex = 3;
	textArea.setAttribute('name','textArea');
	newCorner.style.position='absolute';
	newCorner.style.width= radius + 'px';
	newCorner.style.height = radius + 'px';
	newCorner.style.top='0px';
	newCorner.style.left='0px';
	newCorner.style.overflow='hidden';
	botCorner.style.position='absolute';
	botCorner.style.width= radius + 'px';
	botCorner.style.height = radius + 'px';
	botCorner.style.bottom='0px';
	botCorner.style.left='0px';
	botCorner.style.overflow='hidden';

	var topCoord;
	var nDiv;
	var bDiv;
	for (x=0;x<=radius;x++)
	{
		y = Math.floor(Math.sqrt( r - (x*x)));
		topCoord=radius-y;
		nDiv=document.createElement("div");
		bDiv=document.createElement("div");
		nDiv.style.backgroundColor=colorVal;
		nDiv.style.position='absolute';
		nDiv.style.width='1px';
		nDiv.style.height= y + 'px';
		nDiv.style.top=topCoord + 'px';
		nDiv.style.left=(radius-x) + 'px';
		bDiv.style.backgroundColor=colorVal;
		bDiv.style.position='absolute';
		bDiv.style.bottom= topCoord +'px';
		bDiv.style.left=(radius-x)+ 'px';
		bDiv.style.width='1px';
		bDiv.style.height= radius + 'px';
		newCorner.appendChild(nDiv);
		botCorner.appendChild(bDiv);
	}
	newDiv.appendChild(newCorner);
	newDiv.appendChild(botCorner);
	newDiv.appendChild(leftSpace);
	newDiv.appendChild(rightArea);
	newDiv.appendChild(textArea);
	return(elem.appendChild(newDiv));
}

function getPixelProperty(elem,propertyName)
{
	var prop = elem.style[propertyName];
	prop=parseInt(prop.replace('px',''),10);
	return(prop);
}

function getTextElement(elem)
{
	var nodes = elem.childNodes;
	var idx, outputElem=false;
	for (idx=0;idx<nodes.length;idx++)
	{
		if(nodes[idx].nodeType==1)
		{
			if (nodes[idx].getAttribute('name') == 'textArea')
			{
				outputElem = nodes[idx];
				break;
			}
		}
	}
	return (outputElem);
}

function adjustHeight(elem, newHeight)
{
   var nodes = elem.childNodes;
   var idx;
   var leftSpaceNode = 0;
   var rightAreaNode = 0;
   var textNode = 0;
   var cHeight = getPixelProperty(elem, 'height');
  
   var sNodeName;
   if (newHeight & 1) newHeight ++ ;
   elem.style.height = newHeight + 'px';
   for (idx = 0;idx < nodes.length;idx ++ )
   {
     if(nodes[idx].nodeType==1)
     {
		sNodeName = nodes[idx].getAttribute('name');
		switch (sNodeName)
		{
			case 'leftSpace':
				leftSpaceNode = nodes[idx];
				break;
			case 'rightArea':
				rightAreaNode = nodes[idx];
				break;
			case 'textArea':
				textNode = nodes[idx];
				break;
		}
      }
       
   }
   var radius = (cHeight - getPixelProperty(leftSpaceNode, 'height')) / 2;
   leftSpaceNode.style.height = (newHeight - (2 * radius)) + 'px';
   rightAreaNode.style.height = newHeight + 'px';
   textNode.style.height = (newHeight - radius) + 'px';
   var leftObj = document.getElementById("leftNav");
   leftObj.style.height = (totalHeight + 20) + 'px';
   leftObj = document.getElementById("rightTable");
   if (leftObj) leftObj.style.height = (totalHeight + 20) + 'px';

}

var extentTextBox;

function doLeftNav()
{	
	//set up footer string
	
	//create hidden text box	
	extentTextBox=document.createElement('div');
	extentTextBox.className = 'subNavLightBlueText';
	extentTextBox.style.width='190px';
	extentTextBox.style.visibility='hidden';
	document.body.appendChild(extentTextBox);
	
	extentTextBox2=document.createElement('div');
	extentTextBox2.className = 'subNavLightBlueText';
	extentTextBox2.style.width='175px';
	extentTextBox2.style.visibility='hidden';
	document.body.appendChild(extentTextBox2);
	
	var y;
	
	var pathDepth = 2;
	
	currPath = new String(window.location.pathname);

	//if (currPath.substr(currPath.length-5)=='smmc/') currPath+='default.htm';
	if (currPath.substr(currPath.length-1)=='/') currPath+='default.htm';
    currPath=currPath.replace('/smmc/','/');
    pathParts=currPath.split('/');
	//if (pathParts.length > 3)

	if (pathParts.length > pathDepth)
	{
		y=pathParts.length;
		//while (y>3)
		while (y>pathDepth)
		{
			imagePath += '../';
			y--;
		}
	}
    
	//imagePath shows where to find the image we want.
	
	var directoryName = pathParts[pathParts.length-2];

	var xmlName = directoryName.toLowerCase() + '.xml';
	
	if (pathParts.length <= 2) 
	{
		xmlName='smmc.xml';
	}
//	populateTopNav();

// rgs - 10/8/2007 change color of makeCornerDiv from 9ac5be to 7EC6B9 
// so that top nav padding matches lower nav padding of compound nav pages

//alert("doLeftNav - makeCornerDiv(16,'#9ac5be', 220, 64, elem)");

	var elem=document.getElementById("leftNav");
	lightBlueDiv = makeCornerDiv(16,'#7EC6B9', 220, 64, elem);
	lightBlueDiv.setAttribute('id','leftNavLighterBlue');
	lightBlueDiv.style.left='10px';
	lightBlueDiv.style.top='14px';
		
	var mainAJAXReq = new AJAXRequest(null,xmlhttpChange,xmlName);
	
	//alert("doLeftNav : menuPtr: " + menuPtr);
	// rgs closeAccordion(2);
	//closeAccordion(0);
	//alert("doLeftNav : menuPtr: " + menuPtr);
	// rgs setTimeout('closeAccordion(0)', 500);
	
}

function xmlhttpChange(theXML,theText)
{	
	//if (!window.ActiveXObject) theXML = cleanWhitespace(theXML);
	var y;
	var root;
	var pages;
	var ourPage=false;
	var currBar;
	var currNode;
	var currPage;
	var crumb=document.getElementById("crumb");
	var tabRow;
	var nCell, nLink,nURL;
	var theRules = new Array();
	if (document.styleSheets[0].cssRules)
		theRules = document.styleSheets[0].cssRules;
	else if (document.styleSheets[0].rules)
		theRules = document.styleSheets[0].rules;
	var rulesStr;
	
	for (y=0;y<theRules.length;y++)
	{
		if (theRules[y].style.backgroundImage)
		{
			rulesStr = new String(theRules[y].style.backgroundImage);
			rulesStr = rulesStr.substr(4);
			rulesStr = "url(" + imagePath + rulesStr;
		}
	}
	
	currPage = pathParts[pathParts.length-1];
	currPage = currPage.toLowerCase();

	root=theXML.documentElement;
	if (root != null)
	{
		pages=root.getElementsByTagName('page');
		for (y=0;y<pages.length;y++)
		{
			if (pages[y].getAttribute('url').toLowerCase() == currPage)
			{
				ourPage=pages[y];
			}
		}
	}
	
	if ((!ourPage) )
	{
		if (currPage == 'otherservices.htm')
		{
			// let's look at the sitemap...

			// In this case, specialtyservices is hard-coded in.  Some of this could be taken out
			// as other code exists that does this properly (reads .xml file)
			// The unique functionality here is the drawing of the two columns where the content usually goes.

			// highlightTopRightNav(1);
			doTopNav();
			addLightBlueBar('Other Services','otherservices.htm');
			//tabRow = crumb.childNodes[0].childNodes[0].childNodes[0]; // rgs js error in firefox - Mozilla
			tabRow = crumb.getElementsByTagName("table")[0].rows[0];
			tabRow.cells[0].className='currPage';
			tabRow.cells[0].innerHTML = 'Other Services';
			nCell = tabRow.insertCell(0);
			nCell.className = 'divider';
			nCell.innerHTML = '|';
			nCell = tabRow.insertCell(0);

			// rgs nlink code
			nLink = document.createElement('a');
			nLink.setAttribute('href','../default.htm');
			if(window.ActiveXObject)
			{
				nLink.innerText = 'St. Mary\'s Home';
			}
			else
			{
				var thisText= document.createTextNode('St. Mary\'s Home');
				nLink.appendChild(thisText);
			}
			nCell.appendChild(nLink);
		}
		else if (currPage == 'specialtyservices.htm')
		{
			// let's look at the sitemap...

			// In this case, specialtyservices is hard-coded in.  Some of this could be taken out
			// as other code exists that does this properly (reads .xml file)
			// The unique functionality here is the drawing of the two columns where the content usually goes.

			//highlightTopRightNav(0);
			
			doTopNav();
			addLightBlueBar('Specialty Services','specialtyservices.htm');
			//tabRow = crumb.childNodes[0].childNodes[0].childNodes[0]; // rgs js error in firefox - Mozilla
			tabRow = crumb.getElementsByTagName("table")[0].rows[0];
			tabRow.cells[0].className='currPage';
			tabRow.cells[0].innerHTML = 'Specialty Services';
			nCell = tabRow.insertCell(0);
			nCell.className = 'divider';
			nCell.innerHTML = '|';
			nCell = tabRow.insertCell(0);

			nLink = document.createElement('a');
			nLink.setAttribute('href','../default.htm');
			if(window.ActiveXObject)
			{
				nLink.innerText = 'St. Mary\'s Home';
			}
			else
			{
				var thisText= document.createTextNode('St. Mary\'s Home');
				nLink.appendChild(thisText);
			}
			nCell.appendChild(nLink);
			
			var headline = document.getElementById("subHead");
			headline.innerHTML = "St. Mary's Medical Center";
			headline = document.getElementById("mainHeadline");
        	headline.innerHTML = "Specialty Services";
        
			//insert pages as links.
			var pTitle;
			var pLink;
			var nElements;
			pages = root.getElementsByTagName('page');
			nElements = pages.length;
			var div2add2 = document.getElementById("col1");
			div2add2=div2add2.childNodes[0];
			var newElem, newLink;
			for (y=0; y<pages.length; y++)
			{
				pTitle=pages[y].getAttribute('title');
				pLink = pages[y].getAttribute('url');
				if (y > (nElements/2))
				{
					div2add2=document.getElementById("col2");
					div2add2=div2add2.childNodes[0];
				}
				newElem=document.createElement('li');
				newLink=document.createElement('a');
				
				pLink = pLink.toString(); //IE8 Compatibility

				newLink.setAttribute('href',pLink);
				newLink.innerHTML = pTitle;
				
				//rgs add new appendChild code here
				if(window.ActiveXObject)
				{
					newElem.appendChild(newLink);
					div2add2.appendChild(newElem);
				}
				else
				{
					var thisLink = document.createTextNode(pLink);
					var thisElem = document.createTextNode(pTitle);
					//div2add2.appendChild(thisLink);
					//div2add2.appendChild(newElem);
					newElem.appendChild(newLink);
					div2add2.appendChild(newElem);
				}
			}
		}
		else
			alert ("This page isn't in the sitemap XML file yet. No navigation will be displayed.");
	}
	else
	{
		
		currNode = ourPage;

		var nestingLevel=1;
	
		if (currPath != '/default.htm')
		{
    		doTopNav(); 
    		var cc=document.getElementById('centerContent');
    		var lnav=document.getElementById('leftNav');
    		// rgs js error in firefox - Mozilla
			//tabRow = crumb.childNodes[0].childNodes[0].childNodes[0];
			tabRow = crumb.getElementsByTagName("table")[0].rows[0];
			tabRow.cells[0].className='currPage';
			tabRow.cells[0].innerHTML = currNode.getAttribute('title');
		
			if (currNode.getAttribute('topspotlight'))
			{
		     	getTopSpotlight(currNode.getAttribute('topspotlight'));
			}
			
			if (currNode.getAttribute('spotlight'))
			{
		     	getSpotlight(currNode.getAttribute('spotlight'));
			}
			
    		if (parseInt(cc.offsetHeight) < parseInt(lnav.offsetHeight) )
        	{  
				cc.style.height= (lnav.offsetHeight-80)+'px'; cc.style.position='relative';
			}
        
    		while (currNode.tagName != 'sitemap')
			{	
				currNode=currNode.parentNode;
				nURL = currNode.getAttribute('url');
				nCell = tabRow.insertCell(0);
				nCell.className = 'divider';
				nCell.innerHTML = '|';
				nCell = tabRow.insertCell(0);
				nLink = document.createElement('a');
				nURL = nURL.toString(); //IE8 Compatibility
				nLink.setAttribute('href',nURL);
				if(window.ActiveXObject)
				{
					if (currNode.tagName == 'sitemap') 
					{
						nLink.innerText=currNode.getAttribute('site');
					}
					else 
					{
						nLink.innerText = currNode.getAttribute('title');
					}
				}
				else
				{
					var thisText;
					if (currNode.tagName == 'sitemap') 
					{
						thisText = document.createTextNode(currNode.getAttribute('site'));
					}
					else 
					{
						thisText = document.createTextNode(currNode.getAttribute('title'));
					}
					nLink.appendChild(thisText);
				}
				nCell.appendChild(nLink);
				depth++;
			}
			
			//so currNode.tagName should be sitemap.
			//alert(currPath);
			
			var pathArray = currPath.split('/');
	
			var currDirectory = new String(pathArray[pathArray.length - 2]);
			
			var headline = document.getElementById("subHead");
			var parentName = currNode.getAttribute('parent');
			var siteLoc = currNode.getAttribute('site');
			var iNode;
			var sHeadline;
			
			//alert(parentName);
			//alert(siteLoc);
			
			if (currDirectory == "childrenshospital")
			{
				var xmlroot;
				var xmlpages;
				
				//xmlroot=theXML.documentElement;
				if (root != null)
				{
					xmlpages=root.getElementsByTagName('page');

					for (y=0;y<xmlpages.length;y++)
					{
						//if (xmlpages[y].getAttribute('url').toLowerCase() == "")
						//alert("currPage = " + currPage + "; url = " +xmlpages[y].getAttribute('url').toLowerCase() );
						if (xmlpages[y].getAttribute('url').toLowerCase() == currPage)
						{
							sHeadline = xmlpages[y].getAttribute('headline');
							//alert(sHeadline);
							switch (sHeadline)
							{
								case "SMDC":
									sHeadline = "St. Mary's Children's Hospital";
									break;								
								case "DC":
									sHeadline = "Duluth Children's Clinic";
									break;								
								case "CHILD":
									sHeadline = "Duluth Children's";
									break;								
								case "MD":
									sHeadline = "Miller-Dwan Children's Healthcare";
									break;								
								case "POL":
									sHeadline = "Polinsky Children's Rehabilitation Center";
									break;								
								default:
									sHeadline = siteLoc;
									break;
							}
						}
					}
				}
				headline.innerHTML = "Duluth Children's";
				headline = document.getElementById("mainHeadline");
				//headline.innerHTML = siteLoc;
				headline.innerHTML = sHeadline;
			}
			else
			{
				headline.innerHTML = currNode.getAttribute('parent');
				headline = document.getElementById("mainHeadline");
				headline.innerHTML = siteLoc;
			}
		
			/*	   
			if (siteLoc =='Our Affiliates')
            	highlightTopRightNav(4);
        	if (siteLoc == 'Billing & Insurance')
        	{
            	highlightTopRightNav(3);
        	}
        	if (siteLoc == 'Clinic Locations')
        	{
            	highlightTopRightNav(2);
			}
			*/
			if (depth < 3)
			{
				nCell = tabRow.insertCell(0);
				nCell.className = 'divider';
				if(window.ActiveXObject)
				{
					nCell.innerHTML = '|';
				}
				else
				{
					var divider = document.createTextNode('|');
					nCell.appendChild(divider);
				}
			
            	if (parentName == 'Other Services')
				{
					nCell = tabRow.insertCell(0);

					// This puts in a link to homepage and parent sitelets, if necessary.  
					// This is a simplistic solution at this point;
					// At some point this needs to be changed to look at the XML file.
					nLink = document.createElement('a');
					nLink.setAttribute('href',makeEscapePath(nestingLevel++) + 'otherservices.htm');
					if(window.ActiveXObject)
					{
						nLink.innerText = 'Other Services';
					}
					else
					{
						var thisText= document.createTextNode('Other Services');
						nLink.appendChild(thisText);
					}
					nCell.appendChild(nLink);
					nCell = tabRow.insertCell(0);
					nCell.className = 'divider';
					if(window.ActiveXObject)
					{
						nCell.innerHTML = '|';
					}
					else
					{
						var divider = document.createTextNode('|');
						nCell.appendChild(divider);
					}
				}
				if (parentName == 'Specialty Services')
				{

					nCell = tabRow.insertCell(0);
					// This puts in a link to homepage and parent sitelets, if necessary.  This is a simplistic solution at this point;
					// at some point this needs to be changed to look at the XML file.
					nLink = document.createElement('a');
					nLink.setAttribute('href',makeEscapePath(nestingLevel++) + 'specialtyservices.htm');
					if(window.ActiveXObject)
					{
						nLink.innerText = 'Specialty Services';
					}
					else
					{
						var thisText= document.createTextNode('Specialty Services');
						nLink.appendChild(thisText);
					}
					nCell.appendChild(nLink);

					nCell = tabRow.insertCell(0);
					nCell.className = 'divider';
					nCell.innerHTML = '|';
				}
            	if (parentName == 'Clinic Locations')
				{

					nCell = tabRow.insertCell(0);

					// This puts in a link to homepage and parent sitelets, if necessary.  This is a simplistic solution at this point;
					// at some point this needs to be changed to look at the XML file.
					nLink = document.createElement('a');
					nLink.setAttribute('href',makeEscapePath(nestingLevel++) + 'cliniclocations.htm');
					if(window.ActiveXObject)
					{
						nLink.innerText = 'Clinic Locations';
					}
					else
					{
						var thisText= document.createTextNode('Clinic Locations');
						nLink.appendChild(thisText);
					}
					//alert(nLink);
					nCell.appendChild(nLink);
					nCell = tabRow.insertCell(0);
					nCell.className = 'divider';
					nCell.innerHTML = '|';
				}
				
				nCell = tabRow.insertCell(0);

				nLink = document.createElement('a');
				nLink.setAttribute('href',makeEscapePath(nestingLevel++) + 'default.htm');
				if(window.ActiveXObject)
				{
					nLink.innerText = 'St. Mary\'s Home';
				}
				else
				{
					var thisText= document.createTextNode('St. Mary\'s Home');
					nLink.appendChild(thisText);
				}
				nCell.appendChild(nLink);
			}
   		}
		else
   		{
      		var lnav=document.getElementById('leftNav');
   
        	currNode=currNode.parentNode;    	  
	 
			var p=new AJAXRequest(null,finishImageLoad,'piclist.xml');
			
      		// make notecard.
      		enableTabs();
      		var getNoteCard = new AJAXRequest(null, drawNoteCard, "qualityfirst.htm");
      		// fire async request for notecard data.
   		}

    	//set centercontent height.

      	// look at the XML & set up subheader & header.

		depth++;
		var currTitle;
		var currURL;
		var origURL;
		var displayFlag;
		var p;
		var newdivFlag=false;
		var expandedFlag=false;
		var specialIndent=false;
		var subNav=false;
		var nwindow;
		var boldFlag;
		var DCColorFlag;
		var MDMCFlag, SMDCFlag, polinskyFlag;
	
		for (p=0; p<currNode.childNodes.length; p++)
		{
			if (currNode.childNodes[p].nodeType==1)
			{
				currTitle=new String(currNode.childNodes[p].getAttribute('title'));
				currURL = new String(currNode.childNodes[p].getAttribute('url'));
				boldFlag = currNode.childNodes[p].getAttribute('boldface');
			    boldFlag = (boldFlag=='true'?true:false);
			    DCColorFlag=currNode.childNodes[p].getAttribute('DCColor');
			    DCColorFlag=(DCColorFlag=='true'?true:false);
			    MDMCFlag=currNode.childNodes[p].getAttribute('MDMCColor');
			    MDMCFlag=(MDMCFlag=='true'?true:false);
			    SMDCFlag=currNode.childNodes[p].getAttribute('SMDCColor');
			    SMDCFlag=(SMDCFlag=='true'?true:false);
			    polinskyFlag=currNode.childNodes[p].getAttribute('polinskyColor');
			    polinskyFlag=(polinskyFlag=='true'?true:false);
			    			    
				expandedFlag = currNode.childNodes[p].getAttribute('expanded');
				expandedFlag = (expandedFlag=='true'?true:false);
				
				if (currNode.childNodes[p].getAttribute('nwindow')) nwindow=true; 
				else nwindow=false;
				
				displayFlag = (currNode.childNodes[p].getAttribute('display'));
				displayFlag = (displayFlag=='no' ? false:true);

				origURL = currURL;
				currURL=currURL.toLowerCase();
				
				specialIndent = (currNode.childNodes[p].getAttribute('specialindent'));
				specialIndent = (specialIndent=='true'?true:false);
				
				subNav = (currNode.childNodes[p].getAttribute('subnav'));
				subNav = (subNav=='true'?true:false);
				
				newdivFlag = currNode.childNodes[p].getAttribute('ndiv');
				newdivFlag = (newdivFlag =='true'?true:false);
				
				if ((newdivFlag) && (displayFlag))
				{
				    menuAddFlag=true;
					var elem2=document.getElementById("leftNav");
					lightBlueDiv = makeCornerDiv(16,'#7EC6B9', 220,64,elem2);
					lightBlueDiv.setAttribute('id','leftNavLighterBlue');
					lightBlueDiv.style.left='10px';
					currHeight+=29+6;
					totalHeight = currHeight+10;
					lightBlueDiv.style.top=currHeight+'px';
					currHeight=10;
				}
				
				if ((isChildOf(currPage,currNode.childNodes[p]) || expandedFlag) && (displayFlag))
				{
					if ((expandedFlag) && !isChildOf(currPage, currNode.childNodes[p])) {
						currBar = addBlueBar(currTitle, origURL, nwindow, specialIndent, subNav);
					}
					else {
						currBar = addLightBlueBar(currTitle, origURL, nwindow, specialIndent);
					}
					
					var circleElem;
				    if (DCColorFlag)				    
				       makeDCTab(currBar,expandedFlag);				    
                    if (MDMCFlag)
                       makeMDMCTab(currBar,expandedFlag);
                    if (SMDCFlag)
                       makeSMDCTab(currBar,expandedFlag);   
                    if (polinskyFlag)
                       makePolinskyTab(currBar,expandedFlag);
                    						
					if ((currNode.childNodes[p].hasChildNodes()) && depth >=1)
					{
						var realLen=0;
						var nChildNodes=currNode.childNodes[p].childNodes;
						var idz;
						for (i=0;i<nChildNodes.length;i++)
						{
							if(nChildNodes[i].nodeType==1)
							{
								realLen+=1;
							}
						}
						for (idz=0;idz<nChildNodes.length;idz++)
						{
							if(nChildNodes[idz].nodeType==1)
							{
								if (nChildNodes[idz].getAttribute('display') == 'no') 
									realLen--;
							}
						}
						if (realLen !=0)
						{
							if (isChildOf(currPage, currNode.childNodes[p]) && (!expandedFlag))
							{
								rotateArrow(currBar);
							}
							//alert("addlevel3: currpage : " + currPage);
							addLevel3(currBar,currNode.childNodes[p].childNodes,currPage);
						}
					}
				}
				else
				{
					if (displayFlag && (!expandedFlag)) 
					{
						//if (p == 1)
						if (currTitle == "Access SMDC MyHealth")
						    currBar=addPurpleBar(currTitle, origURL, nwindow, specialIndent, subNav);
						else
					        currBar=addBlueBar(currTitle, origURL, nwindow, specialIndent, subNav);
					}
					
					if (DCColorFlag)				    
				       makeDCTab(currBar,expandedFlag);
                    if (MDMCFlag)
                       makeMDMCTab(currBar,expandedFlag);
                    if (SMDCFlag)
                       makeSMDCTab(currBar,expandedFlag);                       
				    if (polinskyFlag)
				       makePolinskyTab(currBar,expandedFlag);
				}
			}
		}
    lnav.style.height='468px'; //specific to smmc
	}
}

function isChildOf(pageURL,currNode)
{
	if(currNode.nodeType==1)
	{
		if (currNode.getAttribute('url').toLowerCase() == pageURL) return(true);
		else
		{
			var pages=currNode.getElementsByTagName('page');
			var y;
			var returnVal=false;
			for (y=0;y<pages.length;y++)
			{
				if (pages[y].getAttribute('url').toLowerCase() == pageURL)
				{
					returnVal = true;
					break;
				}
			}
			return(returnVal);
		}
	}
}

function makeDCTab(currBar,expanded)
{
        circleElem=document.createElement('img');				        
        circleElem.setAttribute('src',imagePath+'Images/dcleft.gif')

        circleElem.style.zIndex='0';
        circleElem.style.left='0px';
        circleElem.style.top='0px';
        circleElem.style.position='absolute';
        currBar.appendChild(circleElem);
        circleElem=document.createElement('img');				        
        circleElem.setAttribute('src',imagePath+'Images/dcsmall.gif')

        circleElem.style.zIndex='4';
        circleElem.style.left='7px';
        circleElem.style.top='3px';
        circleElem.style.height='18px';
        circleElem.style.width='18px';
        circleElem.style.position='absolute';
        
        currBar.appendChild(circleElem);
        currBar.childNodes[6].style.left='34px';
}

function makePolinskyTab(currBar,expanded)
{
        circleElem=document.createElement('img');
        circleElem.setAttribute('src',imagePath+'Images/polinskyleft.gif')
        circleElem.style.zIndex='0';
        circleElem.style.left='0px';
        circleElem.style.top='0px';
        circleElem.style.position='absolute';
        currBar.appendChild(circleElem);
        circleElem=document.createElement('img');
        circleElem.setAttribute('src',imagePath+'Images/polsmall.gif')
        circleElem.style.zIndex='4';
        circleElem.style.left='7px';
        circleElem.style.top='3px';
        circleElem.style.position='absolute';
        currBar.appendChild(circleElem);
        currBar.childNodes[6].style.left='34px';
}

function makeMDMCTab(currBar,expanded)
{
        circleElem=document.createElement('img');				        
        circleElem.setAttribute('src',imagePath+'Images/mdmcleft.gif')
        circleElem.style.zIndex='4';
        circleElem.style.left='0px';
        circleElem.style.top='0px';
        circleElem.style.position='absolute';
        currBar.appendChild(circleElem);
        circleElem=document.createElement('img');
        circleElem.setAttribute('src',imagePath+'Images/mdmcsmall.gif')
        circleElem.style.zIndex='4';
        circleElem.style.left='7px';
        circleElem.style.top='3px';
        circleElem.style.height='18px';
        circleElem.style.width='18px';
        circleElem.style.position='absolute';
        currBar.appendChild(circleElem);
        currBar.childNodes[6].style.left='34px';
}

function makeSMDCTab(currBar,expanded)
{
        circleElem=document.createElement('img');				    
        circleElem.setAttribute('src',imagePath+'Images/smdcleftdark.gif')
        circleElem.style.zIndex='4';
        circleElem.style.left='0px';
        circleElem.style.top='0px';
        circleElem.style.position='absolute';
        currBar.appendChild(circleElem);                        
        circleElem=document.createElement('img');
        circleElem.setAttribute('src',imagePath+'Images/smmcsmall.gif')
        circleElem.style.zIndex='4';
        circleElem.style.left='7px';
        circleElem.style.top='3px';
        circleElem.style.position='absolute';
        currBar.appendChild(circleElem);
        currBar.childNodes[6].style.left='34px';
}

function makeEscapePath (nLevel)
{
	// makes a series of dot-dot-slashes to indicate nLevel parent directories.
	var returnString = new String('');
	while (nLevel--)
		returnString += '../';
	return (returnString);
}

function rotateArrow(bar)
{
	var nodes=bar.childNodes;
	var idx;
	for (idx=0;idx<nodes.length;idx++)
	{	
		if (nodes[idx].className == 'arrow')
		{
			nodes[idx].setAttribute('src',imagePath+'Images/downArrowLighter.gif');
						
			break;
		}
	}
}

function addLevel3(barDiv, nodeList, pageURL)
{
    if (barDiv.childNodes.length==9)
    {
        var currSrc = new String(barDiv.childNodes[7].src);

        //if (currSrc.indexOf('bluebarleft.gif') != -1)
	if (currSrc.indexOf('dcleft.gif') != -1)
            currSrc=imagePath+ 'Images/bluebarleftsquare1.gif';
        if (currSrc.indexOf('mdmcleft.gif') != -1)
            currSrc=imagePath+ 'Images/mdmcleftsquare.gif';
        if (currSrc.indexOf('polinskyleft.gif') != -1)
            currSrc=imagePath+ 'Images/polinskyleftsquare.gif';
        if (currSrc.indexOf('smdcleft.gif') != -1)
            currSrc=imagePath+ 'Images/smdcleftsquare.gif';
		if (currSrc.indexOf('smdcleftdark.gif') != -1)
		{
            currSrc=imagePath+ 'Images/smdcleftsquaredark.gif';
		}
		if (currSrc.indexOf('smmcleft.gif') != -1)
            currSrc=imagePath+ 'Images/smmcleftsquare.gif';
		if (currSrc.indexOf('smmcleftDark.gif') != -1)
            currSrc=imagePath+ 'Images/smmcleftsquaredark.gif';
            
        barDiv.childNodes[7].src=currSrc;
        barDiv.childNodes[7].style.zIndex=7;
        barDiv.childNodes[8].style.left='6px';
        barDiv.childNodes[8].style.zIndex=9;
    }
    
	var lines=0;
	for(i=0;i<nodeList.length;i++)
	{
		if(nodeList[i].nodeType==1)
		{
			lines+=1;
		}
	}
	var idx, currTitle, currURL;
	var nRow, nCell, nLink;
	var newNode,idy;

	var nodeList2;
	var nwindow;
	var isBold;
	var specialIndent;
	var Lvl3;
	var nRow2, nCell2, nBr;
    extentTextBox.innerHTML='&nbsp;';
	var modulus=extentTextBox.offsetHeight;
	var displayFlag, currLines=0, oldHeight=0, ndiv;
	//way to make 'hanging tables': if page element has 'ndiv' set to true, close current rounded box & make a new one.
	for (idx=0;idx<nodeList.length;idx++)
	{
		if(nodeList[idx].nodeType==1)
		{
			if (nodeList[idx].getAttribute('display')== 'no') lines--;
		}
	}
	if (lines!=0)
	{
		var newHTML = new String();
		var newHeight= (lines*16);
		expandBlueBar (barDiv,newHeight);

		var navbluebar;

		if (barDiv.className == 'bluebar')
		{
			navbluebar=addSubMenuDark(barDiv);			
		}
		else
		{
			navbluebar = addSubMenu(barDiv);
		}
		
		var textSpot = getTextElement(navbluebar);
		var hr;
		if (barDiv.className == 'bluebar')
			textSpot.className = 'subNavDarkBlueText';
		else
			textSpot.className = 'subNavLightBlueText';
			
		for (idx=0;idx<nodeList.length;idx++)
		{	
			if(nodeList[idx].nodeType==1)
			{
				currTitle= nodeList[idx].getAttribute('title');
				currURL = nodeList[idx].getAttribute('url');
				nwindow=nodeList[idx].getAttribute('nwindow'); 
				if (nwindow=='true') 
					nwindow=true; 
				else 
					nwindow=false;
				isBold=nodeList[idx].getAttribute('boldface');
				if(isBold=='true') 
					isBold=true; 
				else 
					isBold=false;
				specialIndent=nodeList[idx].getAttribute('specialindent');
				Lvl3=nodeList[idx].getAttribute('lvl3');
				if(specialIndent=='true') 
				    // rgs 10/8/2007 convert this to boolean and add margin left to nCell
				    //specialIndent='&nbsp;&nbsp;&nbsp;&nbsp;'; 
					specialIndent=true;
				else 
				    specialIndent=false;
					
				hr=false;
				hr = nodeList[idx].getAttribute('hr');
				ndiv=false;
				ndiv=nodeList[idx].getAttribute('ndiv');
				displayFlag = nodeList[idx].getAttribute('display');
				displayFlag = (displayFlag=='no'?false:true);
				
				if (ndiv=='true')
				{
					adjustHeight(navbluebar,currLines*16+10);
					if (barDiv.className == 'bluebar')															
						navbluebar = addSubMenuDark(barDiv);																		
					else					
						navbluebar = addSubMenu(barDiv);
                    
					navbluebar.style.top = (currLines*16)+42+'px';
					oldHeight=(currLines*16)+20;
					
					textSpot = getTextElement(navbluebar);
					if (barDiv.className == 'bluebar')
						textSpot.className='subNavDarkBlueText';
					else
					{						
					    textSpot.className='subNavLightBlueText'; // rgs 9/24/2007 add to fix double bubble
					    addExpandBlueBar(barDiv, 16);
					}
					//grab barDiv height and subtract 10.   adjustHeight(navbluebar,26);
				    //	var bluebarheight = getPixelProperty(barDiv,'height');
					var bluebarheight=barDiv.offsetHeight;
				    adjustHeight(navbluebar, (bluebarheight-10)-oldHeight);
				}
					
				nCell = document.createElement('span');
				nCell.style.height='9px';
					
				if (specialIndent!=false)
				{
					// rgs find out how to add padding-left to the style attribute
				    nCell.style.marginLeft='14px';
				}
				
				// process level 2 menu items
				if (isChildOf(pageURL,nodeList[idx]))
				{
					//alert("currURL = " + currURL + "; pageURL = " + pageURL + "; currTitle = " + currTitle + ";Lvl3 = " + Lvl3);
					if ((currURL.toLowerCase() == pageURL) || (hr == 'true'))
					{
					    if (hr=='true') 
					    {
					        nLink=document.createElement('hr');
							//alert("hr == true");
						}
					    else
				        {
							nLink = document.createElement('span');
				            nLink.style.width='190px';
				            nLink.style.fontWeight = 'bold';
							if(window.ActiveXObject)
				            {						    						   
			                    nLink.innerText = currTitle;			                    						        						      
			                }
			                else						    
			                {
			                    var thisText= document.createTextNode(currTitle);
					            nLink.appendChild(thisText);
				            }
				            extentTextBox.innerHTML=currTitle;
				            extentTextBox.style.fontWeight='bold';
    							
				            modulus/=extentTextBox.offsetHeight;								
				            var bluebarheight=barDiv.offsetHeight;
    							
				            if (modulus!=1) 
				            {
				                addExpandBlueBar(barDiv,10);
				                adjustHeight(navbluebar,(bluebarheight)-oldHeight);
				            }        													
				            nLink.style.color='#004477';							
						}
					}
					else
					{
						nLink=document.createElement('a');
						currURL = currURL.toString(); //IE8 Compatibility
						nLink.setAttribute('href',currURL);	
						//alert("currurl <> pageurl; currURL = " + currURL);
						if (nwindow==true)
						{
							nLink.setAttribute('rel','external');
							nLink.setAttribute('target','_blank');
						}
						if(window.ActiveXObject)
						{
							nLink.innerText = currTitle;							
						}
						else
						{
							var thisText= document.createTextNode(currTitle);
							nLink.appendChild(thisText);
						}
						//this here NEW__________
						if (isBold) 
						{
							nLink.style.fontWeight='bold';
						}
					}
					
					if (displayFlag)
					{
						nCell.appendChild(nLink);
					}
					
					// check if level two nav item has childnodes (lvl3)
					if (nodeList[idx].hasChildNodes())
					{
						//alert("haschildnodes");
						nodeList2=nodeList[idx].childNodes;
						var idz;
						var nLength = 0;
						for(i=0;i<nodeList2.length;i++)
						{
							if(nodeList2[i].nodeType==1)
							{
								nLength+=1;
							}
						}
						for (idz=0;idz<nodeList2.length;idz++)
						{
							if(nodeList2[idz].nodeType==1)
							{
								if (nodeList2[idz].getAttribute('display') == 'no')
								{
									nLength--;
								}
							}
						}
						
						newHeight += (nLength*16);
						addExpandBlueBar (barDiv,nLength*16);
						var tHeight=barDiv.offsetHeight;
						adjustHeight (navbluebar,tHeight-(10+oldHeight));
						for (idy=0;idy<nodeList2.length;idy++)
						{
							if(nodeList2[idy].nodeType==1)
							{
								if (nodeList2[idy].getAttribute('display') != 'no')
								{
									currTitle = nodeList2[idy].getAttribute('title');
									currURL = nodeList2[idy].getAttribute('url').toLowerCase();
									Lvl3 = nodeList2[idy].getAttribute('lvl3');
									//alert("nodelist2; currURL = " + currURL +"; Lvl3= " + Lvl3);
									hr=false;
									hr=nodeList2[idy].getAttribute('hr');
									nRow2=document.createElement('br');
									nCell.appendChild(nRow2);
									currLines++;
									if ((currURL != pageURL) && (hr != 'true'))
									{
										if (nodeList2[idy].getAttribute('display') != 'no')
										{
											nLink = document.createElement('a');
											currURL = currURL.toString(); //IE8 Compatibility
											nLink.setAttribute('href',currURL);
											nLink.style.paddingLeft='14px';
											//alert("Lvl3 = " + Lvl3 + "; currURL = " + currURL + "; pageURL = " + pageURL);
											if (Lvl3 == 'true')
												nLink.style.paddingLeft = '28px';
											if (nodeList2[idy].getAttribute('nwindow')=='true')
											{
												nLink.setAttribute('rel','external');
												nLink.setAttribute('target','_blank');
											}
											//alert(currTitle);
											if(window.ActiveXObject)
											{
												nLink.innerHTML = currTitle;												
											}
											else
											{
												var thisTitle = document.createTextNode(currTitle);
												nLink.appendChild(thisTitle);
											}
											nCell.appendChild(nLink);
										}
									}
									else
									{
										if (hr=='true')
										{
											nLink = document.createElement('hr');
											nLink.setAttribute('width','90%');
											nLink.style.color = '#1F6B9F';
										}
										else
										{
											//alert("pageurl=currurl, hr<>true");
											nLink = document.createElement('span');
											nLink.style.fontWeight='bold';
											nLink.style.paddingLeft='14px';
											if (Lvl3=="true")
												nLink.style.paddingLeft='28px';
											nLink.style.color='#004477';
											extentTextBox2.innerHTML=currTitle;
				                            extentTextBox2.style.fontWeight='bold';
                    						
				                            modulus/=extentTextBox2.offsetHeight;								
				                            var bluebarheight=barDiv.offsetHeight;
                    						
				                            if (modulus!=1) 
				                            {
				                                addExpandBlueBar(barDiv,10);
				                                adjustHeight(navbluebar,(bluebarheight)-oldHeight);
				                            }        													
											if(window.ActiveXObject)
											{								
												nLink.innerHTML = currTitle;
											}
											else
											{
												var thisTitle = document.createTextNode(currTitle);
												nLink.appendChild(thisTitle);
											}
										}
										nCell.appendChild(nLink);
									}
								}
							}
						}
					}
				}
				else
				{ 
					if (displayFlag)
					{ 
						if (hr == 'true')
						{	
							nLink = document.createElement('hr');
							nLink.setAttribute('width','90%');
							nLink.style.color = '#1F6B9F';
						}
						else
						{
							nLink=document.createElement('a');
							currURL = currURL.toString(); //IE8 Compatibility
							nLink.setAttribute('href',currURL);
							if (nwindow)
							{
								nLink.setAttribute('rel','external');
								nLink.setAttribute('target','_blank');
							}

							if(window.ActiveXObject)
							{
								nLink.innerText = currTitle;								
							}
							else
							{
								var thisText= document.createTextNode(currTitle);
								nLink.appendChild(thisText);								
							}
						}						
						if (isBold) 
						{
							nLink.style.fontWeight='bold'; 
							nLink.style.letterSpacing='1px';
						}
						nCell.appendChild(nLink);
					}
				}
				if (displayFlag)
				{	
					if (hr != 'true')
					{	
						nBr=document.createElement('br');
						nCell.appendChild(nBr);
						currLines++;
					}
					textSpot.appendChild(nCell);
				}
			}
		}
	}
}

function addPurpleBar(nameOf, URL, nwindow, specialIndent, subNav)
{
	var elem;
	var purplebarElem=makeDivClass('purplebar');
	
	purplebarElem.appendChild(makeDivClass('topCorner'));
    purplebarElem.appendChild(makeDivClass('topRight'));		
	/* Let's make a 12x199 block, #63318D (Purple) in color.  Attach an event to it. */
	var t = document.createElement('div');
	t.style.top='0px';
	t.style.left='11px';
	t.style.width='199px';
	t.style.backgroundColor='#63318D';
	t.style.position='absolute';
	t.style.overflow='hidden';
	t.innerHTML= repStr('&nbsp;',300);
	
	if (window.ActiveXObject)
	{
	    t.attachEvent('onmouseover',highlightBar);
	    t.attachEvent('onclick',function(){window.location=URL;});
	}
	else
	{
	    t.addEventListener('mouseover',highlightBar,false);
	    t.addEventListener('click',function(){window.location=URL;},false);
	}
	purplebarElem.appendChild(t);	
	
	elem = makeDivClass('middleExpand');
	elem.style.height='1px';
	var elem2=document.createElement("img");
	elem2.style.height='1px';
	elem2.setAttribute('src',imagePath + 'Images/middleLeftPurple.gif');
	
	elem.appendChild(elem2);
	purplebarElem.appendChild(elem);
	elem = makeDivClass('bottomCorner');
	elem.style.top='13px';
	purplebarElem.appendChild(elem);
	elem=makeDivClass('bottomRight');
	/*put non-breaking spaces in bottom right so event will register.*/
	elem.style.top='13px';
	elem.style.overflow='hidden';
	elem.innerHTML=repStr('&nbsp;',300);
	
	if (window.ActiveXObject)
	{
	    elem.attachEvent('onmouseover',highlightBar);
	    elem.attachEvent('onclick',function(){window.location=URL;});
	}
	else
	{
	    elem.addEventListener('mouseover',highlightBar,false);
	    elem.addEventListener('click',function(){window.location=URL;},false);
	}
	elem.style.top='12px';
	purplebarElem.appendChild(elem);
	elem = makeDivClass('textArea');
	elem2= document.createElement("a");

	URL = URL.toString(); //IE8 Compatibility
	elem2.setAttribute('href',URL);
	if (nwindow) 
	{ 
		elem2.setAttribute('target','_blank'); 
		elem2.setAttribute('rel','external');
	}
	
	if (specialIndent == true)
	   elem2.style.marginLeft='14px';
	elem2.innerHTML = nameOf;
	
	elem.appendChild(elem2);
	purplebarElem.appendChild(elem);
	purplebarElem.style.top = currHeight + 'px';
	// rgs js error in Firefox - Mozilla
	if (window.ActiveXObject)
	{
		purplebarElem.attachEvent ('onmouseover', highlightBar);
		purplebarElem.attachEvent ('onmouseout', unHighlightBar);
		if (!nwindow) purplebarElem.attachEvent('onclick',function(){window.location=URL;});
	}
	else
	{
		purplebarElem.addEventListener('mouseover',highlightBar,false);
		purplebarElem.addEventListener('mouseout',unHighlightBar,false);
		if (!nwindow) purplebarElem.addEventListener('click',function(){window.location=URL;},false);
	}
	
	// rgs 10/16/2007
	if (subNav)
	{
		var imgArrow = document.createElement("img");
		imgArrow.setAttribute('src',imagePath +'Images/downArrowDark.gif');
		imgArrow.className = 'arrow';
	
		purplebarElem.appendChild(imgArrow);
	}
	
	lightBlueDiv.appendChild(purplebarElem);
	currHeight+=29;
	totalHeight+=29;
	adjustHeight(lightBlueDiv,currHeight+6);
	
	if (menuAddFlag==false) menuBars[menuPtr++]=purplebarElem;
	
	return(purplebarElem);	
}

function addBlueBar(nameOf, URL, nwindow, specialIndent, subNav)
{
	var elem;
	var bluebarElem=makeDivClass('bluebar');
	
	bluebarElem.appendChild(makeDivClass('topCorner'));
    bluebarElem.appendChild(makeDivClass('topRight'));		
	/* Let's make a 12x199 block, #108184 in color.  Attach an event to it. */
	var t = document.createElement('div');
	t.style.top='0px';
	t.style.left='11px';
	t.style.width='199px';
	t.style.backgroundColor='#108184';
	t.style.position='absolute';
	t.style.overflow='hidden';
	t.innerHTML= repStr('&nbsp;',300);
	
	if (window.ActiveXObject)
	{
	    t.attachEvent('onmouseover',highlightBar);
	    t.attachEvent('onclick',function(){window.location=URL;});
	}
	else
	{
	    t.addEventListener('mouseover',highlightBar,false);
	    t.addEventListener('click',function(){window.location=URL;},false);
	}
	bluebarElem.appendChild(t);	
	
	elem = makeDivClass('middleExpand');
	elem.style.height='1px';
	var elem2=document.createElement("img");
	elem2.style.height='1px';
	elem2.setAttribute('src',imagePath + 'images/middleLeftDarkBlue.gif');
	
	elem.appendChild(elem2);
	bluebarElem.appendChild(elem);
	elem = makeDivClass('bottomCorner');
	elem.style.top='13px';
	bluebarElem.appendChild(elem);
	elem=makeDivClass('bottomRight');
	/*put non-breaking spaces in bottom right so event will register.*/
	elem.style.top='13px';
	elem.style.overflow='hidden';
	elem.innerHTML=repStr('&nbsp;',300);
	
	if (window.ActiveXObject)
	{
	    elem.attachEvent('onmouseover',highlightBar);
	    elem.attachEvent('onclick',function(){window.location=URL;});
	}
	else
	{
	    elem.addEventListener('mouseover',highlightBar,false);
	    elem.addEventListener('click',function(){window.location=URL;},false);
	}
	elem.style.top='12px';
	bluebarElem.appendChild(elem);
	elem = makeDivClass('textArea');
	elem2= document.createElement("a");

	URL = URL.toString(); //IE8 Compatibility
	elem2.setAttribute('href',URL);
	if (nwindow) 
	{ 
		elem2.setAttribute('target','_blank'); 
		elem2.setAttribute('rel','external');
	}
	
	if (specialIndent == true)
	   elem2.style.marginLeft='14px';
	elem2.innerHTML = nameOf;
	
	elem.appendChild(elem2);
	bluebarElem.appendChild(elem);
	bluebarElem.style.top = currHeight + 'px';
	// rgs js error in Firefox - Mozilla
	if (window.ActiveXObject)
	{
		bluebarElem.attachEvent ('onmouseover', highlightBar);
		bluebarElem.attachEvent ('onmouseout', unHighlightBar);
		if (!nwindow) bluebarElem.attachEvent('onclick',function(){window.location=URL;});
	}
	else
	{
		bluebarElem.addEventListener('mouseover',highlightBar,false);
		bluebarElem.addEventListener('mouseout',unHighlightBar,false);
		if (!nwindow) bluebarElem.addEventListener('click',function(){window.location=URL;},false);
	}
	
	// rgs 10/16/2007
	if (subNav)
	{
		var imgArrow = document.createElement("img");
		imgArrow.setAttribute('src',imagePath +'Images/downArrowDark.gif');
		imgArrow.className = 'arrow';
	
		bluebarElem.appendChild(imgArrow);
	}
	
	lightBlueDiv.appendChild(bluebarElem);
	currHeight+=29;
	totalHeight+=29;
	adjustHeight(lightBlueDiv,currHeight+6);
	
	if (menuAddFlag==false) menuBars[menuPtr++]=bluebarElem;
	
	return(bluebarElem);	
}

function addLightBlueBar(nameOf, URL, nwindow)
{
	var elem;
	var bluebarElem=makeDivClass('lightBluebar');
	
	bluebarElem.style.height='25px';
	
	bluebarElem.appendChild(makeDivClass('topCorner'));

	bluebarElem.appendChild(makeDivClass('topRight'));
	//create a rectangle of color #a7e7b3 (that was old color, new color is aee3c0)
	var t=document.createElement('div');
    t.style.top='0px';
	t.style.left='11px';
	t.style.width='199px';
	//t.style.backgroundColor='#aee3c0';
	t.style.backgroundColor='#90E8C0';
	t.style.position='absolute';
	t.style.overflow='hidden';
	t.innerHTML= repStr('&nbsp;',300);
	
	if (window.ActiveXObject)
	{
	    t.attachEvent('onmouseover',highlightBar);
	    t.attachEvent('onclick',function(){window.location=URL;});
	}
	else
	{
	    t.addEventListener('mouseover',highlightBar,false);
	    t.addEventListener('click',function(){window.location=URL;},false);
	}
	
    bluebarElem.appendChild(t); 
	
	elem = makeDivClass('middleExpand');
	
	elem.style.height='1px';
	var elem2=document.createElement("img");
	elem2.style.height='1px';
	elem2.setAttribute('src',imagePath + 'Images/lightBlueBarMiddle12by1.gif');
	elem.appendChild(elem2);
	bluebarElem.appendChild(elem);
	
	elem = makeDivClass('bottomCorner');
	
	elem.style.top = '13px';
	bluebarElem.appendChild(elem);
	
	elem = makeDivClass('bottomRight');
	
	elem.style.top='13px';
	elem.style.overflow='hidden';
    elem.innerHTML=repStr('&nbsp;',300);
	
    if (window.ActiveXObject)
	{
	    elem.attachEvent('onmouseover',highlightBar);
	    elem.attachEvent('onclick',function(){window.location=URL;});
	}
	else
	{
	    elem.addEventListener('mouseover',highlightBar,false);
	    elem.addEventListener('click',function(){window.location=URL;},false);
	}
	elem.style.top = '13px';
	bluebarElem.appendChild(elem);
	elem = makeDivClass('textArea');
	elem2= document.createElement("a");
	URL = URL.toString(); //IE8 Compatibility
	elem2.setAttribute('href',URL);
	if (nwindow) 
	{ 
		elem2.setAttribute('target','_blank'); 
		elem2.setAttribute('rel','external');
	}
	elem2.innerHTML = nameOf;
	elem.appendChild(elem2);
	bluebarElem.appendChild(elem);
	bluebarElem.style.top = currHeight + 'px';
	
	// rgs js error in Firefox - Mozilla
	if (window.ActiveXObject)
	{
		bluebarElem.attachEvent ('onmouseover', highlightBar);
		bluebarElem.attachEvent ('onmouseout', unHighlightBar);
	}
	else
	{ //fix for non IE swt
		bluebarElem.addEventListener('mouseover',highlightBar,false);
		bluebarElem.addEventListener('mouseout',unHighlightBar,false);
	}
	
	lightBlueDiv.appendChild(bluebarElem);
	
	currHeight+=29;
	totalHeight+=29;
	adjustHeight(lightBlueDiv,currHeight+6);
	
	if (menuAddFlag==false) menuBars[menuPtr++]=bluebarElem;
	
	return (bluebarElem);
}

function expandBlueBar(elem,newHeight)
{
	var idx;
	var expandDiv=false;
	var expandImg=false;
	var bottomRightDiv=false;
	var bottomCornerDiv=false;
	var newBottom;
	newHeight+=24;
	if (newHeight & 1) newHeight++;
	elem.style.height = newHeight + 'px';
	for (idx=0;idx<elem.childNodes.length;idx++)
	{
		if(elem.childNodes[idx].nodeType==1)
		{
			if (elem.childNodes[idx].className == 'middleExpand')
			{
				expandDiv = elem.childNodes[idx];
			}
			if (elem.childNodes[idx].className == 'bottomRight')
			{
				bottomRightDiv = elem.childNodes[idx];
			}
			if (elem.childNodes[idx].className == 'bottomCorner')
			{
				bottomCornerDiv = elem.childNodes[idx];
			}
		}
	}
	if (expandDiv)
	{
		expandDiv.style.height=newHeight+'px';
		expandImg = expandDiv.childNodes[0];
		expandImg.style.height = newHeight + 'px';
		newBottom = getPixelProperty(bottomRightDiv,'top');
		newBottom += (newHeight-1);
		newBottom += 'px';
		bottomRightDiv.style.top=newBottom;
		bottomCornerDiv.style.top=newBottom;
		currHeight+=newHeight;
		totalHeight+=newHeight;
		adjustHeight(lightBlueDiv,currHeight);
	}
}

function makeDivClass(classNameOf)
{
	var newElem = document.createElement("div");
	newElem.className = classNameOf;
	return(newElem);
}

function highlightBar(eventObj)
{ 
	var source;
	 if (window.ActiveXObject)
	 {
		source = eventObj.srcElement;
	 }
	 else
	 {
		source = eventObj.target;
	 }
	var nDepth=0;
	while ((source.className != 'bluebar') && (source.className != 'lightBluebar') && (source.className != 'purplebar'))
	{
		source = source.parentNode;
		nDepth++;
	}
	if (nDepth < 3)
	{
		var nodes = source.childNodes;
		var idx;
		for (idx=0;idx<nodes.length;idx++)
		{
			if(nodes[idx].nodeType==1)
			{
				if (nodes[idx].className == 'arrow')
				{
					nodes[idx].className = 'arrowHighlight';
				}
				if (nodes[idx].className=='textArea')
				{
					nodes[idx].className = 'textAreaHighlight';
				}
			}
		}
	}
}

function unHighlightBar(eventObj)
{	
	var source;
	 if (window.ActiveXObject)
	 {
		source = eventObj.srcElement;
	 }
	 else
	 {
		source = eventObj.target;
	 }
	while ((source.className != 'bluebar') && (source.className != 'lightBluebar') && (source.className != 'purplebar'))
		source = source.parentNode;
	var nodes = source.childNodes;
	var idx;
	for (idx=0;idx<nodes.length;idx++)
	{
		if(nodes[idx].nodeType==1)
		{
			if (nodes[idx].className == 'arrowHighlight')
			{
				nodes[idx].className = 'arrow';
			}
			if (nodes[idx].className=='textAreaHighlight')
			{
				nodes[idx].className = 'textArea';
			}
		}
	}
}

var retStr="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
//returns reps of string
function repStr (string,reps)
{        
    return(retStr);
}

var isInSubDiv=new Array();
var accordionClosing=new Array();
var accordionClosed=new Array();
var barMoveStep=new Array();
var levelThreeMoveStep=new Array();
var middleMoveStep=new Array();
var textAreaMoveStep=0;
var originalBarPositions,origBarHeight=new Array(),origTextHeight=new Array(),origMiddleHeight=new Array(),origBottomCornerTop=new Array(),origBottomRightTop=new Array(),origLevelThreeHeight=new Array();
var iorigLnavBottomLeft,iorigLnavLbarHeight=new Array(),iorigLnavMainBarHeight=new Array(),iLightBlueTop=new Array();
var activeAccordion=0;
var origTextHeight=0;
var origBarPtr=0;

var moveSteps=20;       //this needs to be an integral factor of totalTime
var totalTime=500;      //500 milliseconds, or 1/2 second.
var stepsLeft;
var accordionInterval;
var currSteps;
var lnav;

function openAccordion(whichAccordion)
{
    if (!accordionClosing[whichAccordion])
    {
    accordionClosing[whichAccordion]=true;
    activeAccordion=whichAccordion;
    stepsLeft=moveSteps; 
	currSteps=moveSteps;
    //use setTimeout 'cause it's safer (we do a lot of processing in closingAccordion)
    accordionInterval=setTimeout('openingAccordion()',totalTime/moveSteps);
    }
}

function openingAccordion()
{
    /*
    1. 
    */
    
    stepsLeft--;
	currSteps--;
    var top;
    for (var ix=activeAccordion+1;ix<menuPtr;ix++)
    {
        //get pixel top.
        top = parseInt(menuBars[ix].style.top.replace('px',''));
        menuBars[ix].style.top = (originalBarPositions[activeAccordion][ix] +Math.floor(currSteps* barMoveStep[activeAccordion]))+'px';
    //    menuBars[ix].style.height= (originalBarPositions[ix]+Math.floor(currSteps*barMoveStep))+'px';
    }
    
    menuBars[activeAccordion].childNodes[3].style.height=(origMiddleHeight[activeAccordion]+Math.floor(currSteps*barMoveStep[activeAccordion]))+'px';
    menuBars[activeAccordion].lastChild.style.height=(origLevelThreeHeight[activeAccordion]+Math.floor(currSteps*levelThreeMoveStep[activeAccordion]))+'px';
    menuBars[activeAccordion].childNodes[5].style.top=(origBottomCornerTop[activeAccordion]+Math.floor(currSteps*barMoveStep[activeAccordion]))+'px';
    menuBars[activeAccordion].childNodes[4].style.top=(origBottomCornerTop[activeAccordion]+Math.floor(currSteps*barMoveStep[activeAccordion]))+'px';
    menuBars[activeAccordion].childNodes[2].style.height=(origLevelThreeHeight[activeAccordion]+Math.floor(currSteps*levelThreeMoveStep[activeAccordion]))+'px';
   	lnav.childNodes[3].style.height=(iorigLnavMainBarHeight[activeAccordion]+Math.floor(currSteps*barMoveStep[activeAccordion]))+'px';
    lnav.childNodes[2].style.height=(iorigLnavLbarHeight[activeAccordion]+Math.floor(currSteps*barMoveStep[activeAccordion]))+'px';
    lnav.childNodes[1].style.top=((iorigLnavMainBarHeight[activeAccordion]-16)+Math.floor(currSteps*barMoveStep[activeAccordion]))+'px';
    if (stepsLeft)
        accordionInterval=setTimeout('openingAccordion()',totalTime/moveSteps);
    else
    {
        accordionClosed[activeAccordion]=false;
        menuBars[activeAccordion].lastChild.style.visibility='visible';
        accordionClosing[activeAccordion]=false;
        menuBars[activeAccordion].lastChild.childNodes[1].style.top=menuBars[activeAccordion].lastChild.offsetHeight+'px';
    }
        
}

var originalBarPositions=new Array();

function closeAccordion(whichAccordion)
{
   /*
   1. set accordionClosing to true
   2. calculate amount to move each of the bars per timer interval, as well as final bar positions
   3. save original bar positions so we can restore them later
   4. calculate amount to move text area per timer interval
   5. save its height so we can restore it later
   6. disable arrow event handler
   7. start timer   
   */
   	var currAccordion=whichAccordion;
	
   	if (accordionClosed[currAccordion]) 
   	{
		openAccordion(whichAccordion);
	}
    if ((!accordionClosing[currAccordion]) && (!accordionClosed[currAccordion]))
    {
    	accordionClosing[currAccordion]=true;
    	originalBarPositions[currAccordion]=new Array();
    	activeAccordion=whichAccordion;
    	origBarHeight = menuBars[whichAccordion].offsetHeight;
    	var newHeight=0, delta=newHeight-origBarHeight;
        
    	origLevelThreeHeight[whichAccordion]=menuBars[whichAccordion].lastChild.lastChild.offsetHeight;
    	var newLevelThreeHeight=4,deltaLevelThree=newLevelThreeHeight-origLevelThreeHeight[whichAccordion];    
    
    	origMiddleHeight[whichAccordion]=menuBars[whichAccordion].childNodes[3].offsetHeight;
    	var newMiddleHeight=0,deltaMiddleHeight=newMiddleHeight-origMiddleHeight[whichAccordion];
    	origBottomCornerTop[whichAccordion]=parseInt(menuBars[whichAccordion].childNodes[5].style.top.replace('px',''));
    
 //   origBottomRightTop = parseInt(menuBars[whichAccordion].childNodes[6].style.top.replace('px',''));
    
    	barMoveStep[whichAccordion]=delta/moveSteps; levelThreeMoveStep[whichAccordion]=deltaLevelThree/moveSteps;
    	/* to find distance to move bottom corner and bottom right, just use delta. */
    
    	menuBars[whichAccordion].lastChild.style.visibility='hidden';
    	stepsLeft=moveSteps; 
		currSteps=0;
		
    	//use setTimeout 'cause it's safer (we do a lot of processing in closingAccordion)
    	accordionInterval=setTimeout('closingAccordion()',totalTime/moveSteps);
    	menuBars[whichAccordion].childNodes[3].style.overflow='hidden';
    
   	 	if (!originalBarPositions[whichAccordion]) 
	 		originalBarPositions[whichAccordion]=new Array();
    	for (var ix=0;ix<menuPtr;ix++)    
        	originalBarPositions[whichAccordion][ix]=parseInt(menuBars[ix].style.top.replace('px',''));
    
    	lnav=menuBars[activeAccordion].parentNode;
    
    	iorigLnavBottomLeft=parseInt(lnav.childNodes[1].style.top.replace('px',''));
    
    	iorigLnavLbarHeight[activeAccordion]=parseInt(lnav.childNodes[2].style.height.replace('px',''));
    	iorigLnavMainBarHeight[activeAccordion]=parseInt(lnav.childNodes[3].style.height.replace('px',''));
    	iorigLnavBottomLeft=iorigLnavMainBarHeight-16;
  		//  iLightBlueTop[activeAccordion]=parseInt(lightBlueDiv.style.top.replace('px',''));
    }
}

function closingAccordion()
{
    /*
    1. 
    */
    
    stepsLeft--;
	currSteps++;
	
    var top;
    for (var ix=activeAccordion+1;ix<menuPtr;ix++)
    {
        //get pixel top.
        top = parseInt(menuBars[ix].style.top.replace('px',''));
        menuBars[ix].style.top = (originalBarPositions[activeAccordion][ix] +Math.floor(currSteps* barMoveStep[activeAccordion]))+'px';
    }
    
    menuBars[activeAccordion].childNodes[3].style.height=(origMiddleHeight[activeAccordion]+Math.floor(currSteps*barMoveStep[activeAccordion]))+'px';
 //   menuBars[activeAccordion].lastChild.style.height=(origLevelThreeHeight+Math.floor(currSteps*levelThreeMoveStep))+'px';
    menuBars[activeAccordion].childNodes[5].style.top=(origBottomCornerTop[activeAccordion]+Math.floor(currSteps*barMoveStep[activeAccordion]))+'px';
    menuBars[activeAccordion].childNodes[4].style.top=(origBottomCornerTop[activeAccordion]+Math.floor(currSteps*barMoveStep[activeAccordion]))+'px';
    menuBars[activeAccordion].childNodes[2].style.height=(origLevelThreeHeight[activeAccordion]+Math.floor(currSteps*levelThreeMoveStep[activeAccordion]))+'px';
   lnav.childNodes[3].style.height=(iorigLnavMainBarHeight[activeAccordion]+Math.floor(currSteps*barMoveStep[activeAccordion]))+'px';
    lnav.childNodes[2].style.height=(iorigLnavLbarHeight[activeAccordion]+Math.floor(currSteps*barMoveStep[activeAccordion]))+'px';
    lnav.childNodes[1].style.top=((iorigLnavMainBarHeight[activeAccordion]-16)+Math.floor(currSteps*barMoveStep[activeAccordion]))+'px';
   // lightBlueDiv.style.top=iLightBlueTop[activeAccordion]+Math.floor(currSteps*barMoveStep[activeAccordion])+'px';
    if (stepsLeft)
        accordionInterval=setTimeout('closingAccordion()',totalTime/moveSteps);
    else
    {
        accordionClosed[activeAccordion]=true;
        accordionClosing[activeAccordion]=false;
    }
}

function addExpandBlueBar(elem,newHeight)
{
	var idx;
	var expandDiv=false;
	var expandImg=false;
	var bottomRightDiv=false;
	var bottomCornerDiv=false;
	var newBottom;
	var delta = newHeight;
	newHeight += getPixelProperty(elem,'height');
	if (newHeight & 1) newHeight++;
	elem.style.height = newHeight + 'px';
	for (idx=0;idx<elem.childNodes.length;idx++)
	{
		if(elem.childNodes[idx].nodeType==1)
		{
			if (elem.childNodes[idx].className == 'middleExpand')
			{
				expandDiv = elem.childNodes[idx];
			}
			if (elem.childNodes[idx].className == 'bottomRight')
			{
				bottomRightDiv = elem.childNodes[idx];
			}
			if (elem.childNodes[idx].className == 'bottomCorner')
			{
				bottomCornerDiv = elem.childNodes[idx];
			}
		}
	}
	if (expandDiv)
	{
		expandDiv.style.height=newHeight+'px';
		expandImg = expandDiv.childNodes[0];
		expandImg.style.height = newHeight + 'px';
		newBottom = getPixelProperty(bottomRightDiv,'top');
		newBottom += (delta);
		newBottom += 'px';
		bottomRightDiv.style.top=newBottom;
		bottomCornerDiv.style.top=newBottom;
		currHeight+=delta;
		totalHeight+=delta;
		adjustHeight(lightBlueDiv,currHeight);
	}
}

function addSubMenu(parentElem)
{
    var rightArrowImage = document.createElement("img");
	rightArrowImage.setAttribute('src',imagePath +'Images/downArrowLighter.gif');
	rightArrowImage.className = 'arrow';
	var currMenuPtr;            //need to declare this in here, too, so it will go out of scope.
	currMenuPtr = menuPtr-1;
	if (window.ActiveXObject)
	{
	    rightArrowImage.attachEvent('onclick',function(){closeAccordion(currMenuPtr);});       
	}
	else
	{
	    rightArrowImage.addEventListener('click',function(){closeAccordion(currMenuPtr);},false);
	}
	
	if (parentElem.childNodes.length<9)
    {
	    parentElem.appendChild(rightArrowImage);
	}
	
	accordionClosed[currMenuPtr]=false;
	accordionClosing[currMenuPtr]=false;
	
	var newHeight = getPixelProperty(parentElem,'height');
	
	if (newHeight & 1) newHeight++;
	newHeight-=10;
	
	var newMenu = makeCornerDiv(12, '#BDF4DB',200,newHeight,parentElem);
	
	newMenu.style.right='0px';
	newMenu.style.top='22px';
	if (parentElem.childNodes.length==10)
	    newMenu.style.top='25px';
	return(newMenu);
}

function addSubMenuDark(parentElem)
{
    //here's where we add handler for open accordion.

	var imgArrow = document.createElement("img");
	// rgs 10/17/2007 change to down arrow image
	//imgArrow.setAttribute('src',imagePath+'images/rightArrowDarkBlue.gif');
	imgArrow.setAttribute('src',imagePath+'images/downArrowDark.gif');
	imgArrow.className = 'arrow';	   

	var currMenuPtr;            //need to declare this in here, too, so it will go out of scope.
	
	currMenuPtr = menuPtr-1;
	
	if (window.ActiveXObject)
	{
	    imgArrow.attachEvent('onclick',function(){closeAccordion(currMenuPtr);});       
	}
	else
	{
	    imgArrow.addEventListener('click',function(){closeAccordion(currMenuPtr);},false);
	}
	
	if (parentElem.childNodes.length<9)
	    parentElem.appendChild(imgArrow);
	
	accordionClosed[currMenuPtr]=false;
	accordionClosing[currMenuPtr]=false;
	
	var newHeight = getPixelProperty(parentElem,'height');
	if (newHeight & 1) newHeight++;

	newHeight-=10;
	var newMenu = makeCornerDiv(12, '#54AEAD', 200, newHeight, parentElem);
	newMenu.style.right='0px';
	newMenu.style.top='22px';
    if (parentElem.childNodes.length==10)
        newMenu.style.top='25px';
	return(newMenu);
}


function finishImageLoad(theXML,theText)
{
	var gfx=theXML.documentElement.getElementsByTagName('image');

	for (var ix=0;ix<gfx.length;ix++)
	{
		imageArray[nImages]=new Image();
		picLinkArray[nImages]=new String(gfx[ix].getAttribute('link'));
		imageArray[nImages++].src = gfx[ix].getAttribute('url');
	}
	currOpacity=0;
	currPic=0;
	mPic=document.getElementById('picture');

	document.getElementById('placeHolder').src=imageArray[currPic].src;
	iTimer=setInterval(fadeIn,50);
}

function doPicLink()
{
	window.location = picLinkArray[currPic];	
}

var picLinkArray=new Array();
var currOpacity;
var currPic;
var iTimer;
var imageArray=new Array();
var currImageIndex;
var nImages=0;
var lastImage=false;
var lightUps=new Array();

function doNextImage1()
{
	clearInterval(iTimer);
	iTimer=setInterval(fadeOut,50);
}

function fadeIn()
{
	currOpacity+=5;
	if (currOpacity==100) 
	{
		clearInterval(iTimer);
		iTimer=setInterval(doNextImage1,4000);
	}
	setOpacity(mPic,currOpacity);
}

function fadeOut()
{
	currOpacity-=5;
	setOpacity(mPic,currOpacity);
	if (currOpacity==0) 
	{
		clearInterval(iTimer);
		currPic++;
		if (currPic>=nImages) currPic=0;
		document.getElementById('placeHolder').src=imageArray[currPic].src;
		iTimer=setInterval(fadeIn,50);
	}	
}

function setOpacity(obj,alpha)
{
	if (window.ActiveXObject)
		obj.filters.alpha.opacity=alpha;
	else
		obj.style.opacity=(alpha/100);
}

function getOpacity(obj)
{
	if (window.ActiveXObject)
		return (obj.filters.alpha.opacity);
	else
		return Math.floor(obj.style.opacity*100);
}

