//This code originated from http://www.javascriptcity.com/scripts/img/simage4.htm and was modified to suit the purposes of the home page

var my_imgs = new Array();
var my_imgs_link = 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 = 1;

/* Set timer interval (in milliseconds) */
var timer_intv = 3500;

/* Set image URLs */

my_imgs[0] = "/support/graphics/announcements/mexico.jpg";
my_imgs[1] = "/support/graphics/announcements/academicprogramsearch.gif";
my_imgs[2] = "/support/graphics/announcements/cusco.jpg";
my_imgs[3] = "/support/graphics/announcements/olympicbanner.jpg";

my_imgs_link[0] = "/programs/document/featureMexico";
my_imgs_link[1] = "/programs/programSearch";
my_imgs_link[2] = "/programs/document/featureCusco";
my_imgs_link[3] = "/programs/document/featureOlympic";

/* my_imgs_text[0] = "<div class=\"slide_text_box_container\"><div class=\"slide_1_headline\">ISA HAS MOVED!</div><br /><br /><div class=\"slide_1_text\">Beginning August 6th, ISA will be officially moved in! All phone numbers and email addresses will remain the same, but please note our new address: 1112 West Ben White Boulevard Austin, TX 78704 <br /><br /><a href=\"/programs/document/featureISA_moving\">Click here</a> to see a few shots of the new office!</div></div><div class=\"slide_tagline\">The World Awaits...</div>"; */

/* for italics use 

my_imgs_text[0] = "<div class=\"slide_text_box_container\"><div class=\"slide_1_headline\"><div class=\"slide_1_headline_portuguese\">ISA has extended many of our Winter/Spring 2010deadlines to Friday, October 16th!</div></div><br/><br/><br/><div class=\"slide_2_text\">  </div><br /><br /><div class=\"slide_2_text\"> Please <a href=\"/programs/document/featureDueDates\">click here</a> to find out what programs have been extended!</a></div><div class=\"slide_tagline\">The World Awaits...</div>";
*/



my_imgs_text[0] = "<div class=\"slide_text_box_container\"><div class=\"slide_1_headline\">Get to know your neighbor, </div><div class=\"slide_1_text\">study abroad in Mexico with ISA!<a href=\"/programs/document/featureMexico\"><br /><br /><br />Click here</a> to begin your journey. <br /><br /></div></div><div class=\"slide_tagline\">The World Awaits...</div>";

my_imgs_text[1] = "<div class=\"slide_text_box_container\"><div class=\"slide_3_headline\">A whole new way to find the perfect program!</div><div class=\"slide_3_text\" style=\"font-size:8pt;padding-top:10px;\">ISA has launched the Academic Program Search tool to help you find a study abroad program that best matches your academic goals and destination interests! <br/><br/>Search by <ul id='white'><li>Subject</li><li>Country</li><li>Language</li><li>Term</li></ul> <a href=\"/programs/programSearch\">Click here</a> to begin your search </div></div> <div class=\"slide_tagline\">The World Awaits...</div>";

my_imgs_text[2] = "<div class=\"slide_text_box_container\"><div class=\"slide_1_headline\">ELAP offers an exciting new volunteer program in Cusco, Peru this winter!</div><br /><br /><br /><div class=\"slide_1_text\"><br /><br /><a href=\"/programs/document/featureCusco\">Click here</a> for more information.<br /><br /></div></div><div class=\"slide_tagline\">The World Awaits...</div>";

my_imgs_text[3] = "<div class=\"slide_text_box_container\"><div class=\"slide_1_headline\">Explore future olympic host countries!</div><br /><div class=\"slide_1_text\"><br /><br /><a href=\"/programs/document/featureLondon\">Click here</a> to learn more about ISA's England programs.<br /><br /><a href=\"/programs/document/featureFlorianopolis\">Click here</a> to learn more about ISA's programs in Florianopolis, Brazil. <br /></div></div><div class=\"slide_tagline\">The World Awaits...</div>";




/* Set alt text for each image */
my_imgs_alt[0] = "Academic Program Search";
my_imgs_alt[1] = "Top 5 reasons to study in Mexico with ISA";
my_imgs_alt[2] = "Elap offers an exciting new volunteer program in Cusco";
my_imgs_alt[3] = "Explore future olympic host countries!";


if (document.getElementById && document.createTextNode) {

  var slide_div = document.getElementById("slide_show");
  var slide_text_div = document.getElementById("slide_text");
//  var slide_control_div = document.getElementById("user_controls");
  var play_pause = document.getElementById("play_pause");
  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 = "";
  var is_paused = 0;

  function newHTML(index)
  {
	if(my_imgs_link[index] == undefined) {
		return "<image style=\"display: block;padding: 0;\" src=\""+my_imgs[index]+"\" class=\"flip\" alt=\""+my_imgs_alt[index]+"\"></image>";
	} else {
		return "<a href=\""+my_imgs_link[index]+"\"><image style=\"display: block;padding: 0;\" src=\""+my_imgs[index]+"\" class=\"flip\" alt=\""+my_imgs_alt[index]+"\"></image></a>";
	}
  }
  
  function change_slide() {
    slide_count +=1;
	if (slide_count >= my_imgs.length) {
		slide_count = 0;
	}
//	slide_HTML = "<a href=\""+my_imgs_link[slide_count]+"\"><image foo='bar' style=\"display: block;padding: 0;\" src=\""+my_imgs[slide_count]+"\" class=\"flip\"";
//	slide_HTML += " alt=\""+my_imgs_alt[slide_count]+"\"></image></a>";
	slide_div.innerHTML = newHTML(slide_count);
	slide_text_div.innerHTML = my_imgs_text[slide_count];
	keep_going = setTimeout("change_slide()",timer_intv);
  }
  
  if (timer_set == 1) {
    setTimeout("change_slide()",timer_intv);	
  }

  function toggle()
  {
	if(is_paused == 0)
	{
		pause_slide();
	}
	else
	{
		r_start();
	}
  }
  
  function pause_slide() {
	clearTimeout(keep_going);
	is_paused = 1;
	play_pause.src = "/support/graphics/buttons/play.gif";
  }

  function scroll(direction) 
  {
	pause_slide();
	if(direction == "forward")
	{
		slide_count +=1;
		if (slide_count >= my_imgs.length)
		{
			slide_count = 0;
		}
	}

	if(direction == "backward")
	{
		slide_count -=1;
		if (slide_count < 0)
		{
		    slide_count = my_imgs.length - 1;
		}
	}

	slide_div.innerHTML = newHTML(slide_count);
	slide_text_div.innerHTML = my_imgs_text[slide_count];
  }
 
  function r_start() 
  {
	is_paused = 0;
	play_pause.src = "/support/graphics/buttons/pause.gif";
	change_slide();
  }
  
} 
