// JavaScript Document
/* Script taken from http://www.leemessenger.co.uk - Please do not remove this line */
function ChangeCSSBgImg() {
	if (!document.getElementById) return false;
	
	var MyElement = "wrapper" //The ID of the element you want to change
	var ImgPath = "assets/backgrounds/" //The file path to your images
	
	if (!document.getElementById(MyElement)) return false;
	
	var random_images = new Array ();
	random_images[0] = "bg01.jpg";
	random_images[1] = "bg02.jpg";
	random_images[2] = "bg03.jpg";
	random_images[3] = "bg04.jpg";
	random_images[4] = "bg05.jpg";
	random_images[5] = "bg06.jpg";
	random_images[6] = "bg07.jpg";
	random_images[7] = "bg08.jpg";
	random_images[8] = "bg09.jpg";
	random_images[9] = "bg09.jpg";
	random_images[10] = "bg10.jpg";
	random_images[11] = "bg12.jpg";
	random_images[12] = "bg13.jpg";
	random_images[13] = "bg14.jpg";
	random_images[14] = "bg15.jpg";// Don't forget to increase the array number each time
	
	var $header = document.getElementById(MyElement);
	var $backgroundurl = $header.style.backgroundImage;
	var ImgURL = "url(" + ImgPath + random_images[rand(random_images.length)] + ")";
	
	if ($backgroundurl != ImgURL) {
		$header.style.backgroundImage = ImgURL;	
	}
	
//	movement = setTimeout("ChangeCSSBgImg()",28000); // Initially 14000
}

/* random number generator */
function rand(n) {
  return ( Math.floor ( Math.random ( ) * n ) );
}

/* Custom onload function */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
/* trigger onload */
addLoadEvent(ChangeCSSBgImg);