// JavaScript Document

var UniqueID = 314 //for PlayAudio function
var newWinOffset=0 //for PlayAudio function

function doSearch()
{
    //window.location = imagePath+"search/search.asp?SearchField="+escape(document.getElementById('searchField').value);
	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.location = document.getElementById('groupscombo').value;
}

function gotoLink4(theForm)
{
    window.location = document.getElementById('cmecombo').value;
}

function gotoLink3(theForm)
{
    window.location = 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;
            //alert(inURL);
            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 xmakeBlueBar()
{
   // 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 + 'rightMiddleDarkBlue.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 + 'rightBottomDarkBlue.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('#BEDFDB', '#13859e', '#59a9bb', '#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('/smdc/','/');
   var pathArray = currPath.split('/');

   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="30%" align="left"><a href="'+iPath+'webprivacy/webprivacy.htm">Privacy Statement</a>&nbsp;|&nbsp;<a href="'+iPath+'termsofusage/termsofusage.htm">Terms of Usage</a>&nbsp;|&nbsp;<a href="https://webmail.smdc.org" target="_blank">OWA</a></td><td width="70%" align="right">400 East 3rd Street, Duluth, MN 55805 &bull; 218&ndash;786&ndash;8364</td></tr></table>';

   if (document.getElementById("footer"))	document.getElementById('footer').innerHTML=footerHTML;
   
   var zn=document.getElementById('navItems');

/*   zn.innerHTML='<table width="600" cellspacing="0" cellpadding="0" border="0" align="right"><tr>
   '<td width="120" class="topItems"><a href="'+iPath+'billinginsurance/onlinebilling.htm">'+'Online Bill Payment</a></td>'+
   '<td class="topItems" width="100"><a href="'+iPath+'urgentcare/urgentcare.htm">Urgent Care</a></td>'+
   '<td class="topItems" width="100"><a href="'+iPath+'nurseonline/nurseonline.htm">Nurse Online</a></td>'+
   '<td class="topItems" width="120"><a href="'+iPath+'rxrefills/prescriptionrefills.htm">Pharmacy Refill</td></tr></table><div id="topNavBar"></div>';
*/
   el=document.getElementsByTagName('a');
   for (var ix=0;ix<el.length;ix++)
   {
    if (el[ix].className == 'onlineBillPayment')
        {
        	el[ix].href = iPath+'billinginsurance/onlinebilling.htm';
        	el[ix].target='_blank';
        }
    if (el[ix].className=='urgentCare')
    	{    	
        	el[ix].href = 'http://www.duluthclinic.org/urgentcare/urgentcare.htm';
        	el[ix].target='_blank';
        }
    if (el[ix].className=='nurseOnline')
        {
        el[ix].href = iPath+'nurseonline/nurseonline.htm';
        el[ix].innerHTML = 'Nurse-On-Line';
        }
    if (el[ix].className =='pharmacyRefill')
    	{    		
        	el[ix].href= 'http://www.duluthclinic.org/rxrefills/prescriptionrefills.htm';
        	el[ix].target='_blank';
        }
    }
   el=document.getElementById('header');
   var istr=new String(el.innerHTML);
   istr=istr.replace('/smdc/',iPath);
   el.innerHTML=istr;
    
   imagePath="";
   thisPageName = new String(pathArray[xptr]);
   if (thisPageName == '') { thisPageName = new String('default.htm'); xmlspec='smdc.xml';}
   thisPageName=thisPageName.toLowerCase();
//   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 = '#BEDFDB';

   var lnavLev1 = '#13859e';
   var lnavLev2 = '#59a9bb';
   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 == 'smdc')
   {
      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="/smdc/default.htm">SMDC 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 : 'About Us', url : 'aboutus/mission.htm'},
   {name : 'Our Affiliates', url : 'ouraffiliates/ouraffiliates.htm'},
   {name : 'Patient Resources/Billing', url : 'patientresources/patientresources.htm'},
   {name : 'Employment', url : 'employment/employment.htm'},
   {name : 'Volunteering', url : 'volunteering/volunteering.htm'},
   {name : 'Foundation/Giving', url : 'foundationjoint/jointfoundations.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('/smdc/','/');
   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=' + "'#7cbab5';" +
      '" 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';
   // tabs.linkArray[0] = 'forphysicians.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 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;
      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;
   }
   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));
}

//  ---------------------------------------

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");
   // rgs -- leftObj.style.height = (totalHeight + 20) + 'px';
   leftObj.style.height = (totalHeight + 25) + 'px';
   leftObj = document.getElementById("rightTable");
   // rgs -- if (leftObj) leftObj.style.height = (totalHeight + 20) + 'px';
   if (leftObj) leftObj.style.height = (totalHeight + 25) + 'px';

}

function doLeftNav()
{	
	//set up footer string
	var y;
	var pathDepth = 2;
	
	currPath = new String(window.location.pathname);

//	if (currPath.substr(currPath.length-5)=='smdc/') currPath+='default.htm';
	if (currPath.substr(currPath.length-1)=='/') currPath+='default.htm';
    currPath=currPath.replace('/smdc/','/');
    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='smdc.xml';}
//	populateTopNav();

	var elem=document.getElementById("leftNav");
	lightBlueDiv = makeCornerDiv(16,'#BEDFDB', 220, 64, elem);
	lightBlueDiv.setAttribute('id','leftNavLighterBlue');
	lightBlueDiv.style.left='10px';
	// rgs -- lightBlueDiv.style.top='14px';
	lightBlueDiv.style.top='10px';
		
	var mainAJAXReq = new AJAXRequest(null,xmlhttpChange,xmlName);
	
}

function isChildOf(pageURL,currNode)
{	//alert(currNode.nodeType);
	if(currNode.nodeType==1)
	{
		if (currNode.getAttribute('url').toLowerCase() == pageURL) return(true);
		else
		{
			var pages=currNode.getElementsByTagName('page');
			//alert(pages.length);
			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 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 == 'otherspecialties.htm')
		{
			// let's look at the sitemap...

			// In this case, otherspecialties 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);
			addLightBlueBar('Medical Specialties','otherspecialties.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 = 'Medical Specialties';
			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 = 'SMDC Home';
			}
			else
			{
				var thisText= document.createTextNode('SMDC Home');
				nLink.appendChild(thisText);
			}
			nCell.appendChild(nLink);

			//insert pages as links.
			/*	var pTitle;
			var pLink;
			var nElements;
			pages = root.getElementsByTagName('page');
			nElements = pages.length;

			//turn pages into a list, so we can sort them.
							
			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');
				newLink.setAttribute('href',pLink);
				newLink.innerHTML = pTitle;
				newElem.appendChild(newLink);
				div2add2.appendChild(newElem);
			}
			*/
		}
		else if (currPage == 'specialtycenters.htm')
		{
			// let's look at the sitemap...

			// In this case, otherspecialties 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);
			addLightBlueBar('Specialty Centers','specialtycenters.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 Centers';
			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 = 'SMDC Home';
			}
			else
			{
				var thisText= document.createTextNode('SMDC Home');
				nLink.appendChild(thisText);
			}
			nCell.appendChild(nLink);
			
			//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');

				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');
				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.
			var headline = document.getElementById("subHead");
			headline.innerHTML = currNode.getAttribute('parent');
			var parentName = currNode.getAttribute('parent');
			headline = document.getElementById("mainHeadline");
        	var siteLoc = currNode.getAttribute('site');
			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 == 'Medical Specialties')
				{

					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++) + 'otherSpecialties.htm');
					if(window.ActiveXObject)
					{
						nLink.innerText = 'Medical Specialties';
					}
					else
					{
						var thisText= document.createTextNode('Medical Specialties');
						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 Centers')
				{

					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++) + 'specialtycenters.htm');
					if(window.ActiveXObject)
					{
						nLink.innerText = 'Specialty Centers';
					}
					else
					{
						var thisText= document.createTextNode('Specialty Centers');
						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 = 'SMDC Home';
				}
				else
				{
					var thisText= document.createTextNode('SMDC Home');
					nLink.appendChild(thisText);
				}
				nCell.appendChild(nLink);
			}
        }
		else
   		{
      		var lnav=document.getElementById('leftNav');
    		lnav.style.height='435px';
        	currNode=currNode.parentNode;
/*      var babiesImg = document.createElement('img');
      babiesImg.src = 'babiesonline.jpg';
      babiesImg.style.position = 'absolute';
      babiesImg.style.top = '400px';
      babiesImg.style.left = '60px';
      babiesImg.style.width = '114px';
      babiesImg.style.height = '60px';

      document.getElementById('leftNav').appendChild(babiesImg);

      		doCenterRect();*/

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 nwindow;
		
		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'));
				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();
				newdivFlag = currNode.childNodes[p].getAttribute('ndiv');
				newdivFlag = (newdivFlag =='true'?true:false);
				if ((newdivFlag) && (displayFlag))
				{
					var elem2=document.getElementById("leftNav");
					lightBlueDiv = makeCornerDiv(16,'#BEDFDB', 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);
					else
						currBar = addLightBlueBar(currTitle, origURL, nwindow);
					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);
							addLevel3(currBar,currNode.childNodes[p].childNodes,currPage);
						}
					}
				}
				else
				{
					if (displayFlag && (!expandedFlag)) 
					{
						//rgs - 2/26/2009 - add cod eto insert SMDC MyHealth NavBar
						//alert("currTitle: " + currTitle +"; origURL: " + origURL);
						if (currTitle == "Access SMDC MyHealth")
						{
						   addPurpleBar(currTitle, origURL, nwindow);
						}
						else if (currTitle == "Find a Physician/Provider")
						{
						   addRoyalBlueBar(currTitle, origURL, nwindow);
						}
						else
						{
						   addBlueBar(currTitle, origURL, nwindow);
						}
					}
				}
			}
		}
	}
}


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/smallDownArrowLighterBlue.gif');
			break;
		}
	}
}

function addLevel3(barDiv, nodeList, pageURL)
{	
	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,nwindow;
	var nRow2, nCell2,nBr;
	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 royalbluebar;

		if (barDiv.className == 'bluebar')
		{
			royalbluebar=addSubMenuDark(barDiv);
		}
		else
			royalbluebar = addSubMenu(barDiv);
		var textSpot = getTextElement(royalbluebar);
		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;															
				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(royalbluebar,currLines*16+10);
					if (barDiv.className == 'bluebar')
						royalbluebar = addSubMenuDark(barDiv);
					else
						royalbluebar = addSubMenu(barDiv);

					royalbluebar.style.top = (currLines*16)+42+'px';
					oldHeight=(currLines*16)+20;
					textSpot = getTextElement(royalbluebar);
					if (barDiv.className == 'bluebar')
						textSpot.className='subNavDarkBlueText';
					else
						textSpot.className='subNavLightBlueText';
					addExpandBlueBar(barDiv,16);
					//grab barDiv height and subtract 10.   adjustHeight(royalbluebar,26);
					var bluebarheight = getPixelProperty(barDiv,'height');
					adjustHeight(royalbluebar, (bluebarheight-10)-oldHeight);
				}
					
				nCell = document.createElement('span');
				nCell.style.height='9px';
					
				if (isChildOf(pageURL,nodeList[idx]))
				{
					if ((currURL.toLowerCase() == pageURL) || (hr == 'true'))
					{
						if (hr=='true') nLink=document.createElement('hr');
						else
						{
							nLink = document.createElement('span');
							nLink.style.fontWeight = 'bold';
							if(window.ActiveXObject)
							{
								nLink.innerText = currTitle;
							}
							else
							{
								var thisText= document.createTextNode(currTitle);
								nLink.appendChild(thisText);
							}
							nLink.style.color='#004477';
						}
					}
					else
					{
						nLink=document.createElement('a');
						currURL = currURL.toString();
						nLink.setAttribute('href',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);
						}
					}
					if (displayFlag)
					{
						nCell.appendChild(nLink);
					}
					if (nodeList[idx].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);
						adjustHeight (royalbluebar,getPixelProperty(barDiv,'height')-(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();
									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();
											nLink.setAttribute('href',currURL);
											nLink.style.paddingLeft='15px';
											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
										{
											nLink = document.createElement('span');
											nLink.style.fontWeight='bold';
											nLink.style.paddingLeft='15px';
											nLink.style.color='#004477';
											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();
							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);
							}
						}
						nCell.appendChild(nLink);
					}
				}
				if (displayFlag)
				{	
					if (hr != 'true')
					{	
						nBr=document.createElement('br');
						nCell.appendChild(nBr);
						currLines++;
					}
					textSpot.appendChild(nCell);
				}
			}
		}
	}
}

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';
			}
		}
	}
}

function addPurpleBar(nameOf, URL, nwindow)
{
	var elem;
	var purplebarElem=makeDivClass('purplebar');
	//var rightArrowImage = document.createElement("img");
	//rightArrowImage.setAttribute('src',imagePath+'images/rightArrowPurple.gif');
	//rightArrowImage.className = 'arrow';
	//purplebarElem.appendChild(rightArrowImage);
	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';
	
	//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');
	elem.style.top='12px';
	purplebarElem.appendChild(elem);
	elem = makeDivClass('textArea');
	elem2= document.createElement("a");
	URL = URL.toString();
	elem2.setAttribute('href',URL);
	if (nwindow) { elem2.setAttribute('target','_blank'); elem2.setAttribute('rel','external');}
	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);
	}
	else
	{
		purplebarElem.addEventListener('mouseover',highlightBar,false);
		purplebarElem.addEventListener('mouseout',unHighlightBar,false);
	}
	lightBlueDiv.appendChild(purplebarElem);
	currHeight+=29;
	totalHeight+=29;
	adjustHeight(lightBlueDiv,currHeight+6);
	return(purplebarElem);
}


function addRoyalBlueBar(nameOf, URL, nwindow)
{
	var elem;
	var royalbluebarElem=makeDivClass('royalbluebar');
	royalbluebarElem.appendChild(makeDivClass('topCorner'));
	royalbluebarElem.appendChild(makeDivClass('topRight'));
	
	
	elem = makeDivClass('middleExpand');
	elem.style.height='1px';
	var elem2=document.createElement("img");
	elem2.style.height='1px';
	elem2.setAttribute('src',imagePath + 'images/royalBlueBarMiddleLeft12by1.gif');
	elem.appendChild(elem2);
	royalbluebarElem.appendChild(elem);
	elem = makeDivClass('bottomCorner');
	elem.style.top='13px';
	royalbluebarElem.appendChild(elem);
	elem=makeDivClass('bottomRight');
	elem.style.top='12px';
	royalbluebarElem.appendChild(elem);
	elem = makeDivClass('textArea');
	elem2= document.createElement("a");
	URL = URL.toString();
	elem2.setAttribute('href',URL);
	if (nwindow) { elem2.setAttribute('target','_blank'); elem2.setAttribute('rel','external');}
	elem2.innerHTML = nameOf;
	elem.appendChild(elem2);
	royalbluebarElem.appendChild(elem);
	royalbluebarElem.style.top = currHeight + 'px';
	// rgs js error in Firefox - Mozilla
	if (window.ActiveXObject)
	{
		royalbluebarElem.attachEvent ('onmouseover', highlightBar);
		royalbluebarElem.attachEvent ('onmouseout', unHighlightBar);
	}
	else
	{
		royalbluebarElem.addEventListener('mouseover',highlightBar,false);
		royalbluebarElem.addEventListener('mouseout',unHighlightBar,false);
	}
	lightBlueDiv.appendChild(royalbluebarElem);
	currHeight+=29;
	totalHeight+=29;
	adjustHeight(lightBlueDiv,currHeight+6);
	return(royalbluebarElem);
}





function addBlueBar(nameOf, URL, nwindow)
{

	var elem;
	var bluebarElem=makeDivClass('bluebar');
	//var rightArrowImage = document.createElement("img");
	//rightArrowImage.setAttribute('src',imagePath+'images/rightArrowDarkBlue.gif');
	//rightArrowImage.className = 'arrow';
	//bluebarElem.appendChild(rightArrowImage);
	bluebarElem.appendChild(makeDivClass('topCorner'));
	bluebarElem.appendChild(makeDivClass('topRight'));
	elem = makeDivClass('middleExpand');
	elem.style.height='1px';
	var elem2=document.createElement("img");
	elem2.style.height='1px';
	elem2.setAttribute('src',imagePath + 'images/middleLeftDarkBlue.png');
	elem.appendChild(elem2);
	bluebarElem.appendChild(elem);
	elem = makeDivClass('bottomCorner');
	elem.style.top='13px';
	bluebarElem.appendChild(elem);
	elem=makeDivClass('bottomRight');
	elem.style.top='12px';
	bluebarElem.appendChild(elem);
	elem = makeDivClass('textArea');
	elem2= document.createElement("a");
	URL = URL.toString();
	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
	{
		bluebarElem.addEventListener('mouseover',highlightBar,false);
		bluebarElem.addEventListener('mouseout',unHighlightBar,false);
	}
	lightBlueDiv.appendChild(bluebarElem);
	currHeight+=29;
	totalHeight+=29;
	adjustHeight(lightBlueDiv,currHeight+6);
	return(bluebarElem);
}

function addLightBlueBar(nameOf, URL, nwindow)
{
	var elem;
	var bluebarElem=makeDivClass('lightBluebar');
	bluebarElem.style.height='25px';
	var rightArrowImage = document.createElement("img");
	rightArrowImage.setAttribute('src',imagePath +'Images/smallRightArrowLighterBlue.gif');
	rightArrowImage.className = 'arrow';
	bluebarElem.appendChild(rightArrowImage);
	bluebarElem.appendChild(makeDivClass('topCorner'));
	bluebarElem.appendChild(makeDivClass('topRight'));
	elem = makeDivClass('middleExpand');
	elem.style.height='1px';
	var elem2=document.createElement("img");
	elem2.style.height='1px';
	elem2.setAttribute('src',imagePath + 'Images/lightBlueBarMiddle.gif');
	elem.appendChild(elem2);
	bluebarElem.appendChild(elem);
	elem = makeDivClass('bottomCorner');
	elem.style.top = '13px';
	bluebarElem.appendChild(elem);
	elem = makeDivClass('bottomRight');
	elem.style.top = '13px';
	bluebarElem.appendChild(elem);
	elem = makeDivClass('textArea');
	elem2= document.createElement("a");
	URL = URL.toString();
	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);
	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 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 newHeight = getPixelProperty(parentElem, 'height');
	if (newHeight & 1) newHeight++;
	newHeight-=10;
	var newMenu = makeCornerDiv(12, '#AAD9E3', 200, newHeight, parentElem);
	newMenu.style.right='0px';
	newMenu.style.top='22px';
	return(newMenu);
}

function addSubMenuDark(parentElem)
{
	var newHeight = getPixelProperty(parentElem,'height');
	if (newHeight & 1) newHeight++;

	newHeight-=10;
	var newMenu = makeCornerDiv(12, '#59a9bb', 200, newHeight, parentElem);
	newMenu.style.right='0px';
	newMenu.style.top='22px';
	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);
}




function PlayAudio(soundfiledesc,soundfilepath) 
{ 
PlayWin = window.open('',UniqueID,'width=320,height=190,top=' + newWinOffset +',left=0,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
PlayWin.focus(); 

var winContent = "<HTML><HEAD><TITLE>" + soundfiledesc + "</TITLE></HEAD><BODY bgcolor='#BDD5AE'>"; 
winContent += "<B style='font-size:13px;font-family:Arial, Helvetica, sans-serif;line-height:1.5;color:black;font-weight:bold'>" + soundfiledesc + "</B>";

winContent += "<OBJECT width='325' height='42'>"; 
winContent += "<param name='SRC' value='" + soundfilepath + "'>";
winContent += "<param name='AUTOPLAY' VALUE='true'>"; 
winContent += "<param name='CONTROLLER' VALUE='true'>";
winContent += "<param name='BGCOLOR' VALUE='#BDD5AE'>"; 
winContent += "<EMBED SRC='" + soundfilepath + "' AUTOSTART='TRUE' LOOP='FALSE' WIDTH='300' HEIGHT='42' CONTROLLER='TRUE' BGCOLOR='#BDD5AE'></EMBED>";
winContent += "</OBJECT>"; 


winContent += "<FORM><DIV align='center'><INPUT type='button' value='Close this window' onclick='javascript:window.close();'></DIV></FORM>"; 
winContent += "</BODY></HTML>";

PlayWin.document.write(winContent); 
PlayWin.document.close(); // "Finalizes" new window 
UniqueID = UniqueID + 1 // newWinOffset = newWinOffset + 20 // subsequent pop-ups will be this many pixels lower 
} 
