Derivation of demand for intermediate goods in DSGE model I'm self-studying Herbst-Schorfheide book on DSGE estimation and having troubles replicating their steps in the derivation of demand for final goods firms (Ungated model is here, page 3: http://ink.library.smu.edu.sg/cgi/viewcontent.cgi?article=1361&amp;context=soe_research). Their final goods producers maximize profit function:

$\Pi_t = P_t (\int_0^1 Y_t(j)^{1-\nu} dj)^\frac{1}{1-\nu} - \int_0^1 P_t (j)  Y_t(j) dj$

and get the demand:

$Y_t(j) = (\frac{P_t(j)}{P_t})^{-\frac{1}{\nu}} Y_t$

My trouble is that I cannot understand derivation steps: how FOC looks like and why? Help is much appreciated!
So I've seen this sort of thing where you basically differentiate with respect to each Y_j so the integral drops out (seen this in moral hazard chapter from 
MWG and Romer's endogenous growth model). 

The foc becomes:

$P_t(Y_t(j)^{(1-v)})^{v/(1-v)}Y^{-v}-P_t(j)=0$

This gets the result.