/* 
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/party1.jpg" alt="" title="" width="440" height="293" />', fcaption:'', flabel:'Image 1', fsrc:'../minneapolis-hotel-images/party1.jpg' };
images[1] = { htm:'<img src="../minneapolis-hotel-images/party2.jpg" alt="" title="" width="440" height="293" />', fcaption:'', flabel:'Image 2', fsrc:'../minneapolis-hotel-images/party2.jpg' };
images[2] = { htm:'<img src="../minneapolis-hotel-images/party3.jpg" alt="" title=""  width="440" height="293" />', fcaption:'', flabel:'Image 3', fsrc:'../minneapolis-hotel-images/party3.jpg' };
images[3] = { htm:'<img src="../minneapolis-hotel-images/party4.jpg" alt="" title=""  width="440" height="293"" />', fcaption:'', flabel:'Image 4', fsrc:'../minneapolis-hotel-images/party4.jpg' };
images[4] = { htm:'<img src="../minneapolis-hotel-images/party5.jpg" alt="" title=""  width="440" height="293" />', fcaption:'', flabel:'Image 5', fsrc:'../minneapolis-hotel-images/party5.jpg' };
images[5] = { htm:'<img src="../minneapolis-hotel-images/party6.jpg" alt="" title=""  width="440" height="293" />', fcaption:'', flabel:'Image 6', fsrc:'../minneapolis-hotel-images/party6.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('btnpauseplay'); 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('imagelist3');
	imglst.innerHTML += '';
	for (x in images) {
		//preload.innerHTML += images[x].htm;
		imglst.innerHTML += '<a href=\"javascript:showImg(' + x + ');\" onmouseover="hideCaption();" class="imglistthumb3" 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);