A square inside an equilateral triangle Given an equilateral triangle and a point $D$ on one of its sides, I need to construct a square $DEFG$ with the vertices $E, F$ lying on the other two sides of the triangle and $G$ somewhere inside it (see picture).

I know if $D$ is the midpoint of the respective side, the problem is easy, but how about the general case? Are there any solutions at all? Actually, my intuition says there should not be if $D$ is not quite close to the middle. 
Furthermore, I have tried using analytic geometry but it quickly became messed up....so I wonder also if we can construct such a square with compass and ruler only. 
Thanks in advance.

Let 
the vertex of the triangle between $D$ and $E$ be $A$ 
and 
the vertex of the triangle between $E$ and $F$ be $C$
Let the length of the side of the triangle be $a$
length of the side of the square be $u$
$\angle ADE = \theta$ (therefore, $\angle EFC = \frac{5 \pi}{6} - \theta$)
length of $AE$ be $x$, therefore length of $CE$ is $a-x$
length of $AD$ be $y$
Then consider the triangle $ ADE$ and use Sine rule:
$\displaystyle \frac{u}{\sin \frac{\pi}{3}} = \frac{x}{\sin \theta} = \frac{y}{\sin \left(\frac{2 \pi}{3} - \theta \right)}$ ........ (1)
Next consider triangle $CEF$ and use Sine rule:
$\displaystyle \frac{u}{\sin \frac{\pi}{3}} = \frac{a-x}{\sin \left( \frac{5 \pi}{6} - \theta \right)}$ ........ (2)
All the above quantities of (1) and (2) are equal to 
$\frac{a}{\sin \theta + \sin \left( \frac{5 \pi}{6} - \theta \right)}$
[Ratio of the sum of the numerators and denominators of $\frac{x}{\sin \theta}$ and $\frac{a-x}{\sin \left( \frac{5 \pi}{6} - \theta \right)}$]
Hence 
$\displaystyle u = \frac{a \sin \frac{\pi}{3}}{\sin \theta + \sin \left( \frac{5 \pi}{6} - \theta \right)}$
$\displaystyle x = \frac{a \sin \theta}{\sin \theta + \sin \left( \frac{5 \pi}{6} - \theta \right)}$
$\displaystyle y = \frac{a \sin \left(\frac{2 \pi}{3} - \theta \right)}{\sin \theta + \sin \left( \frac{5 \pi}{6} - \theta \right)}$
Note: 


*

*Suppose only $y$ is known. You can easily find $\theta$ and then calculate $u$ and $x$ 

*Not all the values of $y$ are admissible. For example, if $y > \sqrt{3} a$, then the equation does not have any solution. Practically, $0 \leq y \leq a$
