Show Facebook like box popup if referrer is Facebook
<p>I have a Facebook Like Box inside a Popup div. However, I would like the Facebook Like Box to be displayed ONLY when a user entered the site directly from Facebook.</p>

<p><strong>In short:</strong></p>

<p>User came from Facebook: show</p>

<p>User entered URL directly: do not show</p>

<p>User came from google: do not show</p>

<hr>

<p>How can I check and validate that facebook is the user referrer? Here is my code:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>if (document.cookie.indexOf('_visited=1') == -1) {
  var delay_popup = 1000;
  setTimeout("document.getElementById('parent_popup').style.display='block'", delay_popup);
  var date = new Date;
  date.setDate(date.getDate() + 1); // текущая дата + 1 день
  document.cookie = '_visited=1; path=/; expires=' + date.toUTCString();
}</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>#parent_popup {
  background-color: rgba(0, 0, 0, 0.8);
  display: none;
  position: fixed;
  z-index: 99999;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

#popup {
  background: #fff;
  width: 380px;
  margin: 10% auto;
  padding: 5px 20px 13px 20px;
  border: 10px solid #ddd;
  position: relative;
  -webkit-box-shadow: 0px 0px 20px #000;
  -moz-box-shadow: 0px 0px 20px #000;
  box-shadow: 0px 0px 20px #000;
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  border-radius: 10px;
}

#popup h4 {
  font: 28px Monotype Corsiva, Arial;
  font-weight: bold;
  text-align: center;
  color: #008000;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

#popup h5 {
  font: 24px Monotype Corsiva, Arial;
  color: red;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.close {
  background-color: rgba(0, 0, 0, 0.8);
  border: 2px solid #ccc;
  height: 24px;
  line-height: 24px;
  position: absolute;
  right: -24px;
  cursor: pointer;
  font-weight: bold;
  text-align: center;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
  text-shadow: 0 -1px rgba(0, 0, 0, 0.9);
  top: -24px;
  width: 24px;
  -webkit-border-radius: 15px;
  -moz-border-radius: 15px;
  -ms-border-radius: 15px;
  -o-border-radius: 15px;
  border-radius: 15px;
  -moz-box-shadow: 1px 1px 3px #000;
  -webkit-box-shadow: 1px 1px 3px #000;
  box-shadow: 1px 1px 3px #000;
}

.close:hover {
  background-color: rgba(0, 122, 200, 0.8);
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="parent_popup"&gt;
  &lt;div id="popup"&gt;
    &lt;font size="2" style="font-size: 15pt;"&gt;
      &lt;b style="color: rgb(255, 0, 0);"&gt;&lt;center&gt;pls like us !&lt;/center&gt;&lt;/b&gt;
    &lt;/font&gt;
    &lt;center&gt;like box code &lt;/center&gt;
    &lt;p style="text-align: center;"&gt;
      &lt;strong&gt;&lt;a class="button" href=""&gt;&lt;/a&gt;&lt;/strong&gt;
    &lt;/p&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre>
</div>
</div>
</p>