// Image with caption banner rotator
// written by: Lars Michael Astrom
// A3 IT Solutions
var imgCur = 0; // should be 0, since we start on the first image
var capCur = 0; // should be 0, since we start on the first caption
var imgNum = 16; // number of images
var capNum = 16; // number of captions
var imgSpeed = 4000; // # of milliseconds between images
var capSpeed = 4000; // # of milliseconds between captions

var dynImg = "banner" // id of the image to change
dynImg = document.getElementById(dynImg);
var capsDiv = "bannerText" // set id of caption layer
capsDiv = document.getElementById(capsDiv);

var imgs = new Array(imgNum); // declares image array
// Add images to the array; can easily be made dynamic
imgs[0] = "/images/header/banners/McNeilly.jpg";
imgs[1] = "/images/header/banners/NDI.jpg";
imgs[2] = "/images/header/banners/Tritter.jpg";
imgs[3] = "/images/header/banners/bigFish.jpg";
imgs[4] = "/images/header/banners/BDI.jpg";
imgs[5] = "/images/header/banners/Shilling.jpg";
imgs[6] = "/images/header/banners/Chinawind.jpg";
imgs[7] = "/images/header/banners/ancientMosiac.jpg";
imgs[8] = "/images/header/banners/Trextillery.jpg";
imgs[9] = "/images/header/banners/euroStyle.jpg";
imgs[10] = "/images/header/banners/Artesia.jpg";
imgs[11] = "/images/header/banners/Currey.jpg";
imgs[12] = "/images/header/banners/Hammer.jpg";
imgs[13] = "/images/header/banners/Wunderley.jpg";
imgs[14] = "/images/header/banners/Skovby.jpg";
imgs[15] = "/images/header/banners/Seasonal.jpg";


var caps = new Array(capNum); // declares caption array
// Add images to the array; can easily be made dynamic
caps[0] = "[made-at-home comfort]";
caps[1] = "[rich and rosy]";
caps[2] = "[simple elegance]";
caps[3] = "[winged wall art]";
caps[4] = "[masterfully modern]";
caps[5] = "[daring curves]";
caps[6] = "[exotic expressions]";
caps[7] = "[outdoor opulence]";
caps[8] = "[easy-care and cozy]";
caps[9] = "[function with flair]";
caps[10] = "[rustic charm]";
caps[11] = "[luxe lighting]";
caps[12] = "[modules with moxy]";
caps[13] = "[accents with attitude]";
caps[14] = "[intelligent minimalist]";
caps[15] = "[bright designs]";

// start the timers
var t = setTimeout("nextImg()",imgSpeed);
var q = setTimeout("nextCap()",capSpeed);

 // displays the next image
function nextImg(){
  if (imgCur < imgNum - 1){
    imgCur += 1;
    changeImg(imgCur);
  }else{
    imgCur = 0;
    changeImg(imgCur);
  }
  
  // continue cycling through banners
  t = setTimeout("nextImg()",imgSpeed);
}

// displays the next caption
function nextCap(){
  if (capCur < capNum - 1){
    capCur += 1;
    changeCaps(capCur);
  }else{
    capCur = 0;
    changeCaps(capCur);
  }
  
  // continue cycling through banners
  q = setTimeout("nextCap()",capSpeed);
}

// changes image
function changeImg(changeTo){
  dynImg.src = imgs[changeTo];
}

// change caption
function changeCaps(changeTo){
  capsDiv.innerHTML = caps[changeTo];
}
