
/* Script taken from http://www.leemessenger.co.uk - Please do not remove this line */
function ChangeCSSBgImg() {
	if (!document.getElementById) return false;
	
	var MyElement = "wrapper2" //The ID of the element you want to change
	// var ImgPath = "/clients/studioTOTA/rhg/tomoko/imgs/side_images/"; //The file path to your images
	var ImgPath = "/imgs/side_images/"; //The file path to your images	
	
	if (!document.getElementById(MyElement)) return false;
	
	var random_images_num = 29;
	
	var $header = document.getElementById(MyElement);
	var $backgroundurl = $header.style.backgroundImage;
	var rand_num = rand(random_images_num)+1;
	var num_prefix ="";
	if (rand_num < 10)
		num_prefix = "0";
	
	var ImgURL = "url(" + ImgPath + "side"+num_prefix+rand_num + ".jpg)";
	
	if ($backgroundurl != ImgURL) {
		$header.style.backgroundImage = ImgURL;	
	}	
}

/* 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);