Structure and electronic properties of nitrogen-containing carbon nanotubes