function managePassword(elt) {
    if (elt.value.length != 0) {
        document.getElementById("setpwd").checked = true;
    }
}

function validateForm() {
    var setpwd = document.getElementById("setpwd").checked;
    var pwd = document.getElementById("pwd").value;
    if (setpwd && pwd.length == 0) {
        return confirm("You've requested a password protection, but your password is empty. Do you want to continue ?");
    } else if (!setpwd && pwd.length != 0) {
        return confirm("You've not requested a password protection, but your password is not empty. Do you want to continue ?");
    } else {
        return true;
    }
}

function initPaste() {
    init();
}

function initPasted() {
    init();
    document.getElementById("original").style.display=="none";
    document.getElementById("highlight").style.display=="block";
    switchPastedView();
}

function init() {
    var ga_enabled = (document.getElementById("ga_enabled").value == "true");
    var ga_id = document.getElementById("ga_id").value;
    if (ga_enabled && typeof(_gat) == "object") {
        var pageTracker = _gat._getTracker(ga_id);
        pageTracker._trackPageview();
    }
}

function switchPastedView() {
    var h = document.getElementById("highlight");
    var o = document.getElementById("original");
    var b = document.getElementById("content_switcher");
    b.disabled = true;
    if (o.style.display == "" || o.style.display == "block") {
        h.style.display = "block";
        o.style.display = "none";
        b.value = "Show original";
    } else {
        o.style.display = "block";
        h.style.display = "none";
        b.value = "Show highligthed";
    }
    b.disabled = false;
}

