$(function() {
/*下拉*/
	$(".letter_left").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
  	});
	
/*下拉*/
	$(".letter_right").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	
	$(".head_information_skin").click(function(){
		$.ajax({
			type:"POST",
			url:"/my/wallpaper",
			dataType:"json",
			success:function(res){
				if(QzTool.ajaxLoginCheck(res)===false){return ;}
				if(res.status==0){alert(res.msg);return false;}
				$("#wallpaper").html(res.html);
				$("#set_wallpaper").popupSkin();
			}
		});
		
	});

	/*皮肤*/
	$.fn.popupSkin = function() {
		//获取滚动条高度 for ie6
		var $docWidth = document.documentElement.clientWidth / 2;
		var $scrTop = document.documentElement.scrollTop || document.body.scrollTop
		var $docHeight = (document.documentElement.clientHeight / 2) + $scrTop;
		var $scrHeight = document.body.scrollHeight;

		//获得窗口高度和对象高度，除以2居中，40微调
		var $winHeight = $(window).height();
		// $h = $winHeight - this.height();
		// $h = $h / 2 + 100;
		$h = $docHeight - (this.height() / 2);

		//获得窗口宽度和对象宽度，除以2居中
		var $winWidth = $(window).width();
		$w = $winWidth - this.width();
		$w = $w / 2;

		//-----结构
		$(".ui_mask").show().height($scrHeight);
		this.css({
			"top": $h + "px",
			"left": $w + "px",
			"display" : "block",
			"z-index" : "9999999"
		});

		// 隐藏Div的方法
		$hideDiv = function(){
			$(".ui_mask,.ui_popup").hide();
			$("body").css("overflow","auto");
			$(".ui_popup").find(".add_tool_list").remove();
		};

		//关闭
		$(".send_close,.cancel").click(function() {
			$hideDiv();
		});
		//绑定Esc键移除Div
		$("body").bind("keydown",function(){
			if (event.keyCode == 27) {
				$hideDiv();
			};
		});
	};


	/*float start*/
	if (checkId("cloud")) {
		var $ul = $("#cloud");
	}else{
		var $ul = "";
	};
	if ($ul!="") {
		var $ulTop = $ul.offset().top;
	}else{
		var $ulTop =0;
	};	
	window.onscroll = function(){
		var $scroll = $(document).scrollTop();
		if ($ulTop!=0) {
			if ($scroll > $ulTop) {
				$ul.css({
					"position" : "fixed",
					"top" :"0" 
				});
			} else {
				$ul.css({
					"position" : "static",
					"top" : "auto"
				});
			};
		};
	};
	/*float end*/


	$(".feed_content").hover(function(){
		$(this).addClass("dd_hover");
	},function(){
		$(this).removeClass("dd_hover");
	});
	$(".name_content,.item").hover(function(){
		$(this).addClass("dd_hover");
	},function(){
		$(this).removeClass("dd_hover");
	});
	$(".personal_feed_content").hover(function(){
		$(this).addClass("dd_hover");
	},function(){
		$(this).removeClass("dd_hover");
	});
	$(".system_feed_content").hover(function(){
		$(this).addClass("dd_hover");
	},function(){
		$(this).removeClass("dd_hover");
	});
	$(".copyText li").hover(function(){
		$(this).addClass("on");
	},function(){
		$(this).removeClass("on");
	});
	$(".group_list").hover(function(){
		$(this).addClass("dd_hover");
	},function(){
		$(this).removeClass("dd_hover");
	});
	/*显示删除按钮*/
	$(".group_list,.name_content,.feed_content,.skin_con,.item,.head_release_linkHeadPic,.linkHeadPic1111").hover(function(){
		$(this).find(".del_my_item").css("display","block");
		$(this).find(".name_content_del").css("visibility","visible");
	},function(){
		$(this).find(".del_my_item").css("display","none");
		$(this).find(".name_content_del").css("visibility","hidden");
	});

	/*$(".comments ul li .right").hover(function(){
		$(this).find(".report").show();
	},function(){
		$(this).find(".report").hide();
  	});*/

	$(".member_info .pimg").hover(function(){
	    $(this).find(".change").show();
	}
	,function(){
	    $(this).find(".change").hide();
	});
	
});

function checkId(id){
	var myId=document.getElementById(id);
	if (myId){return true;}else{return false;};
};
function ieBackground(src){
	var win_width = $(window).width();
	var win_height = $(window).height();
	$("body").removeAttr("style");
	$("#main_iebg").remove();
	$("head").append('<style type="text/css">#main_iebg{position:fixed;left:0;top:0;z-index:-100;}<style>');
	$("body").append("<div id='main_iebg'></div>");
	$("#main_iebg").append("<img src='"+src+"' id='ie_pic' />");
	var iepic_w=$("#ie_pic").width();
	var iepic_h=$("#ie_pic").height();
	var num_w=win_width / iepic_w;
	var num_h=win_height / iepic_h;
	var new_width=0;
	var new_height=0;
	if (num_w>num_h) {
		new_width=Math.round(iepic_w * num_w);
		new_height=Math.round(iepic_h * num_w);
	}else if(num_w<num_h){		
		new_width=Math.round(iepic_w * num_h);
		new_height=Math.round(iepic_h * num_h);
	}else{
		new_width=win_width;
		new_height=win_height;
	};
	var margin_left=new_width / 2;
	$("#ie_pic").attr({height:new_height,width:new_width});
	$("#main_iebg").attr({"style":"margin-left:-"+margin_left+"px;left:50%;top:0;"});
};


ActMember={
	replyMessage:function(user_id,msg_type){
		$.ajax({
			type:"POST",
			url:"/ajax/actmessage?method=messagebox",
			data:"user_id="+user_id+"&msg_type="+msg_type,
			dataType:"json",
			success:function(res){
				if(QzTool.ajaxLoginCheck(res)===false){return false;}
				if (res.status==200) {
					$("body").append(res.html);
					var my=mypostion(".send_con");
					$(".send_con").css({"position":"absolute","z-index":"9999999","top":my.top+"px","left":my.left+"px"});
					$(".ui-mask").show();
					$(".send_con").show();
				}else{
					myTips(res.msg,"error");
					return false;
				};
			}
		});
	},
	sendMessage:function(user_id){
	    var message=$.trim($("#message").val());
	    var captcha=$.trim($("#captcha").val());
	    var msg_type=$.trim($("#msg_type").val());
	    $.ajax({
	        type:"POST",
	        url:"/ajax/actmessage?method=sendmessage",
	        data:"user_id="+user_id+"&message="+message+"&captcha="+captcha+"&msg_type="+msg_type,
	        dataType:"json",
	        success:function(res){
	        	if(QzTool.ajaxLoginCheck(res)===false){return ;}
	            if (res.status==200) {
		                myTips(res.msg,"success");
		                $("#messageBox").remove();
	            }else{
		            myTips(res.msg,"error");
	                return false;
	            };
	        }
	    });
	},
	deleteMessage:function(message_id,delete_type){
		if(confirm("确定要删除私信吗？")){
			$.ajax({
		        type:"POST",
		        url:"/ajax/actmessage?method=deletemessage",
		        data:"message_id="+message_id+"&delete_type="+delete_type,
		        dataType:"json",
		        success:function(res){
		        	if(QzTool.ajaxLoginCheck(res)===false){return ;}
		            if (res.status==200) {
		            	$("#message_"+res.message_id).remove();
		            	myTips(res.msg,"success");
		            }else{
		            	myTips(res.msg,"error");
		                return false;
		            };
		        }
		    });
		}
	},
	/*delShow:function(show_id,user_id){
		if(confirm("删除自拍需要扣除100金币\n确定删除吗？")){
			$.ajax({
				type:"POST",
				url: "/show/actdel",
				data:"show_id="+show_id+"&user_id="+user_id,
				dataType:"json",
				success:function(res){
					if(res.status==403){
						myTips(res.msg,"error");return false;
					};
					if (res.msg!=''&&res.msg!==null){
						myTips(res.msg,"success");
					};
					$("#share_"+res.show_id).remove();
				}
			});
		};
	},*/
	delName:function(name_id){
		$(".alert").html("<img src='images/loading.gif'>正在删除中...");
		var my=mypostion(".alert");
		$(".alert").css({"position":"absolute","z-index":"9999999","top":my.top+"px","left":my.left+"px"});
		$.ajax({
			type:"POST",
			url: "/my/deleteshare?nav=name",
			data:"name_id="+name_id,
			dataType:"json",
			success:function(res){
				if(res.status!='200'){
					myTips(res.msg,"error");return false;
				};
				$(".ui-mask,.alert").remove();
				myTips(res.msg,"success");
				$("#share_"+res.name_id).remove();
			}
		});
	},
	delSign:function(sign_id){
		$(".alert").html("<img src='images/loading.gif'>正在删除中...");
		var my=mypostion(".alert");
		$(".alert").css({"position":"absolute","z-index":"9999999","top":my.top+"px","left":my.left+"px"});
		$.ajax({
			type:"POST",
			url: "/my/deleteshare?nav=sign",
			data:"sign_id="+sign_id,
			dataType:"json",
			success:function(res){
				if(res.status!='200'){
					myTips(res.msg,"error");return false;
				};
				$(".ui-mask,.alert").remove();
				myTips(res.msg,"success");
				$("#share_"+res.sign_id).remove();
			}
		});
	},
	delGroup:function(group_id){
		$(".alert").html("<img src='images/loading.gif'>正在删除中...");
		var my=mypostion(".alert");
		$(".alert").css({"position":"absolute","z-index":"9999999","top":my.top+"px","left":my.left+"px"});
		$.ajax({
			type:"POST",
			url: "/my/deleteshare?nav=group",
			data:"group_id="+group_id,
			dataType:"json",
			success:function(res){
				if(res.status!='200'){
					myTips(res.msg,"error");return false;
				};
				$(".ui-mask,.alert").remove();
				myTips(res.msg,"success");
				$("#share_"+res.group_id).remove();
			}
		});
	},
	delNote:function(note_id){
		$(".alert").html("<img src='images/loading.gif'>正在删除中...");
		var my=mypostion(".alert");
		$(".alert").css({"position":"absolute","z-index":"9999999","top":my.top+"px","left":my.left+"px"});
		$.ajax({
			type:"POST",
			url: "/my/deleteshare?nav=note",
			data:"note_id="+note_id,
			dataType:"json",
			success:function(res){
				if(res.status!='200'){
					myTips(res.msg,"error");return false;
				};
				$(".ui-mask,.alert").remove();
				myTips(res.msg,"success");
				$("#share_"+res.note_id).remove();
			}
		});
	},
	delAvatar:function(avatar_id){
		$(".alert").html("<img src='images/loading.gif'>正在删除中...");
		var my=mypostion(".alert");
		$(".alert").css({"position":"absolute","z-index":"9999999","top":my.top+"px","left":my.left+"px"});
		$.ajax({
			type:"POST",
			url: "/my/deleteshare?nav=avatar",
			data:"avatar_id="+avatar_id,
			dataType:"json",
			success:function(res){
				if(res.status!='200'){
					myTips(res.msg,"error");return false;
				};
				$(".ui-mask,.alert").remove();
				myTips(res.msg,"success");
				$("#share_"+res.avatar_id).remove();
			}
		});
	},
	delPic:function(pic_id){
		$(".alert").html("<img src='images/loading.gif'>正在删除中...");
		var my=mypostion(".alert");
		$(".alert").css({"position":"absolute","z-index":"9999999","top":my.top+"px","left":my.left+"px"});
		$.ajax({
			type:"POST",
			url: "/my/deleteshare?nav=pic",
			data:"pic_id="+pic_id,
			dataType:"json",
			success:function(res){
				if(res.status!='200'){
					myTips(res.msg,"error");return false;
				};
				$(".ui-mask,.alert").remove();
				myTips(res.msg,"success");
				$("#share_"+res.pic_id).remove();
			}
		});
	},
	delSkin:function(skin_id){
		$(".alert").html("<img src='images/loading.gif'>正在删除中...");
		var my=mypostion(".alert");
		$(".alert").css({"position":"absolute","z-index":"9999999","top":my.top+"px","left":my.left+"px"});
		$.ajax({
			type:"POST",
			url: "/my/deleteshare?nav=skin",
			data:"skin_id="+skin_id,
			dataType:"json",
			success:function(res){
				if(res.status!='200'){
					myTips(res.msg,"error");return false;
				};
				$(".ui-mask,.alert").remove();
				myTips(res.msg,"success");
				$("#share_"+res.skin_id).remove();
			}
		});
	},
	delShow:function(show_id){
		$(".alert").html("<img src='images/loading.gif'>正在删除中...");
		var my=mypostion(".alert");
		$(".alert").css({"position":"absolute","z-index":"9999999","top":my.top+"px","left":my.left+"px"});
		$.ajax({
			type:"POST",
			url: "/my/deleteshare?nav=show",
			data:"show_id="+show_id,
			dataType:"json",
			success:function(res){
				if(res.status!='200'){
					myTips(res.msg,"error");return false;
				};
				$(".ui-mask,.alert").remove();
				myTips(res.msg,"success");
				$("#share_"+res.show_id).remove();
			}
		});
	},
	delShare:function(mapping_id,nav){
		$.ajax({
			type:"POST",
			url: "/ajax/fetchdeletecard",
			data:"nav="+nav+"&mapping_id="+mapping_id,
			dataType:"json",
			success:function(res){
				if(res.status!='200'){
					myTips(res.msg,"error");
					return false;
				}else{
					$("body").append(res.html);
					$(".ui-mask").show();
					var my=mypostion(".alert");
					$(".alert").css({"position":"absolute","z-index":"9999999","top":my.top+"px","left":my.left+"px"});
				};
			}
		});
	},
	setSkin:function(o){
		// alert('22');return false;
		$.ajax({
			type:"POST",
			url:"/my/wallpaper",
			dataType:"json",
			success:function(res){
				if(QzTool.ajaxLoginCheck(res)===false){return ;}
				if(res.status==0){alert(res.msg);return false;}
				$("body").append("<div id='wallpaper'></div>");
				$("#wallpaper").html(res.html);
				$("#set_wallpaper").popupSkin();
				// var my=mypostion(".alert");
				// $("#set_wallpaper").css({"display":"block","position":"absolute","z-index":"9999999","top":my.top+"px","left":my.left+"px"});
				// $("#set_wallpaper").show();
			}
		});
	}
};