function confirmationPopup(url, title)
{
    var win = new Window('modal_window', {className: "dialog", width:450, height:230, zIndex:150, opacity:1, resizable: false, maximizable: false, minimizable: false});
    win.setTitle(title);
    win.setAjaxContent(url, {asynchronous:true});
    win.setDestroyOnClose();
    win.showCenter(true);
}

function recommend(url, title)
{
    var win = new Window('modal_window', {className: "dialog", width:330, height:530, zIndex:150, opacity:1, resizable: false, maximizable: false, minimizable: false});
    win.setTitle(title);
    win.setAjaxContent(url, {asynchronous:true});
    win.setDestroyOnClose();
    win.showCenter(true);
}

function fragantCodePopup(url, title)
{
    var win = new Window('modal_window', {className: "dialog", width:500, height:300, zIndex:150, opacity:1, resizable: false, maximizable: false, minimizable: false});
    win.setTitle(title);
    win.setAjaxContent(url, {asynchronous:true});
    win.setDestroyOnClose();
    win.showCenter(true);
}

function loginPopup(type)
{
    var win = new Window('modal_window', {className: "dialog", width:265, height:100, zIndex:150, opacity:1, resizable: false, maximizable: false, minimizable: false});
    win.setTitle('Login');
    
    if (typeof type != "undefined")
    {
      win.setAjaxContent('/content/loginPopup?type='+type, {asynchronous:true});
    }
    else
    {
      win.setAjaxContent('/content/loginPopup', {asynchronous:true});
    }
    
    win.setDestroyOnClose();
    win.showCenter(true);
}

/* PhotoGalleryLightBox class */
var PhotoGalleryLightBoxConfiguration = {
  LeftButton: '/images/photogallery/lightbox_left.gif', 
  RightButton: '/images/photogallery/lightbox_right.gif', 
  DoubleArrow: '/images/photogallery/doublearrow_right.gif'
}

function PhotoGalleryLightBox(images, options)
{
  this.images = images, // path to images
  this.options = options, // name, urls (Array), titles (Array)
  this.shown = false, 
  this.currentIndex, 
  this.win = false, 
  this.show = function(index)
  {    
    this.currentIndex = index; 
    var obj = this; 
    
    if (this.win == false)
    {
      this.win = new Window('modal_window_'+obj.options.name, {className: "dialog", width:600, height:450,  zIndex:150, opacity:1, resizable: false, maximizable: false, minimizable: false, closeCallback: function() { obj.shown = false; return true; }});
      this.win.setTitle('');
      this.win.setHTMLContent(this.buildLayout());
      
      // workaround for ie
      Window.prototype._fixIEOverlapping = function()
      {
      }
    }
    
    if (this.options.tracking && this.options.tracking.show)
    {
      if (typeof urchinTracker != "undefined")
      {
        urchinTracker(this.options.tracking.show);
      }
    }

    $('imageBoxButtonLinkleft'+obj.options.name).onclick = function() { obj.before(false); return false; };
    $('imageBoxButtonLinkright'+obj.options.name).onclick = function() { obj.next(false); return false; };
    
    this.update();
  }, 
  this.buildLayout = function()
  {
    var html = '<div id="imageBox'+this.options.name+'"></div>';
    var link = '';
    
    if (this.options.link)
    {
      link = '<div id="imageBoxLink'+this.options.name+'" style="position:absolute; top:10px; right:0px; display:none; width:85px; color:black"><img src="'+PhotoGalleryLightBoxConfiguration.DoubleArrow+'"/>&nbsp;<a href="'+this.options.link+'" class="gray underline">'+this.options.linktext+'</a></div>';
    }
    else
    {
      link = '';
    }
    
    return '<div style="position:relative;top:0px;left:0px;">' + this.createButton("left") + html + this.createButton("right") + link + '</div>';
  }, 
  this.createButton = function(direction)
  {
    var style = '';
    
    if (direction == "left")
    {
      style = "position:absolute; left:1px; top:10px";
    }
    else
    {
      style = "position:absolute; right:1px; top:10px";
    }
    
    var image = "";
    
    if (direction == "left")
    {
      image = PhotoGalleryLightBoxConfiguration.LeftButton;
    }
    else
    {
      image = PhotoGalleryLightBoxConfiguration.RightButton;
    }
    
    var html = '<div id="imageBoxButton'+direction+this.options.name+'" style="'+style+'"><a href="#" id="imageBoxButtonLink'+direction+this.options.name+'"><img src="' + image  + '"/></a></div>';
    
    return html;
  }
  this.next = function(check)
  {
    if (this.currentIndex >= this.images.length-1)
    {
      return false; 
    }
    
    if (check) return true;
    
    this.currentIndex++; 
    
    if (this.options.tracking && this.options.tracking.browsing)
    {
      if (typeof urchinTracker != "undefined")
      {
        urchinTracker(this.options.tracking.browsing);
      }
    }
    
    this.update();
  }, 
  this.before = function(check)
  {
    if (this.currentIndex-1 < 0)
    {
      return false; 
    }
    
    if (check) return true;
    
    this.currentIndex--;
    
    if (this.options.tracking && this.options.tracking.browsing)
    {
      if (typeof urchinTracker != "undefined")
      {
        urchinTracker(this.options.tracking.browsing);
      }
    }
    
    this.update();
  }, 
  this.update = function()
  {    
    var obj = this; 
    
    if (this.next(true))
    {
      if ($('imageBoxButtonright'+obj.options.name))
      {
        $('imageBoxButtonright'+obj.options.name).style.display = "block";
      }
      
      if ($('imageBoxLink'+obj.options.name))
      {
        $('imageBoxLink'+obj.options.name).style.display = "none";
      }
    }
    else
    {
      if ($('imageBoxButtonright'+obj.options.name))
      {
        $('imageBoxButtonright'+obj.options.name).style.display = "none";
      }
      
      if ($('imageBoxLink'+obj.options.name))
      {
        $('imageBoxLink'+obj.options.name).style.display = "block";
      }
    }
    
    if (this.before(true))
    {
      if ($('imageBoxButtonleft'+obj.options.name))
      {
        $('imageBoxButtonleft'+obj.options.name).style.display = "block";
      }
    }
    else
    {
      if ($('imageBoxButtonleft'+obj.options.name))
      {
        $('imageBoxButtonleft'+obj.options.name).style.display = "none";
      }
    }
        
    var image = new Image();    
    
    var url = this.options.urls[this.currentIndex];
    var title = this.options.titles[this.currentIndex];
      
    image.onload = function()
    {      
      var imageWidth, imageHeight; 
      
      if (image.width > image.height)
      {
        if (image.width < 400)
        {
          imageWidth = image.width + "px;";
        }
        else
        {
          imageWidth = "400px;"; 
        }
        
        imageHeight = false; 
      }
      else
      {
        if (image.height < 400)
        {
          imageHeight = image.height + "px;";
        }
        else
        {
          imageHeight = "400px;"; 
        }
        
        imageWidth = false; 
      }
          
      if ($('imageBoxButtonleft'+obj.options.name))
      {
        $('imageBoxButtonleft'+obj.options.name).style.top = (450/2 - 78/2) + "px";
      }
      
      if ($('imageBoxButtonright'+obj.options.name))
      {
        $('imageBoxButtonright'+obj.options.name).style.top = 450/2 - 78/2 + "px";
      }
      
      if ($('imageBoxLink'+obj.options.name))
      {
        $('imageBoxLink'+obj.options.name).style.top = 450/2 - 20 + "px";
      }
      
      if (obj.shown == false)
      {        
        obj.win.showCenter(true);
        obj.shown = true; 
      }
      
      var content = '<table border="0" height="450" width="600"><tr><td align="center" valign="middle"><span><a href="'+url+'"><img src="'+image.src+'" style="padding:3px; background:white; border:7px solid #E5E5E3;'+(imageWidth ? ' width:'+imageWidth : '')+(imageHeight ? ' height:'+imageHeight : '')+'"/></a></span><p style="clear:both; font-size:12px; color:black; margin-top:5px">'+title+'</p></td></tr></table>'; 
      
      $('imageBox'+obj.options.name).update(content);
    }
    
    image.onerror = function()
    {
      alert("You got an error!");
    }
    
    image.src = this.images[this.currentIndex];
  }
}

var PhotoGalleryLink = { 
  gotoPage: function(normalized_tag, medium_id)
  {
    var mediumLink = "/bilder/generate-url/"+medium_id+"/"+normalized_tag;

    new Ajax.Request(mediumLink, { 
      onSuccess: function(response) 
      { 
        var redirectUrl = response.responseText; 
        if (redirectUrl != '') 
          window.location.href = redirectUrl; 
      }, 
      onFailure: function(response) 
      { 
        alert("Es ist ein Fehler aufgetreten!"); 
      }
    }); 

    return false;
  }
}

var UserLinkToolTip = {
  setup: function()
  {   
    var userlinks = $$('a span.user-tooltip');

    for (var userLinkIndex = 0; userLinkIndex < userlinks.length; userLinkIndex++)
    {
      var userLinkEle = userlinks[userLinkIndex];
      if (typeof userLinkEle == 'object') 
      {
        userLinkEle.id = "user-tooltip-" + userLinkIndex; 
        userLinkEle.observe('mouseover', function(event) { UserLinkToolTip.detachMouseOverEvent(Event.element(event), event); });
        userLinkEle.observe('mouseout', function(event) { UserLinkToolTip.detachMouseOutEvent(Event.element(event)); });
      }
    }    
  }, 
  manager: {
    shouldHideElements: new Array(), 
    currentTimeout: null, 
    setCurrentTimeout: function(timeout)
    {
      this.currentTimeout = timeout; 
    }, 
    clearCurrentTimeout: function()
    {
      if (this.currentTimeout != null)
      {
        window.clearTimeout(this.currentTimeout);
        this.currentTimeout = null;
      }
    }, 
    cleanExcept: function(userLinkEle)
    {
      $$('a span.user-tooltip').each(function(ele)
      {
        if (ele != userLinkEle && ele.getStyle('display') != 'none')
        {
          if ($(ele.id + "-container"))
          {
            $(ele.id + "-container").hide();
          }
        }
      });
    }
  }, 
  detachMouseOverEvent: function(userLinkEle, event)
  {    
    this.manager.clearCurrentTimeout();
    var timeout = window.setTimeout(function() { UserLinkToolTip.popupToolTip(userLinkEle, event); }, 800);
    this.manager.setCurrentTimeout(timeout);
  }, 
  detachMouseOutEvent: function(userLinkEle)
  {
    this.manager.clearCurrentTimeout();
    UserLinkToolTip.hideToolTip(userLinkEle);
  },
  popupToolTip: function(userLinkEle, event)
  {    
    this.manager.cleanExcept(userLinkEle);
            
    if ($(userLinkEle.id + "-container") != null)
    {
			this.positionizeTooltip($(userLinkEle.id + "-container"), event);
      $(userLinkEle.id + "-container").appear();
    }
    else
    {      
      var container = this.createToolTipContainer(userLinkEle, event);      
			this.positionizeTooltip(container, event);
      document.body.appendChild(container);
			container.appear();
    }
  }, 
	positionizeTooltip: function(ele, event)
	{
		var posX = Event.pointerX(event) + 5 + "px";
		var posY = Event.pointerY(event) + 5 + "px";
				
		ele.style.left = posX;
		ele.style.top = posY;
	}, 
  hideToolTip: function(userLinkEle)
  {
    if ($(userLinkEle.id + "-container"))
    {
      $(userLinkEle.id + "-container").hide();
    }
  },
  createToolTipContainer: function(userLinkEle)
  {
    var container = new Element('div', { id: userLinkEle.id + "-container", style: 'position:absolute; index-z:100; display:none' } );
    
    container.innerHTML = '<img src="/images/indicator.gif" style=""/>'; 
    
    new Ajax.Updater(container, '/nutzer/' + userLinkEle.getAttribute('user-nickname') + '/tooltipp');
    
    return container; 
  }
};

document.observe("dom:loaded", function() {
  UserLinkToolTip.setup();
});

var QuestionPreview = {
  setup: function()
  {   
    var questionlinks = $$('a span.question-preview');

    for (var questionLinkIndex = 0; questionLinkIndex < questionlinks.length; questionLinkIndex++)
    {
      var questionLinkEle = questionlinks[questionLinkIndex];
      if (typeof questionLinkEle == 'object') 
      {
        questionLinkEle.id = "question-preview-" + questionLinkIndex; 
        questionLinkEle.observe('mouseover', function(event) { QuestionPreview.detachMouseOverEvent(Event.element(event), event); });
        questionLinkEle.observe('mouseout', function(event) { QuestionPreview.detachMouseOutEvent(Event.element(event)); });
      }
    }    
  }, 
  manager: {
    shouldHideElements: new Array(), 
    currentTimeout: null, 
    setCurrentTimeout: function(timeout)
    {
      this.currentTimeout = timeout; 
    }, 
    clearCurrentTimeout: function()
    {
      if (this.currentTimeout != null)
      {
        window.clearTimeout(this.currentTimeout);
        this.currentTimeout = null;
      }
    }, 
    cleanExcept: function(questionLinkEle)
    {
      $$('a span.question-preview').each(function(ele)
      {
        if (ele != questionLinkEle && ele.getStyle('display') != 'none')
        {
          if ($(ele.id + "-container"))
          {
            $(ele.id + "-container").hide();
          }
        }
      });
    }
  }, 
  detachMouseOverEvent: function(questionLinkEle, event)
  {    
    this.manager.clearCurrentTimeout();
    var timeout = window.setTimeout(function() { QuestionPreview.popupToolTip(questionLinkEle, event); }, 300);
    this.manager.setCurrentTimeout(timeout);
  }, 
  detachMouseOutEvent: function(questionLinkEle)
  {
    this.manager.clearCurrentTimeout();
    QuestionPreview.hideToolTip(questionLinkEle);
  },
  popupToolTip: function(questionLinkEle, event)
  {    
    this.manager.cleanExcept(questionLinkEle);
            
    if ($(questionLinkEle.id + "-container") != null)
    {
			this.positionizeTooltip($(questionLinkEle.id + "-container"), event);
      $(questionLinkEle.id + "-container").appear();
    }
    else
    {      
      var container = this.createToolTipContainer(questionLinkEle, event);      
			this.positionizeTooltip(container, event);
      document.body.appendChild(container);
			container.appear();
    }
  }, 
	positionizeTooltip: function(ele, event)
	{
		var posX = Event.pointerX(event) - 20 + "px";
		var posY = Event.pointerY(event) + 10 + "px";
				
		ele.style.left = posX;
		ele.style.top = posY;
	}, 
  hideToolTip: function(questionLinkEle)
  {
    if ($(questionLinkEle.id + "-container"))
    {
      $(questionLinkEle.id + "-container").hide();
    }
  },
  createToolTipContainer: function(questionLinkEle)
  {
    var container = new Element('div', { 
			id: questionLinkEle.id + "-container", 
			style: 'position:absolute; z-index:99; display:none'
		} );
    
    container.innerHTML = '<img src="/images/indicator.gif" style=""/>'; 
    
    new Ajax.Updater(container, '/frage/' + questionLinkEle.getAttribute('question-id') + '/preview');
    
    return container; 
  }
};

var UserOnlinePopup = {
  setuped: false, 
  setup: function()
  {
    if (this.setuped)
    {
      return;
    }
    
    this.setuped = true;
    
    var userlinks = $$('a.user-online-popup');

    for (var userLinkIndex = 0; userLinkIndex < userlinks.length; userLinkIndex++)
    {
      var userLinkEle = userlinks[userLinkIndex];
      if (typeof userLinkEle == 'object') 
      {
        userLinkEle.id = "user-online-popup-" + userLinkIndex; 
        userLinkEle.observe('click', function(event) { UserOnlinePopup.detachOnClickEvent(Event.element(event), event); return false; });
      }
    }
  }, 
  detachOnClickEvent: function(userLinkEle, event)
  {
    if ($("user-online-popup"))
    {
      this.removePopup();
    }
    
    var ul = document.createElement("ul");
    ul.style.paddingLeft = "0px";
    ul.style.margin = "0px";
    
    ul.appendChild(this.createList("Meinen online-Status für alle ausblenden", "inactive", 2));
    ul.appendChild(this.createList("Meinen online-Status für alle anzeigen", "online", 0));
    ul.appendChild(this.createList("Meinen online-Status nur für Freunde anzeigen", "online_friends", 1));
        
    var closeList = this.createList("Abbrechen", "close", "none");
    closeList.observe("click", function(event) { UserOnlinePopup.removePopup(); });
    ul.appendChild(closeList);
    
    var popup = document.createElement("div");
    popup.id = "user-online-popup";
    
    var popupLayer = document.createElement("div");
    
    popupLayer.appendChild(ul);
    popup.appendChild(popupLayer);
    
    userLinkEle.parentNode.appendChild(popup);
  }, 
  createList: function(text, classname, state)
  {
    var list = document.createElement("li");
    list.className = classname;

    list.innerHTML = text;
    
    $(list).observe('mouseover', function(event) { 
      Event.element(event).style.cursor = "pointer"; 
      Event.element(event).style.color = "#000"; 
    });
    
    $(list).observe('mouseout', function(event) { 
      Event.element(event).style.cursor = "default"; 
      Event.element(event).style.color = "gray"; 
    });
    
    if (state != "none")
    {
      $(list).observe('click', function(event) { window.location.href = "/user_profile/updateOnlineState?state="+state; });
    }
    
    return list;
  },
  removePopup: function()
  {
    if ($("user-online-popup"))
    {
      var popup = document.getElementById('user-online-popup'); 
      popup.parentNode.removeChild(popup);
    }
  }
};

var GutefrageForm = {
	/**
	 * Setup a css input file.
	 * http://www.quirksmode.org/dom/inputfile.html
	 */
	initFileUploads: function(options) {
		// Compatibility check
		var W3CDOM = (document.createElement && document.getElementsByTagName);
		if (!W3CDOM) { 
			return;
		}
		
		// Default options
		this.options = {
			containerFlag:  'fileinputs',
			imageSrc:       '/image/browse.gif',
      imageAlt:       'Browse'
    };
    Object.extend(this.options, options || { });
		
		// Fake input field with image submit
		var fakeFileUpload = document.createElement('div');
		fakeFileUpload.className = 'fakefile';
		var input = document.createElement('input');
		fakeFileUpload.appendChild(input);
		var image = document.createElement('img');
		image.src=this.options.imageSrc;
		image.alt=this.options.imageAlt;
		fakeFileUpload.appendChild(image);
		
		// Look for real real file inputs to replace (filter on class name with containerFlag)
		var x = document.getElementsByTagName('input');
		for (var i=0;i<x.length;i++) {
			if (x[i].type != 'file') continue;
			// fixed: allow mutilple class names for container + the flag
			if (!x[i].parentNode.className.indexOf(this.options.containerFlag)) continue;
			x[i].className = 'file hidden';
			var clone = fakeFileUpload.cloneNode(true);
			x[i].parentNode.appendChild(clone);
			x[i].relatedElement = clone.getElementsByTagName('input')[0];
			x[i].onchange = x[i].onmouseout = function () {
				this.relatedElement.value = this.value;
			}
		}
	}
}

function initPrettyPrint()
{
  $$("pre code").each(function(e)
  {
    if (!e.hasClassName("prettyprint"))
    {
      e.addClassName("prettyprint");
    }
  })
  prettyPrint();
}

// code pretty print
function H(){var x=navigator&&navigator.userAgent&&/\bMSIE 6\./.test(navigator.userAgent);H=function(){return x};return x}(function(){function x(b){b=b.split(/ /g);var a={};for(var c=b.length;--c>=0;){var d=b[c];if(d)a[d]=null}return a}var y="break continue do else for if return while ",U=y+"auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile ",D=U+"catch class delete false import new operator private protected public this throw true try ",
I=D+"alignof align_union asm axiom bool concept concept_map const_cast constexpr decltype dynamic_cast explicit export friend inline late_check mutable namespace nullptr reinterpret_cast static_assert static_cast template typeid typename typeof using virtual wchar_t where ",J=D+"boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient ",V=J+"as base by checked decimal delegate descending event fixed foreach from group implicit in interface internal into is lock object out override orderby params readonly ref sbyte sealed stackalloc string select uint ulong unchecked unsafe ushort var ",
K=D+"debugger eval export function get null set undefined var with Infinity NaN ",L="caller delete die do dump elsif eval exit foreach for goto if import last local my next no our print package redo require sub undef unless until use wantarray while BEGIN END ",M=y+"and as assert class def del elif except exec finally from global import in is lambda nonlocal not or pass print raise try with yield False True None ",N=y+"alias and begin case class def defined elsif end ensure false in module next nil not or redo rescue retry self super then true undef unless until when yield BEGIN END ",
O=y+"case done elif esac eval fi function in local set then until ",W=I+V+K+L+M+N+O;function X(b){return b>="a"&&b<="z"||b>="A"&&b<="Z"}function u(b,a,c,d){b.unshift(c,d||0);try{a.splice.apply(a,b)}finally{b.splice(0,2)}}var Y=(function(){var b=["!","!=","!==","#","%","%=","&","&&","&&=","&=","(","*","*=","+=",",","-=","->","/","/=",":","::",";","<","<<","<<=","<=","=","==","===",">",">=",">>",">>=",">>>",">>>=","?","@","[","^","^=","^^","^^=","{","|","|=","||","||=","~","break","case","continue",
"delete","do","else","finally","instanceof","return","throw","try","typeof"],a="(?:(?:(?:^|[^0-9.])\\.{1,3})|(?:(?:^|[^\\+])\\+)|(?:(?:^|[^\\-])-)";for(var c=0;c<b.length;++c){var d=b[c];a+=X(d.charAt(0))?"|\\b"+d:"|"+d.replace(/([^=<>:&])/g,"\\$1")}a+="|^)\\s*$";return new RegExp(a)})(),P=/&/g,Q=/</g,R=/>/g,Z=/\"/g;function $(b){return b.replace(P,"&amp;").replace(Q,"&lt;").replace(R,"&gt;").replace(Z,"&quot;")}function E(b){return b.replace(P,"&amp;").replace(Q,"&lt;").replace(R,"&gt;")}var aa=
/&lt;/g,ba=/&gt;/g,ca=/&apos;/g,da=/&quot;/g,ea=/&amp;/g,fa=/&nbsp;/g;function ga(b){var a=b.indexOf("&");if(a<0)return b;for(--a;(a=b.indexOf("&#",a+1))>=0;){var c=b.indexOf(";",a);if(c>=0){var d=b.substring(a+3,c),g=10;if(d&&d.charAt(0)==="x"){d=d.substring(1);g=16}var e=parseInt(d,g);if(!isNaN(e))b=b.substring(0,a)+String.fromCharCode(e)+b.substring(c+1)}}return b.replace(aa,"<").replace(ba,">").replace(ca,"'").replace(da,'"').replace(ea,"&").replace(fa," ")}function S(b){return"XMP"===b.tagName}
function z(b,a){switch(b.nodeType){case 1:var c=b.tagName.toLowerCase();a.push("<",c);for(var d=0;d<b.attributes.length;++d){var g=b.attributes[d];if(!g.specified)continue;a.push(" ");z(g,a)}a.push(">");for(var e=b.firstChild;e;e=e.nextSibling)z(e,a);if(b.firstChild||!/^(?:br|link|img)$/.test(c))a.push("</",c,">");break;case 2:a.push(b.name.toLowerCase(),'="',$(b.value),'"');break;case 3:case 4:a.push(E(b.nodeValue));break}}var F=null;function ha(b){if(null===F){var a=document.createElement("PRE");
a.appendChild(document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));F=!/</.test(a.innerHTML)}if(F){var c=b.innerHTML;if(S(b))c=E(c);return c}var d=[];for(var g=b.firstChild;g;g=g.nextSibling)z(g,d);return d.join("")}function ia(b){var a=0;return function(c){var d=null,g=0;for(var e=0,h=c.length;e<h;++e){var f=c.charAt(e);switch(f){case "\t":if(!d)d=[];d.push(c.substring(g,e));var i=b-a%b;a+=i;for(;i>=0;i-="                ".length)d.push("                ".substring(0,i));g=e+1;break;
case "\n":a=0;break;default:++a}}if(!d)return c;d.push(c.substring(g));return d.join("")}}var ja=/(?:[^<]+|<!--[\s\S]*?--\>|<!\[CDATA\[([\s\S]*?)\]\]>|<\/?[a-zA-Z][^>]*>|<)/g,ka=/^<!--/,la=/^<\[CDATA\[/,ma=/^<br\b/i;function na(b){var a=b.match(ja),c=[],d=0,g=[];if(a)for(var e=0,h=a.length;e<h;++e){var f=a[e];if(f.length>1&&f.charAt(0)==="<"){if(ka.test(f))continue;if(la.test(f)){c.push(f.substring(9,f.length-3));d+=f.length-12}else if(ma.test(f)){c.push("\n");++d}else g.push(d,f)}else{var i=ga(f);
c.push(i);d+=i.length}}return{source:c.join(""),tags:g}}function v(b,a){var c={};(function(){var g=b.concat(a);for(var e=g.length;--e>=0;){var h=g[e],f=h[3];if(f)for(var i=f.length;--i>=0;)c[f.charAt(i)]=h}})();var d=a.length;return function(g,e){e=e||0;var h=[e,"pln"],f="",i=0,j=g;while(j.length){var o,m=null,k,l=c[j.charAt(0)];if(l){k=j.match(l[1]);m=k[0];o=l[0]}else{for(var n=0;n<d;++n){l=a[n];var p=l[2];if(p&&!p.test(f))continue;k=j.match(l[1]);if(k){m=k[0];o=l[0];break}}if(!m){o="pln";m=j.substring(0,
1)}}h.push(e+i,o);i+=m.length;j=j.substring(m.length);if(o!=="com"&&/\S/.test(m))f=m}return h}}var oa=v([],[["pln",/^[^<]+/,null],["dec",/^<!\w[^>]*(?:>|$)/,null],["com",/^<!--[\s\S]*?(?:--\>|$)/,null],["src",/^<\?[\s\S]*?(?:\?>|$)/,null],["src",/^<%[\s\S]*?(?:%>|$)/,null],["src",/^<(script|style|xmp)\b[^>]*>[\s\S]*?<\/\1\b[^>]*>/i,null],["tag",/^<\/?\w[^<>]*>/,null]]);function pa(b){var a=oa(b);for(var c=0;c<a.length;c+=2)if(a[c+1]==="src"){var d,g;d=a[c];g=c+2<a.length?a[c+2]:b.length;var e=b.substring(d,
g),h=e.match(/^(<[^>]*>)([\s\S]*)(<\/[^>]*>)$/);if(h)a.splice(c,2,d,"tag",d+h[1].length,"src",d+h[1].length+(h[2]||"").length,"tag")}return a}var qa=v([["atv",/^\'[^\']*(?:\'|$)/,null,"'"],["atv",/^\"[^\"]*(?:\"|$)/,null,'"'],["pun",/^[<>\/=]+/,null,"<>/="]],[["tag",/^[\w:\-]+/,/^</],["atv",/^[\w\-]+/,/^=/],["atn",/^[\w:\-]+/,null],["pln",/^\s+/,null," \t\r\n"]]);function ra(b,a){for(var c=0;c<a.length;c+=2){var d=a[c+1];if(d==="tag"){var g,e;g=a[c];e=c+2<a.length?a[c+2]:b.length;var h=b.substring(g,
e),f=qa(h,g);u(f,a,c,2);c+=f.length-2}}return a}function r(b){var a=[],c=[];if(b.tripleQuotedStrings)a.push(["str",/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""]);else if(b.multiLineStrings)a.push(["str",/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]);else a.push(["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,
null,"\"'"]);c.push(["pln",/^(?:[^\'\"\`\/\#]+)/,null," \r\n"]);if(b.hashComments)a.push(["com",/^#[^\r\n]*/,null,"#"]);if(b.cStyleComments)c.push(["com",/^\/\/[^\r\n]*/,null]);if(b.regexLiterals)c.push(["str",/^\/(?:[^\\\*\/\[]|\\[\s\S]|\[(?:[^\]\\]|\\.)*(?:\]|$))+(?:\/|$)/,Y]);if(b.cStyleComments)c.push(["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null]);var d=x(b.keywords);b=null;var g=v(a,c),e=v([],[["pln",/^\s+/,null," \r\n"],["pln",/^[a-z_$@][a-z_$@0-9]*/i,null],["lit",/^0x[a-f0-9]+[a-z]/i,null],["lit",
/^(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?[a-z]*/i,null,"123456789"],["pun",/^[^\s\w\.$@]+/,null]]);function h(f,i){for(var j=0;j<i.length;j+=2){var o=i[j+1];if(o==="pln"){var m,k,l,n;m=i[j];k=j+2<i.length?i[j+2]:f.length;l=f.substring(m,k);n=e(l,m);for(var p=0,t=n.length;p<t;p+=2){var w=n[p+1];if(w==="pln"){var A=n[p],B=p+2<t?n[p+2]:l.length,s=f.substring(A,B);if(s===".")n[p+1]="pun";else if(s in d)n[p+1]="kwd";else if(/^@?[A-Z][A-Z$]*[a-z][A-Za-z$]*$/.test(s))n[p+1]=s.charAt(0)==="@"?"lit":
"typ"}}u(n,i,j,2);j+=n.length-2}}return i}return function(f){var i=g(f);i=h(f,i);return i}}var G=r({keywords:W,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function sa(b,a){for(var c=0;c<a.length;c+=2){var d=a[c+1];if(d==="src"){var g,e;g=a[c];e=c+2<a.length?a[c+2]:b.length;var h=G(b.substring(g,e));for(var f=0,i=h.length;f<i;f+=2)h[f]+=g;u(h,a,c,2);c+=h.length-2}}return a}function ta(b,a){var c=false;for(var d=0;d<a.length;d+=2){var g=a[d+1],e,h;if(g==="atn"){e=
a[d];h=d+2<a.length?a[d+2]:b.length;c=/^on|^style$/i.test(b.substring(e,h))}else if(g==="atv"){if(c){e=a[d];h=d+2<a.length?a[d+2]:b.length;var f=b.substring(e,h),i=f.length,j=i>=2&&/^[\"\']/.test(f)&&f.charAt(0)===f.charAt(i-1),o,m,k;if(j){m=e+1;k=h-1;o=f}else{m=e+1;k=h-1;o=f.substring(1,f.length-1)}var l=G(o);for(var n=0,p=l.length;n<p;n+=2)l[n]+=m;if(j){l.push(k,"atv");u(l,a,d+2,0)}else u(l,a,d,2)}c=false}}return a}function ua(b){var a=pa(b);a=ra(b,a);a=sa(b,a);a=ta(b,a);return a}function va(b,
a,c){var d=[],g=0,e=null,h=null,f=0,i=0,j=ia(8);function o(k){if(k>g){if(e&&e!==h){d.push("</span>");e=null}if(!e&&h){e=h;d.push('<span class="',e,'">')}var l=E(j(b.substring(g,k))).replace(/(\r\n?|\n| ) /g,"$1&nbsp;").replace(/\r\n?|\n/g,"<br />");d.push(l);g=k}}while(true){var m;m=f<a.length?(i<c.length?a[f]<=c[i]:true):false;if(m){o(a[f]);if(e){d.push("</span>");e=null}d.push(a[f+1]);f+=2}else if(i<c.length){o(c[i]);h=c[i+1];i+=2}else break}o(b.length);if(e)d.push("</span>");return d.join("")}
var C={};function q(b,a){for(var c=a.length;--c>=0;){var d=a[c];if(!C.hasOwnProperty(d))C[d]=b;else if("console"in window)console.log("cannot override language handler %s",d)}}q(G,["default-code"]);q(ua,["default-markup","html","htm","xhtml","xml","xsl"]);q(r({keywords:I,hashComments:true,cStyleComments:true}),["c","cc","cpp","cs","cxx","cyc"]);q(r({keywords:J,cStyleComments:true}),["java"]);q(r({keywords:O,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);q(r({keywords:M,hashComments:true,
multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);q(r({keywords:L,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);q(r({keywords:N,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);q(r({keywords:K,cStyleComments:true,regexLiterals:true}),["js"]);function T(b,a){try{var c=na(b),d=c.source,g=c.tags;if(!C.hasOwnProperty(a))a=/^\s*</.test(d)?"default-markup":"default-code";var e=C[a].call({},d);return va(d,g,e)}catch(h){if("console"in window){console.log(h);
console.trace()}return b}}function wa(b){var a=H(),c=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],d=[];for(var g=0;g<c.length;++g)for(var e=0;e<c[g].length;++e)d.push(c[g][e]);c=null;var h=0;function f(){var i=(new Date).getTime()+250;for(;h<d.length&&(new Date).getTime()<i;h++){var j=d[h];if(j.className&&j.className.indexOf("prettyprint")>=0){var o=j.className.match(/\blang-(\w+)\b/);if(o)o=o[1];var m=false;for(var k=j.parentNode;k;k=
k.parentNode)if((k.tagName==="pre"||k.tagName==="code"||k.tagName==="xmp")&&k.className&&k.className.indexOf("prettyprint")>=0){m=true;break}if(!m){var l=ha(j);l=l.replace(/(?:\r\n?|\n)$/,"");var n=T(l,o);if(!S(j))j.innerHTML=n;else{var p=document.createElement("PRE");for(var t=0;t<j.attributes.length;++t){var w=j.attributes[t];if(w.specified)p.setAttribute(w.name,w.value)}p.innerHTML=n;j.parentNode.replaceChild(p,j);p=j}if(a&&j.tagName==="PRE"){var A=j.getElementsByTagName("br");for(var B=A.length;--B>=
0;){var s=A[B];s.parentNode.replaceChild(document.createTextNode("\r\n"),s)}}}}}if(h<d.length)setTimeout(f,250);else if(b)b()}f()}window.PR_normalizedHtml=z;window.prettyPrintOne=T;window.prettyPrint=wa;window.PR={createSimpleLexer:v,registerLangHandler:q,sourceDecorator:r,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();

