function initialCookie() {
  var expires = new Date();
	var days = 1
	var randomNum = 13 //Math.floor((Math.random() * 18)); // Random number between 0 and 17
	expires.setTime(expires.getTime()+(days*24*60*60*1000));
	var cookie_string = "background" + "=" + "background" + randomNum +"; expires=" + expires; // Set variable for cookie
	document.cookie = cookie_string;
}

// Function for setting random background image and cookie
function setCookie() {
  var expires = new Date();
	var days = 1
	var randomNum = Math.floor((Math.random() * 18)); // Random number between 0 and 18
	expires.setTime(expires.getTime()+(days*24*60*60*1000));
	var cookie_string = "background" + "=" + "background" + randomNum +"; expires=" + expires; // Set variable for cookie
	document.cookie = cookie_string;
	var randomBody = document.getElementById("wrapper2").style // Get main content element.
  randomBody.backgroundImage="URL('images/backgrounds/image" + randomNum + ".jpg')"; // Set background image.
}

// Function for retrieving image information from cookie and setting background
// of other pages in site.
function retrieveCookie() {
  var cookieValue = document.cookie.split(";")[0] // Retrieve value of image from cookie.
	if (cookieValue.length == 23) { // Check length of cookie.
	// Use substring to remove the background name from the cookie.
	// If background name is 12 characters e.g. background10, then set variable cookieValue 
	cookieValue = cookieValue.substr(11,12); 
	// If background name is 11 characters e.g. background1, then set variable cookieValue
	} else {
	cookieValue = cookieValue.substr(11,11);
	}
  var backImage = "images/backgrounds/" + cookieValue + ".jpg"; // Set variable of image string.
  var randomBody = document.getElementById("wrapper").style // Get main content element.
  randomBody.backgroundImage="URL(" + backImage + ")"; // Set background image.
}