
var tagbox_tip_fade_out = null;

// inits tooltips
function init_tips()
{
	// add the animations for the form tips
	$('form .note, #uploaded .note').not('#uploaded #thumbnote').css('opacity', '0').css('display', 'none');
	
	$('form input, #uploaded input').livequery('focus', function()
	{
		$('form .note').stop(true).animate({opacity: '0'}, 400, 'swing', function()
		{
			$(this).css('display', 'none');
		}); // to make sure that the tagbox tip disappears
		
		$(this).prev('.note').stop(true).css('display', 'block').animate({opacity: '1'}, 400);
	});
	$('form textarea').livequery('focus', function()
	{
		$('form .note').stop(true).animate({opacity: '0'}, 400, 'swing', function()
		{
			$(this).css('display', 'none');
		}); // to make sure that the tagbox tip disappears
		$(this).prev('.note').stop(true).css('display', 'block').animate({opacity: '1'}, 400);
	});
	$('form input, #uploaded input').livequery('blur', function()
	{
		$(this).prev('.note').stop(true).animate({opacity: '0'}, 400, 'swing', function()
		{
			$(this).css('display', 'none');
		});
	});
	$('form textarea').livequery('blur', function()
	{
		$(this).prev('.note').stop(true).animate({opacity: '0'}, 400, 'swing', function()
		{
			$(this).css('display', 'none');
		});
	});
	$('form .tagbox, form .tagbox *').livequery('click', function()
	{
		$(this).prev('.note').stop(true).css('display', 'block').animate({opacity: '1'}, 400);
		
		clearTimeout(tagbox_tip_fade_out);
		tagbox_tip_fade_out = setTimeout('close_tagbox_tip()', 4000);
	});
	
	// Hide additional SPAM robots protection
	if($('div#maths_block').length > 0)
	{
		$('input#maths').val('2');
		$('div#maths_block').hide();
	}
}

function close_tagbox_tip()
{
	var note = $('form .tagbox').prev('.note');
	
	$(note).fadeOut(600, function()
	{
		$(note).css('display', 'none');
	});
}

$(function()
{
	$('#uploaded .note').hide();
	init_tips();
	
	$('.message .close').click(function()
	{
		$(this).parent().slideUp(700, function()
		{
			$(this).parent().remove();
		});
	});
	
	$('#header .logo').addClass('js-hover-on').append('<span class="hover"></span>');
	$('#header .logo span.hover').css('opacity', 0);
	$('#header .logo').hover(function()
	{
		$('#header .logo span.hover').stop().fadeTo(500, 1);
	},
	function()
	{
		$('#header .logo span.hover').stop().fadeTo(500, 0);
	});
	
	// edit avatar hover tip (GRAVATAR HINT)
	$('a.edit-avatar').hover(function(){
		$('.gravatar_notice').fadeIn()
	},function(){
		$('.gravatar_notice').fadeOut()
	})
	
});

