actually i have tried your script, and it works properly but when i combine it with .xml, the script will work once I resize the window. any solution about it?

to make it clear please download...