﻿// call this to redirect to the secure sites
RedirectSecure();

// site functions

function RedirectSecure()
{
    // first check if we need to redirect to www
    if ( !RedirectWWW() )
    {
        var SecureSites = new Array();
        SecureSites[0] = "http://www.esignmortgage.com";
        SecureSites[1] = "http://qa.esignmortgage.com";
        SecureSites[2] = "http://esignmortgageqastage";
        SecureSites[3] = "http://esignmortgagetest";

        for ( var i = 0; i < SecureSites.length; i++ )
        {
            if ( window.location.toString().indexOf( SecureSites[ i ] ) == 0 )
            {
                var url = "https" + window.location.toString().substring( 4 );
                window.location = url;
                return;
            }
        }
    }
}

function RedirectWWW()
{
    if ( window.location.toString().indexOf( "http://esignmortgage.com" ) == 0 )
    {
        var url = "https://www." + window.location.toString().substring( 7 );
        window.location = url;
        return true;
    }
    else if ( window.location.toString().indexOf( "https://esignmortgage.com" ) == 0 )
    {
        var url = "https://www." + window.location.toString().substring( 8 );
        window.location = url;
        return true;
    }
    else
        return false;
}

