function vote_bar()
{
	var th=50;
	var c_th=th;
	var max_votecount=0;
	$(".vote_count").each(function(){
		var $this=$(this);
		var data=$this.attr("data");
		if(data!=""&&data!=undefined)
		{
			var i=parseInt(data,10);
			if(i>max_votecount)max_votecount=i;
		}
	});
	$(".vote_count").each(function(){
		var $this=$(this);
		var data=$this.attr("data");
		$this.css({height:c_th.toString()+"px"});
		if(data!=""&&data!=undefined)
		{
			var i=parseInt(data,10);
			var h=(i/max_votecount)*th;
			var htm="<table border=0>";
			htm+="<tr><td style='width:20px;padding:0px;'>"+data+"</td></tr>";
			htm+="<tr><td style='padding:0px;border:1px #a8c9ea solid;background-color:#e5eff9;vertical-align:bottom;height:"+c_th.toString()+"px;width:20px;'>";
			htm+="<div style='background:url(/images/info/vote_bg.jpg);font-size:1px;height:"+parseInt(h,10)+"px;width:100%;'></div>";
			htm+="</td></tr></table>";
			$this.html(htm);
		}
	});
}
function get_hits(siteid,newsid)
{
	$.ajax({
		url:"/_aspx/get_hits.aspx?siteid="+siteid+"&newsid="+newsid,
		cache:false,
		success:function(data){
			$("#news_hits").html(data);
		}
	});	
}
function get_digcount(siteid,newsid,type)
{
	$.ajax({
		url:"/_aspx/get_digcount.aspx?siteid="+siteid+"&newsid="+newsid+"&type="+type,
		cache:false,
		success:function(data){
			$("#dig_"+type).html(data);
		}
	});	
}
function inc_dig(siteid,newsid,type)
{
	$.ajax({
		url:"/_aspx/inc_dig.aspx?siteid="+siteid+"&newsid="+newsid+"&type="+type,
		cache:false,
		success:function(data){
			if(data==""){alert("已经投过了");return;}
			$("#dig_"+type).html(data);
		}
	});	
}
function inc_vote(siteid,newsid,voteid)
{
	var id=("#vote"+voteid.toString());
	var $this=$(id);
	$.ajax({
		url:("/_aspx/inc_vote.aspx?siteid="+siteid.toString()+"&newsid="+newsid.toString()+"&voteid="+voteid.toString()),
		cache: false,
		success:function(data){
			if(data==""){alert("您已经投过票了");return;}
			var i=parseInt(data,10);
			$this.attr("data",i);
			vote_bar();
		}
	});
}
function ajax_load(targetid,file)
{
	if($("#"+targetid).length==0)return;
	$.ajax({
		url:file,
		cache:false,
		success:function(data){
			$("#"+targetid).html(data);
		}
	});	
}
function addvisitlog(siteid,newsid)
{
	var f="/_aspx/visitlog.aspx?siteid="+siteid.toString()+"&newsid="+newsid.toString();
	$.get(f);
}
function ContentSize(size)
{
	var obj=document.all.BodyLabel;
	obj.style.fontSize=size+"px";
}
function selectAll(ckboxname)
{
	o=document.getElementsByName(ckboxname); 
	for(i=0;i<o.length;i++) 
		o[i].checked=event.srcElement.checked;
}
function copyToClipBoard()
{
	var clipBoardContent=document.location;
	words=$("#texttitle").html();
	words=toPlainText(words);
	words+=("\n"+clipBoardContent);
	window.clipboardData.setData("Text",words);
	alert("复制成功！您可直接粘贴在QQ/MSN消息里，把此文推荐给您的好友。非常感谢您对德化网的支持！");
}
function aInfoHit(newsid)
{
}
function toPlainText(str)
{
	str = str.replace(/<[^>]*?>/ig, "");
	return str;
}
function getById(targetid){return document.getElementById(targetid);}
function html2ubb(str){
	//str = str.replace(/(\r\n|\n|\r)/ig, '');
	str = str.replace(/<br[^>]*>/ig,'\n');
	str = str.replace(/<p[^>\/]*\>/ig,'\n');
	//str = str.replace(/\[code\](.+?)\[\/code\]/ig, function($1, $2) {return phpcode($2);});
	str = str.replace(/\son[\w]{3,16}\s?=\s*([\'\"]).+?\1/ig,'');

	str = str.replace(/<hr[^>]*>/ig,"[hr]");
	str = str.replace(/<(sub|sup|u|strike|b|i|pre)>/ig,"[$1]");
	str = str.replace(/<\/(sub|sup|u|strike|b|i|pre)>/ig,"[/$1]");
	str = str.replace(/<(\/)?strong>/ig,"[$1b]");
	str = str.replace(/<(\/)?em>/ig,"[$1i]");
	str = str.replace(/<(\/)?blockquote([^>]*)>/ig,"[$1blockquote]");
	str = str.replace(/<(\/)?H6>/ig," "); 

	str = str.replace(/<img[^>]*smile=\"(\d+)\"[^>]*>/ig,"[s:$1]");
	str = str.replace(/<img[^>]*src=[\'\"\s]*([^\s\'\"]+)[^>]*>/ig,"[img]http://www.dehua.net"+"$1"+"[/img]");
	str = str.replace(/<a[^>]*href=[\'\"\s]*([^\s\'\"]*)[^>]*>(.+?)<\/a>/ig,"[url=http://www.dehua.net$1]"+"$2"+"[/url]");
	str = str.replace("http://www.dehua.nethttp://","http://");
	str = str.replace("http://www.dehua.netwww.","www.");
	//str = str.replace(/<h([1-6]+)([^>]*)>(.*?)<\/h\1>/ig,function($1,$2,$3,$4){return h($3,$4,$2);});
	str = str.replace(/<embed[^>]*src=[\'\"\s]*([^\s\'\"]+)[^>]*>/ig,"[mp=450,383]http://www.dehua.net"+"$1"+"[/mp]");
	//<embed src=/_wmv/2009/07/055.wmv width=450 height=383 type=video/x-ms-wmv autostart="true" loop="false">

	str = str.replace(/<[^>]*?>/ig, "");
	str = str.replace(/&amp;/ig, "&");
	str = str.replace(/&lt;/ig, "<");
	str = str.replace(/&gt;/ig, ">");

	return str;
}
function makeUbbCode()
{
	var title=getById("texttitle").innerHTML.toString();
	//title = title.replace(/<FONT[^>]*>/ig,"");
	//title = title.replace("<B>","");
	//title = title.replace("</B>","");
	//title = title.replace("</FONT>","");
	//title = title.replace("<strong>","");
	//title = title.replace("</strong>","");
	//title = title.replace("<STRONG>","");
	//title = title.replace("</STRONG>","");
	title = title.replace(/<(\/)?STRONG>/ig,"");
	title = title.replace(/<(\/)?strong>/ig,"");
	title = title.replace(/<(\/)?FONT>/ig,"");
	title = title.replace(/<(\/)?B>/ig,"");
	title = title.replace(/<(\/)?H1>/ig,""); 
	title = title.replace(/<(\/)?H6>/ig,""); 

	var content=getById("BodyLabel").innerHTML;
	content=html2ubb(content);
	var ubb=("[url="+location.href+"][b][size=4]"+title+"[/size][/b][/url]\n");
	//ubb+=("[b][/b]"+title+"\n");
	ubb+=("[b][/b]\n");
	ubb+=(content);
	window.clipboardData.setData("text", ubb);
	alert("复制成功！您可直接粘贴在论坛里，与大家一起分享。非常感谢您对德化网的支持！");
}
