(function(){if(typeof window.Quode=="undefined"){window.Quode={}}window.Quode.JSH={version:"0.3",inCssPrefix:"jsh:",outCssPrefix:"jsh-",highlight:function(b){if(typeof b=="string"){this.process(document.getElementsByTagName(b))}else{if(b.length){this.process(b)}}this.process([b])},process:function(m){var c=RegExp(Quode.JSH.inCssPrefix+"(\\w+)"),d=new Quode.JSH.Buffer;for(var g=0,l,h,b,f,k,j=m.length;g<j;++g){l=m[g];if(l.parentNode&&(h=l.className.match(c))){if((b=Quode.JSH.language.registered[h[1]])&&(f=l.firstChild)){do{d.push(f.nodeValue)}while(f=f.nextSibling);d.clearPush(d.value().replace(/^[\n\r]+|\s+$/g,""));k=Quode.JSH.parse(d,b);Quode.JSH.build(l,d,k,Quode.JSH.language.registeredClass[h[1]]);d.clear()}}}},build:function(j,a,f,g){var p=a.value(),b,l=cur=document.createElement(j.nodeName);var m=document.createElement("span");for(var d=0,c=0,o,h=f.length;d<h;++d){o=f[d];if(o.index&&o.index>c){cur.appendChild(document.createTextNode(p.substring(c,o.index)));if(!o.len){c=o.index}}if(o.embed){b=m.cloneNode(false);b.className=o.embed;cur.appendChild(b);cur=b}if(o.len){b=m.cloneNode(false);b.className=o.css;b.appendChild(document.createTextNode(p.substring(o.index,o.len)));cur.appendChild(b);c=o.len}if(o.endEmbed){cur=cur.parentNode}}if(c<p.length){cur.appendChild(document.createTextNode(p.substr(c)))}l.className=Quode.JSH.outCssPrefix+g;j.parentNode.replaceChild(l,j)},parse:function(t,w){var h=t.value(),g=[],e,q,n,a,v=false,f,i={patterns:w.patterns.slice(),capture:[],embedder:null},l=[i],r=prevLastIndex=0;for(;;){e=null;q=n=0;prevLastIndex=r;for(var m=i.patterns.length-1,d;m>=0;--m){i.patterns[m].regex.lastIndex=prevLastIndex;if(d=i.patterns[m].regex.exec(h)){if(e==null||d.index<e){e=d.index;q=d;n=m;r=i.patterns[m].regex.lastIndex;if(e==prevLastIndex){break}}}else{i.patterns.splice(m,1);--n}}if(!q){break}if(i.patterns[n].exclude){r=e}else{g.push({index:e,len:r,css:i.patterns[n].css})}if(i.patterns[n].exit){i=l.pop();if(i.nest){if(e!=prevLastIndex){g.push({index:r})}g[g.length-1].endEmbed=true}if(i.embedder.captured){for(var o=0,c,p;p=i.embedder.captured[o++];){c=false;for(var u in p.test){if(typeof p.test[u]=="boolean"){if(!p.test[u]&&i.capture[u]!=f||p.test[u]&&i.capture[u]==f){c=true;break}}else{if(!i.capture[u]||!p.test[u].test(i.capture[u])){c=true;break}}}if(c){continue}v=false;if(p.embed&&typeof p.embed=="string"&&(a=Quode.JSH.language.registered[p.embed])){g.push({embed:p.embed});v=true}if(a&&p.until){i={patterns:a.patterns.concat({regex:p.until,css:p.css,exit:true,exclude:p.exclude}),capture:{},embedder:i.patterns[n],nest:v};l.push(i)}break}}i=l[l.length-1];continue}if(i.patterns[n].capture){i.capture[i.patterns[n].capture]=q[0]}if(a=i.patterns[n].embed){v=false;if(typeof a=="string"&&(a=Quode.JSH.language.registered[a])){g[g.length-1].embed=i.patterns[n].embed;v=true}if(a&&i.patterns[n].until){i={patterns:a.patterns.concat({regex:i.patterns[n].until,css:i.patterns[n].css,exit:true}),capture:{},embedder:i.patterns[n],nest:v};l.push(i)}continue}if(i.patterns[n].once){i.patterns.splice(n,1)}}return g},language:{register:function(d,b,g){if(typeof b=="string"){this.registered[b]=d;this.registeredClass[b]=g||b}else{g=g||b[0];for(var e=0,f;f=b[e++];){this.registered[f]=d;this.registeredClass[f]=g}}},registered:{},registeredClass:{}},regexLib:{multiLComment:/\/\*[\s\S]*?\*\//g,singleLComment:/\/\/[^\n]*/g,perlComment:/#[^\n]*/g,cComment:/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g,phpComment:/\/\*[\s\S]*?\*\/|(?:\/\/|#)[^\n]*/g,string:/(['"])(?:\\.|[^\1])*?\1/g,singleString:/'(?:\\.|[^'])*?'/g,doubleString:/"(?:\\.|[^"])*?"/g,number:/\b(?:0x[0-9a-f]+|[0-9]+(?:\.[0-9]+)?(?:e[+-]?[0-9]+)?(?:ul|[ulf])?)\b/g,xmlString:/(['"])[^\1]*?\1/g,xmlComment:/<!--[\s\S]*?-->/g,xmlCDATA:/<!\[CDATA\[[\s\S]*?\]\]>/g,xmlDoctypeAlt:/<!DOCTYPE[^>\[]+\[[\s\S]*?\]>/g,xmlDoctype:/<!DOCTYPE[\s\S]*?>/g,xmlPI:/<\?[\s\S]*?\?>/g,xmlEntity:/&[#a-zA-Z0-9_-]+;/g,keywords:function(b,a){return new RegExp("\\b(?:"+b.replace(/\s+/g,"|")+")\\b",a)}}};if(!!document.attachEvent){Quode.JSH.Buffer=function(){var b=[],a=0;this.push=function(c){b[a++]=c;return this};this.value=function(){return b.join("")};this.clear=function(){b=[];return this};this.clearPush=function(c){return this.clear().push(c)}}}else{Quode.JSH.Buffer=function(){var b=[],a="";this.push=function(c){a+=c;if(a.length>2800){b.push(a);a=""}return this};this.value=function(){b.push(a);a="";return(b=[b.join("")])[0]};this.clear=function(){b=[];return this};this.clearPush=function(c){return this.clear().push(c)}}}})();new function(){var a="abstract boolean break byte case catch char class const continue debugger default delete do double else enum export extends final finally float for function goto if implements import in instanceof int interface long native new package private protected public return short static super switch synchronized this throw throws transient try typeof var void volatile while with true false prototype";this.patterns=[{regex:/\/(?:\\.|[^\r\n\/])*?\/[gim]*/g,css:"regex"},{regex:/\b(?:0x[0-9a-f]+|[0-9]+(?:\.[0-9]+)?(?:e[+-]?[0-9]+)?)\b/gi,css:"number"},{regex:/(['"])(?:\\.|[^\1])*?\1/g,css:"string"},{regex:/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g,css:"comment"},{regex:Quode.JSH.regexLib.keywords(a,"g"),css:"keyword"},{regex:/[(){}\][=,?;.:!&|^+*%>-]+|</g,css:"operator"}];Quode.JSH.language.register(this,["js","jscript","javascript"])};new function(){this.patterns=[{regex:Quode.JSH.regexLib.xmlEntity,css:"entity"},{regex:Quode.JSH.regexLib.xmlPI,css:"pi"},{regex:Quode.JSH.regexLib.xmlDoctype,css:"doctype"},{regex:Quode.JSH.regexLib.xmlDoctypeAlt,css:"doctype"},{regex:Quode.JSH.regexLib.xmlCDATA,css:"cdata"},{regex:Quode.JSH.regexLib.xmlComment,css:"comment"},{regex:/<\/?(?![\?!])/g,embed:{patterns:[{regex:Quode.JSH.regexLib.xmlString,css:"attribute-value"},{regex:/[\w-]+\s*=/g,css:"attribute"},{regex:/[\w-]+/g,css:"tag-name",once:true},{regex:/[\w-]+:/g,css:"prefix"}]},until:/\/?>/g,css:"tag"}];Quode.JSH.language.register(this,["xml","xsl","xslt","xsd"])};new function(){this.patterns=[{regex:Quode.JSH.regexLib.xmlEntity,css:"entity"},{regex:Quode.JSH.regexLib.xmlPI,css:"pi"},{regex:Quode.JSH.regexLib.xmlDoctype,css:"doctype"},{regex:Quode.JSH.regexLib.xmlDoctypeAlt,css:"doctype"},{regex:Quode.JSH.regexLib.xmlCDATA,css:"cdata"},{regex:/<\?(?:php\s+|=)/g,embed:"php",until:/\?>/g,css:"tag"},{regex:Quode.JSH.regexLib.xmlComment,css:"comment"},{regex:/<(?![\?!])/g,embed:{patterns:[{regex:Quode.JSH.regexLib.xmlString,css:"attribute-value"},{regex:/[\w-]+\s*=/g,css:"attribute"},{regex:/[\w-]+/g,css:"tag-name",capture:"tagn",once:true},{regex:/[\w-]+:/g,css:"prefix"},{regex:/\//g,css:"tag",capture:"closed"}]},until:/\/?>/g,css:"tag",captured:[{test:{closed:false,tagn:/^script$/i},embed:"js",until:/(?:\/\/-->\s*)?<\/script>/gi,exclude:true,css:"js"},{test:{closed:false,tagn:/^style$/i},embed:"css",until:/(?:\/\/-->\s*)?<\/style>/gi,exclude:true,css:"css"}]}];Quode.JSH.language.register(this,["html","xhtml","phtml"],"xml")};new function(){this.patterns=[{regex:Quode.JSH.regexLib.multiLComment,css:"comment"},{regex:/@[a-zA-Z0-9_-]+\b/g,css:"media"},{regex:Quode.JSH.regexLib.string,css:"string"},{regex:/#(?:[a-fA-F0-9]{3}){1,2}\b/g,css:"color"},{regex:/#[a-zA-Z0-9_-]+\b(?=[^{}]*\{)/g,css:"id"},{regex:/\.[a-zA-Z][a-zA-Z0-9_-]+\b(?!\))/g,css:"class"},{regex:/[(){}\][;,:=|!+~>-]+|</g,css:"operator"},{regex:/[a-zA-Z0-9-]+(?=\s*:)(?=[^{};]*[;\}])/g,css:"keyword"}];Quode.JSH.language.register(this,"css")};new function(){var a="and or xor __FILE__ __LINE__ array as break case cfunction class const continue declare default die do echo else elseif enddeclare endfor endforeach endif endswitch endwhile extends for foreach function include include_once global if new old_function return static switch namespace use require require_once var while __FUNCTION__ __CLASS__ true false bool boolean null unset isset int integer float double real empty instanceof __METHOD__ __NAMESPACE__ __construct __destruct __set __get __isset __sleep __wakeup abstract interface public implements extends private protected try catch throw self string float object";this.patterns=[{regex:Quode.JSH.regexLib.number,css:"number"},{regex:/<>\?\/+/g,css:"operator"},{regex:/<<<(\w+)[\r\n][\s\S]*?\1/g,css:"double-string"},{regex:/<<<'(\w+)'[\r\n][\s\S]*?\1/g,css:"single-string"},{regex:Quode.JSH.regexLib.doubleString,css:"double-string"},{regex:Quode.JSH.regexLib.singleString,css:"single-string"},{regex:/<\?(?:php\s+|=)/g,css:"tag"},{regex:/\?>/g,css:"tag"},{regex:/\$\w+/g,css:"variable"},{regex:Quode.JSH.regexLib.phpComment,css:"comment"},{regex:Quode.JSH.regexLib.keywords(a,"g"),css:"keyword"},{regex:/[(){}\][=,;.:!&|^+*%\\-]+/g,css:"operator"}];Quode.JSH.language.register(this,"php")};new function(){var a="abstract and and_eq auto bitand bitor bool break case catch char class compl const const_cast continue default delegate delete do double dynamic_cast each else enum explicit extern event false finally float for friend gcnew generic goto if in inline int internal initonly interface literal long mutable namespace new not not_eq nullptr operator or or_eq override private property protected public ref register reinterpret_cast return sealed signed sizeof short static static_cast struct switch template this true try typedef typeid throw typename union unsigned using value virtual void volatile wchar_t while where xor xor_eq";this.patterns=[{regex:Quode.JSH.regexLib.number,css:"number"},{regex:/^[ \t]*#[^#](?:[^\r\n](?!\/[\/*]))*/mg,css:"preproc"},{regex:Quode.JSH.regexLib.doubleString,css:"double-string"},{regex:Quode.JSH.regexLib.singleString,css:"single-string"},{regex:Quode.JSH.regexLib.cComment,css:"comment"},{regex:Quode.JSH.regexLib.keywords(a,"g"),css:"keyword"},{regex:/[(){}\][=,?;.:!&|^+*%><~-]+/g,css:"operator"}];Quode.JSH.language.register(this,["cpp","c++","c"])};
$(document).ready(function(){
  Quode.JSH.highlight("code");
  $("#previewb").click(function(){
    previewComment();
  });
  if (typeof aInit != "undefined") aInit();
});

function previewComment() {
  if (!jQuery.trim($("#com_con").val()).length) 
    return;
  $.ajax({
    type: "POST",
    url: "/preview",
    dataType: "text",
    data: [
     { name: 'user', value: $("#user").val() },
     { name: 'email', value: $("#email").val() },
     { name: 'site', value: $("#site").val() },
     { name: 'com_con', value: $("#com_con").val() }
   ],
    success: function(data){
      $("#preview-comment").html(data);
      //Quode.JSH.highlight(document.getElementById('preview-comment').getElementsByTagName('code'));
    },
    complete: function() {
    }
  });
}
