window.addEvent('domready', function() {


	if ( $defined($('locations-trigger')) ) {
		$('locations-panel').setStyle('display', 'block');
		var locationspanel_slide = new Fx.Slide($('locations-panel'), {mode: 'vertical', duration: 200, transition: Fx.Transitions.Sine.easeInOut}).hide();

		$('locations-trigger').addEvent('click', function(e){
			e.stop();
			
			if ( locationspanel_slide.open ) {
				this.removeClass('on');
				locationspanel_slide.slideOut();
			} else {
				this.addClass('on');
				locationspanel_slide.slideIn();
			}
		});

	}



	var faqScroll = new Fx.Scroll( $('pagebody'), {
		duration: 500
	});

	var faq_anchor_index;
	$$('.faqs-questions li a').each( function(trigger, index) {
		trigger.addEvent('click', function(e){
			e.stop();
			faq_anchor_index = index + 1;
			faqScroll.toElement('faq' + faq_anchor_index);
		});
	});



	$$('.backtotop').addEvent('click', function(e){
		e.stop();
		faqScroll.toTop();
	});



	/*
	http://davidwalsh.name/mootools-form-field-default-plugin
	*/
	var dwDefaults = new Class({
		//implements
		Implements: [Options],
	
		//options
		options: {
			collection: $$('input[type=text]')
		},
		
		//initialization
		initialize: function(options) {
			//set options
			this.setOptions(options);
			this.defaults();
		},
		
		//a method that does whatever you want
		defaults: function() {
			this.options.collection.each(function(el) {
				el.set('value',el.get('alt'));
				el.addEvent('focus', function() { if(el.get('value') == el.get('alt')) { el.set('value',''); } });
				el.addEvent('blur', function() { if(el.get('value') == '') { el.set('value',el.get('alt')); } });
			});
		}
		
	});

});