function UseSSL()
{
    var cbox = document.getElementById('cbUseSSL');
    if (!cbox)
        return;
    
    cbox.disabled = false;      
    cbox.checked = true;
}

function ClientValidate(source, arguments)
{
    var tmp = document.getElementById("pnlLogonFailed");
    if (tmp)
        tmp.style.display="none";
    tmp = document.getElementById("login_notice");
    if (tmp)
        tmp.style.display="none";
       
    arguments.IsValid = true;
}

function getLogonUrl()
{
    var retString;
    var cbox = document.getElementById('cbUseSSL'); //.checked = true;
    
    if (!cbox)
        return "";
        
    if (location.protocol == "http:")
    {
        if (cbox.checked == true)   
            retString = "https://" + location.hostname + ":" + httpsport + location.pathname;
        else
            retString = location.pathname;
    }
    else
    {
       if (cbox.checked == true)   
            retString = location.pathname;
        else
            retString = "http://" + location.hostname + ":" + httpport + location.pathname;
    }
    return retString;
}
    
function performSSLCheck()
{
    if (document.getElementById('cbUseSSL'))
            document.getElementById('cbUseSSL').disabled = true;

    var loginBtn = document.getElementById('btnLogin');
    if (loginBtn)
    {
        loginBtn.onclick = function() 
        {
            WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("btnLogin", "", true, "", getLogonUrl(), false, false));
        };
    }

    var secScript = document.createElement("script");
    var path = location.pathname.substring(0, location.pathname.lastIndexOf('/'));
    path = path + "/scripts/CheckSSL.js";    
    if (location.protocol == "http:")
        secScript.src = "https://" + location.hostname + ":" + httpsport + path;
    else
        secScript.src = path;

    document.body.appendChild(secScript);
}
