// 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 = "headerBG" //The ID of the element you want to change
	var ImgPath = "images/general/headerBG/" //The file path to your images
	
	if (!document.getElementById(MyElement)) return false;
	
	var random_images = new Array ();
	random_images[0] = "1.jpg";
	random_images[1] = "2.jpg";
	random_images[2] = "3.jpg";
	random_images[3] = "4.jpg";
	random_images[4] = "5.jpg";
	random_images[5] = "6.jpg";
	
	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;	
	}
	
        //Uncomment the line below to allow for random rotating image
	//movement = setTimeout("ChangeCSSBgImg()",5000);
}

/* 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);