Classic Multidimensional scaling code in Javascript