// original utils.js functions
// start
function printversion(){
	document.printform.pagetext.value = document.getElementById("printversion").innerHTML; 
	document.printform.pagetitle.value = document.title;
	} 

function printthis(){
	document.printform.submit();
	}

// end

var parentid = null;
var menuid = null;
function init(){
	printversion();
	// sitemap should come from included file
	// if it is not there do not manipulate menu at all
	if (!sitemap)
		return;

	//look for parentid
	if (sitemap[currentid])
		parentid = currentid;
	else {
		for (var i in sitemap) {
			for (var j in sitemap[i]){
				if (sitemap[i][j]==currentid) {
					parentid = i;
					break;
				}
			}
		}
	}
	var lvl1 = null;
	//having parentid look up parent menu id
	//it better be there
	for (var i in leftnav) {
		if (leftnav[i]==parentid) {
			lvl1 = document.getElementById('menulvl1-'+i);
			if (lvl1){
				menuid = i;
				break;
			}
		}
	}

	//apply highlight styles
	if (lvl1){
		var hue = '_' + lvl1.className.split('_')[1];
		lvl1.className = 'topitemselect'+hue;
	}
	var current = document.getElementById('menu-'+currentid+':'+currentid);
	if (current)
		current.className = 'subitemselect'+hue;

	//hide what is not relevant
	for (var i in leftnav) {
		if (i != menuid) {
			var lvl2 = document.getElementById('menulvl2-'+i);
			if (lvl2)
				lvl2.style.display = 'none';
		}
	}

}

function menuMouseOut(menutd, hue) {
	//without id it is topitem
	if (!menutd.attributes.id) {
		menutd.className = 'topitem'+hue;
		return
	}

	//current page menu
	var mid = menutd.attributes.id.value.split('-')[1];
	if (mid == currentid+':'+currentid) {
		menutd.className = 'subitemselect'+hue;
		return
	}
	if (mid == menuid) {
		menutd.className = 'topitemselect'+hue;
		return
	}
	//anything else
	if (mid.split(':').length > 1)
		// with colon it is level2
		menutd.className ='subitem'+hue;
	else
		menutd.className ='topitem'+hue;
}
