passing subdomain to a variable then creating new url
<p>HI, 
I am nearly there I think but am struggling to put the final bits in place. </p>

<p>I am trying to look up the the subdomain of a number of different envoronments and pass the subdomain as a variable to prefix a url called via an onclick event. This is all delivered through an xsl transformation. </p>

<p>I am just getting the domain passed to the link at present. Any tips on how to make this work or write the code in a better way greatly appreciated.</p>

<pre><code>            &lt;xsl:text disable-output-escaping="yes"&gt;        
                            &lt;![CDATA[
                            &lt;script type="text/javascript"&gt;

                                function enironment()
                                {       
                                    if (window.location.host.toLowerCase() === 'www.mydomain.com') {
                                                    SsoServer = "https://sso.mydomain.com";
                                    }
                                    else{
                                    var sub_domain = window.location.split('.')[0].split('//')[1];
                                    SsoServer = "https://" + sub_domain + "sso.mydomain.com";
                                    }                           

                                    top.location.replace(SsoServer);                                            
                                }

                            &lt;/script&gt;]]&gt;

                        &lt;/xsl:text&gt;

                                &lt;a href="#" onClick="javascript:enironment()" title="Sign in"&gt;Sign
                                    in&lt;/a&gt;
</code></pre>
