/*
 * JsMin
 * Javascript Compressor
 * http://www.crockford.com/
 * http://www.smallsharptools.com/
*/

var dp={sh:{Version:'2.1',Strings:{aboutDialog:'<html><head><title>About...</title></head><body class="dp-about"><table cellspacing="0"><tr><td class="copy"><p class="title">Gembox SyntaxHighlighter</div><div class="para">Version: {V}</p><p><a href="http://onursafak.com/code/gembox/" target="_blank">http://onursafak.com/code/gembox/</a></p>&copy;2008 Onur Safak<br/>&copy;2004-2008 Alex Gorbatchev.<br/><br/>Based on Syntax Highlighter by Alex Gorbatchev.<br/>This is a free software under the GPL v3</td></tr><tr><td class="footer"><input type="button" class="close" value="OK" onClick="window.close()"/></td></tr></table></body></html>'},Toolbar:{create:function(highlighter)
{var div=document.createElement('DIV');div.className='toolbar';for(var name in dp.sh.Toolbar.Commands)
{var cmd=dp.sh.Toolbar.Commands[name];if(cmd.check!=null&&!cmd.check(highlighter))
continue;div.innerHTML+='<a href="#" onclick="dp.sh.Toolbar.command(\''+name+'\',this);return false;">'+cmd.label+'</a>';}
return div;},command:function(name,sender)
{var n=sender;while(n!=null&&n.className.indexOf('dp-highlighter')==-1)
n=n.parentNode;if(n!=null)
dp.sh.Toolbar.Commands[name].func(sender,n.highlighter);},Commands:{expandSource:{label:'+ expand source',check:function(highlighter)
{return highlighter.getParam('collapse',false);},func:function(sender,highlighter)
{sender.parentNode.removeChild(sender);highlighter.div.className=highlighter.div.className.replace('collapsed','');}},viewSource:{label:'view source',func:function(sender,highlighter)
{var code=dp.sh.Utils.fixForBlogger(highlighter.originalCode).replace(/</g,'&lt;');var wnd=window.open('','_blank','width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=0');wnd.document.write('<textarea style="width:99%;height:99%">'+code+'</textarea>');wnd.document.close();}},copyToClipboard:{label:'copy to clipboard',check:function()
{return window.clipboardData!=null||dp.sh.ClipboardSwf!=null;},func:function(sender,highlighter)
{var code=dp.sh.Utils.fixForBlogger(highlighter.originalCode).replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');if(window.clipboardData)
{window.clipboardData.setData('text',code);}
else if(dp.sh.ClipboardSwf!=null)
{var flashcopier=highlighter.flashCopier;if(flashcopier===null)
{flashcopier=document.createElement('div');highlighter.flashCopier=flashcopier;highlighter.div.appendChild(flashcopier);}
flashcopier.innerHTML='<embed src="'+dp.sh.ClipboardSwf+'" FlashVars="clipboard='+encodeURIComponent(code)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';}
alert('The code is in your clipboard now');}},printSource:{label:'print',func:function(sender,highlighter)
{var iframe=document.createElement('IFRAME');var doc=null;iframe.style.cssText='position:absolute;width:0px;height:0px;left:-500px;top:-500px;';document.body.appendChild(iframe);doc=iframe.contentWindow.document;dp.sh.Utils.copyStyles(doc,window.document);doc.write('<div class="'+highlighter.div.className.replace('collapsed','')+' printing">'+highlighter.div.innerHTML+'</div>');doc.close();iframe.contentWindow.focus();iframe.contentWindow.print();alert('Printing...');document.body.removeChild(iframe);}},about:{label:'?',func:function(highlighter)
{var wnd=window.open('','_blank','dialog,width=300,height=210,scrollbars=0');var doc=wnd.document;dp.sh.Utils.copyStyles(doc,window.document);doc.write(dp.sh.Strings.aboutDialog.replace('{V}',dp.sh.Version));doc.close();wnd.focus();}}}},Settings:{BrushPath:'',BrushFiles:'Plain',ClipboardSwf:null,BloggerMode:false,GlobalParams:{controls:true,autolinks:true,collapse:false,gutter:true,ruler:false,smarttabs:true,smarttabssize:4}},Utils:{OverrideParams:function(Par1,Par2){ParRes={}
for(var key in Par1)
ParRes[key]=Par1[key];for(var key in Par2)
ParRes[key]=Par2[key];return ParRes;},AddOnLoad:function(Func){if(window.addEventListener)window.addEventListener("load",function(){Func()},false);else if(window.attachEvent)window.attachEvent("onload",function(){Func()});else{if(window.onload!=null){var oldOnload=window.onload;window.onload=function(e){oldOnload(e);Func();}}
else window.onload=function(){Func()};}},IncludeBrushesOnLoad:function(path,brushes){dp.sh.Settings.BrushPath=path;dp.sh.Settings.BrushFiles=brushes;dp.sh.Utils.AddOnLoad(dp.sh.Utils.IncludeBrushes);},IncludeBrushes:function(path,brushes){var files=[];if(!path)path=dp.sh.Settings.BrushPath;if(!brushes)brushes=dp.sh.Settings.BrushFiles;brushes=brushes.split(",");for(var i=0;i<brushes.length;i++)
files.push(path+"shBrush"+brushes[i]+".js");dp.sh.Utils.IncludeJS(files);},IncludeJS:function(files){var head=document.getElementsByTagName('head').item(0);if(head){for(var i=0;i<files.length;i++){var js=document.createElement('script');js.setAttribute('language','javascript');js.setAttribute('type','text/javascript');js.setAttribute('src',files[i]);head.appendChild(js);}
return true;}else{return false;}},trimFirstAndLastLines:function(str)
{return str.replace(/^[ ]*[\n]+|[\n]*[ ]*$/g,'');},inArray:function(array,value)
{for(var i in array)
if(array[i]===value)
return true;return false;},parseParams:function(str)
{var match,result={},arrayRegex=/^\[(.*?)\]$/,regex=/([\w-]+)\s*:\s*(([\w-]+)|(\[.*?\]))/g;while((match=regex.exec(str))!=null)
{var value=match[2];if(value!=null&&arrayRegex.test(value))
{var m=arrayRegex.exec(value);value=(m!=null)?m[1].split(/\s*,\s*/):null;}
result[match[1]]=value;}
return result;},processUrls:function(code)
{return code.replace(dp.sh.RegexLib.url,function(m)
{return'<a href="'+m+'">'+m+'</a>';})},decorateBit:function(str,css)
{if(str==null||str.length==0||str=='\n')
return str;str=str.replace(/</g,'&lt;');str=str.replace(/ {2,}/g,function(m)
{var spaces='';for(var i=0;i<m.length-1;i++)
spaces+='&nbsp;';return spaces+' ';});if(css!=null)
str=str.replace(/^.*$/gm,function(line)
{if(line.length==0)
return'';var spaces='';line=line.replace(/^(&nbsp;| )+/,function(s)
{spaces=s;return'';});if(line.length==0)
return spaces;return spaces+'<span class="reset font '+css+'">'+line+'</span>';});return str;},padNumber:function(number,length)
{var result=number.toString();while(result.length<length)
result='0'+result;return result;},measureSpace:function()
{var span=document.createElement("span");span.innerHTML="&nbsp;";span.className="dp-highlighter reset font";document.body.appendChild(span);var result=0;if(/opera/i.test(navigator.userAgent))
{var style=window.getComputedStyle(span,null);result=parseInt(style.getPropertyValue("width"));}
else
{result=span.offsetWidth;}
document.body.removeChild(span);return result;},processSmartTabs:function(code,tabSize)
{var lines=code.split('\n'),tab='\t',spaces='';for(var i=0;i<50;i++)
spaces+='                    ';function insertSpaces(line,pos,count)
{return line.substr(0,pos)
+spaces.substr(0,count)
+line.substr(pos+1,line.length);};function processLine(line,tabSize)
{if(line.indexOf(tab)==-1)
return line;var pos=0;while((pos=line.indexOf(tab))!=-1)
{var spaces=tabSize-pos%tabSize;line=insertSpaces(line,pos,spaces);}
return line;};return code.replace(/^.*$/gm,function(m)
{return processLine(m,tabSize);});},copyStyles:function(destDoc,sourceDoc)
{var links=sourceDoc.getElementsByTagName('link');for(var i=0;i<links.length;i++)
if(links[i].rel.toLowerCase()=='stylesheet')
destDoc.write('<link type="text/css" rel="stylesheet" href="'+links[i].href+'"></link>');},fixForBlogger:function(str)
{return(dp.sh.isBloggerMode==true)?str.replace(/<br\s*\/?>|&lt;br\s*\/?&gt;/gi,'\n'):str;},trim:function(str)
{return str.replace(/\s*$/g,'').replace(/^\s*/,'');},unindent:function(str)
{var lines=dp.sh.Utils.fixForBlogger(str).split('\n'),indents=new Array(),regex=/^\s*/,min=1000;for(var i=0;i<lines.length&&min>0;i++)
{var line=lines[i];if(dp.sh.Utils.trim(line).length==0)
continue;var matches=regex.exec(line);if(matches==null)
return str;min=Math.min(matches[0].length,min);}
if(min>0)
for(var i=0;i<lines.length;i++)
lines[i]=lines[i].substr(min);return lines.join('\n');},matchesSortCallback:function(m1,m2)
{if(m1.index<m2.index)
return-1;else if(m1.index>m2.index)
return 1;else
{if(m1.length<m2.length)
return-1;else if(m1.length>m2.length)
return 1;}
return 0;},getMatches:function(code,regexInfo)
{function defaultAdd(match,regexInfo)
{return[new dp.sh.Match(match[0],match.index,regexInfo.css)];};var index=0,match=null,result=[],func=regexInfo.func?regexInfo.func:defaultAdd;;while((match=regexInfo.regex.exec(code))!=null)
result=result.concat(func(match,regexInfo));return result;}},RegexLib:{multiLineCComments:/\/\*[\s\S]*?\*\//gm,singleLineCComments:/\/\/.*$/gm,singleLinePerlComments:/#.*$/gm,doubleQuotedString:/"(?:\.|(\\\")|[^\""\n])*"/g,singleQuotedString:/'(?:\.|(\\\')|[^\''\n])*'/g,url:/\w+:\/\/[\w-.\/?%&=]*/g},Brushes:{},highlight:function(element)
{var elements=element?[element]:document.getElementsByTagName('pre'),propertyName='innerHTML',highlighter=null,brushes={};if(elements.length===0)
return;for(var brush in dp.sh.Brushes)
{dp.sh.Brushes[brush].prototype=new dp.sh.Highlighter();var aliases=dp.sh.Brushes[brush].aliases;if(aliases===null)
continue;for(var i=0;i<aliases.length;i++)
brushes[aliases[i]]=brush;}
for(var i=0;i<elements.length;i++)
{var element=elements[i],params=dp.sh.Utils.parseParams(element.className),brush=brushes[params['brush']];if(!brush)
brush=brushes[params['hl']];if(!brush)
continue;highlighter=new dp.sh.Brushes[brush]();element.style.display='none';highlighter.highlight(element[propertyName],dp.sh.Utils.OverrideParams(params,dp.sh.Settings.GlobalParams));highlighter.source=element;element.parentNode.insertBefore(highlighter.div,element);highlighter=null;}},highlightOnLoad:function(){dp.sh.Utils.AddOnLoad(dp.sh.highlight);},BloggerMode:function()
{dp.sh.isBloggerMode=true;}}};dp.SyntaxHighlighter=dp.sh;dp.sh.Match=function(value,index,css)
{this.value=value;this.index=index;this.length=value.length;this.css=css;};dp.sh.Match.prototype={toString:function()
{return this.value;}};dp.sh.Highlighter=function()
{this.params={};this.div=null;this.lines=null;this.code=null;this.bar=null;this.spaceWidth=dp.sh.Utils.measureSpace();};dp.sh.Highlighter.prototype={getParam:function(name,defaultValue)
{var result=this.params[name];switch(result)
{case"false":result=false;break;case"true":result=true;break;}
return result!=null?result:defaultValue;},createElement:function(name)
{var result=document.createElement(name);result.highlighter=this;return result;},isMatchNested:function(match)
{for(var i=0;i<this.matches.length;i++)
{var item=this.matches[i];if(item===null)
continue;if((match.index>item.index)&&(match.index<item.index+item.length))
return true;}
return false;},findMatches:function()
{var result=[];if(this.regexList!=null)
for(var i=0;i<this.regexList.length;i++)
result=result.concat(dp.sh.Utils.getMatches(this.code,this.regexList[i]));result=result.sort(dp.sh.Utils.matchesSortCallback);this.matches=result;},setupRuler:function()
{var div=this.createElement('div');var ruler=this.createElement('div');var showEvery=10;var i=1;while(i<=150)
{if(i%showEvery===0)
{div.innerHTML+=i;i+=(i+'').length;}
else
{div.innerHTML+='&middot;';i++;}}
ruler.className='ruler font line';ruler.appendChild(div);this.bar.appendChild(ruler);},removeNestedMatches:function()
{for(var i=0;i<this.matches.length;i++)
if(this.isMatchNested(this.matches[i]))
this.matches[i]=null;},splitIntoDivs:function(code)
{var lines=code.split(/\n/g),firstLine=parseInt(this.getParam("first-line",1)),padLength=(firstLine+lines.length).toString().length,highlightedLines=this.getParam("highlight-lines",[]);if(highlightedLines!=null&&highlightedLines.join==null)
highlightedLines==[highlightedLines];code='';for(var i=0;i<lines.length;i++)
{var line=lines[i],indent=/^(&nbsp;)+ /.exec(line),lineClass='font line alt'+(i%2==0?1:2),lineNumber=dp.sh.Utils.padNumber(firstLine+i,padLength),highlighted=dp.sh.Utils.inArray(highlightedLines,(firstLine+i).toString());if(indent!=null)
{line=line.substr(indent[0].length);indent=this.spaceWidth*(indent[0].length+5)/6;}
else
{indent=0;}
line=dp.sh.Utils.trim(line);if(line.length==0)
line='&nbsp;';if(highlighted)
lineClass+=' highlighted';code+='<div class="'+lineClass+'">'
+'<div class="number">'+lineNumber+'.</div>'
+'<div class="content">'
+'<div style="padding-left:'+indent+'px;">'+line+'</div>'
+'</div>'
+'</div>';}
return code;},processMatches:function()
{function copy(string,pos1,pos2)
{return string.substr(pos1,pos2-pos1);}
var pos=0,code='',decorateBit=dp.sh.Utils.decorateBit;for(var i=0;i<this.matches.length;i++)
{var match=this.matches[i];if(match===null||match.length===0)
continue;code+=decorateBit(copy(this.code,pos,match.index),'plain');code+=decorateBit(match.value,match.css);pos=match.index+match.length;}
code+=decorateBit(this.code.substr(pos),'plain');code=this.splitIntoDivs(dp.sh.Utils.trim(code));if(this.getParam('auto-links',true))
code=dp.sh.Utils.processUrls(code);this.lines.innerHTML=code;},highlight:function(code,params)
{if(code===null)
code='';if(params!=null)
this.params=params;this.div=this.createElement('DIV');this.bar=this.createElement('DIV');this.lines=this.createElement('DIV');this.lines.className='lines';this.div.className='dp-highlighter';this.bar.className='bar';if(this.getParam('collapse',false))
this.div.className+=' collapsed';if(this.getParam('gutter',true)==false)
this.div.className+=' nogutter';this.originalCode=code;this.code=dp.sh.Utils.trimFirstAndLastLines(code).replace(/\r/g,' ');if(this.getParam('smart-tabs',true))
{this.code=dp.sh.Utils.processSmartTabs(this.code,this.getParam('smart-tabs-size',4));this.code=dp.sh.Utils.unindent(this.code);}
if(this.getParam('controls',true))
this.bar.appendChild(dp.sh.Toolbar.create(this));if(this.getParam('ruler',false))
this.setupRuler();this.div.appendChild(this.bar);this.div.appendChild(this.lines);this.findMatches();this.removeNestedMatches();this.processMatches();},getKeywords:function(str)
{return'\\b'+str.replace(/ /g,'\\b|\\b')+'\\b';}};
