How could I increase the topmargin value in my bodytag depending on the screen resolution?

For example if the users res is 8x6 or lower I want topmargin=0. If its 1024 then topmargin=5, 1200 topmargin=10 etc etc

My knowledge of js is zilch so any help would be greatly appreciated!