Cufon.replace(['h2']);

$(document).ready(function() {
	$('#head h2').fadeIn(1000);
	
	$('a.mail').each(function() {
		var mail = $(this).text().split('').reverse().join('');

		$(this).text(mail).attr('href', 'mailto:'+mail);
	});
	
	$('.reset').each(function() {
		var def = $(this).val();
		this.def = def;
		
		$(this).focus(function() {
			if($(this).val() == def) $(this).val('').removeClass('reset');
		}).blur(function() {
			if($(this).val() == '') $(this).val(def).addClass('reset');
		});
	});
	
	$('form').submit(function() {
		var error = false;
		
		$(this).find('.required').each(function() {
			if($(this).val() == '' || $(this).val() == this.def) {
				$(this).hide().fadeIn();
				error = true;
			}
		});
		
		if(error) {
			$('p.error').remove();
			$(this).append('<p class="error"><b>Hey!</b> Please fill at least your name and idea...</p>');
			$('p.error').hide().fadeIn();
			
			return(false);
		}
		
		$.post($(this).attr('action'), $(this).serialize());
		
		$(this).empty().html('<p class="thx">Thanks for contacting us!</p>')
		$(this).find('p').hide().fadeIn();
		
		spaceConverse('contact');
		
		return(false);
	});
	
	setInterval(function() {
		$('span.pipe').fadeOut(250).fadeIn(500);
	}, 1000);
	
	$('#code').val('Fj97'+'Da9G');
});
