﻿function CreateCaptcha(captchaId, publicKey)
{
    var container = document.getElementById(captchaId);
    
    if (container != null)
    {
        Recaptcha.create(
            publicKey,
            captchaId, 
            {
               theme: 'custom',
               lang: 'en',
               custom_theme_widget: captchaId
            });
    }
}

function StoreCatchaData(challengeId, responseId)
{
    var challenge = document.getElementById(challengeId);
    var response = document.getElementById(responseId);                                
    challenge.value = Recaptcha.get_challenge();
    response.value = Recaptcha.get_response();
}

function ProposeProfileValue(input, firstNameId, familyNameId, host)
{
    if (input.value.length == 0)
    {
        input.value = document.getElementById(firstNameId).value + document.getElementById(familyNameId).value;
        
        SetProfileUrl(input.id, host);
    }    
}    

function SetProfileUrl(usernameId, host)
{
    var oUserName = document.getElementById(usernameId);
    var oProfileUrl = document.getElementById("profileUrl");
    
    if (oUserName != null && oProfileUrl != null)
    {
        if (oUserName.value.length > 0) {
            oProfileUrl.innerHTML = "<div style='display: inline;' onclick='javascript:VxOpenPopupMenu(this, event, GetPopupHelp(\"HelpProfileUrl\"));'><a style='color: #999999;' tabindex='0' href='javascript:void 0;'>" + host + "/people/" + oUserName.value + "</a></div>";
        } else {
            oProfileUrl.innerHTML = "http://" + host + "/people";
        }
    }
}