Ah, you need to redefine CargoPanel_Frame in each function you want to access it in as they are local to the function unless you set it outside the function.
Code:
plugin.setSelected = function( selected )
if selected ~= plugin.selected then
plugin.selected = selected;
local CargoPanel_Frame = _G["CargoPanel_Frame"];
if selected then
CargoPanel_Frame:show()
else
CargoPanel_Frame:hide()
end
end
end