//hack for CSS dropmenus in IE5x

var keyword="";
var keyword2="";

function iehack(navRoot) {
  for (i=0; i<navRoot.childNodes.length; i++) {
    node = navRoot.childNodes[i];
    if (node.nodeName=="LI") {
      node.onmouseover=function() {
        this.className+="over";
      }
      node.onmouseout=function() {
        this.className=this.className.replace("over", "");
      }
    }
  }
}

//highlighter
function highlightWord(node,word) {
        // Iterate into this nodes childNodes
        if (node.hasChildNodes) {
                var hi_cn;
                for (hi_cn=0;node.childNodes.length>hi_cn;hi_cn++) {
                        highlightWord(node.childNodes[hi_cn],word);
                }
        }

        // And do this node itself
        if (node.nodeType == 3) { // text node
                tempNodeVal = node.nodeValue.toLowerCase();
                tempWordVal = word.toLowerCase();
                if (tempNodeVal.indexOf(tempWordVal) != -1) {
                        pn = node.parentNode;
                        if (pn.className != "searchword") {
                                // word has not already been highlighted!
                                nv = node.nodeValue;
                                ni = tempNodeVal.indexOf(tempWordVal);
                                // Create a load of replacement nodes
                                before = document.createTextNode(nv.substr(0,ni));
                                docWordVal = nv.substr(ni,word.length);
                                after = document.createTextNode(nv.substr(ni+word.length));
                                hiwordtext = document.createTextNode(docWordVal);
                                hiword = document.createElement("span");
                                hiword.className = "searchword";
                                hiword.appendChild(hiwordtext);
                                pn.insertBefore(before,node);
                                pn.insertBefore(hiword,node);
                                pn.insertBefore(after,node);
                                pn.removeChild(node);
                        }
                }
        }
}

function highlightSearchTerms() {
  if (!document.createElement) return;
  if (document.getElementById("results")) {
    if (keyword.length > 0) {highlightWord(document.getElementById("results"),keyword); }
    if (keyword2.length > 0) {highlightWord(document.getElementById("results"),keyword2); }
  }

}

startList = function() {
  if (document.all&&document.getElementById) {
    navRoot = document.getElementById("navmenu");
    iehack(navRoot);

    if (document.getElementById("docnav")) {
      navRoot = document.getElementById("docmenu");
      iehack(navRoot);
    }
 
    if (document.getElementById("menu1")) {
      count=1;
      while (document.getElementById("menu"+count)) {
        navRoot = document.getElementById("menu"+count);
        iehack(navRoot);
        count++;
      }
    }
  }
  //added for search highlights where available
  highlightSearchTerms();
}

window.onload=startList; 


//styleswitcher

function getCSS(a) { 
  var i=0,j=0,e=0,theSheet="";
  a=a+"=",t="<",u="link";
  var alen=a.length,clen=document.cookie.length;
  while (i < clen) {
   j=i+alen;
   if(document.cookie.substring(i,j)==a) {
     e = document.cookie.indexOf(";",j);
     if (e==-1) {e=clen}
     theSheet = unescape(document.cookie.substring(j,e));
     document.write(t+u+' rel="stylesheet" type="text/css" href="' + theSheet + '">');
     break;}
   else {i=document.cookie.indexOf(" ",i)+1;
     if (i==0) break; } }
}
getCSS('UVaLibCSS');

function setCSS(d, theStyle) { 
  var expDays=parseInt(d),path = "/";
  var expdate = new Date();
  expdate.setTime(expdate.getTime() + (expDays*24*60*60*1000));
  document.cookie = "UVaLibCSS=" + escape (theStyle) + "; expires=" + expdate.toGMTString() +'; path=' + path;
  top.location.reload();
}


if(document.layers) onresize = gbReload;
function gbReload() {location.reload();}


// list stripe

 function stripe(id) {

/*
    // the flag we'll use to keep track of 
    // whether the current row is odd or even
    var even = false;
  
    // if arguments are provided to specify the colours
    // of the even & odd rows, then use the them;
    // otherwise use the following defaults:
    var evenColor = arguments[1] ? arguments[1] : "#ffffea";
    var oddColor = arguments[2] ? arguments[2] : "#ddd";
  
    // obtain a reference to the desired list
    // if no such list exists, abort
    var ul = document.getElementById(id);
    if (! ul || !header) { return; }
    
     // find all the &lt;li&gt; elements... 
      var lis = ul.getElementsByTagName("li");
      
      // ... and iterate through them
      for (var i = 0; i < lis.length; i++) {
        
            var myli = lis[i];
            
              myli.style.backgroundColor =
                even ? evenColor : oddColor;
            
            
        // flip from odd to even, or vice-versa
        even =  ! even;
        }
*/ 
}
 
 
if (document.all)
{
	var detect = navigator.userAgent.toLowerCase();
	var browser,thestring;
	var version = 0;

	if (checkIt('msie')) 
	{
		browser = "IE "
		browser += detect.substr(place + thestring.length,3);
		document.title = browser + ' - ' + document.title;
	}
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


