here are some valuable javascript functions for getting window width and height a long with the get element X position, and Y position all of this functions are not my invention; its copied from the website and blog listed in the reference list.
lets start with getWindowDimension:

Recent comments
3 days 23 hours ago
1 week 5 days ago
2 weeks 4 hours ago
2 weeks 2 days ago
2 weeks 3 days ago
3 weeks 16 hours ago
3 weeks 16 hours ago
4 weeks 6 days ago
9 weeks 3 days ago
9 weeks 4 days ago