
      trickyImageUrl = "http://democognos.gatton.uky.edu/bdjwebstats/dot.gif";
      echoServletUrl = "http://democognos.gatton.uky.edu/bdjwebstats/echoLinkTo.txt";

      shown = false;
      externalUrl = false;
            
      function hideMainContainerChildren()
      {
         var items = document.getElementById("mainContainer").childNodes;
         for (var i = 0; i < items.length; ++i)
         {
	     if (items[i].nodeType == 1) //ELEMENT
               items[i].style.display = 'none';
         }
      }

      function showById( elemId )
      {
         document.getElementById(elemId).style.display = 'block';
      }

      function setInternalContent()
      {
         document.getElementById("externalMain").style.display = 'none';
         document.getElementById("mainContainer").style.display = 'block';
      }

      function setExternalContent()
      {
         document.getElementById("mainContainer").style.display = 'none';
         document.getElementById("externalMain").style.display = 'block';
      }

      function hideOpenExternalPanel()
      {
         document.getElementById("openExternalPanel").style.display = 'none';
      }

      function showOpenExternalPanel()
      {
         document.getElementById("openExternalPanel").style.display = 'block';
      }

      function openExternal()
      {
          var ifrm = document.getElementById("emIFrame");
          window.open(ifrm.src, "_blank");
      }

      function showInternalContentNoReport( elemId )			     
      {
          setInternalContent();			     
          hideMainContainerChildren();
          hideOpenExternalPanel();
          showById(elemId);
          shown = elemId;      /* global */
	  externalUrl = false; /* global */		     
      }

      function showInternalContent( elemId )			     
      {
         var oldShown = shownOrUrl();
         showInternalContentNoReport( elemId );
         reportInlineJump( oldShown, elemId );
      }

      function createRandomTrickyImageUrl()
      {
	  var num = Math.floor(Math.random()*10000);
	  var url = "http://democognos.gatton.uky.edu/bdjwebstats/" + num + ".sgif";
	  //alert( url );
	  return url;
      }

      function reportJump( oldShown, elemId, inline )
      {
          var reportImage = document.getElementById("reportImage");
          //reportImage.src = trickyImageUrl + '?linkfrom=' + oldShown + '&linkto=' + elemId + '&inline=' + inline;
          reportImage.src = createRandomTrickyImageUrl() + '?linkfrom=' + oldShown + '&linkto=' + elemId + '&inline=' + inline;
      }

      function reportInlineJump( oldShown, elemId )
      { reportJump( oldShown, elemId, true ); }

      function embedExternalContentNoReport( url )			     
      {
          var ifrmWidth = document.body.clientWidth - 300;
	  /* alert(ifrmWidth); */
          hideMainContainerChildren();
          showOpenExternalPanel();
          setExternalContent();
          var ifrm = document.getElementById("emIFrame");
          ifrm.width = ifrmWidth;
          ifrm.src = url;

          shown = "emIFrame";
          externalUrl = url;
      }

      function shownOrUrl()
      {
         if (shown == "emIFrame" && externalUrl != false)
           return externalUrl;
         else
           return shown;
      }

      function embedExternalContent( url )			     
      {
         var oldShown = shownOrUrl();
         embedExternalContentNoReport( url );
         reportInlineJump( oldShown, url );			     
      }

/*
      // currently unused
      function ajaxReportAndEcho( linkfrom, linkto, inline )
      {
	// modified from http://ilovethecode.com/Javascript/Javascript-Tutorials/Javascript_Ajax_Call.shtml
        var http = false;

        //Check for Internet Explorer
        if (navigator.appName == "Microsoft Internet Explorer") 
        {
           http = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else 
        {
           http = new XMLHttpRequest();
        }

        var params = 'linkfrom=' + linkfrom + '&linkto=' + linkto + '&inline=' + inline;

        var resp = false;

        //Using POST, not necessary here, but if URL was long...
        http.open("POST", url, true);

        //Set Headers
        http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        http.setRequestHeader("Content-length", params.length);
        http.setRequestHeader("Connection", "close");

        //Inline function to connect to the server
        http.onreadystatechange = function() 
        {
           if (http.readyState == 4 && http.status == 200) 
           {
             resp = http.responseText;
             //alert(resp);
           }
        }

        //Send it all
        http.send(params);

        return (linkto == resp);
      }
*/
      function openExternallyNoReport( url, target )
      {
         var newWindow = window.open(url, target);
         newWindow.focus();
      }

      function openExternally( url, target )
      {
         openExternallyNoReport( url, target )
         reportJump( shownOrUrl(), url, false )
      }

      function setUpPage()
      {
          showInternalContent("briefBio");			     
      }

