$(function(){
	// 推荐微博冒泡
	if($('.loveTip')){
		$('.loveTip').poshytip({
			className: 'tip-bluesimple',
			content: function(updateCallback) {
				window.setTimeout(function() {
					updateCallback(function(){return $(this).attr("tip");});
				}, 100);
				return $(this).attr("tip");
			},
			showTimeout: 1,
			alignTo: 'target',
			alignX: 'center',
			liveEvents:	true,
			offsetY: 5,
			allowTipHover: false
		});
	}
	
	// 话题冒泡
	if($('.hao123_tip')){
		shiwan_tip("hao123_tip", 4);
	}
	// 话题冒泡
	if($('.topic_tip')){
		shiwan_tip("topic_tip", 3);
	}
	//游戏冒泡
	if($('.game_tip')){
		shiwan_tip("game_tip", 2);
	}
	//用户冒泡
	if($('.user_tip')){
		shiwan_tip("user_tip", 1);
	}
	
});

function shiwan_tip(cssName, type)
{
	if(type == 1){var tipClass = "class_user_tip";	}
	if(type == 2){var tipClass = "class_game_tip";	}
	if(type == 3){var tipClass = "class_topic_tip";	}
	if(type == 4){var tipClass = "class_hao123_tip";	}
	$('.'+cssName).poshytip({
		className: tipClass,
		alignTo: 'cursor',
		alignX: 'center',
		liveEvents:	true,	
		content: function(updateCallback){
			var html = "";
			var id = $(this).attr("tipid");
			$.ajax({
				type: "get",
				url: "/weibo/getlayer",
				data :{id:id,type:type,format:"json"},
				dateType:"json",
				success: function(data, textStatus){
					html = data["html"];
					updateCallback(html);
				}
			});
			return "正在加载……";
		}
	});
}

function shiwanDir(){
	// 游戏目录浮动链接
	$(".result_list li").mouseover(function(){
		$(this).addClass("curr");
		$(this).find("div.dir_ido").show();
	});
	$(".result_list li").mouseout(function(){
		$(this).removeClass("curr");
		$(this).find("div.dir_ido").hide();
	});
	
	// 目录排序下拉菜单
	$(".dir_sort").mouseover(function(){
		$(this).addClass("sort_hover");
		$("ul.sort_list").show();
	});
	$(".dir_sort").mouseleave(function(){
		$("ul.sort_list").hide();
		$(this).removeClass("sort_hover");
	});
	$("ul.sort_list").mouseover(function(){
		$(".dir_sort").addClass("sort_hover");
		$(this).show();
	});
	$("ul.sort_list").mouseleave(function(){
		$(".dir_sort").removeClass("sort_hover");
		$(this).hide();
	});	
}
