It could be. It is using whatever was passed to it as cDay. That could have happened on the original document. By the way, what do you mean by "original document"? Is that the page that is using this external file?
In any case the calcMAge function expects to be given a valid Date Object which it then processes internally as cDay, and appears to use that to return the "Age of the Moon" on that date.
So to get the current "Age of the Moon", one could do:
Code:
alert(calcMAge(new Date()));
If you had some other date in mind - say, May 1st 1960, one could do:
Code:
alert(calcMAge(new Date(1960, 4, 1)));
or:
Code:
alert(calcMAge(new Date("5/1/1960")));
or:
Code:
alert(calcMAge(new Date("May 1 1960")));
Again though, I cannot tell where or how it's messing up without seeing the page where this is a problem.
But it looks like the calcMAge function is OK at least (I won't vouch for its accuracy, simply that it appears workable* if fed a valid Date Object), so now it's most likely the problem is that it's being fed faulty data - something other than a Date Object.
If you want more help, please post a link to the page on your site that contains the problematic code so we can check it out.
*However, it appears to require the assistance of two other functions (normalize** and roundValue), which are not native functions in javascript. Hopefully these are available to it, otherwise it will not function.
**normalize is a native javascript function, but not as it's used here.
Bookmarks