/* rss stuff */
var RSS = (function() {
	this.pipebase = 'http://pipes.yahoo.com/pipes/9oyONQzA2xGOkM4FqGIyXQ/run?&_render=json&_callback=RSS.piper&feed=';
	this.feedItemLimit = 4;
	this.getFeed = function(feed){
		var newScript = document.createElement('script');
		newScript.type = 'text/javascript';
		newScript.src = this.pipebase + feed;
		document.getElementsByTagName("head")[0].appendChild(newScript);
	}
	this.piper = function(feed) {
		var tmp='';
		for (var i=0; (i<feed.value.items.length) && ( i < this.feedItemLimit); i++) {
			tmp+='<div class="title">'+feed.value.items[i].title+'</div>';
			if (feed.value.items[i].description) { tmp+= '<div class="desc">'+feed.value.items[i].description + '</div>'; }
		}
		var container=document.getElementById('rss_events');
		if (container != null){
			container.innerHTML=tmp;
		}
	}
	return this;
})();

var image_loading = false;

var main_image_loaded = function(){

	image_loading = false;
}

var init_thumbs = function(){
	var MAX_IMAGES = 8;	
	var x = 0;
	for (var i = 1; i <= MAX_IMAGES; ++i){
		(function(){
		 var c = i;
		if (jQuery('#main_thumb_' + c.toString() + ' img').length && jQuery('#main_image_' + c.toString() + ' img').length){
			jQuery('#main_thumb_' + c.toString() + ' img').bind('click', 
				function() {
					if (image_loading) return;
					jQuery('.centerimage img').load(
						function(){
						main_image_loaded();
						}
					);
					image_loading = true;
					jQuery('.centerimage img').attr('src', 
						jQuery('#main_image_' + c.toString() + ' img').attr('src')
					);
				}
			);
			jQuery('#main_thumb_' + c.toString() + ' img').attr('alt', '');
			jQuery('#main_thumb_' + c.toString() + ' img').attr('title', '');
	 	}	
		})();
		++x;
	}
	if (x > 0){
	}
}

jQuery('body').ready(
	function() {
		init_thumbs();
	}
);

