var slideShowSpeed = 10000;
var crossFadeDuration = 4;
var i = 0;
var photo0 = new Array("./images/boys-walking.jpg");
var photo1 = new Array("./images/grads-fall.jpg");
var photo2 = new Array("./rhim/images/gateway/overton1web.jpg");
var photo3 = new Array("./images/gradconf.jpg");
var photo4 = new Array("./images/fittech.jpg");
var photo5 = new Array("./images/pbd.jpg");
var photo6 = new Array("./images/pbd2.jpg");
var photo7 = new Array("./ns/images/fillipp_award.jpg");
var photo8 = new Array("./images/thailand-visit.jpg");
var photo9 = new Array("./images/ntit-visit-09.jpg");
var photo10 = new Array("./RET/images/fc-1.jpg");
var photo11 = new Array("./RET/images/fc-2.jpg");
var photo12 = new Array("./RET/images/fc-3.jpg");
var photo14 = new Array("./images/norma.gif");
var photo15 = new Array("./images/fc-2009.gif");
var photo16 = new Array("./images/i-chrie-09.jpg");
//var photo17 = new Array("./images/i-chrie-02.jpg");
//var photo18 = new Array("./images/i-chrie-03.jpg");
//var photo19 = new Array("./images/gradconf-08-01.jpg");
//var photo20 = new Array("./images/gradconf-08-02.jpg");
//var photo21 = new Array("./images/spanish-01.jpg");
//var photo22 = new Array("./images/spanish-02.jpg");
//var photo23 = new Array("./images/spanish-03.jpg");
//var photo24 = new Array("./images/skyviews.jpg");
var photo35 = new Array("./images/gradconf-09.jpg");
var photo36 = new Array("./images/readersaward.jpg");
var photo37 = new Array("./images/walmart-research.jpg");

var Pic = new Array(photo36, photo2, photo16, photo35, photo9, photo4, photo8, photo14, photo11, photo7, photo37, photo36, photo2, photo16, photo35, photo9, photo4, photo8, photo14, photo10, photo7, photo37, photo36, photo2, photo16, photo35, photo9, photo4, photo8, photo14, photo12, photo7);

var text0 = new Array("<h4>HEADING GOES HERE</h4><p>Some Text Goes HERE <br>1 Some Text Goes HERE 1<br>1 Some Text Goes HERE 1</p>");
//var text1 = new Array("<h4>Congratulations to our 2009 Graduates</h4><p>Spring Graduation Commencement is on May 8-9.</p><ul><li>May 9, 1:30pm - Undergraduate Commencement.</li><li>May 8, 7pm - Graduate School Commencement.</li></ul><p>We wish all our graduates good luck!</p><p><a href='http://www.depts.ttu.edu/provost/commencement/' class='learn-more'>Learn More</a></p>");
var text2 = new Array("<h4>RHIM Partners with New Overton Hotel</h4><p>Restaurant, Hotel and Institutional Management (RHIM) students will have an opportunity to work and learn in the brand new Overton Hotel.</p><p><a href='http://www.depts.ttu.edu/hs/nhr/rhim/overton.php' class='learn-more'>Learn More</a></p>");
var text3 = new Array("<h4>2009 Graduate Conference</h4><p>RHIM Graduate students attended The 14th Annual Graduate Student Research Conference in Hospitality &amp; Tourism hosted by the William F. Harrah College of Hotel Administration at the University of Nevada, Las Vegas.</p><p><a href='./gradconf.php' class='learn-more'>Learn More</a></p>");
var text4 = new Array("<h4>FIT TECH</h4><p>Make your plans to be a part of FIT Tech V this semester! Watch for announcements of activities on TechAnnounce. Also, it is not too early to be thinking about FIT Tech V in Spring 2009 when we will have our team competition. Get your team of 6 together: 6 faculty, staff, students, or mixed teams for an 8 week fitness program. Teams will register in 1 of the 3 participation levels depending on their fitness levels and goals.</p>");
var text6 = new Array("<h4>Texas Dietetic Association Awards</h4><p>Shelley Fillipp, NS faculty, received the 2008-2009 Texas Dietetic Association Outstanding Dietetic Educator Award.</p>");
var text7 = new Array("<h4>Visit to NTIT</h4><p>Dr. Ben K. Goh visited the National Taichung Institute of Technology (NTIT) in Aug 1-3 and made a presentation on hospitality curriculum development to their faculty. In the picture Dr. Goh receiving gifts from the department chairperson, Dr. Juichang Cheng and next to him Dr. Frank Tsai (Ph.D., 2004).</p>");
var text8 = new Array("<h4>Fashion Camp 2009</h4><p>Fashion Camp held at Texas Tech on June<br/><b>Activities Included:</b></p><ul><li>Fashion show production</li><li>Visual merchandising</li><li>History of fashion</li><li>Photo shoot production</li><li>Color theory</li><li>Trend analysis</li></ul><p><a href='./RET/fashion_camp/' class='learn-more'>More News</a></p>");
var text9 = new Array("<h4>QUALITY SERVICE AWARD</h4><p>On May 6th 2008, Norma Sanchez, Bussiness Manager of the Department of Nutrition, Hospitality and Retailing was awarded the Texas Tech Quality Service Award. Congratulations!</p>");
var text10 = new Array("<h4>2009 International CHRIE Conference</h4><p>Annual ICHRIE Conference was held in San Francisco, July 29-Aug 1. Several of our faculty and doctoral students presented research papers and posters at the conference. In the picture left to right: Dr. Linchi Kwock (Ph.D., 2009) and Dean Yin.</p>");
var text11 = new Array("<h4>Visit to Thailand</h4><p>Dr. Ben K. Goh visited Thailand last in Aug 8-13. He made internship connections for RHIM students and also met with our alumni. In the picture from upper-left clockwise, Dr. Goh, Dr. Piyavan Sukalakamala (Ph.D., 2008), Ms. Yaisiri Chaiwong (MS, 2004), Dr. Nealnara Wongkerd (Ph.D., 2006), and Ms. Tipapan Chaiwong (MS, 2007) in Bangkok.</p>");
//var text12 = new Array("<h4>Interactive Spanish Classes with Dr. Sanchez</h4><p>Students follow dance instructions in Spanish as a part of Dr. Sanchez's creative way of teaching in his Spanish Language Class.</p>");
//var text13 = new Array("<h4>Interactive Spanish Classes with Dr. Sanchez</h4><p>Dr. Sanchez's creative way of teaching in his Spanish Language Class includes visualizing the words with illustrations and pictures. This helps students to not just memorizing the words, but also associates them with daily life.</p>");
//var text14 = new Array("<h4>Jody Acrey at the Skyviews Restaurant</h4><p>Jody Acrey (far right), a representaive of Watson-Sysco, and Leigh Kiselis (front), the executive chef, help dinner series students cost out their planned menu.</p>");
var text16 = new Array("<h4>Congratulations to RHIM and Skyviews!</h4><p>According to a report in the Daily Toreador on April 24, 2009 <br>RHIM was voted as the Best Major at Texas Tech University &amp;<br>Skyviews was voted as the 3rd Best Place for a Romantic Dinner.</p><p>We would like to thank everyone for their support!</p>");
var text17 = new Array("<h4>Students Give World’s Largest Retailer Some Tips on Selling Hardware</h4><p>Under the guidance of Deborah Fowler, associate professor in Retailing, the students developed proposals that Wal-Mart may implement to makeover the hardware sections of two regional stores.</p><p><a href='http://today.ttu.edu/2009/10/wal-mart-research/' class='learn-more' target='_blank'>Learn More</a></p>");

var Captions = new Array(text16, text2, text10, text3, text7, text4, text11, text9, text8, text6, text17, text16, text2, text10, text3, text7, text4, text11, text9, text8, text6, text17, text16, text2, text10, text3, text7, text4, text11, text9, text8, text6);

var t;
var j = 0;
var p = Pic.length;

var preLoad = new Array();
for (i = 0; i < p; i++){
   preLoad[i] = new Image();
   preLoad[i].src = Pic[i];
}

function runSlideShow(){
	//Code to check if the user is on a Mac running IE
	//If so then just get a single random image
	if (navigator.platform.indexOf('Mac')>=0 && navigator.appVersion.indexOf('MSIE') >= 0)
	{
        var RandomNumber = Math.floor(Pic.length * Math.random());
		document.images.SlideShow.src = preLoad[RandomNumber].src;
		document.getElementById("fader").innerHTML = Captions[RandomNumber];
		return(0);
	}
   fadeText();
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)";
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
      document.images.SlideShow.filters.blendTrans.Apply();      
   }
   document.images.SlideShow.src = preLoad[j].src;
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play();
   }
   j = j + 1;
   if (j > (p-1)) j=0
}


//  captions:
//  Your messages wich may contain regular html tags
//  Use only single quotes [ ' ] in your html. If you need 
//  a double quote in the message itself use an escape 
//  sign like this: [ \" ]  (not including the brackets)

var bgcolor = "#ffffff"; // background color, must be valid browser hex color (not color names)
var fcolor = "#000000";  // foreground or font color
var steps = 20; // number of steps to fade

// Do Not Edit Below This Line
var colors = new Array(steps);
getFadeColors(bgcolor,fcolor,colors);
var color = 0;
var text = 0;
var step = 1;

// fade: magic fader function
function fadeText() {
	var text_out = "<font color='" + colors[color] + "'>" + Captions[text] + "</font>";

	// actually write message to document
//	if (document.all) fader.innerHTML = text_out; // document.all = IE only
//	if (document.layers) { document.fader.document.write(text_out); document.fader.document.close(); } // document.layers = Netscape only
	document.getElementById("fader").innerHTML = text_out;

// select next fader color
	color += step; 

	// completely faded in?
	if (color >= colors.length-1) {
		step = -1; // traverse colors array backward to fade out
	}

	// completely faded out?
	if (color == 0) {
		step = 1; // traverse colors array forward to fade in again
	
		// select next message
		text += 1;
		if (text == Captions.length) text = 0; // loop back to first message
	}

	if (color == colors.length-2 && step == -1) {
		return;
	} else {
		setTimeout("fadeText()", 10);
	}
}

// getFadeColors: fills Colors (predefined Array)
// with color hex strings fading from ColorA to ColorB

// note: Colors.length equals the number of steps to fade
function getFadeColors(ColorA, ColorB, Colors) {
	len = Colors.length; 
	
	// strip '#' signs if present 
	if (ColorA.charAt(0)=='#') ColorA = ColorA.substring(1);
	if (ColorB.charAt(0)=='#') ColorB = ColorB.substring(1);
	
	// substract rgb compents from hex string 
	var r = HexToInt(ColorA.substring(0,2));
	var g = HexToInt(ColorA.substring(2,4));
	var b = HexToInt(ColorA.substring(4,6));
	var r2 = HexToInt(ColorB.substring(0,2));
	var g2 = HexToInt(ColorB.substring(2,4));
	var b2 = HexToInt(ColorB.substring(4,6));
	
	// calculate size of step for each color component
	var rStep = Math.round((r2 - r) / len);
	var gStep = Math.round((g2 - g) / len);
	var bStep = Math.round((b2 - b) / len);
	
	// fill Colors array with fader colors
	for (i = 0; i < len-1; i++) {
		Colors[i] = "#" + IntToHex(r) + IntToHex(g) + IntToHex(b);
		r += rStep;
		g += gStep;
		b += bStep;
	}
	Colors[len-1] = ColorB; // make sure we finish exactly at ColorB
}

// IntToHex: converts integers between 0-255 into a two digit hex string.
function IntToHex(n) {
	var result = n.toString(16);
	if (result.length==1) result = "0"+result;
	return result;
}

// HexToInt: converts two digit hex strings into integer.
function HexToInt(hex) {
	return parseInt(hex, 16);
}
setInterval(runSlideShow, slideShowSpeed)