<PUBLIC:CompONENT NAME="FormatCodeHTC">
<PUBLIC:ATTACH EVENT="ondocumentready" ONEVENT="FormatCode()" FOR="element"/>
<PUBLIC:PROPERTY NAME="keyword-color" PUT="SetKeyWordColor">
<PUBLIC:PROPERTY NAME="note-color" PUT="SetNoteColor">
<PUBLIC:PROPERTY NAME="summary-color" PUT="SetSummaryColor">
<PUBLIC:PROPERTY NAME="font-size" PUT="SetFontSize">
<script language="Jscript">
var codekeyword = [ "as","bool","break","case","class","define","continue","do","else","extends","false","for","foreach","function",
                    "require","if","in", "is", "new","null","return","set","short","sizeof","static","switch","this","var","true","value","while",
                    "sub","end sub","end function","end class","call","to","and","then","end if","select","case","dim","isarray","ubound","split","exit for","exit sub","exit function","exit do",
                    "not","eof","close","getrows","nothing","empty","int","cint","cbyte","clng","instr","left"];
var reg;
var keyWordsPattern = codekeyword.join("|");
var keywordColor = "#0000FF";			//default keyword color
var noteColor = "#008000";			//default note color
var summaryColor = "#808080";			//default summary color
var fontSize = "12px";
var bb_code_li_1 = '<li style="margin-left:0px;margin-top:0px;margin-bottom:0px">';
var bb_code_li_2 = '</li>';

function SetKeyWordColor(vValue)
{
  keywordColor = vValue;
}

function SetNoteColor(vValue)
{
  noteColor = vValue;
}

function SetSummaryColor(vValue)
{
  summaryColor = vValue;
}

function SetFontSize(vValue)
{
  fontSize = vValue;
}

function FormatCode()
{
  var text = "\n" + element.innerHTML;
  text = text.replace(/<br>/gi,"\n");
  /*
  text = text.replace(/</g,"&lt;");
  text = text.replace(/>/g,"&gt;");
  text = text.replace(/&lt;PRE&gt;/g,"<PRE>");
  text = text.replace(/&lt;\/PRE&gt;/g,"<\/PRE>");
  */
  reg = new RegExp("\\b("+keyWordsPattern+")\\b","g");
  text = text.replace(reg,"<font color='"+keywordColor+"'>$1</font>");
  reg = new RegExp("<font color='"+keywordColor+"'>("+keyWordsPattern+")</font>","gi")
  text = text.replace(/\"(.*?)\"/g,function($1){return $1.replace(reg,"$1")});
  //JS¡¢PHP×¢½â
  text = text.replace(/(^\s*\/{4}.*)|(^\s*\/\/([^\/].*|\\b))/gm,function($1){return "<font color='"+noteColor+"'>"+$1.replace(/<\/?font.*?>/gi,"")+"</font>"});
  //VB×¢½â
  text = text.replace(/(^\s*\/{4}.*)|(^\s*\'([^\/].*|\\b))/gm,function($1){return "<font color='"+noteColor+"'>"+$1.replace(/<\/?font.*?>/gi,"")+"</font>"});
  //text = text.replace(/(\/\*.*?\*\/)/gi,function($1){return "<font color='"+noteColor+"'>"+$1.replace(/<\/?font.*?>/gi, "")+"</font>"});
  text = text.replace(/\[(\/?font[^\]]*)\]/gm,"<$1>");
  text = text.replace(/\n/g, "\n" + bb_code_li_2 + bb_code_li_1);
  element.innerHTML = '<ol>' + text + '</ol>';
  //element.style.fontSize = fontSize;
}
</script>
</PUBLIC:CompONENT>