function hideDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'none';
}

function showDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'block';
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

var username;

function individualArchivesOnLoad(username) {
    if (username) {
        showDocumentElement('downloads');
    } else {
        hideDocumentElement('downloads');
    }
}



function writeDownloadAppGreeting(username) {
    if (username) {
        document.write('<p>You are signed in and can download files. '+ //username
          '(<a href="https://www.typekey.com/t/typekey/logout?_return=http%3A%2F%2Fappnel.com%2Fmt%2Fplugins%2Ftypekey%2Fapp.cgi%3Fapp%3Ddownload%26logout%3D1%26blog_id%3D1">Sign Out</a>)</p>');
    } else {
        document.write('<p>You are not signed in. You need to be registered to download from this site. '+
          '<a href="https://www.typekey.com/t/typekey/login?t=0ZJw3Md63ncxNgSQUbnH&v=1.1&need_email=1&_return=http%3A%2F%2Fappnel.com%2Fmt%2Fplugins%2Ftypekey%2Fapp.cgi%3Fapp%3Ddownload%26blog_id%3D1">Sign in</a></p>');
    }
}

if ('appnel.com' != 'appnel.com') {
    document.write('<script src="http://appnel.com/mt/plugins/download/username_js.cgi"></script>');
} else {
    username = getCookie('tk_commenter');
}

