window.addEvent('domready', function() {	
	
// Horizontal top navigation

var navi = $$('.menu', '.wrapper');

	navi.addEvents({
						
		// Mouseover effect
		'mouseenter': function(){
			this.set('tween', {
				duration: 500,		// Define the delay of the slide
				transition: Fx.Transitions.Quad.easeOut		// Define the motion type of the slide
			}).tween('height', this.getElement('div').getStyle('height'));		// Define the height of the slide
			
			this.getElement('h1').addClass('active');
		},

		// Mouseout effect
		'mouseleave': function(){
			this.set('tween', {}).tween('height', '0px');		// Define the height of the slide after closing
			
			this.getElement('h1').removeClass('active');
		}
	});


// Create an  Accordion
	
	// --> Left Accordion
	
//	var accordion_quick_links = new Accordion($('accordion'), 'div.toggler', 'div.element', {
//		display: 0,			// Define an open element on start -- a number (0 = first element, 1 = second element, 2 = third element etc.) or false
//		opacity: true,			// Define a fade between slidechanges to true on false
//		alwaysHide: true,			// Define if the accordion is closable or not
//		onActive: function(toggler, element){
//			toggler.setStyle('background', 'url(img/gui/188x24_quick_minus.gif)');			// Define the top image when a slide is opened
//		},
//		onBackground: function(toggler, element){
//			toggler.setStyle('background', 'url(img/gui/188x24_quick_plus.gif)');			// Define the top image when a slide is closed
//		}		
//	});

	// --> Alaosio 4 Accordion

	var accordion_1 = new Accordion($('accordion_1'), 'div.toggler_1', 'div.element_1', {
		display: 1,			// Define an open element on start -- a number (0 = first element, 1 = second element, 2 = third element etc.) or false
		opacity: true,			// Define a fade between slidechanges to true on false
		alwaysHide: true,			// Define if the accordion is closable or not
		onActive: function(toggler, element){
			toggler.setStyle('background', 'url(img/gui/576x24_list_minus.gif)');			// Define the top image when a slide is opened
		},
		onBackground: function(toggler, element){
			toggler.setStyle('background', 'url(img/gui/576x24_list_plus.gif)');			// Define the top image when a slide is closed
		}		
	});

	// --> Uudet autot Accordion
	
	var accordion_new_cars = new Accordion($('accordion_new_cars'), 'div.toggler_new_cars', 'div.element_new_cars', {
		display: 0,			// Define an open element on start -- a number (0 = first element, 1 = second element, 2 = third element etc.) or false
		opacity: true,			// Define a fade between slidechanges to true on false
		alwaysHide: true,			// Define if the accordion is closable or not
		onActive: function(toggler, element){
			toggler.setStyle('background', 'url(img/gui/382x24_list_minus.gif) no-repeat');			// Define the top image when a slide is opened
		},
		onBackground: function(toggler, element){
			toggler.setStyle('background', 'url(img/gui/382x24_list_plus.gif) no-repeat');			// Define the top image when a slide is closed
		}		
	});

	// --> Rent Accordion
	
	var accordion_rent = new Accordion($('accordion_rent'), 'div.toggler_rent', 'div.element_rent', {
		display: 0,			// Define an open element on start -- a number (0 = first element, 1 = second element, 2 = third element etc.) or false
		opacity: true,			// Define a fade between slidechanges to true on false
		alwaysHide: true,			// Define if the accordion is closable or not
		onActive: function(toggler, element){
			toggler.setStyle('background', 'url(img/gui/382x24_list_minus.gif) no-repeat');			// Define the top image when a slide is opened
		},
		onBackground: function(toggler, element){
			toggler.setStyle('background', 'url(img/gui/382x24_list_plus.gif) no-repeat');			// Define the top image when a slide is closed
		}		
	});

	// --> Bottom Accordion

	var accordion_bottom = new Accordion($('accordion_bottom'), 'a.toggler_bottom', 'div.element_bottom', {
		display: false,			// Define an open element on start -- a number (0 = first element, 1 = second element, 2 = third element etc.) or false
		opacity: true,			// Define a fade between slidechanges to true on false
		alwaysHide: true			// Define if the accordion is closable or not
	});

	$$('#accordion_bottom .close').addEvent('click', function() {
		accordion_bottom.display(); 		// Closing tags
	});
	
	// --> Bottom AJAX Form 1
	
	$$('.ajax-form_1').addEvent('submit', function(e) {
		
		e.stop();	// Prevents the default submit event from loading a new page.
		
		$$('.response_1').set('id', 'response_1');
		
		var log = $('response_1').getElement('div').empty().addClass('ajax-loading');	// Empty the log and show the spinning indicator.
		
		// Set the options of the form's Request handler. 
		
		this.set('send', {onComplete: function(response) { 
			log.removeClass('ajax-loading');
			log.set('html', response);
		}});
		
		this.send();	// Send the form.
	});

	// --> Bottom AJAX Form 2
	
	$$('.ajax-form_2').addEvent('submit', function(e) {
		
		e.stop();	// Prevents the default submit event from loading a new page.
		
		$$('.response_2').set('id', 'response_2');
		
		var log = $('response_2').getElement('div').empty().addClass('ajax-loading');	// Empty the log and show the spinning indicator.
		
		// Set the options of the form's Request handler. 
		
		this.set('send', {onComplete: function(response) { 
			log.removeClass('ajax-loading');
			log.set('html', response);
		}});
		
		this.send();	// Send the form.
	});
	
	// Smooth page scroller
	
	$$('#accordion_bottom .bottom').each(function(el) {
		if(el.get('name') && !el.get('id'))
		{
			el.set('id',el.get('name'));
		}
	});
	
	new SmoothScroll({ duration:500 }, window);



// Tips - INFO
	
	// --> Uudet autot 2 valinta - Table Cols Varusteet
	
	var tips_info = new Tips($$('.tips_info'), {			// Define container for tips
			showDelay: 100,			// Define the delay for the tip showing
			hideDelay: 100			// Define the delay for the tip hiding
		});



// Calendars

	myCal = new Calendar({ date: 'j.n.Y' }, { direction: 1, tweak: { x: -173, y: 1 }});			// Calendar 1 --> Varaa koeajo - Left Accordion
	myCal1 = new Calendar({ rentDate1: 'j.n.Y' }, { direction: 1, tweak: { x: -173, y: 1 }});			// Calendar 2 --> Alaosio Rent 3
	myCal2 = new Calendar({ rentDate2: 'j.n.Y' }, { direction: 1, tweak: { x: -173, y: 1 }});			// Calendar 3 --> Alaosio Rent 3
	
});
