function isNull(e,title){
	if(e.value==""){
		alert(title+"不能为空!!");
		e.focus();
		return false;
	}
	return true;
}

var xmlHttp;
var tzid;
var pid;  //版块ID
var ztid;
var state;//是主帖还是回帖
function createXMLHttpRequest(){ 
	if(window.ActiveXObject)
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	else            
	 	xmlHttp = new XMLHttpRequest();//
	return xmlHttp;
}

//---------------修改 : 要是管理员，版超，版主和发帖者多可以进行此操作
function perform(kid,status,mark){	
	tzid = kid;
	state=status;
	createXMLHttpRequest();
	url = "login.do?method=ifLogin&kid="+kid+"&state="+state;
	xmlHttp.open("post",url,true); 
		
	xmlHttp.onreadystatechange = mark;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function aa(){
	if(xmlHttp.readyState == 4){ 
		if(xmlHttp.status == 200){
			if(xmlHttp.responseText==1){
				window.location.href="operation.do?method=getStickBykid&opt=1&state="+state+"&kid="+tzid;
				return false;
			}			
			if(xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('请先登陆后再操作！');
				return false;
			}
		}
	}
}

function bb(){
	if(xmlHttp.readyState == 4)	{ 
		if(xmlHttp.status == 200){
			if(xmlHttp.responseText==1){
				check_up();
				return false;
			}
			if(xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('请先登陆后再操作！');
				return false;
			}
		}
	}
}
function check_up(){
	
	var kc = document.getElementById('kcontent');		
	var auvp = document.getElementById('auvp');		
	if(auvp ==1){   //如果是主帖就要判断
		var kt = document.getElementById('ktitle');
		if(isNull(kt,"标题") == false){ return false;}
	}	
	if(isNull(kc,"帖子内容") == false){ return false;}
	document.operationForm.action="operation.do?method=editStick&state="+state+"";
 	document.operationForm.submit();
}

function cc(){
	if(xmlHttp.readyState == 4){ 
		if(xmlHttp.status == 200){
			if(xmlHttp.responseText==1){
				uplog();
				return false;			
			}			
			if(xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('请先登陆后再操作！');
				return false;
			}
		}
	}
}

function uplog(){	    			    		
   		var log  = document.uploadForm.logo.value;
   		
   		if(log ==""){
			alert("请选择图片..");
   			return false;
   		}		   	
		var name = log.substring(log.lastIndexOf("."));
		if(name !=".jpg"&&name !=".gif"&&name !=".JPG"&&name !=".GIF"){
			alert("格式不正确，请以.jpg.gif有图片上传,谢谢合作..");
			return false;
		}		
    	document.uploadForm.action="upload.do";
   		document.uploadForm.submit();
}  	
//-------------修改结束-----------

//-------------引用-------------- 
function quote(kid,status){
	tzid = kid;
	state = status;
	createXMLHttpRequest();
	url = "login.do?method=isLogin";
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = cite;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function cite(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="operation.do?method=quoteBykid&opt=1&state="+state+"&kid="+tzid;
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}
//-------------引用结束--------
//-------------加精华/解精华----
function pink(kid,bid,type){
	tzid = kid;
	pid  = bid;
	createXMLHttpRequest();
	url = "login.do?method=loginOrAadmin&state=main&kid="+tzid;
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = type;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function add(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="model/pink.jsp?auvp=1&pid="+pid+"&kid="+tzid;
				return false;
			}
			if (xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}

function alit(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="model/pink.jsp?auvp=2&pid="+pid+"&kid="+tzid;
				return false;
			}
			if(xmlHttp.responseText==3)	{
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}
//-----------------加精华结束
//-----------------举报
function reply(kid,mid,bid){
	tzid = kid;
	ztid = mid;
	pid  = bid;
	createXMLHttpRequest();
	url = "login.do?method=isLogin";
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = deed;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function deed(){
	if(xmlHttp.readyState == 4){ 
		if(xmlHttp.status == 200){
			if(xmlHttp.responseText==1){
				window.location.href="model/reply.jsp?opt=1&mid="+ztid+"&pid="+pid+"&kid="+tzid;
				return false;
			}else{
				alert('请先登陆后再操作！');
				return false;
			}
		}
	}
}
//-------------举报结束

//=============收藏
function stow(kid){
	tzid = kid;
	createXMLHttpRequest();
	url = "login.do?method=isLogin";
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = hide;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function hide(){
	if(xmlHttp.readyState == 4){ 
		if(xmlHttp.status == 200){
			if(xmlHttp.responseText==1){
				window.location.href="operation.do?method=hideStick&opt=1&kid="+tzid;
				return false;
			}else{
				alert('请先登陆后再操作！');
				return false;
			}
		}
	}
}
//==============收藏结束

//=============删除帖子
function cut(kid,bid,type){
	tzid = kid;
	pid  = bid;
	if(type=="bc");
	state="reply";
	createXMLHttpRequest();
	url = "login.do?method=loginOrAadmin&state="+state+"&kid="+tzid;
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = type;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}
//主帖子
function main(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="model/del.jsp?auvp=1&opt=1&pid="+pid+"&kid="+tzid;
				return false;
			}
			if (xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}
//删除回帖
function bc(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="model/del.jsp?auvp=2&opt=1&pid="+pid+"&kid="+tzid;
				return false;
			}
			if (xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}
//=============删帖结束
//=====屏蔽帖子
function screen(kid,bid,type,status){
	tzid = kid;
	pid  = bid;
	state = status;
	createXMLHttpRequest();
	url = "login.do?method=loginOrAadmin&state="+state+"&kid="+tzid;
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = type;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}
//=====加
function plus(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="model/screen.jsp?auvp=1&opt=1&state="+state+"&pid="+pid+"&kid="+tzid;
				return false;
			}
			if (xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}
//===解
function ple(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="model/screen.jsp?auvp=2&opt=1&state="+state+"&pid="+pid+"&kid="+tzid;
				return false;
			}
			if(xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}
//================屏蔽结束
//================锁帖子
function lock(kid,bid,type){
	tzid = kid;
	pid  = bid;
	createXMLHttpRequest();
	url = "login.do?method=loginOrAadmin&state=main&kid="+tzid;
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = type;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}
//=====加锁
function tote(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="model/lock.jsp?auvp=1&pid="+pid+"&kid="+tzid;
				return false;
			}
			if (xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}
//===解锁
function fire(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="model/lock.jsp?auvp=2&pid="+pid+"&kid="+tzid;
				return false;
			}
			if(xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}
//================锁帖结束
//================固顶
function fixup(kid,bid){
	tzid = kid;
	pid  = bid;
	createXMLHttpRequest();
	url = "login.do?method=loginOrAadmin&state=main&kid="+tzid;
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = duct;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function duct(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="operation.do?method=ductDom&pid="+pid+"&kid="+tzid;
				return false;
			}
			if (xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}
//=============固顶结束--
//------推荐开始---
function push(kid,bid){
	tzid = kid;
	pid  = bid;
	createXMLHttpRequest();
	url = "login.do?method=loginOrAadmin&state=main&kid="+tzid;
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = bunt;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function bunt(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="model/commend.jsp?pid="+pid+"&kid="+tzid;
				return false;
			}
			if (xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}
//------推荐结束--
//------移开始---
function move(kid,bid){
	tzid = kid;
	pid  = bid;
	createXMLHttpRequest();
	url = "login.do?method=loginOrAadmin&state=main&kid="+tzid;
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = shif;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function shif(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="operation.do?method=getAim&pid="+pid+"&kid="+tzid;
				return false;
			}
			if (xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}
//------移结束---
//------合并开始---
function unite(kid,bid){
	tzid = kid;
	pid  = bid;
	createXMLHttpRequest();
	url = "login.do?method=loginOrAadmin&state=main&kid="+tzid;
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = suit;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function suit(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				window.location.href="model/unite.jsp?pid="+pid+"&kid="+tzid;
				return false;
			}
			if (xmlHttp.responseText==3){
				alert('对不起,你没有权限..');
				return false;
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}

function verify(pid){
    var	mkid = document.getElementById("mkid").value; 
	createXMLHttpRequest();
	url = "operation.do?method=verify&pid="+pid+"&kid="+mkid;	
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = spt;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function spt(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){
			//alert(xmlHttp.responseText);
			if(xmlHttp.responseText==1){
				alert('该帖子不存在..');
				document.getElementById("mkid").value = "";		
			}
			if (xmlHttp.responseText==2){
				alert('请正确地输入目标帖子ID...');
				document.getElementById("mkid").value = "";	
			}
			if (xmlHttp.responseText==3){
				alert('贴子不在相同一版块内是不可以进行合并操作..');
				document.getElementById("mkid").value = "";			
			}			
		}
	}
}
//------合并结束---


function power(bid){
	pid = bid
	createXMLHttpRequest();
	url = "login.do?method=isCall&pid="+pid;
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = exit;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function exit(){
	if(xmlHttp.readyState == 4){ 
		if(xmlHttp.status == 200){
			if(xmlHttp.responseText==1){
				window.location.href="model/forum.jsp?pid="+pid
				return false;
			}			
			if(xmlHttp.responseText==3){
				alert('对不起,你所在的用户组不能进入该版块..');
				return false;
			}else{
				window.location.href="model/forum.jsp?pid="+pid
				return false;
			}
		}
	}
}

//-------------发短信-------------- 
function note(){
	createXMLHttpRequest();
	url = "login.do?method=isLogin";
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = begin;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function begin(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				sendnote();
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}
function sendnote(){
	var _title 		=  document.getElementById("title");
	var _content	=  document.getElementById("content");
	if(isNull(_title,"标题..")==false){return false;}
	if(isNull(_content,"内容..")==false){return false;}
	document.noteForm.action="note.do?method=sendNote";
	document.noteForm.submit();
}
//------------回复短信--
function revert(){
	createXMLHttpRequest();
	url = "login.do?method=isLogin";
	xmlHttp.open("post",url,true); 
	xmlHttp.onreadystatechange = action;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xmlHttp.send(null);
}

function action(){
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){   				
			if(xmlHttp.responseText==1){
				doc();
			}else{
				alert('对不起，请先登陆！');
				return false;
			}
		}
	}
}

function doc(){
	
	var _content  =  document.getElementById("content");
	if(isNull(_content,"回复内容")==false){return false;}	
	document.noteForm.action="note.do?method=revertNote";
	document.noteForm.submit();	
	
}


