function drawLightning(x1,y1,x2,y2,displace)
{
if (displace < curDetail) {
graf.moveTo(x1,y1);
graf.lineTo(x2,y2);
}
else {
var mid_x = (x2+x1)/2;
var mid_y = (y2+y1)/2;
mid_x += (Math.random()-.5)*displace;
mid_y += (Math.random()-.5)*displace;
drawLightning(x1,y1,mid_x,mid_y,displace/2);
drawLightning(x2,y2,mid_x,mid_y,displace/2);
}
}