var color

function pit(what) {document.getElementById('output').value = what; }


// ================================================================

function getElementsByClass(classname){
 
var inc=0
var alltags=document.getElementsByTagName("*")
var partscollect = new Array();
 
for (i=0; i<alltags.length; i++){
  if (alltags[i].className==classname)
    partscollect[inc++]=alltags[i]
  }
return partscollect;
}

// ================================================================

function getwwidth ()
{
if (window.innerHeight) return window.innerWidth;
   else return document.body.offsetWidth;
}

// ================================================================
//  The following functions parse the document's mainmenu tree
//  and adds JavaScript handlers for mouseovers
// ================================================================

function tagElement(el) {

while ((el) && (el.nodeType != 1)) el=el.nextSibling;
return el;
}

//================

function prepMenu(col) {

color=col;

var el=document.getElementById('mainmenu').firstChild;
el=tagElement(el);
while (el.tagName != 'UL') el=tagElement(el.nextSibling);
parseLi(tagElement(el.firstChild));
}

// ================

function parseLi(el) {

var tui='';
var c=0;

while (el) {
  if (tagElement(el.firstChild)) el=tagElement(el.firstChild);
  tui=tui+el.tagName+'/';
  switch (el.tagName) {
     case 'A':	hRef=el.getAttribute('href');
		if (hRef) {
		   el.parentNode.onclick = function() {
			tmp=tagElement(this.firstChild);
			window.location=tmp.getAttribute('href'); }
		   el.parentNode.onmouseover = function () {
			tmp=tagElement(this.firstChild);
			this.style.background=color;}
		   el.parentNode.onmouseout = function() {
			tmp=tagElement(this.firstChild);
			this.style.background = 'transparent';}
		} else {
		   el.parentNode.onmouseover = function() {
			this.style.cursor='default'; }
		}
		if (!tagElement(el.parentNode.nextSibling)) {
		  if (comeback) el=tagElement(comeback.parentNode.nextSibling);
		    else el=null;
		  comeback = null;
		  }
                  else {
                     el=tagElement(el.parentNode.nextSibling);
                     tui=tui+c+'/';
		}
		break;
     case 'UL': var comeback = el;
		el=tagElement(el.firstChild);
		break;
     case 'LI': el.onmouseover = function() {
		  this.style.cursor='default'; }
		if (tagElement(el.nextSibling)) el=tagElement(el.nextSibling);
    	          else {
  		    if (tagElement(el.parentNode.nextSibling)) {
		       el=tagElement(el.parentNode.nextSibling);
		       break;
		       }
		    else el=tagElement(comeback.parentNode.nextSibling);
		    }
		break;

     default:   el.onmouseover = function() {
		  this.style.cursor='default'; }
		if (tagElement(el.parentNode.nextSibling)) {
		   el=tagElement(el.parentNode.nextSibling);
		   break;
		   }
		else {
		   el=tagElement(comeback.parentNode.nextSibling);
		}
		break;
    }
//    pit(tui);
    c++;
  }
}

// ================

function disp(what) {
document.getElementById('output').value=what; }

function dispii(what) {
document.getElementById('outputii').value=what; }
