Ok thank you for your answers, but let me clarify what's the problem. I'm making my template using ajax.
Everything works ok, but some components needed the page to be refreshed.
I solved this problem by putting them in iframe and refreshing it's content, but I can't do it for simple-gallery.(when I click on a photo only iframe becomes black, and some photos are too big - so it looks stupid).
What scripts should I include in my template to make simple gallery functioning well, without refreshing the main page.