Thanx, this solved that problem, I still had problems with the function not being defined. I guess when adding script to head at runtime, the onloadmethod does not wait for it.
Anyway, if you do not have any other suggestion I will load the script in all pages created by the CMS, since its so...