// JavaScript Document

var BGImgIndex = 0

/* Script taken from http://www.leemessenger.co.uk - Please do not remove this line */
function ChangeCSSBgImg() {
    if (!document.getElementById) return false;
    
    var MyElement = "box8full" //The ID of the element you want to change
    var ImgPath = "assets/images/backgrounds/" //The file path to your images
    
    if (!document.getElementById(MyElement)) return false;
    
    var random_images = new Array ();
	random_images[0] = "travel-agents-insurance-full-1.jpg"; // Don't forget to increase the array number each time
	random_images[1] = "travel-agents-insurance-full-2.jpg"; 
	random_images[2] = "travel-agents-insurance-full-3.jpg"; 

    var $header = document.getElementById(MyElement);

    var $backgroundurl = $header.style.backgroundImage;
    var ImgURL = "url(" + ImgPath + random_images[BGImgIndex] + ")";

    
    if ($backgroundurl != ImgURL) {
        $header.style.backgroundImage = ImgURL;    
    }
    
    BGImgIndex++
    if(BGImgIndex==random_images.length) {BGImgIndex=0}

    movement = setTimeout("ChangeCSSBgImg()",4000);
}

/* 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);