// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
var Photo = {

	show: function() {
		// $('photo').src = url;
		$('mask').show();
		$('main-text-holder').hide();	
		$('photo-wrapper').visualEffect('appear', {duration:0.5});
//		$('photo-wrapper').visualEffect('BlindDown');
	},

	hide: function() {
		$('mask').hide();
		$('main-text-holder').show();	
		$('photo-wrapper').visualEffect('fade', {duration:0.5});
	},

	currentIndex: function() {
		return this.urls().indexOf($('photo').src);
	},

	prev: function() {
		if(this.urls()[this.currentIndex()-1]) {
			this.show(this.urls()[this.currentIndex()-1])
		}
	},
	
	next: function() {
		if(this.urls()[this.currentIndex()+1]) {
			this.show(this.urls()[this.currentIndex()+1])
		}
	},
	
	urls: function() {
	    if (!this.cached_urls) {
			this.cached_urls = $$('a.show').collect(function(el){
				return el.onclick.toString().match(/".*"/g)[0].replace(/"/g,'');
			});
		}
		return this.cached_urls;
	}

}
