/**
 * @script: site.js
 * @website: Albergo Villa Cristina <http://albergovillacristina.com/>
 * @last-update: 2009-10-22
 * @version: 2.7
 *
 * Current MooTools version: 1.2.1 stable <http://mootools.net/>
 *
 * @author: Leonardo Laureti <l.laureti@syn-ergo.com>
 * @copyright: 2009 Syn-Ergo snc, <http://syn-ergo.com/>
 *
 * Tested:
 * 	Safari 2+
 * 	Firefox 1.5+
 * 	Opera 9+
 * 	IE 6+
*/

Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h4');
Cufon.replace('input#submit');

window.addEvent('domready', function(){

	//slideshow
	if($('slideshow')){
		var widescreen = new Slideshow.KenBurns("slideshow", data, {
			controller: false,
			delay: 5000,
			duration: 2500,
			width: 930,
			height: 320,
			hu: 'assets/images/full-size',
			linked: true,
			thumbnails: false,
			resize: true,
			zoom: false
		}); 
		widescreen.slideshow.retrieve('images').getElements('a').set('rel', 'shadowbox');
		var options = {
			skipSetup: true,
			animSequence: 'sync',
			overlayColor: '#567b5e',
			overlayOpacity: 0.7,
			initialHeight: 200,
			initialWidth: 100
		}
		Shadowbox.init(options); Shadowbox.setup();
	}

	if($('securedCaptcha')){
		$('securedCaptcha').addEvent('click', function(el){
			el.stop();
			this.set('load', {method: 'get'});
			this.load('secured/refresh');
		});
	}
	
	//index
	if($('gbook')){
		$('gbook').addEvent('submit', function(e){
			e.stop();
			
			$('gbook_log').setStyle('visibility', 'visible');
			var log = $('gbook_log').empty().addClass('spinner');

			if(this.getProperty('action').contains('eng' || 'nld' || 'deu')){
				log.set('html', 'sending, please wait...');
			} else {
				log.set('html', 'attendere, invio in corso...');
			}

			this.set('send', {onComplete: function(response){ 
				log.removeClass('spinner');
				log.set('html', response);
			}});

			this.send();
		});
	}
	
	//contactus
	if($('contact')){
		$('contact').addEvent('submit', function(e){
			e.stop();

			$('contact_log').setStyle('visibility', 'visible');
			var log = $('contact_log').empty().addClass('spinner');

			if(this.getProperty('action').contains('eng' || 'nld' || 'deu')){
				log.set('html', 'sending, please wait...');
			} else {
				log.set('html', 'attendere, invio in corso...');
			}

			this.set('send', {onComplete: function(response){ 
				log.removeClass('spinner');
				log.set('html', response);
			}});

			this.send();
		});
	}

});
