// JavaScript Document

var tabs;
var pictures;
var numberOfPictures;
var currPicture = 0;
var cycleTimer;
var qtimer;
var fadeOutPicture;
var fadeInPicture;
var opacity;
var currHeight = 10;
var nMenuItems = 0;
var XMLHeaderB64="PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/PiAg";

// base64 conversion class for Javascript.  Very fast!
// August 7, 2006 by Tony Kaiser


  var base64 = (function () 
        {
        
            var b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

            function encode(instring)
            {
            //get length of string.
            	var x;
            	var iWord;
            	var r=(instring.length % 3);
            	var oStr="";
            	var y;
            	
            	var fourStr;
            	while (r>=0) {instring += " "; r--;}
            
            	for (x=0;x<instring.length-2;x+=3)
            	{
            		iWord=instring.charCodeAt(x) << 8;
            		iWord=(instring.charCodeAt(x+1) | iWord) << 8;
            		iWord = iWord | instring.charCodeAt(x+2);
            	
            		fourStr="";
            		for (y=0;y<4;y++)
            		{
            			fourStr = b64.charAt(iWord & 63) + fourStr;
            			iWord = iWord >> 6;
            		}
            		oStr +=fourStr;
            	}
            
            	return (oStr);
            }

            function decode (instream)
            {
            	var x,y;
            	var iWord;
            	var oStream="";
            	var os3;
            	for (x=0;x<instream.length-3;x+=4)
            	{
            		iWord=0;
            		for (y=x;y<x+4;y++)				
            		{
            			iWord = (iWord<<6) | b64.indexOf(instream.charAt(y));
            		}
            		os3="";
            		for (y=0;y<3;y++)
            		{
            			os3 = String.fromCharCode(iWord & 255) + os3;
            			iWord = iWord >> 8;
            		}
            		oStream += os3;
            	}
            	return (oStream);
            }
            
            return {'encode':encode, 'decode':decode};
        })();
        
        

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].getAttribute('name') == 'textArea')
		{
			outputElem = nodes[idx];
			break;
		}
	}

	return (outputElem);
}

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 adjustHeight (elem, newHeight)
{
	var nodes = elem.childNodes;
	var idx;
	var leftSpaceNode = 0;
	var rightAreaNode = 0;
	var textNode = 0;
	var cHeight = getPixelProperty(elem, 'height');

	if (newHeight & 1)
		newHeight++;

	elem.style.height = newHeight + 'px';

	for (idx = 0; idx < nodes.length; idx++)
	{
		if (nodes[idx].getAttribute('name') == 'leftSpace')
			leftSpaceNode = nodes[idx];

		if (nodes[idx].getAttribute('name') == 'rightArea')
			rightAreaNode = nodes[idx];

		if (nodes[idx].getAttribute('name') == 'textArea')
			textNode = nodes[idx];
	}

	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';
}

// encapsulates all the functionality of ajax in a single function.


function logTransaction()
{
 //    alert (arguments.length);
}

function AJAXRequest(sendData, 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()
      {
         if (xhrq.readyState == readyStates.complete)

            if (xhrq.status == statusCodes.OK)
               rFunc(xhrq.responseXML, xhrq.responseText);
            else
               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();
            }
            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);
}

//  ---------------------------------------

function init ()
{
	doLeftNavHomePage();
}

function doLeftNavHomePage ()
{	
	var elem = document.getElementById("leftNav");
	var elem2;
	lightBlueDiv = makeCornerDiv(16, '#d9e9f2', 176, 64, elem);
	//	lightBlueDiv.setAttribute('id','leftNavLighterBlue');
	lightBlueDiv.style.left = '5px';
	lightBlueDiv.style.top = '14px';

	//addPurpleBar('Duluth Clinic', 'http://www.duluthclinic.org');
	addRoyalBlueBar('SMDC Employment', 'employment.htm');
	addRoyalBlueBar('About the Region', 'aboutregion.htm');
	addRoyalBlueBar('Benefits', 'benefits.htm');
	addRoyalBlueBar('Diversity', 'diversity.htm');
	addRoyalBlueBar('Contact Us', 'contactus.asp');

	blueDiv = makeCornerDiv(16, '#b3d8ea', 176, 64, elem);
	//blueDiv.setAttribute('id', 'leftNavLighterBlue');
	blueDiv.style.left = '5px';
	blueDiv.style.top = '190px';
	currHeight = 10;
	lightBlueDiv = blueDiv;
	elem2 = addBlueBar('Physician/Providers', 'http://www.duluthclinic.org/career');
	elem2.style.height = '25px';
	//expandBlueBar(elem2, 64);
}

var rightArrowImage = 0;
var bluebarElem = 0;

function makeDivClass (classNameOf)
{
	var newElem = document.createElement("div");
	newElem.className = classNameOf;
	return (newElem);
}

function addBlueBar (nameOf, URL)
{
	var elem;
	var bluebarElem = makeDivClass('bluebar');
	var rightArrowImage = document.createElement("img");
	rightArrowImage.setAttribute('src', 'images/smallRightArrow.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', 'images/blueBarMiddle12by1.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");
	elem2.setAttribute('href', URL);
	elem2.setAttribute('target', '_parent');
	elem2.innerHTML = nameOf;
	elem.appendChild(elem2);
	bluebarElem.appendChild(elem);
	bluebarElem.style.top = currHeight + 'px';
	//bluebarElem.attachEvent('onmouseover', highlightBar);
	//bluebarElem.attachEvent('onmouseout', unHighlightBar);
	lightBlueDiv.appendChild(bluebarElem);
	currHeight += 29;
	adjustHeight(lightBlueDiv, currHeight + 5);
	return (bluebarElem);
}

function addPurpleBar (nameOf, URL)
{
	var divs = new Array('topCorner', 'bottomCorner', 'rightArea');
	var idn;

	var purple = makeDivClass('purplebar');

	for (idn = 0; idn < 3; idn++)
	{
		purple.appendChild(makeDivClass(divs[idn]));
	}

	var newImg = document.createElement('img');
	newImg.setAttribute('src', 'images/purpleMiddleLeft12by1.gif');
	newImg.style.position = 'absolute';
	newImg.style.left = '0px';
	newImg.style.top = '12px';
	newImg.style.height = '1px';
	newImg.style.zIndex = 3;

	purple.appendChild(newImg);
	var circleDiv = document.createElement('div');
	circleDiv.style.position = 'absolute';
	circleDiv.style.left = '9px';
	circleDiv.style.top = '5px';
	circleDiv.style.width = '13px';
	circleDiv.style.height = '13px';
	circleDiv.style.overflow = 'hidden';
	circleDiv.setAttribute('name', 'circleDiv');
	circleDiv.style.zIndex = 4;

	newImg = document.createElement('img');
	newImg.setAttribute('src', 'images/yellowCircleOnPurple13by13.gif');
	newImg.style.position = 'absolute';
	newImg.style.left = '0px';
	newImg.style.top = '0px';
	newImg.style.zIndex = 4;
	circleDiv.appendChild(newImg);

	newImg = document.createElement('img');
	newImg.setAttribute('src', 'images/rightArrowForYellowCircle.gif');
	newImg.style.position = 'absolute';
	newImg.style.left = '4px';
	newImg.style.top = '3px';
	newImg.style.zIndex = 6;
	circleDiv.appendChild(newImg);

	var hl = document.createElement('div');
	hl.style.position = 'absolute';
	hl.style.width = '3px';
	hl.style.height = '5px';

	hl.style.left = '5px';
	hl.style.top = '4px';
	hl.style.zIndex = 5;
	hl.style.overflow = 'hidden';
	hl.style.backgroundColor = '#216b9e';
	hl.setAttribute('name', 'arrowLeft');
	circleDiv.appendChild(hl);

	hl = document.createElement('div');
	hl.style.position = 'absolute';
	hl.style.width = '1px';
	hl.style.height = '1px';
	hl.style.left = '8px';
	hl.style.top = '6px';
	hl.style.zIndex = 5;
	hl.style.overflow = 'hidden';
	hl.setAttribute('name', 'arrowRight');
	hl.style.backgroundColor = '#216b9e';
	circleDiv.appendChild(hl);

	purple.appendChild(circleDiv);

	var textA = makeDivClass('purplebarLink');

	var newLink = document.createElement('a');
	newLink.setAttribute('href', URL);
	newLink.innerHTML = nameOf;

	textA.appendChild(newLink);

	purple.appendChild(textA);
	purple.style.height = '25px';
	purple.style.top = currHeight + 'px';
	
	if (window.ActiveXObject)
	{
		purple.attachEvent ('onmouseover', highlightTopBar);
		purple.attachEvent ('onmouseout', unHighlightTopBar);
	}
	else
	{
		purple.addEventListener('mouseover',highlightTopBar,false);
		purple.addEventListener('mouseout',unHighlightTopBar,false);
	}

	lightBlueDiv.appendChild(purple);
	currHeight += 29;
	adjustHeight(lightBlueDiv, currHeight + 6);
	return (purple);
}

function addRoyalBlueBar (nameOf, URL)
{
	var divs = new Array('topCorner', 'bottomCorner', 'rightArea');
	var idn;

	var royalbluebar = makeDivClass('royalbluebar');

	for (idn = 0; idn < 3; idn++)
	{
		royalbluebar.appendChild(makeDivClass(divs[idn]));
	}

	var newImg = document.createElement('img');
	newImg.setAttribute('src', 'images/royalBlueBarMiddleLeft12by1.gif');
	newImg.style.position = 'absolute';
	newImg.style.left = '0px';
	newImg.style.top = '12px';
	newImg.style.height = '1px';
	newImg.style.zIndex = 3;

	royalbluebar.appendChild(newImg);

	var circleDiv = document.createElement('div');
	circleDiv.style.position = 'absolute';
	circleDiv.style.left = '9px';
	circleDiv.style.top = '5px';
	circleDiv.setAttribute('name', 'circleDiv');
	circleDiv.style.width = '13px';
	circleDiv.style.height = '13px';
	circleDiv.style.overflow = 'hidden';
	circleDiv.style.zIndex = 4;

	newImg = document.createElement('img');
	newImg.setAttribute('src', 'images/yellowCircleOnBlueTop13by13.gif');
	newImg.style.position = 'absolute';
	newImg.style.left = '0px';
	newImg.style.top = '0px';
	newImg.style.zIndex = 4;
	circleDiv.appendChild(newImg);

	newImg = document.createElement('img');
	newImg.setAttribute('src', 'images/rightArrowForYellowCircle.gif');
	newImg.style.position = 'absolute';
	newImg.style.left = '4px';
	newImg.style.top = '3px';
	newImg.style.zIndex = 6;
	circleDiv.appendChild(newImg);

	var hl = document.createElement('div');
	hl.style.position = 'absolute';
	hl.style.width = '3px';
	hl.style.height = '5px';

	hl.style.left = '5px';
	hl.style.top = '4px';
	hl.style.zIndex = 5;
	hl.style.overflow = 'hidden';
	hl.setAttribute('name', 'arrowLeft');
	hl.style.backgroundColor = '#216b9e';
	circleDiv.appendChild(hl);

	hl = document.createElement('div');
	hl.style.position = 'absolute';
	hl.style.width = '1px';
	hl.style.height = '1px';
	hl.style.left = '8px';
	hl.style.top = '6px';
	hl.style.zIndex = 5;
	hl.setAttribute('name', 'arrowRight');
	hl.style.overflow = 'hidden';
	hl.style.backgroundColor = '#216b9e';
	circleDiv.appendChild(hl);

	royalbluebar.appendChild(circleDiv);
	
	var textA = makeDivClass('textAreaLink');

	var newLink = document.createElement('a');
	newLink.setAttribute('href', URL);
	newLink.setAttribute('target', '_parent');
	newLink.innerHTML = nameOf;

	textA.appendChild(newLink);

	royalbluebar.appendChild(textA);
	royalbluebar.style.height = '25px';
	royalbluebar.style.top = currHeight + 'px';
	
	if (window.ActiveXObject)
	{
		royalbluebar.attachEvent ('onmouseover', highlightTopBar);
		royalbluebar.attachEvent ('onmouseout', unHighlightTopBar);
	}
	else
	{
		royalbluebar.addEventListener('mouseover',highlightTopBar,false);
		royalbluebar.addEventListener('mouseout',unHighlightTopBar,false);
	}

	lightBlueDiv.appendChild(royalbluebar);
	currHeight += 29;
	adjustHeight(lightBlueDiv, currHeight + 5);
	return (royalbluebar);
}

function isChildOf (pageURL, currNode)
{
	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);
	}
}

var depth = 0;

function xmlhttpChange ()
{
	var y;
	var root;
	var pages;
	var ourPage;
	var currBar;
	var currNode;
	var currPath;
	var pathParts;
	var currPage;

	if (xmlhttp.readyState == 4)
	{
		if (xmlhttp.status == 200)
		{
			currPath = new String(window.location.pathname);
			pathParts = currPath.split('/');
			currPage = pathParts[pathParts.length - 1];
			currPage = currPage.toLowerCase();

			root = xmlhttp.responseXML.documentElement;
			pages = root.getElementsByTagName('page');

			for (y = 0; y < pages.length; y++)
			{
				if (pages[y].getAttribute('url').toLowerCase() == currPage)
				{
					alert('XML Site Map loaded ok, this page title:' + pages[y].getAttribute('title'));
					ourPage = pages[y];
					break;
				}
			}

			currNode = ourPage;

			while (currNode.parentNode)
			{
				currNode = currNode.parentNode;
				depth++;
			}

			currNode = currNode.childNodes[1];
			var currTitle;
			var currURL;
			var p;

			for (p = 0; p < currNode.childNodes.length; p++)
			{
				currTitle = new String(currNode.childNodes[p].getAttribute('title'));
				currURL = new String(currNode.childNodes[p].getAttribute('url'));
				currURL = currURL.toLowerCase();

				if (isChildOf(currPage, currNode.childNodes[p]))
				{
					currBar = addLightBlueBar(currTitle, '');

					if ((currNode.childNodes[p].hasChildNodes()) && depth >= 3)
						addLevel3(currBar, currNode.childNodes[p].childNodes, currPage);
				}
				else
					addBlueBar(currTitle, '');
			}
		}
	}
}

function addLevel3 (barDiv, nodeList, pageURL)
{
	var lines = nodeList.length;
	var newHTML = new String();
	var newHeight = (lines * 16);

	expandBlueBar(barDiv, newHeight);

	var newNav = addSubMenu(barDiv);

	var textSpot = getTextElement(newNav);
	textSpot.className = 'subNavLightBlueText';
	var idx, currTitle, currURL;

	var nRow, nCell, nLink;
	var newNode, idy;
	var nodeList2;
	var nRow2, nCell2, nBr;

	for (idx = 0; idx < nodeList.length; idx++)
	{
		currTitle = nodeList[idx].getAttribute('title');
		currURL = nodeList[idx].getAttribute('url');

		nCell = document.createElement('span');
		nCell.style.height = '9px';

		if (isChildOf(pageURL, nodeList[idx]))
		{
			nLink = document.createElement('a');
			nLink.setAttribute('href', currURL);
			nLink.innerText = currTitle;
			nCell.appendChild(nLink);

			//NOW, we have to add it's children (if any)
			if (nodeList[idx].hasChildNodes())
			{
				nodeList2 = nodeList[idx].childNodes;
				newHeight += (nodeList2.length * 16);

				addExpandBlueBar(barDiv, nodeList2.length * 16);
				adjustHeight(newNav, getPixelProperty(barDiv, 'height') - 10);

				for (idy = 0; idy < nodeList2.length; idy++)
				{
					currTitle = nodeList2[idy].getAttribute('title');
					currURL = nodeList2[idy].getAttribute('url').toLowerCase();
					nRow2 = document.createElement('br');
					nCell.appendChild(nRow2);

					if (currURL != pageURL)
					{
						nLink = document.createElement('a');
						nLink.setAttribute('href', currURL);
						nLink.style.paddingLeft = '10px';
						nLink.innerHTML = currTitle;
					}
					else
					{
						nLink = document.createElement('span');
						nLink.style.fontWeight = 'bold';
						nLink.style.paddingLeft = '10px';
						nLink.style.color = '#004477';
						nLink.innerHTML = '&bull;&nbsp;' + currTitle;
					}

					nCell.appendChild(nLink);
				}
			}
		}
		else
		{
			nLink = document.createElement('a');
			nLink.setAttribute('href', currURL);
			nLink.innerText = currTitle;
			nCell.appendChild(nLink);
		}

		nBr = document.createElement('br');
		nCell.appendChild(nBr);
		textSpot.appendChild(nCell);
	}
}

function addLightBlueBar (nameOf, URL)
{
	var elem;
	var bluebarElem = makeDivClass('lightBluebar');
	bluebarElem.style.height = '25px';
	var rightArrowImage = document.createElement("img");
	rightArrowImage.setAttribute('src', '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', 'images/lightBlueBarMiddle12by1.gif');

	elem.appendChild(elem2);
	bluebarElem.appendChild(elem);

	elem = makeDivClass('bottomCorner');
	elem.style.top = '13 px';
	bluebarElem.appendChild(elem);

	elem = makeDivClass('bottomRight');
	elem.style.top = '13 px';

	bluebarElem.appendChild(elem);
	elem = makeDivClass('textArea');
	elem.innerHTML = nameOf;
	bluebarElem.appendChild(elem);
	bluebarElem.style.top = currHeight + 'px';
	lightBlueDiv.appendChild(bluebarElem);
	currHeight += 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].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;
		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].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;
		adjustHeight(lightBlueDiv, currHeight);
	}
}


function highlightTopBar (eventObj)
{
	var source;
	 if (window.ActiveXObject)
	 {
		source = eventObj.srcElement;
	 }
	 else
	 {
		source = eventObj.target;
	 }
	var nDepth = 0;

	while ((source.className != 'purplebar') && (source.className != 'royalbluebar'))
	{
		source = source.parentNode;
		nDepth++;
	}

	if (nDepth < 3)
	{
		var cNode;
		var nodes = source.childNodes;
		//	if (source.className == 'purplebar')
		//	nodes[5].className = 'purplebarLink';

		cNode = nodes[4].childNodes[2];
		cNode.style.backgroundColor = '#95c2da';
		nodes[4].childNodes[3].style.backgroundColor = '#95c2da';
		nodes[5].style.color = '#c7e9f5';
	}
}

function unHighlightTopBar (eventObj)
{
	var source;
	 if (window.ActiveXObject)
	 {
		source = eventObj.srcElement;
	 }
	 else
	 {
		source = eventObj.target;
	 }
	 
	var nDepth = 0;

	while ((source.className != 'purplebar') && (source.className != 'royalbluebar'))
	{
		source = source.parentNode;
		nDepth++;
	}

	if (nDepth < 3)
	{
		var cNode;
		var nodes = source.childNodes;
		cNode = nodes[4].childNodes[2];
		cNode.style.backgroundColor = '#216b9e';
		nodes[4].childNodes[3].style.backgroundColor = '#216b9e';
		nodes[5].style.color = '#ffffff';
	}
}

function addSubMenu (parentElem)
{
	var newHeight = getPixelProperty(parentElem, 'height');

	if (newHeight & 1)
		newHeight++;

	newHeight -= 10;
	var newMenu = makeCornerDiv(12, '#a6dce7', 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, '#6397bb', 200, newHeight, parentElem);
	newMenu.style.right = '0px';
	newMenu.style.top = '22px';
	return (newMenu);
}

function highlightBar (eventObj)
{
	var source = eventObj.srcElement;
	var nDepth = 0;

	while ((source.className != 'bluebar') && (source.className != 'lightBluebar'))
	{
		source = source.parentNode;
		nDepth++;
	}

	if (nDepth < 3)
	{
		var nodes = source.childNodes;
		var idx;

		for (idx = 0; idx < nodes.length; idx++)
		{
			if (nodes[idx].className == 'arrow')
				nodes[idx].className = 'arrowHighlight';

			if (nodes[idx].className == 'textArea')
				nodes[idx].className = 'textAreaHighlight';
		}
	}
}

function unHighlightBar (eventObj)
{
	var source = eventObj.srcElement;

	while ((source.className != 'bluebar') && (source.className != 'lightBluebar'))
		 source = source.parentNode;

	var nodes = source.childNodes;
	var idx;

	for (idx = 0; idx < nodes.length; idx++)
	{
		if (nodes[idx].className == 'arrowHighlight')
			nodes[idx].className = 'arrow';

		if (nodes[idx].className == 'textAreaHighlight')
			nodes[idx].className = 'textArea';
	}
}
