//判定显示选项卡
window.onload = function se(){
	     var querys = window.location.search.substring(1).split("&");
		 var num = querys[0].substring(3);
		  var news = document.getElementById("news").getElementsByTagName("div");
		  var con = document.getElementById("con").getElementsByTagName("div");
		  for(var i=0; i < news.length; i++){
			  news[i].className = "normal_m";
			  con[i].className = "normal_c";
  
			  news[num].className = "dis_m";
			  con[num].className = "dis_c";
		  }
		  
		  var o = "";
		  switch(num){
			  case "0":
			      o = "扔纸条";
			  break;
			  case "1":
			      o = "打招呼";
			  break;
			  case "2":
			      o = "留言";
			  break;
			  case "3":
			      o = "图片评论";
			  break;
			  case "4":
			      o = "文章评论";
			  break;
			  case "5":
			      o = "个人信息";
			  break;
			  case "6":
			      o = "用户管理";
			  break;
		  }
		  
		  document.title = "与我相关 — "+o+"";
	}

// tab选项卡
function set(n){
		var news = document.getElementById("news").getElementsByTagName("div");
		var con = document.getElementById("con").getElementsByTagName("div");
		for(var i=0; i < news.length; i++){
			news[i].className = "normal_m";
			con[i].className = "normal_c";

			news[n].className = "dis_m";
		    con[n].className = "dis_c";
		}
        window.location.href = "with_me.php?tab"+n;
	}
	
//单项删除信息
function del(order,id){
   var info = "";
   switch(order){
	   case "paper":
			info = "纸条信息";
	   break;
	   case "hello":
			info = "招呼信息";
	   break;
	   case "mess":
			info = "留言信息";
	   break;
	   case "img":
			info = "图片评论信息";
	   break;
	   case "art":
			info = "文章评论信息";
   }
   
   if(confirm("您真的要删除此"+info+"吗？") == true){
	   window.location.href = "with_me.php?what=del&order="+order+"&id="+id+"";
   }	
}
	
//打开查看信息窗口
function opinfo(info,id,left,top,width,height){
	window.open("open/with_see_"+info+".php?order=see&id="+id+"",""+info+"","left="+left+",top="+top+",width="+width+",height="+height+",toolbar=no,menubar=no,location=yes,scrollbars=no,resizable=no,status=yes");
}
	
//打开图片，文章查看信息窗口
function opas(info,id){
	window.location.href = "see_"+info+"_com.php?order=usersee&id="+id+"";
}
	
//全选/全不选
function setAll(u,n){
   var tname = document.getElementsByName("check_all").item(u);
   var cname = document.getElementsByName(n);
   if(tname.checked){
	   for(i=0;i<cname.length;i++){
		   cname[i].checked = true;
	   }
   }
   else{
	   for(i=0;i<cname.length;i++){
		   cname[i].checked = false;
	   }
   }
}
	
//判断checkbox是否已选
function checkbox(u,n){
	var tname = document.getElementsByName("check_all").item(u);
	var cname = document.getElementsByName(n);
	var checkedcount = 0;
	for(i=0;i<cname.length;i++){
		if(cname[i].checked){
			checkedcount++;
		}
	}
	
	if(checkedcount == cname.length){
		tname.checked = true;
	}
	else{
		tname.checked = false;	
	}
}
	
//删除所选
function setDe(w,t){
	  var cname = document.getElementsByName(t);
	  var myArr = new Array();
	  var count = 0;
	  for(i=0;i<cname.length;i++){
		  if(cname[i].checked){
			   myArr[myArr.length] = cname[i].value;
			   count++;
		  }
	  }
	  
	  var con = myArr.join("*");
	  if(count != 0){
	   if(w == "del"){
		  if(confirm("您真的要删除这"+count+"条信息吗？") == true){
			window.location.href = "with_me.php?order=delAll&type="+t+"&con="+con+"";
		  }
	   }
	   else if(w == "throw"){
		  window.open("open/throw_all_paper.php?order=throwAll&type="+t+"&con="+con+"","throw_paper","top=300,left=500,width=300,height=160,resizable=no");
	   }
	   else if(w == "lock"){
		  if(confirm("您真的要锁住这"+count+"个用户吗？") == true){
			window.location.href = "with_me.php?order=lockAll&type="+t+"&con="+con+"";
		  }  
	   }
	   else if(w == "normal"){
		  if(confirm("您真的要回复这"+count+"个用户的权限吗？") == true){
			window.location.href = "with_me.php?order=normalAll&type="+t+"&con="+con+"";
		  }
	   }
	   else if(w == "manage"){
		 if(confirm("您真的要将这"+count+"个用户设为管理员吗？（请三思而行！）") == true){
			window.location.href = "with_me.php?order=manageAll&type="+t+"&con="+con+"";
		 }
	   }
	  }
	  else{
		  alert("您还没有选择信息呢？");  
	  }
}