There are a few javascript files which you want to call, like json2.js file and probably jquery.js file.
I couldn’t understand initially how you to call another Javascript file from within my javascript file.
The actual answer was quite obvious after I worked it out.
you have to import the Javascript file as a webresource. This won’t mean you will be able to access it because you also have to make sure you select the file in the form properties and then Add it in the form libraries.
What this means is when the form loads, it will also load the javascript file. Once it is loaded you can then call the functions on the form.
I only worked this out because I added the other Javascript file and when I was debugging I could then see all of the Javascript files I had loaded.