function $(id){return document.getElementById(id);}
function $cla(className, parentElement){ //如果父节点对象是空，则默认是body对象,并取得所有子节点
var elems = ($(parentElement)||document.body).getElementsByTagName("*"); //将有与className相同的元素保存在这里
var result=[]; //遍历
for (i=0; j=elems[i]; i++){
if ((" "+j.className+" ").indexOf(" "+className+" ")!=-1){
result.push(j);
} //如果相同保存进result数组中
}
return result; //返回数组
}
function $tag(id){return document.getElementsByTagName(id);}
function getxmlhttp(){
	var xmlhttp=null;
	if(window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{ // code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return xmlhttp;
}
function confo(str){
$('msg').focus();
$('msg').value=$('msg').value+str;
}
$('ms').onsubmit=function(){if($('msg').value==''){$('msg').focus();return false;}else{comment_add();return false;}}
function comment_add(){
	$('msg').style.backgroundColor='#F90';
	xmlhttp=getxmlhttp();
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4 && xmlhttp.status==200){
			$('talkList').innerHTML=xmlhttp.responseText + $('talkList').innerHTML;
			setTimeout("$('msg').style.backgroundColor='#FFF'",100);
			$('msg').value='';
			 allRes();
		}
	}
	var msg = encodeURI($('msg').value);
	var sendate = "msg="+ msg;
	xmlhttp.open("POST","up.php?post",true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send(sendate);
}
function page_next(){
	$('showMore').innerHTML='正在加载...';
	xmlhttp=getxmlhttp();
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			if(xmlhttp.status==200){
				$('talkList').innerHTML+=xmlhttp.responseText;
				if(xmlhttp.responseText==''){
					$('moreList').innerHTML='<span class="showMore l">已是最后</span><a href="#" onclick="window.scrollTo(0,0);return false;" class="goTop r">返回顶部↑</a>'
				}else{
					$('page_numer').innerHTML = Number($('page_numer').innerHTML)+1;
					var NextPage=Number($('page_numer').innerHTML)+1;
					$('showMore').href = '?page='+NextPage;
					$('showMore').innerHTML='查看更多ˇ';
				}
				 allRes();
			}else{
				$('showMore').innerHTML='加载失败';
			}
		}
	}
	var page=Number($('page_numer').innerHTML);
	xmlhttp.open("GET","pages_ajax.php?page="+page,true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send();
}
function post_up(id,upa){
	xmlhttp=getxmlhttp();
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4 && xmlhttp.status==200){
			upa.innerHTML='赞('+xmlhttp.responseText+')';
		}
	}
	xmlhttp.open("GET","up.php?up="+id,true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send();
}
function post_del(id){
	xmlhttp=getxmlhttp();
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4 && xmlhttp.status==200){
			$('post-'+id).innerHTML='<p class="del_ok">'+xmlhttp.responseText+'</p>';
		}
	}
	xmlhttp.open("GET","up.php?c="+id,true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send();
}
function cmt_list(id,upa){
	var msg_ul='cmt_'+id;
	
	if(!$(msg_ul)){
	var cmt_nember=upa.innerHTML;
	upa.innerHTML="加载ing.";
	xmlhttp=getxmlhttp();
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			if(xmlhttp.status==200){
				var msg=document.createElement("ul");
				msg.innerHTML=xmlhttp.responseText;
				msg.id=msg_ul;
				msg.style.display="block";
				$('post-'+id).appendChild(msg);
				upa.innerHTML=cmt_nember;
			}else{
				upa.innerHTML='加载失败';
			}
		}
	}
	xmlhttp.open("GET","cmt_list.php?id="+id,true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send();
	}else if($(msg_ul).style.display!='none'){
	$(msg_ul).style.display="none";
	}else{
	$(msg_ul).style.display="block";
	}
}
function cmt_add(pid,upa){
	$('cmt_'+pid+'_msg').style.backgroundColor='#F90';
	xmlhttp=getxmlhttp();
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4 && xmlhttp.status==200){
			$('cmt_'+pid+'_li').innerHTML=xmlhttp.responseText;
			var cmt_namber=upa.innerHTML;
			cmt_namberupa.id.replace('帖子(,);','')
			cmt_namber++;
			upa.innerHTML="帖子('"+cmt_namber+"')";
		}
	}
	var cmt_pid = $('cmt_'+pid+'_pid').value;
	var cmt_msg = encodeURI($('cmt_'+pid+'_msg').value);
	var cmt_author = encodeURI($('cmt_'+pid+'_author').value);
	var cmt_email = encodeURI($('cmt_'+pid+'_email').value);
	var sendate = "msg="+cmt_msg+"&author="+cmt_author+"&email="+cmt_email+"&pid="+cmt_pid;
	xmlhttp.open("POST","up.php",true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send(sendate);
}
function cmt_fo(str){
$('cmt_msg').focus();
$('cmt_msg').value=$('cmt_msg').value+str;
}
function google_buzz(msg){
window.open("http://www.google.com/buzz/post?"+"message="+msg+"&url="+encodeURIComponent(document.location),"_blank","resizable=0,scrollbars=0,width=690,height=415");
}
function youku(vid){
window.open("youku.php?id="+vid,"_blank","resizable=0,scrollbars=0,width=786,height=455");
}
function img_load_error(img){
img.src='images/sign_err.gif';
img.width=96;
img.height=21;
}
