function my_fadein(item_name, time) {
	$(item_name).hide();
	$(item_name).fadeIn(time);
}

function my_slidedown(item_name,time) {
	$(item_name).hide();
	$(item_name).slideDown(time);
}

function my_hover(item_name, fade_time, opacity_min) {
	$(item_name).stop().css('opacity', 1.0);
	$(item_name).each(function() {
		$(this).hover(function() {
			$(this).stop().animate({ opacity: opacity_min }, fade_time);
		},
		function() {
			$(this).stop().animate({ opacity: 1.0 }, fade_time);
		});
	});
}

function my_tooltip(item_name) {
	$(item_name).hover(function(event) {
		this.tip = this.title;
		this.width = $(this).width();
		$(this).append('<div class="t"><span>'+this.tip+'</span></div>');
		this.title = '';
		var xcss = event.pageX + 24 + 'px';
		var ycss = event.pageY + 24 + 'px';
		$(this).find('.t').css({'position':'absolute','left':xcss,'top':ycss});
		$('.t').hide();
		$(this).children('img').css('opacity',0.5);
		$('.t').css('opacity',0.9).slideDown(500);
	},
	function() {
		$(this).children('img').css('opacity', 1);
		$('.t').fadeOut(1000);
		$(this).children('.t').remove();
		this.title = this.tip;
		}
	);
}

$(window).ready(function() {
	my_tooltip('.social_icon');
	my_tooltip('.flag_icon');
});
