code: function(x1, y1, x2, y2, px, py)
      {
  		x2 -= x1;
  		y2 -= y1;
  
  		px -= x1;
  		py -= y1;
  
  		var dotprod = px * x2 + py * y2;
  		var projlenSq;
  
  		if (dotprod <= 0.0)
  		{
  		    projlenSq = 0.0;
  		}
  		else
  		{
  		    px = x2 - px;
  		    py = y2 - py;
  		    dotprod = px * x2 + py * y2;
  
  		    if (dotprod <= 0.0)
  		    {
  				projlenSq = 0.0;
  		    }
  		    else
  		    {
  				projlenSq = dotprod * dotprod / (x2 * x2 + y2 * y2);
  		    }
  		}
  
  		var lenSq = px * px + py * py - projlenSq;
  		
  		if (lenSq < 0)
  		{
  		    lenSq = 0;
  		}
  		
  		return lenSq;
      }
docs: Function: ptSegDistSq
  
  Returns the square distance between a segment and a point. To get the
  distance between a point and a line (with infinite length) use
  <mxUtils.ptLineDist>.
  
  Parameters:
  
  x1 - X-coordinate of the startpoint of the segment.
  y1 - Y-coordinate of the startpoint of the segment.
  x2 - X-coordinate of the endpoint of the segment.
  y2 - Y-coordinate of the endpoint of the segment.
  px - X-coordinate of the point.
  py - Y-coordinate of the point.