Please see my comments to the question: the whole approach looks very questionable to me, due to the reasons I tried to explain in my comments.
I can explain the idea of introduction of "namespacing" in Javascript, maybe it can help you at this time or in future.
For example, you have two functions:
oneAction
and
anotherAction
, and imagine that eventually you need different versions of them. Consider this script:
<script>
firstNamespace = {
oneAction: function() {
alert("one action 1");
},
anotherAction: function() {
alert("another action 1");
}
};
secondNamespace = {
oneAction: function() {
alert("one action 2");
},
anotherAction: function() {
alert("another action 2");
}
};
firstNamespace.oneAction();
secondNamespace.oneAction();
firstNamespace.anotherAction();
secondNamespace.anotherAction();
</script>
You got proper isolation of some set of functions. In principle, you can do something similar to a big set of Javascript instructions (here, you need to understand that declarations in Javascript are no different from some instructions, they are created during runtime), a whole library. The technique I demonstrated is the most basics, there are different refinements of the idea.
Please see:
http://addyosmani.com/blog/essential-js-namespacing[
^],
http://javascriptweblog.wordpress.com/2010/12/07/namespacing-in-javascript[
^],
http://thanpol.as/javascript/development-using-namespaces[
^],
Namespaces in JavaScript[
^].
—SA