// JavaScript Document
$(document).ready(function(){
   $.post("member.cklogin.php?"+Math.random(),{ checklogin:"checklogin" },send);  
   function send(text)
   {  
	   text = $.trim(text);
	   if(text!='')
	   {
		   $("#loginform").html( text );   
	   }
   }
}); 

function delblog( bid )
{
	if(confirm("是否确认删除？"))
	{  
	    $.post("member.bloglist.php?"+Math.random(),{ action:"del",bid:bid },send);  
	    function send(text)
	    {
			if( text==1 )
			{
			   alert("删除成功！");	
			   $("#blog_"+bid).fadeOut("slow"); ;
			}else
			{
			    alert( text );	
			}
		 }	
	}
}

function blogliuyan()
{
    if(confirm("确定留言？"))
	{ 
		var ctitle = $.trim( $("#blog_ctitle").val() );
		var lytype = $.trim( $("#lytype").val() );	
		var userid = $.trim( $("#userid").val() );	
		var yanzhengma = $.trim( $("#yanzhengma").val() );
		if( ctitle=="" )
		{
		   alert("留言内容不能为空！");	
		}else if( yanzhengma=="" )
		{
			alert("验证码不能为空！");	
		}else
		{
			$.post("liuyan.php?"+Math.random(),{ action:"blogliuyan",ctitle:ctitle, lytype:lytype,userid:userid,yanzhengma:yanzhengma  },send);  
			function send(text)
			{ 
				text = $.trim(text);
				if( text =="验证码不正确" )
				{
					alert("验证码不正确");	
				}else
				{
					refreshValidateCodeFast();
					$("#blog_ctitle").val("");
					$("#yanzhengma").val(""); 
					$("#liuyan_frame").prepend( text); 
					window.location.href="#liuyantop";
				}
			}
		}
	}
}

/*
  修改相册
*/
function mody_pic(picid)
{
	var picmark = $.trim( $("#picmark_"+picid).val() );
	if( picmark=="" )
	{
	   alert("照片备注不能为空哦^_^");	
	}else
	{
		$.post("member.piclist.php?"+Math.random(),{ action:"mody", picid:picid,picmark:picmark },send);  
		function send(text)
		 {
			if( text==1 )
			{
			   alert("修改成功!");	
			}else
			{
			   alert( text );	
			}
		 }
	}
}

/*
  删除相册
*/
function del_pic(picid, file)
{
	if( confirm("确定删除吗?"))
	{
		$.post("member.piclist.php?"+Math.random(),{ action:"del", picid:picid,file:file },send);  
		function send(text)
		{ 
			 $("#onepic_"+picid).hide(200);
		}
	}
}

/*
  刷新验证码
*/
function refreshValidateCodeFast(){
				var d = new Date();
				var src = "verify.php?date=" + d.getTime();
				$("#img_validatecode_fast").attr("src", src );
}

/*
  新闻留言
*/
function newsliuyan()
{
    
    if(confirm("确定遵守国家相关规定并发表评论？"))
	{ 
		var ctitle     = $.trim( $("#pinglun").val() );		 
		var tid        = $.trim( $("#tid").val() );
		var nid        = $.trim( $("#nid").val() );	
		var yanzhengma = $.trim( $("#yanzhengma").val() );
		if( ctitle=="" )
		{
		   alert("留言内容不能为空！");	
		}else if( yanzhengma=="" )
		{
			alert("验证码不能为空！");	
		}else
		{
			$.post("liuyan.php?"+Math.random(),{ action:"newsliuyan",ctitle:ctitle,nid:nid ,yanzhengma:yanzhengma,tid:tid  },send);  
			function send(text)
			{ 
				text = $.trim(text);
				if( text =="验证码不正确" )
				{
					alert("验证码不正确");	
				}else
				{
					refreshValidateCodeFast();
					$("#pinglun").val("");
					$("#yanzhengma").val(""); 
					alert("评论发表成功，等审核后显示");
				}
			}
		}
	}

}
