/*
 * splashScreen
 *
 * For splash screen used for www.drmarkbarlow.com
 *
 */

function SetUpSplashScreen()
{
  var numCols = 4;
  var numRows = 3;

  var numImages = numCols * numRows;

  var startDelayArray = new Array(numImages);
  var endDelayArray   = new Array(numImages);

  var arrayIndex;

  for ( arrayIndex = 0; arrayIndex < numImages; ++arrayIndex )
  {
    startDelayArray[arrayIndex] =  500 + 50 * arrayIndex + Math.floor(Math.random() * 500);
    endDelayArray[arrayIndex]   = 3000 + 50 * arrayIndex + Math.floor(Math.random() * 500);
  }

  // This hides the splash envelope to enable clicking links that were previously underneath it:
  $("#splashenvelope").delay(6000,function(){
    $("#splashenvelope").hide();
  });

  // This fades out the background black window that covers the screen:
  $("#splashbackground").delay(5500,function(){
    $("#splashbackground").fadeOut("slow");
  });

  $("#splashimage00").delay(startDelayArray[0],function(){
    $("#splashimage00").fadeIn("slow",function(){
      $("#splashimage00").delay(endDelayArray[0],function(){
        $("#splashimage00").fadeOut("slow");
      });
    });
  });

  $("#splashimage10").delay(startDelayArray[1],function(){
    $("#splashimage10").fadeIn("slow",function(){
      $("#splashimage10").delay(endDelayArray[1],function(){
        $("#splashimage10").fadeOut("slow");
      });
    });
  });

  $("#splashimage20").delay(startDelayArray[2],function(){
    $("#splashimage20").fadeIn("slow",function(){
      $("#splashimage20").delay(endDelayArray[2],function(){
        $("#splashimage20").fadeOut("slow");
      });
    });
  });

  $("#splashimage30").delay(startDelayArray[3],function(){
    $("#splashimage30").fadeIn("slow",function(){
      $("#splashimage30").delay(endDelayArray[3],function(){
        $("#splashimage30").fadeOut("slow");
      });
    });
  });

  $("#splashimage01").delay(startDelayArray[4],function(){
    $("#splashimage01").fadeIn("slow",function(){
      $("#splashimage01").delay(endDelayArray[4],function(){
        $("#splashimage01").fadeOut("slow");
      });
    });
  });

  $("#splashimage11").delay(startDelayArray[5],function(){
    $("#splashimage11").fadeIn("slow",function(){
      $("#splashimage11").delay(endDelayArray[5],function(){
        $("#splashimage11").fadeOut("slow");
      });
    });
  });

  $("#splashimage21").delay(startDelayArray[6],function(){
    $("#splashimage21").fadeIn("slow",function(){
      $("#splashimage21").delay(endDelayArray[6],function(){
        $("#splashimage21").fadeOut("slow");
      });
    });
  });

  $("#splashimage31").delay(startDelayArray[7],function(){
    $("#splashimage31").fadeIn("slow",function(){
      $("#splashimage31").delay(endDelayArray[7],function(){
        $("#splashimage31").fadeOut("slow");
      });
    });
  });

  $("#splashimage02").delay(startDelayArray[8],function(){
    $("#splashimage02").fadeIn("slow",function(){
      $("#splashimage02").delay(endDelayArray[8],function(){
        $("#splashimage02").fadeOut("slow");
      });
    });
  });

  $("#splashimage12").delay(startDelayArray[9],function(){
    $("#splashimage12").fadeIn("slow",function(){
      $("#splashimage12").delay(endDelayArray[9],function(){
        $("#splashimage12").fadeOut("slow");
      });
    });
  });

  $("#splashimage22").delay(startDelayArray[10],function(){
    $("#splashimage22").fadeIn("slow",function(){
      $("#splashimage22").delay(endDelayArray[10],function(){
        $("#splashimage22").fadeOut("slow");
      });
    });
  });

  $("#splashimage32").delay(startDelayArray[11],function(){
    $("#splashimage32").fadeIn("slow",function(){
      $("#splashimage32").delay(endDelayArray[11],function(){
        $("#splashimage32").fadeOut("slow");
      });
    });
  });
}
