Why do you have two of the exact same functions just with different names?
Anyways one of your problems is that you are not passing anything to hwnd_owner. This causes a problem because in the code it says hwnd_owner = 1*hwnd_owner;
However when you don't specify anything it is null. So you have two options. Either pass a value to the parameter or add this to the top of the function
jscript code:
if (typeof hwnd_owner === 'undefined') hwnd_owner = 0;