if (!SITE){var SITE = new Object();};
SITE.hasRequired = function(){
	if (document.getElementById && document.getElementsByTagName){
		var html = document.getElementsByTagName('html')[0];
		//html.className += ((html.className=='')?'':' ')+'has-dom';
		return true;
	};
	return false;
}();
SITE.onload = function() {if (SITE.hasRequired) { for (var module in SITE) { if (SITE[module].domready) { SITE[module].onload(); };};};};
SITE.domready = function() {if (SITE.hasRequired) { for (var module in SITE) { if (SITE[module].domready) { SITE[module].domready(); };};};};
/******************************************************************************
 Fancy Selector
 ******************************************************************************/
SITE.Selector = 
{
	/*
	domready	: function(){
		var selectors = document.getElementsBySelector('.selector', true);
		selectors.each(function(selector, i){	
			var fx = new Fx.Slide(selector.getElement('.options'));
			fx.hide();
			selector.addEvent('mouseenter', function(e){fx.slideIn();});
			selector.addEvent('mouseleave', function(e){fx.slideOut();});
		});
	}
	*/
}
/******************************************************************************
 Sliding picture
 ******************************************************************************/
 SITE.SlidingPictures = 
{
	
	/*
	domready	: function(){
		var shop = document.getElementsBySelector('.store', true);
		shop.each(function(element) {				   		 
			var fx = new Fx.Style(element.getElement('.picture'), 'background-position', {duration:200, wait:false, ransition: Fx.Transitions.easeIn});
			element.addEvent('mouseenter', function(){fx.start('0 -290');});
			element.addEvent('mouseleave', function(){fx.start('0 0');});
		});
	}*/
}
/******************************************************************************
 Picture Rotator
 ******************************************************************************/
SITE.Rotator = {
	
	domready: function(){
		
		if(!$('pictures'))return;
		this.index = 1;
		this.rotator = $('pictures');
		this.slides = this.rotator.getChildren().reverse();
		
		if(this.slides.length>1){
			this.activeImage = this.slides[0].setProperty('id','visual');
			this.slides.each(function(slide, i, slides){
				if(i>0){slide.remove()}
			});
			this.timer = this.loadSlide.delay(2000, this);
		}
	},
	
	loadSlide: function(){
		
		$clear(this.timer);
		this.imageLoader = this.slides[this.index].setStyle('opacity','0').injectInside('pictures');
		this.imageLoader.onload = this.onSlideLoaded.delay(500,this);
	},
	
	onSlideLoaded: function(){
		
		this.imageLoader.effect('opacity', {duration: 2000, transition: Fx.Transitions.sineInOut , onComplete: this.onSlideInit.bind(this)}).start(0,1);
		this.activeImage.effect('opacity', {duration: 2000}).start(1,0);
	},
	
	onSlideInit: function(){
		this.activeImage.remove();
		this.activeImage = this.imageLoader.setProperty('id', 'visual');
		this.index = (this.index >= this.slides.length-1)? 0 : this.index+1;
		this.timer = this.loadSlide.delay(3000, this);
	}
};

window.addEvent('domready', function(){SITE.domready();});
