﻿    var currentURL=location.href.substring(0,5)
     
    if(currentURL.toLowerCase()!="http:")
    {
        currentURL = location.href.substring(5,location.href.lastIndexOf(''))
        var portStartPos = currentURL.lastIndexOf(':')
        var sslPort = null
        
        if(portStartPos!=0)
        {
            var relativeURL = currentURL.substring(portStartPos)
            var postPortURL = relativeURL.substring(relativeURL.indexOf('/'))
            var URL = currentURL.substring(0,portStartPos)
            // If you are running your SSL site on a non default port other than 443 then uncomment the next line and add the right Port number.
            //sslPort = ":15000"
            if(sslPort == null)
                currentURL = URL + postPortURL
            else
                currentURL = URL + sslPort + postPortURL
        }
         
        var targetURL = "http" + currentURL
        window.location = targetURL
    }