Sofia, I need a little more information here in order to try to figure out if there is something we can do here. I did want to point out to you that the OnOpen trigger is an unsupported trigger in the Ajax Client, this is documented in the following Help link:
Just off the top of my head, I am thinking the better way to go at this may be to set a variable in the script and then use the variable to set the date etc... My post will kick this back up in the list, so someone else may have something better, but I think that is going to potentially be the better way to go here, but I do not have an example for you. If you have not searched the prior posts, you may want to do that, as I am pretty sure there are other posts out there along these lines too. I would do it for you, but you know your use case better than do I, so I will let you have a look to see what you can find, and if you do find something but have further questions, just post that link back here and pose your question and hopefully one of can try to help you further.
To help users find verified answers, please don't forget to use the "Accept as Solution" button on any posts that helped you resolve your problem or question.