var coord = -1125;

$(document).ready(function() {

	setTimeout("shake()", 2000);
});

function reveal()
{
	setTimeout("moreCrack(coord)", 200);
}

function shake()
{
	coord = coord + 50;
	if(coord < -125)
	{
		$("#crack").effect("shake", {distance: 1}, 40, reveal);
		$("#error_code").effect("bounce", {distance: 5}, 50);
		$("#error_status").effect("pulsate", {times: 2}, 50);
	} else {
	
		$("#crack_overlay").hide();	
	
	}
}

function randomXToY(minVal,maxVal,floatVal)
{
  var randVal = minVal+(Math.random()*(maxVal-minVal));
  return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}

function moreCrack(coord)
{
	$("#crack_overlay").animate({backgroundPosition:"(0 " + coord + ")"});
	setTimeout("shake()", randomXToY(3500, 5000));
}