var _submenu_timer = {};
var SUBMENU_TIMER_INTERVAL = 75;
// onmouse actions are on the li b/c when the short div moves upward the pointer might fall off
function submenu(item_id, active){
	if( _submenu_timer[item_id] != undefined )
		clearInterval(_submenu_timer[item_id]);
	_submenu_timer[item_id] = setInterval(function(){ _submenu_animate(item_id, active); }, SUBMENU_TIMER_INTERVAL);
}
function coerce_style_int(n,c){ var v = parseInt(n); if( isNaN(v) ){ v=c; } return v; }
function _submenu_animate(item_id, active){
	var item = document.getElementById(item_id);
	var again = true; 	// run this function again?
	var t_interval = 23;
	var t_max = -69; 	// -(Math.floor(75/t_interval)*t_interval)
	var h_interval = 26;
	var h_max = 204; 	//  (100 + (h_interval*4))
	if( active ){
		// first move up
		var top = coerce_style_int(item.style.top, 0);
		if( top > t_max ){
			item.style.top = (top - t_interval) + 'px';
		}else{
			// then grow
			var height = coerce_style_int(item.style.height, 100);
			if( height < h_max ){
				item.style.height = (height + h_interval) + 'px';
			}else{
				again = false;
			}
		}
	}else{
		// shrink
		var height = coerce_style_int(item.style.height, h_max);
		if( height > 100 ){
			item.style.height = (height - h_interval) + 'px';
		}else{
			// move back down
			var top = coerce_style_int(item.style.top, t_max);
			if( top < 0 ){
				item.style.top = (top + t_interval) + 'px';
			}else{
				again = false;
			}
		}
	}
	if( !again ){
		clearInterval(_submenu_timer[item_id]);
	}
}

