jQuery(document).ready(function($){
	
	//
	//	Nicetitle
	//
	$('a').each(function(i,e){
		if ($(this).attr('title')) {
			$(this).append('<div class="nicetitle" style="top: '+($(this).offset().top+$(this).height())+'px; left: '+$(this).offset().left+'px; width: 300px;">'+$(this).attr('title')+'</div>');
			$(this).attr('nicetitle', $(this).attr('title'));
			$(this).children('img').removeAttr('title');
			$(this).mouseenter(function(){
				$(this).removeAttr('title');
				$(this).children('.nicetitle:first').show();
			});
			$(this).mouseleave(function(){
				$(this).children('.nicetitle:first').hide();
			});
			$(this).mousemove(function(e){
				var el = $(this).children('.nicetitle:first');
				el.css({'top': (e.pageY+25)+'px', 'left': (e.pageX+20)+'px'});
			});
			$(this).click(function(){
				$('a').each(function(i,e){
					if ($(this).attr('nicetitle')) {
						$(this).attr('title', $(this).attr('nicetitle'));
					}
				});
			});
		}
	});

	$('.nicetitle').hide();
	
	
	//
	//	Shadowed
	//

	var shadowed_focus = '#ffffff';
	var shadowed_blur = '#662222';

	$('#search input:submit').hide();

	$('.shadowed').focus(function(){
		$(this).css('color',shadowed_focus);
		if ($(this).val() == $(this).attr('title')) {
			$(this).val('');
		}
	});
	
	$('.shadowed').blur(function(){
		if ($(this).val() == '') {
			$(this).val($(this).attr('title'));
			$(this).css('color',shadowed_blur);
		}
	});
	
	function clean_shadowed(what){
		what.find('.shadowed').each(function(){
			if ($(this).val() == $(this).attr('title')) {
				$(this).val('');
			}
		});
	}

	$('#search input:submit').click(function(){
		clean_shadowed($(this).parent());
	});
	
	$('.shadowed').each(function(){
		if (jQuery.inArray($(this).val(), ['',$(this).attr('title')]) != -1) {
			$(this).val($(this).attr('title'));
			$(this).css('color',shadowed_blur);
		} else {
			$(this).css('color',shadowed_focus);
		}
	}); 	
	
	
});
