var menu_ext = "menu_";
var drop_ext = "drop_";
var display_ext = "display_";
var menu_separator = "___";
var fc = "form_controls";
document[fc] = new Object;

var current_menu=null;
document.onclick=hide_menu;
document.onkeydown=handle_keydown;

function display_none(x){
	if(x && x.style && x.style.display){
		return "none" == x.style.display;
	} else {
		return false;
	}
}

function toggle_menu(e){
	set_pos(this.menu,this.display); 
	if(this.menu.style.display=='none'){
//		alert('showing menu '+ this.menu.style.display);
		hide_menu(e);
		this.menu.style.display='';
		current_menu=this;
	} else {
//		alert('hiding menu');
		hide_menu(e);
	}
	cancel_bubble(e);
}

function handle_keydown(e){
	if (!e) var e = window.event;
//	alert(current_menu + e.type);
	if(current_menu){
		return current_menu.onkeydown(e);
	}
	var action_form = document.getElementById('action_form');
	if(action_form) captureCTRL(e);
}

function hide_menu(e){
	if(current_menu){
		current_menu.menu.style.display='none';
	}
	current_menu=false;
}

function set_pos(m,p){
	m.style.left = getPosX(p.obj) + "px";
	m.style.top = (getPosY(p.obj) + p.obj.offsetHeight) + "px";
}

function set_pos_overlap(m,p){
	m.style.left = (getPosX(p.obj)-1) + "px";
	m.style.top = getPosY(p.obj) + "px";
}

function colour_border(myid,colour){
	var mycell = new getObj(myid);
	if(mycell.style){
//		alert("object " + myid + " found");
		mycell.style.border = colour + " 1px solid";
	} else {
//		alert("object " + myid + " not found");
	}
}
