window.addEvent('domready', function(){
	
	var myTips = new Tips('.thisisatooltip', {
		className: 'bubble',
		showDelay: 100,
		hideDelay: 400
		
	});
	
	myTips.addEvents({
		'show': function(tip) {
			tip.fade('in');
		},
		'hide': function(tip) {
			tip.fade('out');
		}
	});
	
	$('result').fade(0);
	
 	$('sendmail').addEvent('submit', function(e) {
		e.stop();
		$('result').fade(1);
		$('sendmail').fade(0);
		var log = $('result').empty().addClass('ajax-loading');
		
		this.set('send', {onComplete: function(response) { 
			log.removeClass('ajax-loading');
			log.set('html', response);
		}});
		
		this.send();
	});
	
	var PulseFade = new Class({
			
		//implements
		Implements: [Options,Events],
	
		//options
		options: {
			min: 0,
			max: 1,
			duration: 200,
			times: 5
		},
		
		//initialization
		initialize: function(el,options) {
			//set options
			this.setOptions(options);
			this.element = $(el);
			this.times = 0;
		},
		
		//starts the pulse fade
		start: function(times) {
			if(!times) times = this.options.times * 2;
			this.running = 1;
			this.fireEvent('start').run(times -1);
		},
		
		//stops the pulse fade
		stop: function() {
			this.running = 0;
			this.fireEvent('stop');
		},
		
		//run
		run: function(times) {
			var self = this;
			var to = self.element.get('opacity') == self.options.min ? self.options.max : self.options.min;
			self.fx = new Fx.Tween(self.element,{
				duration: self.options.duration / 2,
				onComplete: function() {
					self.fireEvent('tick');
					if(self.running && times)
					{
						self.run(times-1);
					}
					else
					{
						self.fireEvent('complete');
					}
				}
			}).start('opacity',to);
		}
	});
	
	var pf1 = new PulseFade('link1',{
		min: 0.1,
		max: 0.4,
		duration: 1700,
		times: 9000
	});
	
	var pf2 = new PulseFade('link2',{
		min: 0.1,
		max: 0.4,
		duration: 1200,
		times: 9000
	});
	
	var pf3 = new PulseFade('link3',{
		min: 0.2,
		max: 0.4,
		duration: 1700,
		times: 9000
	});
	
	var pf4 = new PulseFade('link4',{
		min: 0.1,
		max: 0.3,
		duration: 1500,
		times: 9000
	});
	
	var pf5 = new PulseFade('link5',{
		min: 0.2,
		max: 0.5,
		duration: 1300,
		times: 9000
	});
	
	pf1.start();
	pf2.start();
	pf3.start();
	pf4.start();
	pf5.start();
	
	var myMenu = new MenuMatic();
	
});
