It's because you are adding the text from php to js, which splits up the lines:
$('div.qa-main').html('This is sample message.
This is the 2nd line.');
This is not kosher in js. A quick way to fix this would be to use:
$final = str_replace("\n",'\\n',qa_opt('msg_before_ask'));
which seems to work.