--When in Safari, the coordinates {0,0} refer to the upper corner *not* including the menubar.
tell application "Safari"
-- For some reason Safari has two invisible windows
set allWindows to (every window where visible is true)
set n to count of allWindows
-- Determine screen size of your machine
tell application "Finder"
set screenSize to bounds of window of desktop
set screenWidth to item 3 of screenSize
set screenHeight to item 4 of screenSize
end tell
-- Dividing by zero is bad
if n is equal to 0 then return
set windowWidth to screenWidth / n
if (n > 0) then
activate
set x to 1
-- Position each window in turn
repeat
tell window x
set bounds to {windowWidth * (x - 1), 0, windowWidth * x, screenHeight}
end tell
set x to x + 1
if x is equal to (n + 1) then exit repeat
end repeat
end if
end tell