window.addEvent('domready', function() {
	var status = {
		'true': 'open',
		'false': 'close'
	};
	
	var myVerticalSlide = new Fx.Slide('sliderbox', {
			duration: 500,
			transition: Fx.Transitions.Circ.easeOut
		}).hide(),
		myVerticalSlideOffer = new Fx.Slide('sliderbox-offer', {
			duration: 1000,
			transition: Fx.Transitions.Circ.easeOut
		}).hide(),
		scroll = new Fx.Scroll(window);
  	
  	$('v_toggle').addEvent('click', function(e){
		e.stop();
		myVerticalSlide.toggle().chain(function(){
      		scroll.toBottom();
      	});
	});
  	
  	$('v_toggle_1').addEvent('click', function(e){
		e.stop();
		myVerticalSlideOffer.toggle().chain(function(){
      		scroll.toBottom();
      	});
	});
	
	// The elements used.
  	var myForm = document.id('myForm'),
    	myResult = document.id('myResult');

  	// Labels over the inputs.
  	myForm.getElements('[type=text], textarea').each(function(el){
    	new OverText(el);
  	});

  	// Validation.
  	new Form.Validator.Inline(myForm);

  	// Ajax (integrates with the validator).
  	new Form.Request(myForm, myResult, {
    	requestOptions: {
      		'spinnerTarget': myForm
    	},
    	extraData: { // This is just to make this example work.
    		'html': 'Form sent.'
    	}
	});
});

function reset() {
    $$('ul#gallery li').each(function(e) {
    	e.setStyle('opacity', 0);
    });
}

function animate() {
    reset();
    delay = 100;
    speed = 600;
    
    var i = 0; 
    var li = $$('ul#gallery li');
    li.each(function(e) {  
    	i += delay; 
    	setTimeout( function() {
    		e.set('tween', {duration: speed, transition: 'back:in'}).tween('opacity', 0, 1);
    	}, i);   
    });
}

window.addEvent('load', animate);
