//slideshow
function SlideShow(slideShow){
	this.slideShow = slideShow;
	this.i = 0;
	me = this;
	
	this.init = function() {
		this.runSlides();
	};
	
	this.runSlides = function(){
		this.runSlide();
		((this.i + 1) == this.slideShow.length)? this.i=0: this.i++;
		setTimeout('me.runSlides()', 5000);
	};
	
	this.runSlide = function(){
		var html;
		html  = '<a href="' + this.slideShow[this.i].link + '">';
		html += '	<div id="slide">';
		html += '	<img src="' + this.slideShow[this.i].image + '" />';
		html += '		<div id="title" style="display: none">' + this.slideShow[this.i].title + '</div>';
		html += '		<div id="sub_title" style="display: none">' + this.slideShow[this.i].subTitle + '</div>';
		html += '	</div>';
		html += '</a>';
	
		$('slideshow').innerHTML = html;
		
		new Effect.Move($('slide'), 	{ x: 0, y: 0, mode: 'absolute', duration: 1.6  });
		
		$('sub_title').appear({ duration: 3.0 });
		new Effect.Move($('sub_title'),	{ x: 35, y: 275, mode: 'absolute', duration: 2.25 });
		
		$('title').appear({ duration: 3.0 });
		new Effect.Move($('title'), 	{ x: 35, y: 240, mode: 'absolute', duration: 2.4 });
	};
}

// Handles the changing of the days on the events interface.
var marker=0;
function changeDay(id, thumbSrc, linkHref){
	// Change Tab
	elms = document.getElementsByTagName('li');
	for(i=0; i < elms.length; i++) {
		if(elms[i].getAttribute('attr') == 'days'){
			elms[i].setAttribute('class', '');
			elms[i].setAttribute('className', '');
		}
	}
	newDay = document.getElementById('days_'+id);
	newDay.setAttribute('class', 'selected');
	newDay.setAttribute('className', 'selected');
	
	// Change Day
	elms = document.getElementById('day').childNodes;
	for(i=0; i < elms.length; i++){
		if(elms[i].nodeType == 1){
			elms[i].style.display='none';
		}
	}	
	newDay = document.getElementById('day_'+id);
	newDay.style.display='block';

	// Change Thumbnail
	if(thumbSrc){
		changeThumb(thumbSrc, linkHref);
	}
}

function changeThumb(thumbSrc, linkHref){
	if(thumbSrc){
		thumb = document.getElementById('featured_event_img');
		thumb.setAttribute('src', '/uploads/' + thumbSrc);

		link = document.getElementById('featured_event_link');
		link.setAttribute('href', '/city/events/' + linkHref + '/featured event');
	}
}