/* 更换验证码 */
function getCodeImg(path, eid, key){
	document.getElementById(eid).src = path + "/validationCode.do?key="+key+"&"+Math.random();
}
String.prototype.replaceAll  = function(s1,s2){    
	return this.replace(new RegExp(s1,"gm"),s2);    
}
/* 清除空格 */
function clearSpace(str){
	return str.replace(/^\s+|\s+$/g,"");
}
function checkSQL(text){
	text = text.replaceAll("'","''");
	return text;
}
function checkJAVA(text){
	text = text.replaceAll("\\\\","\\\\");
	return text;
}
function checkHTML(text){
	text = text.replaceAll("<","&lt;");
	text = text.replaceAll(">","&gt;");
	text = text.replaceAll("\\\"","&quot;");
	return text;
}
function checkNOTHTML(text){
	return checkSQL(checkJAVA(text));
}
function checkAll(text){
	return checkSQL(checkJAVA(checkHTML(text)));
}
/* 检测Email是否正确 */
function checkEmail(email){
	var reg = /(\S)+[@]{1}(\S)+[.]{1}(\w)+/;
	if(!reg.test(email))
		return false;
	return true;
}
/* 去除HTML样式 */
function stripHTMLTag(text)
{
	/*
	var reg = /<\w.*style="(.*?)".*?>|<\w.*size="(.*?)".*?>/img;
	text = text.replace(reg,"");
    return text;
    */
    text = escapeScriptTag(stripStyle(text));
	return text;
}
function stripStyle(text){
	var styleReg = /(<\w[^>]*?(style=\s*?(['|"]).*?\3).*?>)/img;
	var fontReg = /<font[^>]*?>|<\/font>/img;
	var spanReg = /<span[^>]*?>|<\/span>/img;
	text = text.replace(styleReg, function($0, $1, $2){
		return $1.replace($2, "");
	});
	text = text.replace(fontReg, "");		
	text = text.replace(spanReg, "");				
	
	return text;
}
function escapeScriptTag(text){
	var sScriptReg = /<(script[^>]*?)>/img;
	var eScriptReg = /<\/script>/img;
	text = text.replace(/<\/script>/img, "&lt;/script&gt;");
	text = text.replace(sScriptReg, function($0, $1, $2, $3){
		return "&lt;" + $1 + "&gt;";
	});
	
	return text;
}