var my_imgs = new Array();
var my_imgs_text = new Array();
var my_imgs_alt = new Array();
var the_controls = new Array();

/* Set as 1 to turn the timer on, 0 (or anything else) to turn off
   and have user controls only */
var timer_set = 0;

/* Set timer interval (in milliseconds) */
var timer_intv = 2000;

/* Set image URLs */
my_imgs[0] = "http://myweb.loras.edu/loras/featurestory/obrian/image1.jpg";
my_imgs[1] = "http://myweb.loras.edu/loras/featurestory/obrian/image2.jpg";
my_imgs[2] = "http://myweb.loras.edu/loras/featurestory/obrian/image3.jpg";
my_imgs[3] = "http://myweb.loras.edu/loras/featurestory/obrian/image4.jpg";
my_imgs[4] = "http://myweb.loras.edu/loras/featurestory/obrian/image5.jpg";
my_imgs[5] = "http://myweb.loras.edu/loras/featurestory/obrian/image6.jpg";
my_imgs[6] = "http://myweb.loras.edu/loras/featurestory/obrian/image7.jpg";
my_imgs[7] = "http://myweb.loras.edu/loras/featurestory/obrian/image8.jpg";
my_imgs[8] = "http://myweb.loras.edu/loras/featurestory/obrian/image9.jpg";
my_imgs[9] = "http://myweb.loras.edu/loras/featurestory/obrian/image10.jpg";

/* Set text to display under each image */
my_imgs_text[0] = "Spain highlight Photos";
my_imgs_text[1] = "Spain highlight Photos";
my_imgs_text[2] = "Spain highlight Photos";
my_imgs_text[3] = "Spain highlight Photos";
my_imgs_text[4] = "Spain highlight Photos";
my_imgs_text[5] = "Spain highlight Photos";
my_imgs_text[6] = "Spain highlight Photos";
my_imgs_text[7] = "Spain highlight Photos";
my_imgs_text[8] = "Spain highlight Photos";
my_imgs_text[9] = "Spain highlight Photos";

/* Set alt text for each image */
my_imgs_alt[0] = "highlight Photos";
my_imgs_alt[1] = "Image2";
my_imgs_alt[2] = "Image3";
my_imgs_alt[3] = "Image4";
my_imgs_alt[4] = "Image5";
my_imgs_alt[5] = "Image6";
my_imgs_alt[6] = "Image7";
my_imgs_alt[7] = "Image8";
my_imgs_alt[8] = "Image9";
my_imgs_alt[9] = "Image10";


if (document.getElementById && document.createTextNode) {

  var slide_div = document.getElementById("slide_show");
  var my_controls = document.getElementsByTagName("input");
  
  for (var a=0; a<my_controls.length; a++) {
    if (my_controls[a].className == "controls") {
	  the_controls.push(my_controls[a]);
    }
  }
  
  var slide_count = 0;
  var keep_going = 1;
  var slide_HTML = "";
  
  function change_slide() {
    slide_count +=1;
	if (slide_count >= my_imgs.length) {
		slide_count = 0;
	}
	slide_HTML = "<img src=\""+my_imgs[slide_count]+"\" class=\"flip\"";
	slide_HTML += " alt=\""+my_imgs_alt[slide_count]+"\" /><br />";
	slide_HTML += my_imgs_alt[slide_count];
	slide_div.innerHTML = slide_HTML;
	keep_going = setTimeout("change_slide()",timer_intv);
  }
  
  if (timer_set == 1) {
    setTimeout("change_slide()",timer_intv);	
  }
  
  
  function pause_slide() {
	if (keep_going != 1) {
	  clearTimeout(keep_going);
	}
  }
  
  function g_back() {
	if (keep_going != 1) {
      clearTimeout(keep_going);
	}
	slide_count -=1;
	if (slide_count < 0) {
	    slide_count = my_imgs.length - 1;
	}
	slide_HTML = "<img src=\""+my_imgs[slide_count]+"\" class=\"flip\"";
	slide_HTML += " alt=\""+my_imgs_alt[slide_count]+"\" /><br />";
	slide_HTML += my_imgs_alt[slide_count];
	slide_div.innerHTML = slide_HTML;
  }
  
  function g_forward() {
	if (keep_going != 1) {  
	  clearTimeout(keep_going);
	}
	slide_count +=1;
	if (slide_count >= my_imgs.length) {
		slide_count = 0;
	}
	slide_HTML = "<img src=\""+my_imgs[slide_count]+"\" class=\"flip\"";
	slide_HTML += " alt=\""+my_imgs_alt[slide_count]+"\" /><br />";
	slide_HTML += my_imgs_alt[slide_count];
	slide_div.innerHTML = slide_HTML;
  }
  
  function r_start() {
	keep_going = setTimeout("change_slide()",timer_intv); 
  }
  
  function newEvent(c) {
    
    function which_func() {
	  var the_id = the_controls[c].id;
	  if (the_id == "goback"){
	    g_back();
	  }
	  if (the_id == "pause_slide"){
	    pause_slide();
	  }
	  if (the_id == "goforward"){
	    g_forward();
	  }
	  if (the_id == "restart"){
	    r_start();
	  }
	}
	  
    if (typeof the_controls[c].addEventListener != "undefined") {	
      the_controls[c].addEventListener("click", which_func, false);
    }

    else if (typeof the_controls[c].attachEvent != "undefined" ) {
      the_controls[c].attachEvent("onclick", which_func );
    }

    else {
      the_controls[c].onclick = which_func;
    }
	
  }
  
  for (var d=0; d<the_controls.length; d++) {
    newEvent(d);
  }
  
} 