/* Code to HTML with Syntax Highlighting */
var $=function(a,b){return document.getElementById(a)},G={}
G.hilite={
exec:function(){
	var m=this,o=$('source').value,r,v
	r=m.rVal(document.forms[0].codetype)
	v=m.get(o,m[r]())
	$('out').innerHTML=v
	$('html-out').value='<p class="code">'+v+'</p>'
},
get:function(a,b){
	var m=this,r=m.match(a,b),v=[],p=0,i,q
	for(i=0;i<r.length;i++){
		q=r[i]
		if(q[0]>p-1){
			v.push(m.esc(a.substring(p,q[0])))
			v.push(q[1]?'<span class="'+q[1]+'">'+m.esc(q[2])+'</span>':m.esc(q[2]))
			p=q[0]+q[2].length
		}
	}
	v.push(m.esc(a.substring(p)))
	return v.join('').replace(/\r/gm,'').replace(/\n/gm,'<br/>\n').replace(/\t/gm,'&nbsp;&nbsp;&nbsp;&nbsp;')
},
match:function(a,b){
	var m=this,v=[],q,i,p
	for(i=0;i<b.length;i++){q=null;p=b[i];while((q=p[0].exec(a))!=null)v.push([q.index,p[1],q[0]])}
	return v.sort(function(a,b){return a[0]-b[0]})
},
esc:function(a){return a.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;')},
keys:function(a){return new RegExp('\\b'+a.replace(/ /g,'\\b|\\b')+'\\b','gm')},
rVal:function(a){for(var i=0;i<a.length;i++)if(a[i].checked)return a[i].value;return null}
}
/* HTML */
G.hilite.html=function(){
	var exp=[
		[/<!--[\s\S]*?-->/gm,'comment'],
		[/"(?:\.|(\\\")|[^\""])*"/g,'string'],
		[/'(?:\.|(\\\')|[^\''])*'/g,'string'],
		[/<[\/]?[a-z0-9]+/g,'keyword'],
		[/>/g,'keyword']
	]
	return exp
}
/* CSS */
G.hilite.css=function(){
	var f=G.hilite.keys,
	values='above absolute all always auto baseline block bold bolder both bottom capitalize caption center center-left center-right circle code collapse compact condensed continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero default digits disc dotted double embed embossed e-resize expanded extra-condensed extra-expanded fixed format groove handheld help hidden hide high higher icon inline-table inline inset inside invert italic justify landscape large larger left-side left leftwards level lighter line-through list-item local lowercase lower low ltr marker medium middle mix move narrower ne-resize none no-repeat normal nowrap n-resize nw-resize oblique outset outside overline pointer portrait pre print projection relative repeat repeat-x repeat-y rgb ridge right right-side rightwards rtl run-in screen scroll show small small-caps small-caption smaller soft solid square s-resize static status-bar sub super sw-resize table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group text-bottom text-top thick top transparent underline uppercase url visible wider w-resize x-fast x-high x-large x-small xx-large xx-small',
	fonts='[mM]onospace [tT]ahoma [vV]erdana [aA]rial [hH]elvetica [sS]ans-serif [sS]erif',
	exp=[
		[/\/\*[\s\S]*?\*\//gm,'comment'],
		[/.+{/g],
		[/"(?:\.|(\\\")|[^\""])*"/gm,'string'],
		[/'(?:\.|(\\\')|[^\''])*'/gm,'string'],
		[/\#[a-zA-Z0-9]{3,6}/g,'color'],
		[/(\d+)(px|pt|%|\:){0,1}/g,'string'],
		[/[a-z|-]+(?=:)/gm,'keyword'],
		[f(values),'string'],
		[f(fonts),'string']
	]
	return exp
}
/* Java */
G.hilite.java=function(){
var f=G.hilite.keys,
keywords='abstract assert boolean break byte case catch char class const continue default do double else enum extends false final finally float for goto if implements import instanceof int interface long native new null package private protected public return short static strictfp super switch synchronized this throw throws true transient try void volatile while',
exp=[
	[/\/\/.*$/gm,'comment'],
	[/\/\*[\s\S]*?\*\//gm,'comment'],
	[/"(?:\.|(\\\")|[^\""])*"/gm,'string'],
	[/'(?:\.|(\\\')|[^\''])*'/gm,'string'],
	[/\\b([\\d]+(\\.[\\d]+)?|0x[a-f0-9]+)\\b/gi,'number'],
	[/(?!\\@interface\\b)\\@[\\$\\w]+\\b/g,'annotation'],
	[/\\@interface\\b/g,'keyword'],
	[f(keywords),'keyword']
]
return exp
}
/* JavaScript */
G.hilite.js=function(){
	var f=G.hilite.keys,
	keywords='abstract boolean break byte case catch char class const continue debugger default delete do double else enum export extends false final finally float for function goto if implements import in instanceof int interface long native new null package private protected public return short static super switch synchronized this throw throws transient true try typeof var void volatile while with',
	dom='window document navigator getElementsByTagName getElementById appendChild tagName createElement .innerHTML',
	exp=[
		[/\/\/.*$/gm,'comment'],
		[/\/\*[\s\S]*?\*\//gm,'comment'],
		[/"(?:\.|(\\\")|[^\""])*"/gm,'string'],
		[/'(?:\.|(\\\')|[^\''])*'/gm,'string'],
		[f(keywords),'keyword'],
		[f(dom),'domobj']
	]
	return exp
}
/* LotusScript */
G.hilite.ls=function(){
	var f=G.hilite.keys,
	functions='CBool Implode Join Replace Split StrToken Abs ACos ActivateApp ArrayAppend ArrayGetIndex ArrayReplace Asc ASin ATn ATn2 Beep Bin Bin$ Call CCur CDat CDbl ChDir ChDrive Chr Chr$ CInt CLng Close CodeLock CodeLockCheck CodeUnlock Command Command$ Cos CreateLock CreateObject CSng CStr CurDir CurDir$ CurDrive CurDrive$ CVar DataType Date Date$ DateNumber DateSerial DateValue Day Deftype DefCur DefDbl DefInt DefLng DefSng DefStr DefVar Delete DestroyLock Dir Dir$ Doevents Environ Environ$ EOF Erase Erl Err Error$ Error Evaluate Execute Exp FileAttr FileCopy FileDateTime FileLen Fix Format Format$ Fraction FreeFile FullTrim GetFileAttr GetObject GetThreadInfo Hex Hour IMESetMode IMEStatus Input Input$ InputB InputB$ InputBP InputBP$ InputBox InputBox$ InStr Instr InStrB InStrBP InStrC Int IsArray IsDate IsDefined IsElement IsEmpty IsList IsNull IsNumeric IsObject IsScalar IsUnknown Kill LBound LCase LCase$ Left Left$ LeftB LeftB$ LeftBP LeftBP$ LeftC Len LenB LenBP LenC Line ListTag LOC Lock LOF Log LSet LTrim LTrim$ MessageBox Mid Mid$ MidB MidB$ MidBP MidBP$ MidC Minute MkDir Month MsgBox Name Now Oct Oct$ Open Print Put Randomize Reset Right Right$ RightB RightB$ RightBP RightBP$ RightC RmDir Rnd Round RSet RTrim RTrim$ Run Second Seek SendKeys SetFileAttr Sgn Shell Sin Sleep Space Space$ Spc Sqr Str Str$ StrComp StrCompare StrConv StrLeft StrLeftBack StrRight StrRightBack Tab Tan Time Time$ TimeNumber TimeSerial TimeValue Timer Today Trim Trim$ TypeName Ubound Lbound UBound Ucase UCase$ UChr UChr$ Uni Unlock UString UString$ Val Weekday Width Write Year Yield',
	keywords='Access Alias Append Array As Base Binary Bind ByVal ByRef Byval Byref Compare Currency Declare Event Explicit Currency From GoSub GoTo Initialize Input Integer Len Lib List LMBCS LoadMsgFile Lock Long LSServer Me Messagebox MsgDescription MsgText New NoCase NoPitch Option Output Pitch Preserve Private Public Published Random Read Remove Shared Single Static String Terminate Unicode Variant Write',
	methods='AppendItemValue GetFirstItem CreateRichTextItem CloseMIMEEntities ComputeWithForm CopyAllItems CopyItem CopyItem CopyToDatabase CreateMIMEEntity CreateReplyMessage Encrypt GetAttachment GetFirstItem GetItemValue GetItemValue CustomDataBytes GetItemValueDateTimeArray GetMIMEEntity GetReceivedItemText HasItem Lock LockProvisional MakeResponse PutInFolder Remove RemoveFromFolder RemoveItem RemovePermanently RenderToRTItem ReplaceItemValue ReplaceItemValue CustomDataBytes Save Send Sign UnLock',
	statements='And Boolean Or Mod Case Class Const Dim Do Else %Else ElseIf %ElseIf End %End %ENDREM Exit For ForAll Forall Function Get If %If Include %Include Let Loop Next Not On Property ReDim Redim REM %REM Resume Return Select Set Step Stop Sub Then To Type Use UseLSX Wend While With true True TRUE false False FALSE',
	classes='Button Field Navigator Notes[a-z]{3}',
	exp=[
		[/%REM(.|\n)*?%END REM/gm,'comment'],
		[/'.*$/gm,'comment'],
		[/"(?:\.|(\\\")|[^\""])*"/gm,'string'],
		[/\|(?:[^\|])*\|/gm,'string'],
		[f(functions),'keyword'],
		[f(keywords),'keyword'],
		[f(statements),'keyword'],
		[f(methods),'keyword'],
		[f(classes),'keyword']
	]
	return exp
}
/* Notes Formula */
G.hilite.frm=function(){
	var exp=[
		[/"(?:\.|(\\\")|[^\""])*"/gm,'string'],
		[/@\w+/g,'keyword']
	]
	return exp
}
