var Welcome	= new Class({
	
	initialize: function() {
		this.header		= $('contentHeader');
		this.images		= this.header.getElements('img');
		this.position	= 0;
		
		this.images[0].setStyle('opacity', 1);
		if(this.images.length == 1) return;
		
		// this.images.each(this.setup, this);
		this.step.periodical(5000, this);
	},
	
	setup: function(image, i) {
		image.set('tween', {
			onComplete: this.next.bind(this, i)
		});
	},
	
	step: function() {
		var i		= this.position == (this.images.length-1) ? 0 : this.position + 1;
		var next	= this.images[i];
		var current	= this.images[this.position];
		
		current.tween('opacity', 1, 0);
		next.tween('opacity', 0, 1);
		
		this.position	= i;
	},
	
	next: function(i) {
		if( i != this.position ) {
			this.images[i].setStyle('display', 'none');
			this.images[this.position].setStyles({
				'display': '',
				'opacity': 0
			}).tween('opacity', 1);
		}
	}
});

window.addEvent('load', function() {
	new BannerRotation('rotatingBanners');
});

window.addEvent('domready', function() {
	new Welcome();
	new Modal.Newsletter($('banner-1'), $('newsletter-container'));
	
	var url	= 'http://www.countryvillasouth.com/flv';
	new Swiff(url+'/player.swf', {
		'width': 182,
		'height': 134,
		'container': $('ourVideo'),
		'params': {
			'allowfullscreen': 'true',
			'allowscriptaccess': 'always',
			'wmode': 'transparent'
		},
		'vars': {
			'file': Site.absolute+'/assets/flv/welcome.flv',
			'autostart': 'false',
			'controlbar': 'over',
			'skin': url+'/play.swf',
			'image': Site.url +'/assets/img/thumb.video.jpg',
			'stretching': 'exactfit'
		}
	});
});