
window.addEvent('domready', function() {
	
	/* contact form */
	if($('contactForm')) {
		$('contactForm').addEvent('submit', function(e) {


			new Event(e).stop();

			var log = $('contactThanks').empty().addClass('contact-ajax');
		
			$('formContainer').addClass('hide');

			evalScripts: true;
		
			this.send({
				update: log,
				onComplete: function() {
					log.removeClass('contact-ajax');
				}
			});
		});
	}
	
	if($('dietryForm')) {
		
		$('dietryForm').addEvent('submit', function(e) {
				new Event(e).stop();
				this.send({update: $('buttons')});
				$('buttons').empty();	
			});
	}
	
	if($('maybeForm')) {
		
		$('maybeForm').addEvent('submit', function(e) {
				new Event(e).stop();
				this.send({update: $('buttons')});
				$('buttons').empty();	
			});
	}
	
	if($('noForm')) {
		
		$('noForm').addEvent('submit', function(e) {
				new Event(e).stop();
				this.send({update: $('buttons')});
				$('buttons').empty();	
			});
		
	}
	
	if($('noWayForm')) {
		
		$('noWayForm').addEvent('submit', function(e) {
				new Event(e).stop();
				this.send({update: $('result')});
				$('result').empty();	
			});
		
	}
	
	if($('remindForm')) {
		
		$('remindForm').addEvent('submit', function(e) {
				new Event(e).stop();
				this.send({update: $('result')});
				$('result').empty();	
			});
		
	}
	
	if($('tweenSubject')) {	
		// doesn't seem to work with our version of mootools
	 	//highlight('tweenSubject');
	}
});

function highlight(element) {
	var myFx = new Fx.Tween(element);
	myFx.set('tween', {duration: 'long'});
	myFx.start('background-color', '#ffffff', '#FFD391');
}

/* news toggler */
function updateNews(id) {
	var url = "ajax/news.ajax.php?id="+id;
	
	var log = $('news').empty();
	
	evalScripts: true;

	new Ajax(url, {
		method: 'get',
		update: log
	}).request();
}

function tryAgain() {
	$('formContainer').removeClass('hide');
	$('contactThanks').empty();	
}

function clearBox(string,element) {
	var item = $(element);
	if(item.value == string) {
		item.value = '';
	}
}

function fillBox(string,element) {
	var item = $(element);
	if(item.value == '') {
		item.value = string;
	}
}