Capturing Mouse Clicks

The first JavaScript function getPoints(event) captures four clicks.

It captures the x value of the first click, the y value of the second, and so on. (I was using it to pick points for clipping an image.)
The second function pass4Points() writes a form which will pass these JavaScript variables on to a PHP program on the server. The second function was activated with a double click.
<head>
<script type="text/javascript">
var click=new Array(0,0,0,0);
var step=0;

function getPoints(event)
{
if (step/2==0)
  click[step]=event.clientX;
else if (step/2!=0)
  click[step]=event.clientY;
step++;
if (step >=4)
  step=0;
return click;
}

function pass4Points()
{
document.write('<form method="POST" action="copySmaller2.php">');
document.write('<input type="text" name="y1" value="',click[0],'">');
document.write('<input type="text" name="x2" value="',click[1],'">');

document.write('<input type="text" name="y2" value="',click[2],'">');
document.write('<input type="text" name="x1" value="',click[3],'">');
document.write('');
document.write('<input type="submit" value="Submit Coordinates">');
document.write('</form>');
}
</script> </head> <body onDblClick="pass4Points()">