(for this message, whenever I put "*", replace it by a "?" ... I can't write it the right way, else it treats it as php)
ok assuming your page you are linking to is called
www.domain.com/redir.php
you'd link to it like
www.domain.com/redir.php?id=magnatique
then, on that redir.php page you'd have
if (screen.width >= 1024)
{window.location.href='girls1024.php?id=<* echo $id;*>'}
else if (screen.width >= 800)
{window.location.href='girls800.php?id=<* echo $id;*>'}
else
{window.location.href='girls640.php?id=<* echo $id;*>'}