/*
	Image Cross Fade Redux
	Version 1.0
	Last revision: 02.15.2006
	steve@slayeroffice.com

	Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html
*/

	
window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init);

var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;
var timer = null;



	
	imgs[0] = '/news/facts/slideshow/photos/00.jpg';
	imgs[1] = '/news/facts/slideshow/photos/01.jpg';
	imgs[2] = '/news/facts/slideshow/photos/02.jpg';
	imgs[3] = '/news/facts/slideshow/photos/03.jpg';
	imgs[4] = '/news/facts/slideshow/photos/04.jpg';
	imgs[5] = '/news/facts/slideshow/photos/05.jpg';
	imgs[6] = '/news/facts/slideshow/photos/06.jpg';
	imgs[7] = '/news/facts/slideshow/photos/07.jpg';
	imgs[8] = '/news/facts/slideshow/photos/08.jpg';
	imgs[9] = '/news/facts/slideshow/photos/09.jpg';
	imgs[10] = '/news/facts/slideshow/photos/10.jpg';
	imgs[11] = '/news/facts/slideshow/photos/11.jpg';
	imgs[12] = '/news/facts/slideshow/photos/12.jpg';
	imgs[13] = '/news/facts/slideshow/photos/13.jpg';
	imgs[14] = '/news/facts/slideshow/photos/14.jpg';
	imgs[15] = '/news/facts/slideshow/photos/15.jpg';
	imgs[16] = '/news/facts/slideshow/photos/16.jpg';
//var timer = setTimeout(so_xfade,2000);
function so_init()
{
	if(!d.getElementById || !d.createElement)return;

	//css = d.createElement('link');
	//css.setAttribute('href','css/slideshow2.css');
	//css.setAttribute('rel','stylesheet');
	//css.setAttribute('type','text/css');
	//d.getElementsByTagName('head')[0].appendChild(css);

	//imgs = d.getElementById('rotator').getElementsByTagName('img');
	
	
	
	
	var url = location.href;
	//alert(url);
	if (url == 'http://www.colorado.edu/news/facts/campus/index.html') { 
		current = 0; 
		} else if (url == 'http://www.colorado.edu/news/facts/campus/rankings.html') { 
		current = 2; 
		} else if (url == 'http://www.colorado.edu/news/facts/students/index.html') { 
		current = 3; 
		} else if (url == 'http://www.colorado.edu/news/facts/students/diversity.html') { 
		current = 4; 
		} else if (url == 'http://www.colorado.edu/news/facts/students/undergraduate.html') { 
		current = 5; 
		} else if (url == 'http://www.colorado.edu/news/facts/research/index.html') { 
		current = 7; 
		} else if (url == 'http://www.colorado.edu/news/facts/campus/infrastructure.html') { 
		current = 10; 
		} else if (url == 'http://www.colorado.edu/news/facts/campus/technology.html') { 
		current = 11; 
		} else if (url == 'http://www.colorado.edu/news/facts/campus/athletics.html') { 
		current = 13; 
		} else if (url == 'http://www.colorado.edu/news/facts/administration/budget.html') { 
		current = 14; 
		} else if (url == 'http://www.colorado.edu/news/facts/facultystaff/index.html') { 
		current = 15; 
		} else {
	current = Math.round((imgs.length-1)*Math.random());
	
	//current = Math.round((imgs.length-1)*Math.random());
		}
	//alert(current);
	document.getElementById('photo').src = imgs[current];
	//alert(document.getElementById('photo').src);
	document.getElementById('photo').style.display = 'block';
	document.getElementById('debug').innerHTML = captions[current];
	//for(i=0;i<imgs.length;i++) imgs[i].style.display = 'none';
	//imgs[0].style.display = 'block';
	//imgs[0].xOpacity = .99;
	
	//imgs[current].style.display = 'block';
	
	
	
	
}





	
	
function forward() {
	
	
	if (current == imgs.length-1) {
		nIndex = 0;
	} else {
		nIndex = current+1;
	}
	//alert(nIndex);
	document.getElementById('photo').src = imgs[nIndex];		
	document.getElementById('debug').innerHTML = captions[nIndex];	
	current = nIndex;
}

function reverse() {
	

	if (current == 0) {
		nIndex = imgs.length - 1;
		} else {
	nIndex = current-1;
	}
	document.getElementById('photo').src = imgs[nIndex];		
	document.getElementById('debug').innerHTML = captions[nIndex];	
	current = nIndex;
}