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 6 days ago
16 weeks 4 days ago
16 weeks 6 days ago
16 weeks 6 days ago
28 weeks 2 days ago
32 weeks 3 days ago
33 weeks 4 days ago
1 year 1 week ago
1 year 1 week ago
1 year 5 weeks ago