


/*VINEYARDS-PHOTOS*/



/* * *
	VINEYARDS PHOTOS
* * */
var vineyardsPhotos = new Object();
Object.extend(vineyardsPhotos, {
	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(){
		new Insertion.Before($('info_img'), '<div id="info_img_back"></div>');
		Object.extend($('info_img_back').style, {
			opacity: 0.6,
			height: $('info_img').offsetHeight+'px',
			background:'#000'
		})
    if(/MSIE/.test(navigator.userAgent))  
			Element.setStyle($('info_img_back'), {filter:'alpha(opacity=60)'});  
		
		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', vineyardsPhotos.prevSentence.bindAsEventListener(vineyardsPhotos));
		else
			Element.hide('prev');
			
		if(this.current < this.sentences.length)
			Event.observe('next', 'click', vineyardsPhotos.nextSentence.bindAsEventListener(vineyardsPhotos));
		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][0]+'</p>';
		$('info_img').innerHTML = '<span>'+this.sentences[this.current-1][1]+'</span>';
		Element.setHeight($('info_img_back'), $('info_img').offsetHeight);
		
		$('img').getElementsByTagName('img')[0].src = 'images/vineyards/'+ (this.current < 10 ? '0'+this.current : this.current) +'.jpg';
		this.ajustPage();
	}
	
});