I\'ve tried searching for a javascript function that will detect if two lines intersect each other.
The function will take the x,y values of both the start end point
First, find intersection coordinates - here it's described in detail: http://www.mathopenref.com/coordintersection.html
Then check if the x-coordinate for intersection falls within the x ranges for one of the lines (or do the same with y-coordinate, if you prefer), i.e. if xIntersection is between lineAp1x and lineAp2x, then they intersect.