var featureinterval = 5000; /* Time between each rotation */
var featuretimerid = 0;
var tStart  = null;
var initialized = false; /* Is necessary variables initialized? */
var visibleindex = 0; /* Index in rotateelems (declared below) of the current visible element */

/* The following variables should be assigned proper values in a function named initVariables() */
var rotateelems = null; /* The elements that should be rotated */
var visibledisplay = ""; /* display value for elements in visible state */


/* Initialize variables for rotation */
function initVariables(){
    rootelem = document.getElementById("location13");
    rotateelems = rootelem.getElementsByTagName("td");
    visibledisplay = "table-cell";
}

/* Hide rotatable elements except the current/first */
function hideElems(rotateelems, visibleindex){
    for(i=0; i<rotateelems.length; i++){
        if (i != visibleindex){
            rotateelems[i].style.display = "none";
        }
    }
}

/* call this once at beginning of rotation to initialize variables and hide non-visible elements */
function initialize(){
  initVariables();
  hideElems(rotateelems, visibleindex);
  initialized = true;
}


function FeatureTimer() {
  if (featuretimerid) {
      clearTimeout(featuretimerid);
  }
	rotate();
	featuretimerid = setTimeout("FeatureTimer()", featureinterval);
}

function Start() {
	rotate();
	featuretimerid  = setTimeout("FeatureTimer()", featureinterval);
}

function rotate() {
    /* Make sure init function has been called before proceeding */
    if (!initialized){
        initialize();
    }
    current = rotateelems[visibleindex];
    if (visibleindex >= rotateelems.length-1){
        visibleindex = 0;
    }
    else{
        visibleindex += 1;
    }
    next = rotateelems[visibleindex];
    current.style.display = "none";
    try{
      next.style.display = visibledisplay;
    } catch(e) {
      /* Some browsers (IE) do not understand all possible display values. Empty string works fairly well then. */
      next.style.display = "";
    }
}





