I'm still not sure I understand how to determine a random occurrence.
Are you asking to set the even/odd (1/2) value for a particular day and then continue from there with the display?
I guess you could change this line only to alter the display from the current 'dayNum'
from: str += (dayNum % 2)+1;
to: str += ((dayNum+1) % 2)+1;
Since you only have two choices (1/2), then you would change it when the 'random' occurrence occurred.
Only other suggestions would be:
1. to pass a parameter to the program like:
when it snowed and then
when you wanted to go back into the original sequence
using the 'daySetting' as the adjustment value for the str = ((dayNum+daySetting) % 2) +1;
2. read from a .php programs as you proposed, but I don't know anything about php programs. I would not be much of a help here.
3. read a variable from a file with an AJAX function. Use that variable as in suggestion #1.
Bottom line: I know it can be done, I just don't know how you want to go about it and how often it would be required.
If it only changes once or twice (randomly) per year, then I would just modify the script directly in the one line.
If it happens on a more frequent basis, then passing a parameter might be the better route.
If you need more than two selections (1/2), you could also do that with the script
(up to 1-7 times before it cycled back to the original),
but you would have the same problems with your random occurrences.