after deploy the site need exact domain name with jquery
<p>I am going to deploy my site and I need to get the domain name after deploying the site. 
It is very simple if the address was <code>www.domain.com</code> then the domain name is <code>domain.com</code>
but if the client deploys the site as a sub domain like <code>subdomain.domain.com</code> then how can I get exact domain name? I have  already get host name with</p>

<pre><code>window.location.hostname
</code></pre>

<p>I need exact domain name after deploying the site to set a cookie 
I don't know what domain the client will be use</p>

<ul>
<li>option 1 www.domain.com</li>
<li>option 2 domain.com</li>
<li>option 3 subdomain.domain.com</li>
<li>option 4 subdomain.domain.com.us</li>
<li>option 5 domain.com.us
etc</li>
</ul>

<p>What function do I write to apply for all conditions and get exact domain name 
in jQuery?</p>
