// JavaScript Document

// when the DOM is ready
$(function () {
var totalNum = 6; var rndNum = Math.floor(Math.random() * totalNum); 
var img = new Image();

			// checks for IE6 and runs GIF routine
		
    if(!window.XMLHttpRequest) {
        $(img)
    // once the image has loaded, execute this code
    .load(function () {
      // set the image hidden by default    
      $(this).hide();
    
      // with the holding div #loader, apply:
      $('#leftpicbg')
        // remove the loading class (so no background spinner), 
        .removeClass('loading')
        // then insert our image
        .append(this);
    
      // fade our image in to create a nice effect
      $(this).fadeIn().addClass("leftimg");
    })
    
    // if there was an error loading the image, react accordingly
    .error(function () {
      $(this).attr("src", "images/leftpic0.gif");
    })
    
    // *finally*, set the src attribute of the new image to our image
    .attr("src", "images/leftpic" + rndNum + ".gif");
	

}
    else // ok to continue

  // wrap our new image in jQuery, then:
  $(img)
    // once the image has loaded, execute this code
    .load(function () {
      // set the image hidden by default    
      $(this).hide();
    
      // with the holding div #loader, apply:
      $('#leftpicbg')
        // remove the loading class (so no background spinner), 
        .removeClass('loading')
        // then insert our image
        .append(this);
    
      // fade our image in to create a nice effect
      $(this).fadeIn().addClass("leftimg");
    })
    
    // if there was an error loading the image, react accordingly
    .error(function () {
      $(this).attr("src", "images/leftpic0.png");
    })
    
    // *finally*, set the src attribute of the new image to our image
    .attr("src", "images/leftpic" + rndNum + ".png");
	
});
