
function show_index(){
	$("#main_chat").hide();
	$("#main_hot").show();
	getChatListByLimit(3);
}

function show_chat(){
	$("#main_chat").show();
	$("#main_hot").hide();
}

function chat_add_face($msg){
	$("#msg").val($("#msg").attr("value")+$msg);
}

function note_out(){ 
	$('#note').animate({top:'0'}, 500, function(){ 
		$(this).css({display:'none', top:'-100px'}); 
	}); 
} 

function note_show(msg){
	
	if(!$('#note').is(':visible')){ 
		$("#note").html(msg); 	
		$('#note').css({display:'block', top:'+200px'}).animate({top: '+200'}, 10, function(){ 
		setTimeout(note_out, 3000); 
	}); 
	} 
}


function add_to_favorites(){

	$.ajax({ 
	   type:'get', 
	   url:'ajax_json.php', 
	   dataType: "json",
	   data:"op=add_to_favorites&rand="+Math.random(),
	
	   success:function(re){ 
		   
		   alert('谢谢你的关注和无尝的爱护');
	   } 
		  
	}); 

}

function send_weibo(mid){

	$.ajax({ 
	   type:'get', 
	   url:'ajax_json.php', 
	   dataType: "json",
	   data:"op=send_weibo&mid="+mid+"&rand="+Math.random(),
	
	   success:function(re){ 
	   //alert(re.error_code);
			if(re.error_code==undefined){
				alert('发送微博成功');
			}else{
				alert('发送微博失败！请重新登陆！');
			}
	   } 
		  
	}); 
	
     
}

function getChatListByLimit(num) { 
	$("#chat_list_3").html('');

	$.ajax({ 
	   type:'get', 
	   url:'ajax_json.php', 
	   dataType: "json",
	   data:"op=chat_list_by_limit&num="+num+"&rand="+Math.random(),
	
	   success:function(re){ 
	   
	   
		   for (var i=0; i < re.length; i++) {
				var msg = re[i].msg;
				$("#chat_list_3").append('<div class="c"><div class="c1"><img src="http://tp3.sinaimg.cn/'+re[i].userid+'/50/5611102962/0" border="0" /></div><div class="c2">(<a href="http://weibo.com/'+re[i].userid+'/profile/"  target="_blank"><font color="#0072C1"><span style="text-decoration:underline">'+re[i].nickname+'</span></font></a>)</div><div class="c2">'+msg+'</div></div>'); 

		  }
		   
	   } 
		  
	}); 
} 


var new_cid = 0;

function getOtherChatList(){
	getChatListById(new_cid);
}

function setToUser(to_userid,to_nickname){
	$("#to_userid").val(to_userid); 
	$("#msg").focus();
	$("#to_nickname").val(to_nickname); 
	$("#send_user").show();
}

function closeToUser(){
	$("#to_userid").val(''); 
	$("#msg").focus();
	$("#to_nickname").val(''); 
	$("#send_user").css("display","none");
	
}

function getChatListById(chat_id) { 
	//$("#chat_list").html('');

	$.ajax({ 
	   type:'get', 
	   url:'ajax_json.php', 
	   dataType: "json",
	   data:"op=chat_list_by_id&chat_id="+chat_id+"&rand="+Math.random(),
	
	   success:function(re){ 
	   
	   
		for (var i=re.length-1; i > -1 ; i--) {
			
			
			say = '<img src="http://tp3.sinaimg.cn/'+re[i].userid+'/50/5611102962/0" border="0" width="20" height="20" align="absmiddle" style="d5"/>&nbsp;&nbsp;(<a href="#" onclick="setToUser(\''+re[i].userid+'\',\''+re[i].nickname+'\')"><font color="#0072C1"><span style="text-decoration:underline">'+re[i].nickname+'</span></font></a>)&nbsp;&nbsp;';
			
			if(re[i].to_userid!=0){
				say = say + '&nbsp;@&nbsp;&nbsp;&nbsp;&nbsp;<img src="http://tp3.sinaimg.cn/'+re[i].to_userid+'/50/5611102962/0" border="0" width="20" height="20" align="absmiddle" style="d5"/>&nbsp;&nbsp;(<a href="#" onclick="setToUser(\''+re[i].to_userid+'\',\''+re[i].to_nickname+'\')"><font color="#666666"><span style="text-decoration:underline">'+re[i].to_nickname+'</span></font></a>)&nbsp;&nbsp;';
			}
			
			say= say+'<font color="#0000FF">'+re[i].gtime+'</font><br/><div style="height:24;padding-top: 4px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+re[i].msg+'<br/></div>';
			
			$("#chat_list").append(say);
			
			
			new_cid=re[i].id;
			
		  }
			
			
		    $("#chat_list")[0].scrollTop = $("#chat_list")[0].scrollHeight;
			
			
	   } 
		   

	}); 
	


} 

function addChat(msg,to_userid,to_nickname) { 
	//alert(msg);
	//alert(to_userid);
	//alert(to_nickname);

	$.ajax({ 
	   type:'post', 
	   url:'ajax_json.php', 
	   dataType: "json",
	   data:"op=chat_add&msg="+msg+"&to_userid="+to_userid+"&to_nickname="+to_nickname+"&rand="+Math.random(),
	
	   success:function(re){ 
	   	//alert(re.id);
	   		if(re.id>0){
				$("#msg").css('border-color','#dddddd');
				$("#msg").val("");
				//$("#to_userid").val("");
				getChatListById(re.id-1);
			}else{
				note_show('你被禁言了！');
				//note_show('请先登陆！才能发送信息！');
			}
	   }
	    
		  
	}); 
} 

function getOnlineUser() { 
	$.ajax({ 
	   type:'get', 
	   url:'ajax_json.php', 
	   dataType: "json",
	   data:"op=online"+"&rand="+Math.random(),
	
	   success:function(re){ 
	   
			 $("#online_user").html('在线等更人数：'+re.count_ol_user+'　登陆用户：'+re.count_ol_login+'&nbsp;&nbsp;&nbsp;'); 		
	   } 
		  
	}); 
} 



function refreshNewList() { 
	
	
	
	for(var i=0;i<10;i++){
		$("#manhua_"+i).css("background-color","#ffffff");
	}
	

	
	$.ajax({ 

			type:'get', 
			url:'ajax_json.php', 
			dataType: "json",
			data:"op=new_update&rand="+Math.random(),
	
		   success:function(re){ 
			
			//$.sound.play('say.mid'); 
			$("#new_list").html('');
			
			for (var i=re.length-1; i > -1 ; i--) {
				
				if(i==0){
					if(new_mid!=re[i].id && new_mid!=0 && $("#select_mid").attr("value")!='0'){
						//$.sound.play('say.mid'); 
						var mid_url = 'mid/'+$("#select_mid").attr("value");
						//alert(mid_url);
						$.sound.play(mid_url); 
						change_title();
		
					}
					new_mid = re[i].id;	
				}
				
				var str ='';
				
				if(new Date().getTime()-re[i].atime*1000<36000000){
					str=str+'<div class="b"  style="background-color:#F3F9EC">';
				}else{
					str=str+'<div class="b" style="background-color:#FFF">';
				}
				
				
				
				str=str+'<div class="b1"><a href="#" onclick="send_weibo('+re[i].id+')">';

				
				str=str+'<img src = "images/icons/'+re[i].style+'.jpg"  align="absmiddle" border="0" title="发送微博"/>';
				
				str=str+"</a></div>";
				
				
				str = str+'<div class="b2"><a href="show.php?id='+re[i].id+'" title="'+re[i].all_title+'" target="_blank"> '+re[i].all_title+'</a></div>';
				
				
				str=str+'<div class="b3">'+re[i].gtime+'</div>';
				
				str=str+'<div class="b4"></div></div>';
				
				
				$("#new_list").prepend(str); 
				 
				 //更新热门
				if(re[i].title_id<10 && (re[i].style==1 || re[i].style==2)){
					
					var str_hot ='';

					str_hot=str_hot+'<div class="d1"><a href="#" onclick="send_weibo('+re[i].id+')"><img src = "images/icons/'+re[i].style+'.jpg"  align="absmiddle" border="0" title="发送微博"/></a></div>';

					str_hot = str_hot+'<div class="d2"><a href="show.php?id='+re[i].id+'" target="_blank"> '+re[i].chapter+'话</a>&nbsp;';
					
					if(new Date().getTime()-re[i].atime*1000<36000000){
						str_hot = str_hot+'  <image src="images/new.gif" align="absmiddle"/>&nbsp;';
						
						$("#manhua_"+re[i].title_id).css("background-color","#8CC04F");
					
					}
					
					str_hot=str_hot+'</div>';
					
					 $("#manhua_"+re[i].style+"_"+re[i].title_id).html(str_hot); 
					 
					 
				 
				}
				
			}
	
			
		   } 
		  
	}); 
} 
/*
function refreshHotList() { 

	$.ajax({ 
	
			type:'get', 
			url:'cache/hot_update.html', 
			dataType: "json",
			data:"rand="+Math.random(),
	   
		   success:function(re){ 

			for (var i=0; i < re.length; i++) {
				var str ='';
				
				str=str+'<div class="d1"><a href="#" onclick="send_weibo('+re[i].id+')"><img src = "images/icons/'+re[i].style+'.jpg"  align="absmiddle" border="0" title="发送微博"/></a></div>';
				
				str = str+'<div class="d2"><a href="show.php?id='+re[i].id+'"> '+re[i].chapter+'话</a>&nbsp;';
				
				if(new Date().getTime()-re[i].atime*1000<36000000){
					str = str+'  <image src="images/new.gif" align="absmiddle"/>&nbsp;';
					$("#manhua_"+re[i].title_id).css("background-color","#8CC04F");
				
				}
				
				str=str+'</div>';
				
				 $("#manhua_"+re[i].style+"_"+re[i].title_id).html(str); 
				
			}
	
			
		   } 
		  
	}); 
} 
*/

function autoSendWeibo() { 
	$.ajax({ 
	   type:'get', 
	   url:'admin/auto_send_weibo.php', 
	   dataType: "json",
	   data:"rand="+Math.random(),
	
		success:function(re){ 

		} 
		  
	}); 
} 





function start_change_title(){
	step=0;
	change_title();
}

var step=0; 
function change_title(){ 
	step++; 
	if (step%2==0)
	{
	document.title='路肥动漫－动漫第一时间更新报导网站'
	}else{
		document.title='有更新啦！－动漫第一时间更新报导网站'
	}
	if(step<30){
		setTimeout("change_title()",1000); 
	}else{
		document.title='路肥动漫－动漫第一时间更新报导网站';
	}
} 




