Il loop l'ho tolto scrivendo
if (screen.width < 1024 || f.res.value = "1024")
con un solo uguale...
ma non mi funziona lo stesso... (