Adding Image using javascript
I looked in CRM.config to see if there was a helpful variable, but there isn't.  I think you need to add this variable via PHP.

From the CiviCRM Javascript Reference on Server-Side Variables:

In PHP:

$config = CRM_Core_Config::singleton();
CRM_Core_Resources::singleton()-&gt;addVars('myNamespace', array('extensionsUrl' =&gt; $config-&gt;extensionsURL));


In JS:

src = CRM.vars.myNamespace.extensionsUrl + "/images/myimg.png"