var i, j, cursubi = -1, killtimer = 0;
for(i=0;i<submen.length;i++) {
	submen[i] = document.createElement('div');
	for(var j=0; j < menunames[i].length; j++) {
		submen[i].appendChild(document.createElement('a'));
		submen[i].lastChild.style.display = 'block';
		submen[i].lastChild.style.borderTopColor = 'white';
		submen[i].lastChild.style.borderTopWidth = '1px';
		submen[i].lastChild.style.whiteSpace = 'nowrap';
		submen[i].lastChild.style.paddingLeft = '1em';
		submen[i].lastChild.style.paddingTop = '1px';
		submen[i].lastChild.style.paddingRight = '1em';
		submen[i].lastChild.style.paddingBottom = '1px';
		submen[i].lastChild.style.fontWeight = 'normal';
		submen[i].lastChild.style.cursor = document.all ? 'hand' : 'pointer';
		submen[i].lastChild.href = menuhref[i][j];
		submen[i].lastChild.appendChild(document.createTextNode(menunames[i][j]));
	}
}
	
function dropoff(i) {
		submen[i] = document.getElementById('navbar').removeChild(document.getElementById('dropmen'));
		cursubi = -1;
}
function timedkill() {
	if(cursubi >= 0) dropoff(cursubi);
	killtimer = 0;
}
function killsub() {
	if(document.getElementById) {
		if(killtimer) {
			clearTimeout(killtimer);
			killtimer = 0;
		}
		if(cursubi >= 0) {
			killtimer = setTimeout(timedkill,500);
		}
	}
}
function killkill() {
	if(killtimer) clearTimeout(killtimer);
	killtimer = 0;
}
function makesub(a,i) {
	if(document.getElementById) {
		killkill();
		if(cursubi != i) {
			if(cursubi >= 0) dropoff(cursubi);
			submen[i].style.left = a.offsetLeft + 'px';
			var d = document.getElementById('navbar').appendChild(submen[i]);
			d.id = 'dropmen';
			if(a.tagName == 'SPAN') d.className = 'seldrop';
			if (d.addEventListener){
			  d.addEventListener('mouseover', killkill, false); 
			  d.addEventListener('mouseout', killsub, false); 
			} else if (d.attachEvent){
			  d.attachEvent('onmouseover', killkill);
			  d.attachEvent('onmouseout', killsub);
			}
			cursubi = i;
		}
	}
}
function killprevsub(i) {
	if(document.getElementById) {
		killkill();
		if(cursubi != i) {
			if(cursubi >= 0) dropoff(cursubi);
		}
	}
}
window.onunload = function() {
	if(cursubi >= 0) dropoff(cursubi);
}
window.onload = function() {
	if(document.all) {
		document.all.rightblock.style.height = document.all.main.offsetHeight + "px";
	}
}
window.onresize = function() {
	if(document.all) {
		document.all.rightblock.style.height = document.all.main.offsetHeight + "px";
	}
}