Centroid and JavaScript