//open menu with given ID next to given link positioned 'right' or 'bottom' with optional padding
function openMenu(menuID,linkObj,position,paddingX,paddingY) {
	if (um.ready) {
		//find the window size
		var winSize = um.getWindowDimensions()
		//find the offset of the main container
		var xoffset = winSize.x / 2 - 400
		//find co-ordinates of link object
		var coords = {'x' : um.getRealPosition(linkObj,'x'),'y' : um.getRealPosition(linkObj,'y')}
		//move the x-position by the offset
		coords.x -= xoffset
		
		switch (position) {
			case "right" :
				//increase x-position to place it to the right of the link
				coords.x += (linkObj.offsetWidth)
				//add padding if any
				break;
			case "bottom" :
				//increase y-position to place it below the link
				coords.y += (linkObj.offsetHeight)
				//add padding if any
				break;
		}
		
		//adjust by any given padding
		if (paddingX) coords.x += paddingX
		if (paddingY) coords.y += paddingY
		
		//activate menu at returned co-ordinates
		um.activateMenu(menuID, coords.x + 'px', coords.y + 'px')
	}
}

//close menu with given ID
function closeMenu(menuID) {
	if (um.ready) {
		um.deactivateMenu(menuID)
	}
}