﻿var imgwidth=700;
function $(id){return document.getElementById(id);}
function show(o){document.getElementById(o).style.display="block";}
function hide(o){document.getElementById(o).style.display="none";}
function geturl(url,id){
var http=false;
$(id).innerHTML='<span class="loading">&nbsp;&nbsp;</span>';
if(window.XMLHttpRequest){http=new XMLHttpRequest();if(http.overrideMimeType){http.overrideMimeType('text/plain');}}else if(window.ActiveXObject){try{http=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{http=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}
if(!http){alert('Cannot send an XMLHTTP request');return false;}
http.onreadystatechange=function(){if(http.readyState==4){$(id).innerHTML=http.responseText;}}
http.open("get", url, true);
http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
http.send(null);
}
function imgsize(){
	var img=document.getElementById("content").getElementsByTagName("img");
	for(var i=0; i<img.length;i++){
		if(img[i].width>imgwidth){img[i].width=imgwidth;img[i].style.width=imgwidth;img[i].title="View";img[i].style.cursor="pointer";img[i].border=0;img[i].onclick=function(e){window.open(this.src);}}
	}
}








function html2txt(str,noEnter){
var html = str;
html = html.replace(/<!--[\s\S]*?-->/img, "");//注释
html = html.replace(/<[\/]*table[^>]*>/img, "\n");//table
html = html.replace(/<[\/]*tbody[^>]*>/img, "");//tbody
html = html.replace(/<[\/]*tr[^>]*>/img, "\n");//tr
html = html.replace(/<[\/]*td[^>]*>/img, "\n");//td
html = html.replace(/<[\/]*p[^>]*>/img, "\n");//p
html = html.replace(/<[\/]*a[^>]*>/img, "\n");//a
html = html.replace(/<[\/]*col[^>]*>/img, "\n");//col
html = html.replace(/<[\/]*br[^>]*>/img, "\n");//br
html = html.replace(/<[\/]*div[^>]*>/img, "\n");//div
html = html.replace(/<[\/]*span[^>]*>/img, "");//span
html = html.replace(/<[\/]*center[^>]*>/img, "");//center
html = html.replace(/<[\/]*ul[^>]*>/img, "");//ul
html = html.replace(/<[\/]*i[^>]*>/img, "");//i
html = html.replace(/<[\/]*li[^>]*>/img, "");//li
html = html.replace(/<[\/]*b[^>]*>/img, "");//b
html = html.replace(/<[\/]*hr[^>]*>/img, "");//hr
html = html.replace(/<[\/]*h\d+[^>]*>/img, "");//h1,2,3,4,5,6
html = html.replace(/<STYLE[\s\S]*?<\/STYLE>/img, "");//样式
html = html.replace(/<script[\s\S]*?<\/script>/img, "");//引用的脚本
//html = html.replace(/<[\?!A-Za-z\][^><]*>/img, "");alert("str:"+html)
html = html.replace(/\r/img, "");//换行
html = html.replace(/\n/img, "\r\n");//回车
html = html.replace(/[　|\s]*\r\n[　|\s]*\r\n/img, "\r\n");
//html = reg.replace(html,@"(\r\n)[^ 　]/img,"$1");
html = formatHtml(html);
if(noEnter){
   html = html.replace(/\r\n/img, "");
   html = html.replace(/\n/img, "");
   html = html.replace(/\r/img, "");
}
return (html);
} 

function formatHtml(str){
//替换<P>
var html = str.replace(" ", " ");
html = html.replace(/ /img, " ");
html = html.replace(/ /img, " ");
html = html.replace(/?/img, " ");
html = html.replace(/?/img, " ");
html = html.replace(/’/img, "'");
html = html.replace(/“/img, "“");
html = html.replace(/”/img, "”");
html = html.replace(/ /img, "");
html = html.replace(/&/img, "&");
html = html.replace(/?/img, "?");
html = html.replace(/–/img, "–");
html = html.replace(/"/img, " ");
html = html.replace(/</img, " ");
html = html.replace(/>/img, " ");
html = html.replace(/ /img, "");
return html;
}



