$(document).ready(function(){

	
	if($("#isShowFan").val() == '1')
	{
		location.href = "#showFan";
	}
	/**
	 * 添加偶像
	 */
	$("#addFan").click(function(){
		var userID = $("#userIDShow").val();
		confirmAddFanName(userID);
	});
	
	/**
	 * 显示全部粉丝信息
	 */
	$("#otherFansShowClick").click(function(){
		var userID = $("#userIDShow").val();
		var userfannum = $("#userfannum").val();
		$.ajax({
			type:"POST",
			url:"/users.php",
			data:"userid="+userID+"&userfannum="+userfannum,
			success:function(msg){
				$("#otherFansShow").toggle().html(msg);
			}
		});
	});
	
	
	//我最近制作的歌单
	$("#myRecentDoMake").click(function(){
		var userID = $("#userIDShow").val();
		$("#myRecentDoMake").removeClass("link_7").addClass("active no_split font_8");
		$("#myRecentCollect").removeClass("active no_split font_8").addClass("link_7");
		$.ajax({
			type:"POST",
			url:"/users.php",
			data:"myRecentDoShow=make&userID="+userID,
			success:function(msg){
				$("#myRecentDoShow").html(msg);
				orig_id = "myML_1";
			}
		});
	});
	
	//我最近收藏的歌单
	$("#myRecentCollect").click(function(){
		var userID = $("#userIDShow").val();
		$("#myRecentCollect").removeClass("link_7").addClass("active no_split font_8");
		$("#myRecentDoMake").removeClass("active no_split font_8").addClass("link_7");
		$.ajax({
			type:"POST",
			url:"/users.php",
			data:"myRecentDoShow=collect&userID="+userID,
			success:function(msg){
				$("#myRecentDoShow").html(msg);
				orig_id = "myML_1";
			}
		});
	});
	
	var orig_id = "myML_1";
	$("#myRecentDoShow .listItem").live("mouseover",function()
	{
		if($(this).attr("id") != orig_id)
		{
			$(this).addClass("zoom_item").removeClass("orig_item");
			$("#" + orig_id).removeClass("zoom_item").addClass("orig_item");
			orig_id = $(this).attr("id");
		}
	});
	
	var orig_id2 = "myRML_1";
	$("#userecomment .listItem").live("mouseover",function()
	{
		if($(this).attr("id") != orig_id2)
		{
			$(this).addClass("zoom_item").removeClass("orig_item");
			$("#" + orig_id2).removeClass("zoom_item").addClass("orig_item");
			orig_id2 = $(this).attr("id");
		}
	});
	
	var orig_id3 = "listened_1";
	$("#uservisitlogs .listItem").live("mouseover",function()
	{
		if($(this).attr("id") != orig_id3)
		{
			$(this).addClass("zoom_item").removeClass("orig_item");
			$("#" + orig_id3).removeClass("zoom_item").addClass("orig_item");
			orig_id3 = $(this).attr("id");
		}
	});
	
});


/**
 * ajax实现添加偶像
 * @param userid
 * @return
 */
function confirmAddFanName(userid){
if(confirm("您确定要成为Ta的粉丝吗？")){
			$.ajax({
				type:"POST",
				url:"/users.php",
				data:"addFanID="+userid,
				success:function(msg){
					if(msg.indexOf("TRUE") > -1){
						alert("添加成功");
					}else if(msg.indexOf("FALSE") > -1){
						alert("你已经是他的粉丝了");
					}else if(msg.indexOf("SAME") > -1){
						alert("您不能加自己为偶像");
					}else if(msg.indexOf("NOLOGIN") > -1){
						$("#idBoxLoginOpen").click();
					}else{
						alert("我也不知道你哪错了");
					}
				}
			});
	}
}
