// 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 = 14; // number of images
var capNum = 14; // 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/fiermac.jpg"; 
imgs[1] = "/images/header/banners/prestige.jpg"; 
imgs[2] = "/images/header/banners/chinawind.jpg";
imgs[3] = "/images/header/banners/artesia.jpg";
imgs[4] = "/images/header/banners/artimage.jpg";
imgs[5] = "/images/header/banners/sunpan.jpg";
imgs[6] = "/images/header/banners/palecek.jpg";
imgs[7] = "/images/header/banners/classichome.jpg";
imgs[8] = "/images/header/banners/green.jpg";
imgs[9] = "/images/header/banners/barbara.jpg";
imgs[10] = "/images/header/banners/stevenshell.jpg";
imgs[11] = "/images/header/banners/burton.jpg";
imgs[12] = "/images/header/banners/french.jpg";
imgs[13] = "/images/header/banners/natural.jpg";
imgs[14] = "/images/header/banners/wunderley.jpg";
imgs[15] = "/images/header/banners/naturalLight.jpg";
imgs[16] = "/images/header/banners/homeTrends.jpg";
var caps = new Array(capNum); // declares caption array
// Add images to the array; can easily be made dynamic
caps[0] = "[elegant dining]";
caps[1] = "[nature-inspired art]";
caps[2] = "[old-world artistry]";
caps[3] = "[recycled teak]";
caps[4] = "[artful expressions]";
caps[5] = "[upholstery with flair]";
caps[6] = "[unexpected materials]";
caps[7] = "[reclaimed history]";
caps[8] = "[serene bedrooms]";
caps[9] = "[lamps with a twist]";
caps[10] = "[fantastical furnishings]";
caps[11] = "[luxurious beds]";
caps[12] = "[style, on the side]";
caps[13] = "[natural beauty]";
caps[14] = "[dazzling lighting]";
caps[15] = "[sights for sore eyes]";
caps[16] = "[industrial chic]";

// 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];
}