/* 
Copyright 2007 Kraig Larson, kraig-at-ciceron-dot-com
Last modified: 2007-02-24
*/
/* For each slideshow frame, insert HTML  and label */
var images = new Array();
images[0] = { htm:'<img src="../minneapolis-hotel-images/art_judas.jpg" alt="" title="Judas Iscariot" width="382" height="293" />', fcaption:'"Judas Iscariot (The Twelve Disciples)" Damien Hirst, 1994 ', flabel:'', fsrc:'../minneapolis-hotel-images/art_judas.jpg' };
images[1] = { htm:'<img src="../minneapolis-hotel-images/art_lws2.jpg" alt="" title="L.W.S.2." width="382" height="293" />', fcaption:'"L.W.S.2." Ashley Bickerton, 2001', flabel:'', fsrc:'../minneapolis-hotel-images/art_lws2.jpg' };
images[2] = { htm:'<img src="../minneapolis-hotel-images/art_old.jpg" alt="" title=""  width="382" height="293" />', fcaption:'"(Old) No One-In Particular #6, Series 2" Evan Penny, 2005', flabel:'', fsrc:'../minneapolis-hotel-images/art_old.jpg' };
images[3] = { htm:'<img src="../minneapolis-hotel-images/art_other.jpg" alt="" title="Other Thing"  width="382" height="293"" />', fcaption:'"Other Thing" Subodh Gupta, 2006', flabel:'', fsrc:'../minneapolis-hotel-images/art_other.jpg' };
images[4] = { htm:'<img src="../minneapolis-hotel-images/art_candy.jpg" alt="" title=""  width="382" height="293" />', fcaption:'"Candy Stick Forest" Will Cotton, 2005', flabel:'', fsrc:'../minneapolis-hotel-images/art_candy.jpg' };
images[5] = { htm:'<img src="../minneapolis-hotel-images/art_elemental1.jpg" alt="" title=""  width="382" height="293" />', fcaption:'"Elemental" Juxtaposition Arts, Minneapolis, MN, 2006', flabel:'', fsrc:'../minneapolis-hotel-images/art_elemental1.jpg' };
images[6] = { htm:'<img src="../minneapolis-hotel-images/art_elemental2.jpg" alt="" title=""  width="382" height="293" />', fcaption:'"Elemental" Juxtaposition Arts, Minneapolis, MN, 2006', flabel:'', fsrc:'../minneapolis-hotel-images/art_elemental2.jpg' };

/* settings: customize these variables for your page */
var imageID = "cfimage";
var timerTimeout = 10000;


/* do not change anything below this */
var curr = 0;
var photoTimer;
var photoAnim;
var isTiming = 1;

showImg = function(p) {
	hideCaption();
	if (!isTiming) { btn=YAHOO.util.Dom.get('btnpauseplay2'); btn.src = 'i/pause.png'; isTiming=1; }
	curr = p;
	clearTimeout(photoTimer);
	imgCon = YAHOO.util.Dom.get(imageID); 
	YAHOO.util.Dom.setStyle([imageID], 'opacity', 0); 
	imgCon.innerHTML = images[p].htm;
	YAHOO.util.Dom.get('cf_caption_content2').innerHTML = images[p].fcaption; 
	fadeIn(imageID,imgCon);
}
startTimer = function() {
	if (photoAnim) { photoAnim.onComplete.unsubscribeAll(); }
	curr ++; if (curr >= images.length) { curr=0; }
	photoTimer = setTimeout("showImg(curr)",timerTimeout);
}
goNext = function() {
	if (photoAnim) { photoAnim.onComplete.unsubscribeAll(); }
	curr ++; if (curr >= images.length) { curr=0; }
	showImg(curr);
}

toggleTimeout = function() {
	btn=YAHOO.util.Dom.get('btnpauseplay2');
	if (photoAnim) { photoAnim.onComplete.unsubscribeAll(); }
	clearTimeout(photoTimer);
	if (isTiming) { 
		btn.src = 'i/play.png';
		isTiming=0; 
	}
	else if (!isTiming) {
		curr++; if (curr >= images.length) { curr=0; }; showImg(curr);
		btn.src = 'i/pause.png';
		isTiming=1;
	}
}
showCaption = function() {
	//if (images[curr].fcaption != '') {
	if (YAHOO.util.Dom.get('cf_caption_content2').innerHTML != '') {
		YAHOO.util.Dom.setStyle('cf_caption2','display','block');
	}
}
hideCaption = function() {
	YAHOO.util.Dom.setStyle('cf_caption2','display','none');
}
goHome = function() {
	showImg(0); 
}
function fadeIn(e,wp) {
	//alert('e='+ e + '\nwp=' + wp);
	photoAnim = new YAHOO.util.Anim(wp, { opacity: { from: 0, to: 1 } }, 1, YAHOO.util.Easing.easeOut);
	photoAnim.onComplete.subscribe(startTimer);
	photoAnim.animate();
}
function preloadImages(e) {
	//preload = YAHOO.util.Dom.get('cf_preload');
	imglst = YAHOO.util.Dom.get('imagelist2');
	imglst.innerHTML += '';
	for (x in images) {
		//preload.innerHTML += images[x].htm;
		imglst.innerHTML += '<a href=\"javascript:showImg(' + x + ');\" onmouseover="hideCaption();" class="imglistthumb2" title="' + images[x].flabel + '"><img src=\"' + images[x].fsrc + '" /><\/a> ';
	}
	photoTimer = setTimeout("showImg(1)",timerTimeout*2);
	//imglst.innerHTML += '<img src="i/home.png" onclick="goHome();" />&nbsp;&nbsp;&nbsp;<img id="btnpauseplay" src="i/pause.png" title="Click to Pause or Resume" onclick="toggleTimeout();" />';
	showImg(0);
}

YAHOO.util.Event.onAvailable('cf_preload', preloadImages, this);