// JavaScript Document
/* ################################ GENERIC RANDOM BACKGROUND IMAGE ############################## */
/* This function changes the background image of the header, if no Javascript leaves the default in */
function ChangeCSSBgImg() {
	if (!document.getElementById) return false;
	
	var MyElement = "topinfowrap" //The ID of the element you want to change
	var ImgPath = "http://www.bowen-therapy.co/Bowen/images/header-img/" //The file path to your images
	
	if (!document.getElementById(MyElement)) return false;
	
	var random_images = new Array ();
	random_images[0] = "header1i.png";
	random_images[1] = "header2i.png";
	random_images[2] = "header3i.png";
	random_images[3] = "header4i.png";
	random_images[4] = "header5i.png";
	random_images[5] = "header6i.png";
	random_images[6] = "header7i.png";
	random_images[7] = "header8i.png";
	random_images[8] = "header9i.png";
	random_images[9] = "header10i.png";
	random_images[10] = "header11i.png";
	random_images[11] = "header12i.png";
	random_images[12] = "header13i.png";
	random_images[13] = "header14i.png";
	random_images[14] = "header15i.png";
	random_images[15] = "header16i.png";
	random_images[16] = "header17i.png";
	random_images[17] = "header18i.png";
	random_images[18] = "header19i.png";
	random_images[19] = "header20i.png";
	random_images[20] = "header21i.png";
	random_images[21] = "header22i.png";
	random_images[22] = "header23i.png";
	random_images[23] = "header24i.png";
	random_images[24] = "header25i.png";
	random_images[25] = "header26i.png";
	

	
	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()",10000);
}

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