It may be because you are missing the Quote while declaring the javascript event. Can you try something like this?
out.print("<button type=\"button\" onclick='javascript:return friendnamebtn(this)' id=\"btn_friends\">");
function friendnamebtn(sender)
{
return false;
}