function menuExpand(parent_id)
{	
	if(typeof curr_node != "undefined") {
		if(curr_node == parent_id) {
			if(typeof timer_id != "undefined") clearTimeout(timer_id);
		}
	}
	
	holder = document.getElementById(parent_id);
	var url = "index.php?action=menu_controller&parent_id="+parent_id;
	xmlHttpObj(url,menuExpandExec,"get");
}

function menuExpandExec()
{
	var content = "";
	
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		if(xmlHttp.status == 200) {
			var jsonObj = eval("(" + xmlHttp.responseText + ")");
			for(k in jsonObj['label']) {
				content += "<div class=\"menu_node\" onmousedown=fireURL('"+jsonObj['url'][k]+"')>"+jsonObj['label'][k]+"</div>";
			}
			holder.innerHTML = content;
		} else {
			content += "<div class=\"menu_node\">Loading...</div>";
		}
	}
}

function fireURL(targetURL)
{
	location.href = targetURL;
}

function menuCollapse(parent_id)
{
	// set node that mouse is hoovering
	curr_node = parent_id;

	timer_id = setTimeout("menuCollapseExec("+parent_id+")",500);
}

function menuCollapseExec(parent_id)
{
	document.getElementById(parent_id).innerHTML = "";
}