// JavaScript Document
      var this_id = getCookie()?getCookie(): Items[0];

      function site_onerror()
	  {
	     return true;
	  }
	  
	  function getArrayItemIndex(arr, val)
	  {
		 for(i = 0; i < arr.length; i++)
		    if(arr[i] == val)
			   return i;
         return -1;
	  }

	  //window.onerror = site_onerror;

      function setCookie(value, seconds)
	  {
	     var date = new Date();
         var time = date.getTime() + (seconds * 1000);
         date.setTime(time);
         document.cookie = value+"; expires=" + date.toGMTString();
	  }

	  function getCookie()
	  {
	     var exp1 = /([a-zA-Z0-9_]+)/;
		 exp1.exec(document.cookie);
		 return RegExp.$1;
	  }

      function setAttr(obj, attrnam, attrval)
	  {
	     var attr = document.createAttribute(attrnam);
		 attr.nodeValue = attrval;
		 obj.setAttributeNode(attr);
	  }
	  
	  function menuitem_onmousemove()
	  {
	     if(!Links[this.id])  {
			setAttr(this, "target", "data");
			setAttr(this, "href", content_path + "/" + this.id + ".html");
		 }
		 else {
		    setAttr(this, "target", "_blank");
			setAttr(this, "href", Links[this.id]);
		 }
	  }

          function initFirstContent()
          {
            var tabObj = document.getElementById(Items[0]);
            buildContent(Items[0], tabObj);
          }

          function buildContent(tabName, tabObj)
          {
            if(!Links[tabName])  {
            for(i = 0; i < Items.length; i++)
              setAttr(document.getElementById(Items[i]), "class", "std");
            var this_index = getArrayItemIndex(Content, tabName);
            if(this_index==-1) {
              setAttr(tabObj, "class", "active")
              setCookie(tabName, item_time);
              setAttr(tabObj, "target", "data");
              setAttr(tabObj, "href", content_path + "/" + tabName + ".html");
            }
            else
              setContent(this_index);
            }
          }

	  function menuitem_onmousedown()
	  {
	     this.blur();
	     buildContent(this.id, this);
	     return;
         if(!Links[this.id])  {
		    for(i = 0; i < Items.length; i++)
		       setAttr(document.getElementById(Items[i]), "class", "std");
			this_id = this.id;
			
			var this_index = getArrayItemIndex(Content, this.id);
			if(this_index==-1) {
		       setAttr(this, "class", "active")
		       setCookie(this.id, item_time);
			   setAttr(this, "target", "data");
			   setAttr(this, "href", content_path + "/" + this.id + ".html");
			}
			else
			   setContent(this_index);

		 }
	  }

	  function setData(data)
	  {
		 document.getElementById("content").innerHTML = 
		    Content[Content.length] = 
			"<div class='header'>./"+this_id+"</div>" + data;
	  }
	  
	  function setContent(index)
	  {
	     var content_object = document.getElementById("main");
		 if(content_object) {
		    if(Content[index])
		       content_object.innerHTML = Content[index];
			else
			   content_object.innerHTML = "ERROR: WHERE WAS THE CONTENT? HMM, LOST IT!";
         }
	  }
	  
	  function createMenuItem(name)
	  {
	     var menu = document.getElementById("menu");
		 var new_item = document.createElement("a");
		 var item_text = document.createTextNode(name);
		 var item_href = document.createAttribute("href");
		 var item_onmousedown = document.createAttribute("onmousedown");
		 var item_id = document.createAttribute("id");
		 
		 item_href.nodeValue = "#";
		 item_onmousedown.nodeValue = "";
		 item_id.nodeValue = name;
		 
		 new_item.setAttributeNode(item_href);
		 new_item.setAttributeNode(item_onmousedown);
		 new_item.setAttributeNode(item_id);
		 
		 new_item.onmousedown = menuitem_onmousedown;
		 
		 setAttr(new_item, "onmousemove", menuitem_onmousemove);
		 
		 if(Links[name]) {
		    setAttr(new_item, "href", Links[name]);
			setAttr(new_item, "target", "_blank");
		 }
		 
		 if(getCookie() == name)
		    setAttr(new_item, "class", "active");

		 setAttr(new_item, "onclick", "this.blur();");
		 
		 new_item.appendChild(item_text);
		 menu.appendChild(new_item);
	  }

      function createSite()
      { 
	     if(!getCookie())
            setCookie(Items[0], item_time);
         else
		    setCookie(getCookie(), item_time);
			
		 var data = document.getElementById("data");
		 setAttr(data, "src", content_path + "/" + getCookie() + ".html");
			
         if(Items)
		    for(i = 0; i < Items.length; i++)
               createMenuItem(Items[i]);
			   
         setContent(getCookie());
			   
      }
	  
	  
	  
