When does a codimension 1 submanifold admit a transverse vector field? I'm having some trouble with the following problem, which comes from a released qualifying exam:

Assume that $N \subset M$ is a codimension 1 properly embedded submanifold.  Show that $N$ can be written as $f^{-1}(0)$, where $0$ is a regular value of a smooth function $f\colon M\to\mathbb{R}$, if and only if there is a vector field $X$ on $M$ that is transverse to $N$.

Some of my thoughts include:


*

*If we have $f^{-1}(0)=N$, it seems that we should be able to embed $M$ into $\mathbb{R}^N$ in such a way that $f$ is the last component of our embedding.  Then at each point $p \in M$ we could define $X_p$ to be the projection of $e_N$, the $N$-th standard basis vector, onto $T_pM$.  I believe this would give the desired vector field on $M$ transverse to $N$.

*If we have the vector field, perhaps we could reverse the above argument.  We could (hopefully) embed $M$ into $\mathbb{R}^N$ in such a way that $X$ always points in the direction of $e_N$.  Then the $N$-th component of our embedding would (again, hopefully) be constant on $N$.  We could then use Sard's theorem to make sure this constant value is regular for $f$.


My questions are as follows.  Does this strategy have a chance at solving the problem?  If so, how do I fill in the details?  Whether this strategy will or won't work, is there a solution to this problem which is particularly desirable?
 A: Actually, the "if" part of the problem statement is false. Here's a counterexample. 
Let $M = \mathbb S^1\times \mathbb S^1$ be the torus, and let $N$ be an embedded circle $\mathbb S^1\times \{z_0\}$. If $(\theta,\phi)$ are angle coordinates on $M$, then the vector field $X = \partial/\partial \phi$ is globally defined and nowhere tangent to $N$. However, if $f\colon M\to\mathbb R$ is a smooth function such that $N = f^{-1}(0)$, then the fact that $M\smallsetminus N$ is connected forces $f$ to be either everywhere positive or everywhere negative on $M\smallsetminus N$. That means that every point of $N$ is either a local minimum or a local maximum of $f$, and therefore $0$ cannot be a regular value of $f$.
A: I assume $N$ is compact in the paracompact $M$.
Suppose that $f$ is a regular function such that $N=f^{-1}(0)$. Consider a differentiable metric. You can define a vector $X$ in a neighborhood of $U$ of $N$ where $df$ is not trivial by setting $<X,.>=df$. Extend $X$ to $Y$ on $M$ by using cut off functions such that $Y$ coincide with $X$ in a neighborhood $V$ of $N$.
Now suppose that there exists a vector field $X$. transverse to $N$. You have an interval $I$ such that $\phi_t(x), x\in N$ is defined where $\phi$ is the flow of $X$. Set $h:N\times I\rightarrow M$ by $h(x,t)=\phi_t(x)$. The image of $h$ is a neighborhood $U$ of $N$. Define the function $f$ on $U$ by $f(\phi_t(x))=t$. Thus the existence of a regular function $f$ such that $N=f^{-1}(0)$ is true on a neighborhood of $N$. 
