Every time you want to use a single-quote, use a \ before it. In javascript \ is the escape character, it allows you to escape the functionality of the single quote.
\'
Example:
document.write('<a href="javascript: popup(\'http://google.com\');">Google</a>');