JavaScript: SkyLine Problem