var ajaxload = '<img src="Template/Image/Default/images/ajaxload.gif" alt="" title="" />';

function myresult(tag,lang){
	if(tag == 0) return '<img src="Template/Image/Default/images/icon_fail.png" alt="" title="" />'+lang;
	if(tag == 1) return '<img src="Template/Image/Default/images/icon_success.png" alt="" title="" />';
}
function empty()
{
	comment = document.getElementById("profilecomment").value;
	var defaulttext = new Array()
    defaulttext[0] = "Type reply here...";
    defaulttext[1] = "在这里回复..."
	defaulttext[2] = "在這裡回复..."
	var len = defaulttext.length;
	for(i=0;i<len;i++)
	{
		if(comment == defaulttext[i])
		{
			document.getElementById("profilecomment").value = "";
		}
		
	}
    
}

$(document).ready(function(){  
		$("#meinfolist").html(ajaxload);
		$("#profilecontent").html(ajaxload);
		$mid = $("#mid").val();
		
		
			$("#private").click(function(){  //是否为私
				if(this.checked){
					$(this).val("1");
				}else{
					$(this).val("0");
				}
			});
		
//个人用户列表
		$.ajax({
			type:"POST",
			url :"index.php?m=Meinfolist",
			data:"mid="+$mid,
			success:function(result){
				$("#meinfolist").html(result);
			}
		});	
		
//个人用户留言
		$.ajax({
			type:"POST",
			url :"index.php?m=Profilecontent",
			data:"mid="+$mid,
			success:function(result){
				$("#profilecontent").html(result);
			}
		});

//回复留言
    $("#btnprofile").click(function(){
		$send = $("#whther_send_email").val();
		$("#profilecontent").html(ajaxload);
		$profilecomment = $("#profilecomment").val();
		$mid = Number($("#mid").val());
		$private = Number($("#private").val());
		if($profilecomment == '在这里回复...' || $profilecomment == '在這裡回复...' || $profilecomment=='Type reply here...' || $profilecomment=='' ){
			jQuery.facebox(_please_input_a_message);
			$("#profilecomment").val(_type_reply_here);
			$.ajax({
				type:"POST",
				url :"index.php?m=Profilecontent",
				data:"mid="+$mid,
				success:function(result){
					$("#profilecontent").html(result);
				}
			});
			return false;
		}else{
				$.ajax({
			type:"POST",
			url :"index.php?m=Profilecontent",
			data:"profilecomment="+$profilecomment+"&mid="+$mid+"&piv="+$private,
			success:function(result){
				if(!result){
					$("#dialog").show();
					$("#dialog").html(_no_user_login_);
					$('#dialog').dialog({ //失败提示对话框
						title: _login_user_dialog,
						buttons: {
							'yes' : function() { $(this).dialog('close'); window.location.href="index.php?m=Login"; }
						}
					});
				}else{
					$("#profilecontent").html(result);
					$("#profilecomment").val(_type_reply_here);
					if($send == "1"){	
			
						//发送email
							$.ajax({
								type:"POST",
								url :"index.php?m=Sendemail",
								data:"profilecomment="+$profilecomment+"&mid="+$mid+"&piv="+$private,
								success:function(result){
									//alert(result);
								}
							});	
						
					}
					
				}
			}
		  });
		}

	
	});
});
// doggy poke
function doggy_poke(){
	$.ajax({
		type:"POST",
		url :"index.php?m=doggypoke",
		data:"mid=2",
		success:function(result){
			jQuery.facebox(result);
		}
	});	
}


//添加好友
function addpeer(key){
		$mymid = $("#mid").val();
		$.ajax({
			type:"POST",
			url :"index.php?m=Regajax&ordermodel&cid=5",
			data:"mid="+key+"&mymid="+$mymid,
			success:function(result){
				if(result == 'peer_ok'){
					//alert("好友添加成功");
					jQuery.facebox(_add_peer_ok);
				}else if(result == 'peer_on'){
					//alert("已经存在这个好友");
					jQuery.facebox(_add_peer_yes);
				}
			}
		});
}

//没有手机照片错错
function cuocuophone(key){
		$mymid = $("#mid").val();
		$.ajax({
			type:"POST",
			url :"index.php?m=Regajax&ordermodel&cid=6",
			data:"mid="+key+"&mymid="+$mymid,
			success:function(result){
				if(result == 'cuocuo_ok'){
					//alert("好友添加成功");
					jQuery.facebox(_cuocuo_sj_success);
				}else if(result == 'cuocuo_on'){
					//alert("已经存在这个好友");
					jQuery.facebox(_cuocuo_sj_faile);
				}
			}
		});	
}

//错错头象
function cuocuotx(key){
		$mymid = $("#mid").val();
		$.ajax({
			type:"POST",
			url :"index.php?m=Regajax&ordermodel&cid=7",
			data:"mid="+key+"&mymid="+$mymid,
			success:function(result){
				if(result == 'cuocuo_ok'){
					//alert("好友添加成功");
					jQuery.facebox(_cuocuo_sj_success);
				}else if(result == 'cuocuo_on'){
					//alert("已经存在这个好友");
					jQuery.facebox(_cuocuo_sj_faile);
				}
			}
		});	
}
