function readCookie(name) {
var n = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(n) == 0) return c.substring(n.length,c.length);
}
return null;
}

function mtlogin() {
        var mt_commenter = readCookie('mt_commenter');
        var commenter_name = readCookie('commenter_name');
		var mt_user;
		var author_name = '';
        if (mt_commenter) {
				mt_user = readCookie('mt_user');
				if (mt_user) {
					author_name = mt_user.replace(/^(.*?)(%3A%3A|::).*$/i, '$1');
				}
               document.write("Hello <b><a href=\"/community/members/" + author_name + "\">"
                        + escape(author_name)
                        + "</a></b> <a href=\"/community/members/\">Edit Profile</a> | <a href=\"/mt/mt-cp.cgi?__mode=logout&return_to="
                        + escape(document.location) + "\">Log Out</a>"
                    );
        } else {
               document.write("<b>You are not logged in.</b> You may <a href=\"/login/index.html?return_to="
                        + escape(document.location) + "\">login</a> or <a href=\"/registration/index.html?return_to="
                        + escape(document.location) + "\">register</a>."
                    );
        }
}
mtlogin();

