window.addEvent('domready', function () {
	var fotos = $$('.foto_Box_elem');
	if (fotos[0]) {
		var timer2 = 0;
		var active_foto = fotos.length - 1;
		var switchFotos = function () {
		var new_active_foto = active_foto + 1;
		if (new_active_foto == fotos.length) {
			new_active_foto = 0;
		} 
		var fotos_to_switch = [fotos[active_foto], fotos[new_active_foto]];
			fotos[active_foto].setStyle('display', 'block');
			fotos[active_foto].setStyle('opacity', '1');
			fotos[new_active_foto].setStyle('display', 'block');
			fotos[new_active_foto].setStyle('opacity', '0');
			
			new Fx.Elements(fotos_to_switch, {'link': 'cancel', duration: 1000, transition: Fx.Transitions.linear, onComplete: function () {
				active_foto = new_active_foto;
			}}).start({
				'0': {
       			'opacity': [1,0]
    			},
    			'1': {
					'opacity': [0,1]
   	 		}
			}); 
		}

		timer2 = switchFotos.periodical(5000);
	}
	
	var texts1 = $$('.text_BoxA_hidden .element');
	if (texts1[0]) {
		var timer = 0;
		var time1 = 2500;
		var active_texts1 = 0;
		var switchTexts1 = function () {
		
			new Fx.Elements($$('.text_BoxA')[0], {'link': 'cancel', duration: 1000, transition: Fx.Transitions.linear, onComplete: function () {
				active_texts1 = active_texts1 + 1;
				if (active_texts1 == texts1.length) {
					active_texts1 = 0;
				}
				
				$$('.text_BoxA .text')[0].innerHTML = texts1[active_texts1].innerHTML;  
				$$('.text_BoxA .shadow')[0].innerHTML = texts1[active_texts1].innerHTML;
				
				time1 = 5000;
				$clear(timer);
				timer = switchTexts1.periodical(time1);
				
				new Fx.Elements($$('.text_BoxA')[0], {'link': 'cancel', duration: 1000, transition: Fx.Transitions.linear}).start({
					'0': {'opacity': [0,1]}
   	 		});
			}}).start({
				'0': {'opacity': [1,0]}
			}); 
		}
		
		$$('.text_BoxA .text')[0].innerHTML = texts1[0].innerHTML;  
		$$('.text_BoxA .shadow')[0].innerHTML = texts1[0].innerHTML;

		timer = switchTexts1.periodical(time1);
	}
	
	var texts2 = $$('.text_BoxB_hidden .element');
	if (texts2[0]) {
		var timer = 0;
		var time2 = 2500;
		var active_texts2 = 0;
		var switchTexts2 = function () {
		
			new Fx.Elements($$('.text_BoxB')[0], {'link': 'cancel', duration: 1000, transition: Fx.Transitions.linear, onComplete: function () {
				active_texts2 = active_texts2 + 1;
				if (active_texts2 == texts2.length) {
					active_texts2 = 0;
				}
				
				$$('.text_BoxB')[0].setStyle('top', 40);
				$$('.text_BoxB .text')[0].innerHTML = texts2[active_texts2].innerHTML;  
				$$('.text_BoxB .shadow')[0].innerHTML = texts2[active_texts2].innerHTML;
				
				time2 = 5000;
				$clear(timer);
				timer = switchTexts2.periodical(time2);
				
				new Fx.Elements($$('.text_BoxB')[0], {'link': 'cancel', duration: 1000, transition: Fx.Transitions.linear}).start({
					'0': {
						'opacity': [0,1],
						'top': [40, 160]
					}
   	 		});
			}}).start({
				'0': {
					'opacity': [1,0],
					'top': [160, 240] 
				}
			}); 
		}
		
		$$('.text_BoxB .text')[0].innerHTML = texts2[0].innerHTML;  
		$$('.text_BoxB .shadow')[0].innerHTML = texts2[0].innerHTML;

		timer = switchTexts2.periodical(time2);
	}
	
	var texts4 = $$('.text_BoxC_hidden .element');
	if (texts4[0]) {
		var timer = 0;
		var time4 = 2500;
		var active_texts4 = 0;
		var switchTexts4 = function () {
		
			new Fx.Elements($$('.text_BoxC')[0], {'link': 'cancel', duration: 1000, transition: Fx.Transitions.linear, onComplete: function () {
				active_texts4 = active_texts4 + 1;
				if (active_texts4 == texts4.length) {
					active_texts4 = 0;
				}
				
				$$('.text_BoxC .text')[0].innerHTML = texts4[active_texts4].innerHTML;  
				$$('.text_BoxC .shadow')[0].innerHTML = texts4[active_texts4].innerHTML;
				
				time4 = 5000;
				$clear(timer);
				timer = switchTexts4.periodical(time4);
				
				new Fx.Elements($$('.text_BoxC')[0], {'link': 'cancel', duration: 1000, transition: Fx.Transitions.linear}).start({
					'0': {'opacity': [0,1]}
   	 		});
			}}).start({
				'0': {'opacity': [1,0]}
			}); 
		}
		
		$$('.text_BoxC .text')[0].innerHTML = texts4[0].innerHTML;  
		$$('.text_BoxC .shadow')[0].innerHTML = texts4[0].innerHTML;

		timer = switchTexts4.periodical(time4);
	}
	
	var texts5 = $$('.text_BoxD_hidden .element');
	if (texts5[0]) {
		var timer = 0;
		var time5 = 2500;
		var active_texts5 = 0;
		var switchTexts5 = function () {
		
			new Fx.Elements($$('.text_BoxD')[0], {'link': 'cancel', duration: 1000, transition: Fx.Transitions.linear, onComplete: function () {
				active_texts5 = active_texts5 + 1;
				if (active_texts5 == texts5.length) {
					active_texts5 = 0;
				}
				
				$$('.text_BoxD')[0].setStyle('top', 40);
				$$('.text_BoxD .text')[0].innerHTML = texts5[active_texts5].innerHTML;  
				$$('.text_BoxD .shadow')[0].innerHTML = texts5[active_texts5].innerHTML;
				
				time5 = 5000;	
				$clear(timer);
				timer = switchTexts5.periodical(time5);			
				
				new Fx.Elements($$('.text_BoxD')[0], {'link': 'cancel', duration: 1000, transition: Fx.Transitions.linear}).start({
					'0': {
						'opacity': [0,1],
						'top': [40, 135]
					}
   	 		});
			}}).start({
				'0': {
					'opacity': [1,0],
					'top': [135, 240] 
				}
			}); 
		}
		
		$$('.text_BoxD .text')[0].innerHTML = texts5[0].innerHTML;  
		$$('.text_BoxD .shadow')[0].innerHTML = texts5[0].innerHTML;

		timer = switchTexts5.periodical(time5);
	}
});