var fadeIn;
var hide;

function search(parentObject, elementNode) {
	var children = parentObject.childNodes;

	if (!children.length)
		return false;
	
	var result = new Array();
	for (var i = 0; i < children.length; i++) {
		if (children[i].nodeType == 1) {
			if (children[i].nodeName.toLowerCase() == elementNode.toLowerCase()) {
				result.push(children[i]);
			} else {
				var subResult = search(children[i], elementNode);
				
				if (subResult) {
					result.push(subResult);
				}
			}
		}
	}

	return result.length ? result : false;
}

function show(id) {
	if (document.getElementById('subnavi-' + id) && document.getElementById('edge-' + id).className != 'active')
			document.getElementById('edge-' + id).className = 'hover';

	if (hide && hide[id])
		window.clearTimeout(hide[id]);
	
	if (!fadeIn)
		fadeIn = new Array();

	if (document.getElementById('subnavi-' + id) && document.getElementById('subnavi-' + id).className == 'inactive') {

		if (!fadeIn[id]) {
			fadeIn[id] = true;
			document.getElementById('subnavi-' + id).className = 'inactive';

			new Effect.SlideDown('subnavi-' + id, { afterFinishInternal: function() { fadeIn[id] = false; }});
		}
		
		window.setTimeout('document.getElementById(\'subnavi-' + id + '\').className = \'\';', 100);
	}
}	


function hide(id) {
	if (!hide)
		hide = new Array();

	if (fadeIn && fadeIn[id]) {
		window.clearTimeout(hide[id]);
		hide[id] = window.setTimeout('hide(\'' + id + '\');', 200);
	} else {
		window.clearTimeout(hide[id]);
		hide[id] = window.setTimeout('__hide(\'' + id + '\');', 700);
	}
}
	
function __hide(id) {
	if (document.getElementById('subnavi-' + id)) {
		if (document.getElementById('subnavi-' + id).className != 'inactive')
			new Effect.SlideUp('subnavi-' + id, { afterFinishInternal: function() { document.getElementById('subnavi-' + id).className = 'inactive'; if (document.getElementById('edge-' + id).className != 'active') document.getElementById('edge-' + id).className = ''; }});
	} else
		if (document.getElementById('edge-' + id).className != 'active') document.getElementById('edge-' + id).className = '';
}
