$(document).ready(function() {
	/* Input resets */
	$('input.reset, textarea.reset').each(function() {
		var def = $(this).val();
		
		$(this).focus(function() {
			if($(this).val() == def)
				$(this).val('').removeClass('reset-off');
		}).blur(function() {
			if($(this).val() == '')
				$(this).val(def).addClass('reset-off');
		});
	});
	
	
	/* Email obfuscation */
	$('a.email').each(function() {
		var mail = $(this).text().replace(/([0-9A-Fa-f]{2})/g, function() {
			return String.fromCharCode(parseInt(arguments[1], 16));
		});
		
		$(this).text(mail).attr('href', 'mailto:'+mail);
	});
	
	
	/* News roller */
	
	var news_i = 0;
	var news = $('.news p');
	
	news.hide().eq(0).fadeIn(500);
	
	setInterval(function() {
		news.eq(news_i++ % news.length).fadeOut(500);
		news.eq(news_i % news.length).delay(500).fadeIn(500);
	}, 5000);
	
});
