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
2 weeks 17 hours ago
15 weeks 5 days ago
16 weeks 12 hours ago
16 weeks 12 hours ago
27 weeks 3 days ago
31 weeks 4 days ago
32 weeks 5 days ago
1 year 2 days ago
1 year 2 days ago
1 year 4 weeks ago