


/*HISTORY-PHOTOS*/



/* * *
	HISTORY PHOTOS
* * */
var historyPhotos = new Object();
Object.extend(historyPhotos, {
	sentences: [],
	current: 0,
	
	pagination: '<a href="#" id="prev" class="icon iPrev">Previous</a><a href="#" id="next" class="icon iNext">Next</a>',
	
	/* INIT */
	init: function(){
		this.sentences = $A(arguments);
		this.current = this.sentences.shift();
		
		this.ajustPage();
	},
	
	/* AJUST PAGE */
	ajustPage: function(){
		$('pagination').innerHTML = this.pagination;

		if(this.current > 1)
			Event.observe('prev', 'click', historyPhotos.prevSentence.bindAsEventListener(historyPhotos));
		else
			Element.hide('prev');
			
		if(this.current < this.sentences.length)
			Event.observe('next', 'click', historyPhotos.nextSentence.bindAsEventListener(historyPhotos));
		else
			Element.hide('next');
	},
	
	/* PREV SENTENCE */
	prevSentence: function(event){
		Event.stop(event);
		this.current--;
		this.setSentence();
	},
	
	/* NEXT SENTENCE */
	nextSentence: function(event){
		Event.stop(event);
		this.current++;
		this.setSentence();
	},
	
	/* SET SENTENCE */
	setSentence: function(){
		$('info').innerHTML = '<p>'+this.sentences[this.current-1]+'</p>';
		$('img').getElementsByTagName('img')[0].src = 'images/history/'+ (this.current < 10 ? '0'+this.current : this.current) +'.jpg';
		this.ajustPage();
	}
	
});