﻿$(document).ready(function($){

		 _initSendComment();  
		 
		 _initCommentLogin();
})


function _initCommentLogin()
{
     $(".commentlogin a:first").click(function(){
											   
		var username = $("#user").val();
		
		var passwd   = $("#pw").val();
		
		if(username==""||passwd=="")
		{
			alert("请输入完整的用户名和密码");
		}
		else
		{	
		 <!-- start -->
				$.post(
			   "/login/login",
				{name:username,pass:passwd},
				 function(msg)
					{
					  if(msg=="error")
					  {
						 $("#user").val("");
						 
						 $("#pw").val("");
						 
						 alert("登录失败");
					 }
					 else
					 { 
					    $(".commentlogin").html("登录成功，请发表留言：");
						 
					 }
				});
		 <!-- end -->
		}
											   
	 })
}





function  _initSendComment(){

        $(".sendcomment .send img").click(function(){
				
			  var content = KE.util.getData("content");
			  
			  if(content=="")
			  {
				   alert("请您输入内容"); 
			  }
			  else
			  {
				   <!-- start -->
						$.post(
					   "/way/addcomment",
						{id:id,content:content},
						 function(msg)
							{
							  if(msg=="nologin")
							  {
								  alert("请您先登录再进行操作");
							  }
							  else
							  {
						          window.location.href='/way/comment?id='+id;
							  }
					    });
			       <!--  end  -->  
			  }	
		})
}

/* 清空内容 */  

function clearEditor(id) {
	
    KE.g[id].iframeDoc.open();
	
    KE.g[id].iframeDoc.write(KE.util.getFullHtml(id));
	
    KE.g[id].iframeDoc.close();
	
    KE.g[id].newTextarea.value = '';
	
}

