<%
function checkstr(str,lx)
	if lx="" then lx="1" 
	if len(str)>0 then
	else
		str=""
	end if			
	
    Set re=new RegExp
    re.IgnoreCase =true
    re.Global=True

    re.Pattern="(script)"
    str=re.Replace(str,"sc ript")

    re.Pattern="(>"+chr(13)+")"
    str=re.Replace(str,">")
    re.Pattern="(> "+chr(13)+")"
    str=re.Replace(str,">")
    re.Pattern="(>  "+chr(13)+")"
    str=re.Replace(str,">")

    re.Pattern="("+chr(13)+")"
	if lx="2" then
		str=re.Replace(str,"<br>")
	else	
	    str=re.Replace(str,"<br>&nbsp;&nbsp;&nbsp;&nbsp;")
	end if
	if left(lcase(str),6)<>"<table" then
		if lx="1" then
			str="&nbsp;&nbsp;&nbsp;&nbsp;"+str
		end if			
	end if	
	checkstr=str
end function	

function cutstr(str,cd,flag)
	dim i,tot,sstot
	if flag="" then
		flag=0
	end if
	str=trim(str)

    Set re=new RegExp
    re.IgnoreCase =true
    re.Global=True
    
    re.Pattern="("+chr(13)+")"
    str=re.Replace(str,"&nbsp;")
    
    re.Pattern="("+"กก"+")"
    str=re.Replace(str,"")
    
    re.Pattern="("+"\s"+")"
    str=re.Replace(str,"")
    
    re.Pattern="("+"<.*?>"+")"
    str=re.Replace(str,"")
    
	a=len(str)
	b=0
	i=0
	do while b<cd and i<a
		i=i+1
		if asc(mid(str,i,1))>0 then
			b=b+1
		else
			b=b+2
		end if
	loop
	if a>b and flag=0 then
			cutstr=left(str,b)&"..."
		else
			cutstr=left(str,b)
	end if
end function

function checkstr1(str)
		checkstr1=replace(str,"'","")
		checkstr1=replace(checkstr1,")","")
		checkstr1=replace(checkstr1,")","")
end function

function chkstr(str,lx)
	if lx="" then lx="1"
	if len(str)>0 then
	else
		str=""
	end if

    Set re=new RegExp
    re.IgnoreCase =true
    re.Global=True

    re.Pattern="(script)"
    str=re.Replace(str,"sc ript")

    re.Pattern="(>"+chr(13)+")"
    str=re.Replace(str,">")
    re.Pattern="(> "+chr(13)+")"
    str=re.Replace(str,">")
    re.Pattern="(>  "+chr(13)+")"
    str=re.Replace(str,">")
    
    re.Pattern="("+"กก"+")"
    str=re.Replace(str,"")

    re.Pattern="("+chr(13)+")"
	if lx="2" then
		str=re.Replace(str,"<br>&nbsp;&nbsp;&nbsp;")
	else
	    str=re.Replace(str,"<br>")
	end if
	if left(lcase(str),6)<>"<table" then
		if lx<>"1" then
			str="&nbsp;&nbsp;&nbsp;&nbsp;"+str
		end if
	end if
	chkstr=str
end function
%>
