if(typeof(Control)=='undefined')
Control={};var $proc=function(proc){return typeof(proc)=='function'?proc:function(){return proc};};var $value=function(value){return typeof(value)=='function'?value():value;};Object.Event={extend:function(object){object._objectEventSetup=function(event_name){this._observers=this._observers||{};this._observers[event_name]=this._observers[event_name]||[];};object.observe=function(event_name,observer){if(typeof(event_name)=='string'&&typeof(observer)!='undefined'){this._objectEventSetup(event_name);if(!this._observers[event_name].include(observer))
this._observers[event_name].push(observer);}else
for(var e in event_name)
this.observe(e,event_name[e]);};object.stopObserving=function(event_name,observer){this._objectEventSetup(event_name);if(event_name&&observer)
this._observers[event_name]=this._observers[event_name].without(observer);else if(event_name)
this._observers[event_name]=[];else
this._observers={};};object.observeOnce=function(event_name,outer_observer){var inner_observer=function(){outer_observer.apply(this,arguments);this.stopObserving(event_name,inner_observer);}.bind(this);this._objectEventSetup(event_name);this._observers[event_name].push(inner_observer);};object.notify=function(event_name){this._objectEventSetup(event_name);var collected_return_values=[];var args=$A(arguments).slice(1);try{for(var i=0;i<this._observers[event_name].length;++i)
collected_return_values.push(this._observers[event_name][i].apply(this._observers[event_name][i],args)||null);}catch(e){if(e==$break)
return false;else
throw e;}
return collected_return_values;};if(object.prototype){object.prototype._objectEventSetup=object._objectEventSetup;object.prototype.observe=object.observe;object.prototype.stopObserving=object.stopObserving;object.prototype.observeOnce=object.observeOnce;object.prototype.notify=function(event_name){if(object.notify){var args=$A(arguments).slice(1);args.unshift(this);args.unshift(event_name);object.notify.apply(object,args);}
this._objectEventSetup(event_name);var args=$A(arguments).slice(1);var collected_return_values=[];try{if(this.options&&this.options[event_name]&&typeof(this.options[event_name])=='function')
collected_return_values.push(this.options[event_name].apply(this,args)||null);for(var i=0;i<this._observers[event_name].length;++i)
collected_return_values.push(this._observers[event_name][i].apply(this._observers[event_name][i],args)||null);}catch(e){if(e==$break)
return false;else
throw e;}
return collected_return_values;};}}};Element.addMethods({observeOnce:function(element,event_name,outer_callback){var inner_callback=function(){outer_callback.apply(this,arguments);Element.stopObserving(element,event_name,inner_callback);};Element.observe(element,event_name,inner_callback);}});Object.extend(Event,(function(){var cache=Event.cache;function getEventID(element){if(element._prototypeEventID)return element._prototypeEventID[0];arguments.callee.id=arguments.callee.id||1;return element._prototypeEventID=[++arguments.callee.id];}
function getDOMEventName(eventName){if(eventName&&eventName.include(':'))return"dataavailable";if(!Prototype.Browser.IE){eventName={mouseenter:'mouseover',mouseleave:'mouseout'}[eventName]||eventName;}
return eventName;}
function getCacheForID(id){return cache[id]=cache[id]||{};}
function getWrappersForEventName(id,eventName){var c=getCacheForID(id);return c[eventName]=c[eventName]||[];}
function createWrapper(element,eventName,handler){var id=getEventID(element);var c=getWrappersForEventName(id,eventName);if(c.pluck("handler").include(handler))return false;var wrapper=function(event){if(!Event||!Event.extend||(event.eventName&&event.eventName!=eventName))
return false;Event.extend(event);handler.call(element,event);};if(!(Prototype.Browser.IE)&&['mouseenter','mouseleave'].include(eventName)){wrapper=wrapper.wrap(function(proceed,event){var rel=event.relatedTarget;var cur=event.currentTarget;if(rel&&rel.nodeType==Node.TEXT_NODE)
rel=rel.parentNode;if(rel&&rel!=cur&&!rel.descendantOf(cur))
return proceed(event);});}
wrapper.handler=handler;c.push(wrapper);return wrapper;}
function findWrapper(id,eventName,handler){var c=getWrappersForEventName(id,eventName);return c.find(function(wrapper){return wrapper.handler==handler});}
function destroyWrapper(id,eventName,handler){var c=getCacheForID(id);if(!c[eventName])return false;c[eventName]=c[eventName].without(findWrapper(id,eventName,handler));}
function destroyCache(){for(var id in cache)
for(var eventName in cache[id])
cache[id][eventName]=null;}
if(window.attachEvent){window.attachEvent("onunload",destroyCache);}
return{observe:function(element,eventName,handler){element=$(element);var name=getDOMEventName(eventName);var wrapper=createWrapper(element,eventName,handler);if(!wrapper)return element;if(element.addEventListener){element.addEventListener(name,wrapper,false);}else{element.attachEvent("on"+name,wrapper);}
return element;},stopObserving:function(element,eventName,handler){element=$(element);var id=getEventID(element),name=getDOMEventName(eventName);if(!handler&&eventName){getWrappersForEventName(id,eventName).each(function(wrapper){element.stopObserving(eventName,wrapper.handler);});return element;}else if(!eventName){Object.keys(getCacheForID(id)).each(function(eventName){element.stopObserving(eventName);});return element;}
var wrapper=findWrapper(id,eventName,handler);if(!wrapper)return element;if(element.removeEventListener){element.removeEventListener(name,wrapper,false);}else{element.detachEvent("on"+name,wrapper);}
destroyWrapper(id,eventName,handler);return element;},fire:function(element,eventName,memo){element=$(element);if(element==document&&document.createEvent&&!element.dispatchEvent)
element=document.documentElement;var event;if(document.createEvent){event=document.createEvent("HTMLEvents");event.initEvent("dataavailable",true,true);}else{event=document.createEventObject();event.eventType="ondataavailable";}
event.eventName=eventName;event.memo=memo||{};if(document.createEvent){element.dispatchEvent(event);}else{element.fireEvent(event.eventType,event);}
return Event.extend(event);}};})());Object.extend(Event,Event.Methods);Element.addMethods({fire:Event.fire,observe:Event.observe,stopObserving:Event.stopObserving});Object.extend(document,{fire:Element.Methods.fire.methodize(),observe:Element.Methods.observe.methodize(),stopObserving:Element.Methods.stopObserving.methodize()});(function(){function wheel(event){var delta;if(event.wheelDelta)
delta=event.wheelDelta/120;else if(event.detail)
delta=-event.detail/3;if(!delta)
return;var custom_event=Event.element(event).fire('mouse:wheel',{delta:delta});if(custom_event.stopped){Event.stop(event);return false;}}
document.observe('mousewheel',wheel);document.observe('DOMMouseScroll',wheel);})();var IframeShim=Class.create({initialize:function(){this.element=new Element('iframe',{style:'position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);display:none',src:'javascript:void(0);',frameborder:0});$(document.body).insert(this.element);},hide:function(){this.element.hide();return this;},show:function(){this.element.show();return this;},positionUnder:function(element){var element=$(element);var offset=element.cumulativeOffset();var dimensions=element.getDimensions();this.element.setStyle({left:offset[0]+'px',top:offset[1]+'px',width:dimensions.width+'px',height:dimensions.height+'px',zIndex:element.getStyle('zIndex')-1}).show();return this;},setBounds:function(bounds){for(prop in bounds)
bounds[prop]+='px';this.element.setStyle(bounds);return this;},destroy:function(){if(this.element)
this.element.remove();return this;}});if(typeof(Prototype)=="undefined"){throw"Control.ContextMenu requires Prototype to be loaded.";}
if(typeof(Object.Event)=="undefined"){throw"Control.ContextMenu requires Object.Event to be loaded.";}
Control.ContextMenu=Class.create({initialize:function(container,options){Control.ContextMenu.load();this.options=Object.extend({leftClick:false,disableOnShiftKey:true,disableOnAltKey:true,selectedClassName:'selected',activatedClassName:'activated',animation:true,animationCycles:2,animationLength:300,delayCallback:true},options||{});this.activated=false;this.items=this.options.items||[];this.container=$(container);this.container.observe(this.options.leftClick?'click':(Prototype.Browser.Opera?'click':'contextmenu'),function(event){if(!Control.ContextMenu.enabled||Prototype.Browser.Opera&&!event.ctrlKey){return;}
this.open(event);}.bindAsEventListener(this));},open:function(event){if(Control.ContextMenu.current&&!Control.ContextMenu.current.close()){return;}
if(this.notify('beforeOpen',event)===false){return false;}
this.buildMenu();if(this.items.length===0){this.close(event);return false;}
Control.ContextMenu.current=this;Control.ContextMenu.positionContainer(event);Control.ContextMenu.container.show();if(this.notify('afterOpen',event)===false){return false;}
event.stop();return true;},close:function(event){if(event){event.stop();}
if(this.notify('beforeClose')===false){return false;}
Control.ContextMenu.current=false;this.activated=false;Control.ContextMenu.container.removeClassName(this.options.activatedClassName);Control.ContextMenu.container.select('li').invoke('stopObserving');Control.ContextMenu.container.hide();Control.ContextMenu.container.update('');if(this.notify('afterClose')===false){return false;}
return true;},buildMenu:function(){var list=document.createElement('ul');Control.ContextMenu.container.appendChild(list);this.items.each(function(item){if(!(!item.condition||item.condition&&item.condition()!==false)){return;}
var item_container=$(document.createElement('li'));item_container.update($value(item.label));list.appendChild(item_container);item_container[$value(item.enabled)?'removeClassName':'addClassName']('disabled');item_container.observe('mousedown',function(event,item){if(!$value(item.enabled)){return event.stop();}
this.activated=$value(item.label);}.bindAsEventListener(this,item));item_container.observe('click',this.selectMenuItem.bindAsEventListener(this,item,item_container));item_container.observe('contextmenu',this.selectMenuItem.bindAsEventListener(this,item,item_container));}.bind(this));},addItem:function(params){if(!('enabled'in params)){params.enabled=true;}
this.items.push(params);return this;},destroy:function(){this.container.stopObserving(Prototype.Browser.Opera||this.options.leftClick?'click':'contextmenu');this.items=[];},selectMenuItem:function(event,item,item_container){if(!$value(item.enabled)){return event.stop();}
if(!this.activated||this.activated==$value(item.label)){if(this.options.animation){Control.ContextMenu.container.addClassName(this.options.activatedClassName);$A($R(0,this.options.animationCycles*2)).each(function(i){window.setTimeout(function(){item_container.toggleClassName(this.options.selectedClassName);}.bind(this),i*parseInt(this.options.animationLength/(this.options.animationCycles*2),10));}.bind(this));window.setTimeout(function(){if(this.close()&&this.options.delayCallback){item.callback();}}.bind(this),this.options.animationLength);if(!this.options.delayCallback){item.callback();}}else if(this.close()){item.callback();}}
event.stop();return false;}});Object.extend(Control.ContextMenu,{loaded:false,capture_all:false,menus:[],current:false,enabled:false,offset:4,load:function(capture_all){if(Control.ContextMenu.loaded){return;}
Control.ContextMenu.loaded=true;if(typeof(capture_all)=='undefined'){capture_all=false;}
Control.ContextMenu.capture_all=capture_all;Control.ContextMenu.container=$(document.createElement('div'));Control.ContextMenu.container.id='control_contextmenu';Control.ContextMenu.container.style.position='absolute';Control.ContextMenu.container.style.zIndex=99999;Control.ContextMenu.container.hide();document.body.appendChild(Control.ContextMenu.container);Control.ContextMenu.enable();},enable:function(){Control.ContextMenu.enabled=true;Event.observe(document.body,'click',Control.ContextMenu.onClick);if(Control.ContextMenu.capture_all){Event.observe(document.body,'contextmenu',Control.ContextMenu.onContextMenu);}},disable:function(){Event.stopObserving(document.body,'click',Control.ContextMenu.onClick);if(Control.ContextMenu.capture_all){Event.stopObserving(document.body,'contextmenu',Control.ContextMenu.onContextMenu);}},onContextMenu:function(event){event.stop();return false;},onClick:function(){if(Control.ContextMenu.current){Control.ContextMenu.current.close();}},positionContainer:function(event){var dimensions=Control.ContextMenu.container.getDimensions();var top=Event.pointerY(event);var left=Event.pointerX(event);var bottom=dimensions.height+top;var right=dimensions.width+left;var viewport_dimensions=document.viewport.getDimensions();var viewport_scroll_offsets=document.viewport.getScrollOffsets();if(bottom>viewport_dimensions.height+viewport_scroll_offsets.top){top-=bottom-((viewport_dimensions.height+viewport_scroll_offsets.top)-Control.ContextMenu.offset);}
if(right>viewport_dimensions.width+viewport_scroll_offsets.left){left-=right-((viewport_dimensions.width+viewport_scroll_offsets.left)-Control.ContextMenu.offset);}
Control.ContextMenu.container.setStyle({top:top+'px',left:left+'px'});}});Object.Event.extend(Control.ContextMenu);if(typeof(Prototype)=="undefined")
throw"Cookie requires Prototype to be loaded."
if(typeof(Object.Event)=="undefined")
throw"Cookie requires Object.Event to be loaded.";var Cookie={build:function(){return $A(arguments).compact().join("; ");},secondsFromNow:function(seconds){var d=new Date();d.setTime(d.getTime()+(seconds*1000));return d.toGMTString();},set:function(name,value,seconds){Cookie.notify('set',name,value);var expiry=seconds?'expires='+Cookie.secondsFromNow(seconds):null;document.cookie=Cookie.build(name+"="+value,expiry,"path=/");},get:function(name){Cookie.notify('get',name);var valueMatch=new RegExp(name+"=([^;]+)").exec(document.cookie);return valueMatch?valueMatch[1]:null;},unset:function(name){Cookie.notify('unset',name);Cookie.set(name,'',-1);}};Object.Event.extend(Cookie);if(typeof(Prototype)=="undefined")
throw"Event.Behavior requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Event.Behavior requires Object.Event to be loaded.";Event.Behavior={addVerbs:function(verbs){for(name in verbs){v=new Event.Behavior.Verb(verbs[name]);Event.Behavior.Verbs[name]=v;Event.Behavior[name.underscore()]=Event.Behavior[name]=v.getCallbackForStack.bind(v);}},addEvents:function(events){$H(events).each(function(event_type){Event.Behavior.Adjective.prototype[event_type.key.underscore()]=Event.Behavior.Adjective.prototype[event_type.key]=function(){this.nextConditionType='and';this.events.push(event_type.value);this.attachObserver(false);return this;};});},invokeElementMethod:function(element,action,args){if(typeof(element)=='function'){return $A(element()).each(function(e){if(typeof(args[0])=='function'){return $A(args[0]).each(function(a){return $(e)[action].apply($(e),(a?[a]:[]));});}else
return $(e)[action].apply($(e),args||[]);});}else
return $(element)[action].apply($(element),args||[]);}};Event.Behavior.Verbs=$H({});Event.Behavior.Verb=Class.create();Object.extend(Event.Behavior.Verb.prototype,{originalAction:false,execute:false,executeOpposite:false,target:false,initialize:function(action){this.originalAction=action;this.execute=function(action,target,argument){return(argument)?action(target,argument):action(target);}.bind(this,action);},setOpposite:function(opposite_verb){opposite_action=opposite_verb.originalAction;this.executeOpposite=function(opposite_action,target,argument){return(argument)?opposite_action(target,argument):opposite_action(target);}.bind(this,opposite_action);},getCallbackForStack:function(argument){return new Event.Behavior.Noun(this,argument);}});Event.Behavior.addVerbs({call:function(callback){callback();},show:function(element){return Event.Behavior.invokeElementMethod(element,'show');},hide:function(element){return Event.Behavior.invokeElementMethod(element,'hide');},remove:function(element){return Event.Behavior.invokeElementMethod(element,'remove');},setStyle:function(element,styles){return Event.Behavior.invokeElementMethod(element,'setStyle',[(typeof(styles)=='function'?styles():styles)]);},addClassName:function(element,class_name){return Event.Behavior.invokeElementMethod(element,'addClassName',[(typeof(class_name)=='function'?class_name():class_name)]);},removeClassName:function(element,class_name){return Event.Behavior.invokeElementMethod(element,'removeClassName',[(typeof(class_name)=='function'?class_name():class_name)]);},setClassName:function(element,class_name){c=(typeof(class_name)=='function')?class_name():class_name;if(typeof(element)=='function'){return $A(element()).each(function(e){$(e).className=c;});}else
return $(element).className=c;},update:function(content,element){return Event.Behavior.invokeElementMethod(element,'update',[(typeof(content)=='function'?content():content)]);},replace:function(content,element){return Event.Behavior.invokeElementMethod(element,'replace',[(typeof(content)=='function'?content():content)]);}});Event.Behavior.Verbs.show.setOpposite(Event.Behavior.Verbs.hide);Event.Behavior.Verbs.hide.setOpposite(Event.Behavior.Verbs.show);Event.Behavior.Verbs.addClassName.setOpposite(Event.Behavior.Verbs.removeClassName);Event.Behavior.Verbs.removeClassName.setOpposite(Event.Behavior.Verbs.addClassName);Event.Behavior.Noun=Class.create();Object.extend(Event.Behavior.Noun.prototype,{verbs:false,verb:false,argument:false,subject:false,target:false,initialize:function(verb,argument){this.verb=verb;this.argument=argument;},execute:function(){return(this.target)?this.verb.execute(this.target,this.argument):this.verb.execute(this.argument);},executeOpposite:function(){return(this.target)?this.verb.executeOpposite(this.target,this.argument):this.verb.executeOpposite(this.argument);},when:function(subject){this.subject=subject;return new Event.Behavior.Adjective(this);},getValue:function(){return Try.these(function(){return $(this.subject).getValue();}.bind(this),function(){return $(this.subject).options[$(this.subject).options.selectedIndex].value;}.bind(this),function(){return $(this.subject).value;}.bind(this),function(){return $(this.subject).innerHTML;}.bind(this));},containsValue:function(match){value=this.getValue();if(typeof(match)=='function'){return $A(match()).include(value);}else
return value.match(match);},setTarget:function(target){this.target=target;return this;},and:function(){}});Event.Behavior.Noun.prototype._with=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Noun.prototype.on=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Noun.prototype.of=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Noun.prototype.to=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Noun.prototype.from=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Adjective=Class.create();Object.extend(Event.Behavior.Adjective.prototype,{noun:false,lastConditionName:'',nextConditionType:'and',conditions:$A([]),events:$A([]),attached:false,initialize:function(noun){this.conditions=$A([]);this.events=$A([]);this.noun=noun;},attachObserver:function(execute_on_load){if(this.attached){if(execute_on_load)
this.execute();return;}
this.attached=true;if(typeof(this.noun.subject)=='function'){$A(this.noun.subject()).each(function(subject){(this.events.length>0?this.events:$A(['change'])).each(function(event_name){(subject.observe?subject:$(subject)).observe(event_name,function(){this.execute();}.bind(this));}.bind(this));}.bind(this));}else{(this.events.length>0?this.events:$A(['change'])).each(function(event_name){$(this.noun.subject).observe(event_name,function(){this.execute();}.bind(this));}.bind(this));}
if(execute_on_load)
this.execute();},execute:function(){if(this.match())
return this.noun.execute();else if(this.noun.verb.executeOpposite)
this.noun.executeOpposite();},attachCondition:function(callback){this.conditions.push([this.nextConditionType,callback.bind(this)]);},match:function(){if(this.conditions.length==0)
return true;else{return this.conditions.inject(new Boolean(),function(bool,condition){return(condition[0]=='and')?(bool&&condition[1]()):(bool||condition[1]());});}},is:function(item){this.lastConditionName='is';this.attachCondition(function(item){return(typeof(item)=='function'?item():item)==this.noun.getValue();}.bind(this,item));this.attachObserver(true);return this;},isNot:function(item){this.lastConditionName='isNot';this.attachCondition(function(item){return(typeof(item)=='function'?item():item)!=this.noun.getValue();}.bind(this,item));this.attachObserver(true);return this;},contains:function(item){this.lastConditionName='contains';this.attachCondition(function(item){return this.noun.containsValue(item);}.bind(this,item));this.attachObserver(true);return this;},within:function(item){this.lastConditionName='within';this.attachCondition(function(item){}.bind(this,item));this.attachObserver(true);return this;},change:function(){this.nextConditionType='and';this.attachObserver(true);return this;},and:function(condition){this.attached=false;this.nextConditionType='and';if(condition)
this[this.lastConditionName](condition);return this;},or:function(condition){this.attached=false;this.nextConditionType='or';if(condition)
this[this.lastConditionName](condition);return this;}});Event.Behavior.addEvents({losesFocus:'blur',gainsFocus:'focus',isClicked:'click',isDoubleClicked:'dblclick',keyPressed:'keypress'});Event.Behavior.Adjective.prototype.is_not=Event.Behavior.Adjective.prototype.isNot;Event.Behavior.Adjective.prototype.include=Event.Behavior.Adjective.prototype.contains;Event.Behavior.Adjective.prototype.includes=Event.Behavior.Adjective.prototype.contains;Event.Behavior.Adjective.prototype.are=Event.Behavior.Adjective.prototype.is;Event.Behavior.Adjective.prototype.areNot=Event.Behavior.Adjective.prototype.isNot;Event.Behavior.Adjective.prototype.are_not=Event.Behavior.Adjective.prototype.isNot;Event.Behavior.Adjective.prototype.changes=Event.Behavior.Adjective.prototype.change;if(typeof(Prototype)=="undefined"){throw"HotKey requires Prototype to be loaded.";}
if(typeof(Object.Event)=="undefined"){throw"HotKey requires Object.Event to be loaded.";}
var HotKey=Class.create({initialize:function(letter,callback,options){letter=letter.toUpperCase();HotKey.hotkeys.push(this);this.options=Object.extend({element:false,shiftKey:false,altKey:false,ctrlKey:true},options||{});this.letter=letter;this.callback=callback;this.element=$(this.options.element||document);this.handler=function(event){if(!event||((Event['KEY_'+this.letter]||this.letter.charCodeAt(0))==event.keyCode&&((!this.options.shiftKey||(this.options.shiftKey&&event.shiftKey))&&(!this.options.altKey||(this.options.altKey&&event.altKey))&&(!this.options.ctrlKey||(this.options.ctrlKey&&event.ctrlKey))))){if(this.notify('beforeCallback',event)===false){return;}
this.callback(event);this.notify('afterCallback',event);}}.bind(this);this.enable();},trigger:function(){this.handler();},enable:function(){this.element.observe('keydown',this.handler);},disable:function(){this.element.stopObserving('keydown',this.handler);},destroy:function(){this.disable();HotKey.hotkeys=HotKey.hotkeys.without(this);}});Object.extend(HotKey,{hotkeys:[]});Object.Event.extend(HotKey);if(typeof(Control)=="undefined")
Control={};if(typeof(Object.Event)=="undefined")
throw"Control.Pagination requires Object.Event to be loaded.";Control.Paginator=Class.create({initialize:function(items,options){this.items=items;this.options=Object.extend({size:10,onPageChange:Prototype.emptyFunction,onItemChange:Prototype.emptyFunction},options||{});this.setSize(this.options.size);this.page_index=1;this.item_index=0;},setSize:function(size){this.options.size=size;this.number_of_pages=Math.ceil(this.items.length/this.options.size);},pageIndexFromItemIndex:function(item_index){return Math.floor(((item_index||this.item_index)/this.options.size)+1);},goToPage:function(page_index){this.page_index=page_index;this.triggerOnPageChange();},triggerOnPageChange:function(){this.notify('onPageChange',this.items.slice((this.page_index-1)*this.options.size,((this.page_index-1)*this.options.size)+this.options.size),this.page_index);},goToItem:function(item_index){this.item_index=item_index;this.notify('onItemChange',this.items[this.item_index],this.item_index);var new_page_index=this.pageIndexFromItemIndex(this.item_index);if(new_page_index!=this.page_index)
this.goToPage(new_page_index);},hasNextItem:function(){return this.item_index<this.items.length-1;},hasPreviousItem:function(){return this.item_index>=1;},nextItem:function(){if(!this.hasNextItem())
return false;this.goToItem(this.item_index+1);return true;},previousItem:function(){if(!this.hasPreviousItem())
return false;this.goToItem(this.item_index-1);return true;},hasNextPage:function(){return this.page_index<this.number_of_pages;},hasPreviousPage:function(){return this.page_index>=2;},nextPage:function(){if(!this.hasNextPage())
return false;this.goToPage(this.page_index+1);return true;},previousPage:function(){if(!this.hasPreviousPage())
return false;this.goToPage(this.page_index-1);return true;}});Object.Event.extend(Control.Paginator);if(typeof(Prototype)=="undefined")
throw"Control.ProgressBar requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.ProgressBar requires Object.Event to be loaded.";Control.ProgressBar=Class.create({initialize:function(container,options){this.progress=0;this.executer=false;this.active=false;this.poller=false;this.container=$(container);this.containerWidth=this.container.getDimensions().width-(parseInt(this.container.getStyle('border-right-width').replace(/px/,''))+parseInt(this.container.getStyle('border-left-width').replace(/px/,'')));this.progressContainer=$(document.createElement('div'));this.progressContainer.setStyle({width:this.containerWidth+'px',height:'100%',position:'absolute',top:'0px',right:'0px'});this.container.appendChild(this.progressContainer);this.options={afterChange:Prototype.emptyFunction,interval:0.25,step:1,classNames:{active:'progress_bar_active',inactive:'progress_bar_inactive'}};Object.extend(this.options,options||{});this.container.addClassName(this.options.classNames.inactive);this.active=false;},setProgress:function(value){this.progress=value;this.draw();if(this.progress>=100)
this.stop(false);this.notify('afterChange',this.progress,this.active);},poll:function(url,interval){this.active=true;this.poller=new PeriodicalExecuter(function(){new Ajax.Request(url,{onSuccess:function(request){this.setProgress(parseInt(request.responseText));if(!this.active)
this.poller.stop();}.bind(this)});}.bind(this),interval||3);},start:function(){this.active=true;this.container.removeClassName(this.options.classNames.inactive);this.container.addClassName(this.options.classNames.active);this.executer=new PeriodicalExecuter(this.step.bind(this,this.options.step),this.options.interval);},stop:function(reset){this.active=false;if(this.executer)
this.executer.stop();this.container.removeClassName(this.options.classNames.active);this.container.addClassName(this.options.classNames.inactive);if(typeof(reset)=='undefined'||reset==true)
this.reset();},step:function(amount){this.active=true;this.setProgress(Math.min(100,this.progress+amount));},reset:function(){this.active=false;this.setProgress(0);},draw:function(){this.progressContainer.setStyle({width:(this.containerWidth-Math.floor((parseInt(this.progress)/100)*this.containerWidth))+'px'});},notify:function(event_name){if(this.options[event_name])
return[this.options[event_name].apply(this.options[event_name],$A(arguments).slice(1))];}});Object.Event.extend(Control.ProgressBar);if(typeof(Prototype)=="undefined"){throw"Control.Rating requires Prototype to be loaded.";}
if(typeof(Object.Event)=="undefined"){throw"Control.Rating requires Object.Event to be loaded.";}
Control.Rating=Class.create({initialize:function(container,options){Control.Rating.instances.push(this);this.value=false;this.links=[];this.container=$(container);this.container.update('');this.options={min:1,max:5,rated:false,input:false,reverse:false,capture:true,multiple:false,classNames:{off:'rating_off',half:'rating_half',on:'rating_on',selected:'rating_selected'},updateUrl:false,updateParameterName:'value',afterChange:Prototype.emptyFunction};Object.extend(this.options,options||{});if(this.options.value){this.value=this.options.value;delete this.options.value;}
if(this.options.input){this.options.input=$(this.options.input);this.options.input.observe('change',function(input){this.setValueFromInput(input);}.bind(this,this.options.input));this.setValueFromInput(this.options.input,true);}
var range=$R(this.options.min,this.options.max);(this.options.reverse?$A(range).reverse():range).each(function(i){var link=this.buildLink(i);this.container.appendChild(link);this.links.push(link);}.bind(this));this.setValue(this.value||this.options.min-1,false,true);},buildLink:function(rating){var link=$(document.createElement('a'));link.value=rating;if(this.options.multiple||(!this.options.rated&&!this.options.multiple)){link.href='';link.onmouseover=this.mouseOver.bind(this,link);link.onmouseout=this.mouseOut.bind(this,link);link.onclick=this.click.bindAsEventListener(this,link);}else{link.style.cursor='default';link.observe('click',function(event){Event.stop(event);return false;}.bindAsEventListener(this));}
link.addClassName(this.options.classNames.off);return link;},disable:function(){this.links.each(function(link){link.onmouseover=Prototype.emptyFunction;link.onmouseout=Prototype.emptyFunction;link.onclick=Prototype.emptyFunction;link.observe('click',function(event){Event.stop(event);return false;}.bindAsEventListener(this));link.style.cursor='default';}.bind(this));},setValueFromInput:function(input,prevent_callbacks){this.setValue($F(input),true,prevent_callbacks);},setValue:function(value,force_selected,prevent_callbacks){this.value=value;if(this.options.input){if(this.options.input.options){$A(this.options.input.options).each(function(option,i){if(option.value==this.value){this.options.input.options.selectedIndex=i;throw $break;}}.bind(this));}else{this.options.input.value=this.value;}}
this.render(this.value,force_selected);if(!prevent_callbacks){if(this.options.updateUrl){var params={},a;params[this.options.updateParameterName]=this.value;a=new Ajax.Request(this.options.updateUrl,{parameters:params});}
this.notify('afterChange',this.value);}},render:function(rating,force_selected){(this.options.reverse?this.links.reverse():this.links).each(function(link,i){if(link.value<=Math.ceil(rating)){link.className=this.options.classNames[link.value<=rating?'on':'half'];if(this.options.rated||force_selected){link.addClassName(this.options.classNames.selected);}}else{link.className=this.options.classNames.off;}}.bind(this));},mouseOver:function(link){this.render(link.value,true);},mouseOut:function(link){this.render(this.value);},click:function(event,link){this.options.rated=true;this.setValue((link.value?link.value:link),true);if(!this.options.multiple){this.disable();}
if(this.options.capture){Event.stop(event);return false;}}});Object.extend(Control.Rating,{instances:[],findByElementId:function(id){return Control.Rating.instances.find(function(instance){return(instance.container.id&&instance.container.id==id);});}});Object.Event.extend(Control.Rating);if(typeof(Prototype)=="undefined")
throw"Control.ScrollBar requires Prototype to be loaded.";if(typeof(Control.Slider)=="undefined")
throw"Control.ScrollBar requires Control.Slider to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.ScrollBar requires Object.Event to be loaded.";Control.ScrollBar=Class.create({initialize:function(container,track,options){this.enabled=false;this.notificationTimeout=false;this.container=$(container);this.boundMouseWheelEvent=this.onMouseWheel.bindAsEventListener(this);this.boundResizeObserver=this.onWindowResize.bind(this);this.track=$(track);this.handle=this.track.firstDescendant();this.options=Object.extend({active_class_name:'scrolling',apply_active_class_name_to:this.container,notification_timeout_length:125,handle_minimum_height:25,scroll_to_smoothing:0.01,scroll_to_steps:15,proportional:true,slider_options:{}},options||{});this.slider=new Control.Slider(this.handle,this.track,Object.extend({axis:'vertical',onSlide:this.onChange.bind(this),onChange:this.onChange.bind(this)},this.options.slider_options));this.recalculateLayout();Event.observe(window,'resize',this.boundResizeObserver);this.handle.observe('mousedown',function(){if(this.auto_sliding_executer)
this.auto_sliding_executer.stop();}.bind(this));},destroy:function(){Event.stopObserving(window,'resize',this.boundResizeObserver);},enable:function(){this.enabled=true;this.container.observe('mouse:wheel',this.boundMouseWheelEvent);this.slider.setEnabled();this.track.show();if(this.options.active_class_name)
$(this.options.apply_active_class_name_to).addClassName(this.options.active_class_name);this.notify('enabled');},disable:function(){this.enabled=false;this.container.stopObserving('mouse:wheel',this.boundMouseWheelEvent);this.slider.setDisabled();this.track.hide();if(this.options.active_class_name)
$(this.options.apply_active_class_name_to).removeClassName(this.options.active_class_name);this.notify('disabled');this.reset();},reset:function(){this.slider.setValue(0);},recalculateLayout:function(){if(this.container.scrollHeight<=this.container.offsetHeight)
this.disable();else{this.slider.trackLength=this.slider.maximumOffset()-this.slider.minimumOffset();if(this.options.proportional){this.handle.style.height=Math.max(this.container.offsetHeight*(this.container.offsetHeight/this.container.scrollHeight),this.options.handle_minimum_height)+'px';this.slider.handleLength=this.handle.style.height.replace(/px/,'');}
this.enable();}},onWindowResize:function(){this.recalculateLayout();this.scrollBy(0);},onMouseWheel:function(event){if(this.auto_sliding_executer)
this.auto_sliding_executer.stop();this.slider.setValueBy(-(event.memo.delta/20));event.stop();return false;},onChange:function(value){this.container.scrollTop=Math.round(value/this.slider.maximum*(this.container.scrollHeight-this.container.offsetHeight));if(this.notification_timeout)
window.clearTimeout(this.notificationTimeout);this.notificationTimeout=window.setTimeout(function(){this.notify('change',value);}.bind(this),this.options.notification_timeout_length);},getCurrentMaximumDelta:function(){return this.slider.maximum*(this.container.scrollHeight-this.container.offsetHeight);},getDeltaToElement:function(element){return this.slider.maximum*((element.positionedOffset().top+(element.getHeight()/2))-(this.container.getHeight()/2));},scrollTo:function(y,animate){var current_maximum_delta=this.getCurrentMaximumDelta();if(y=='top')
y=0;else if(y=='bottom')
y=current_maximum_delta;else if(typeof(y)!="number")
y=this.getDeltaToElement($(y));if(this.enabled){y=Math.max(0,Math.min(y,current_maximum_delta));if(this.auto_sliding_executer)
this.auto_sliding_executer.stop();var target_value=y/current_maximum_delta;var original_slider_value=this.slider.value;var delta=(target_value-original_slider_value)*current_maximum_delta;if(animate){this.auto_sliding_executer=new PeriodicalExecuter(function(){if(Math.round(this.slider.value*100)/100<Math.round(target_value*100)/100||Math.round(this.slider.value*100)/100>Math.round(target_value*100)/100){this.scrollBy(delta/this.options.scroll_to_steps);}else{this.auto_sliding_executer.stop();this.auto_sliding_executer=null;if(typeof(animate)=="function")
animate();}}.bind(this),this.options.scroll_to_smoothing);}else
this.scrollBy(delta);}else if(typeof(animate)=="function")
animate();},scrollBy:function(y){if(!this.enabled)
return false;this.slider.setValueBy(y/this.getCurrentMaximumDelta());}});Object.Event.extend(Control.ScrollBar);if(typeof(Prototype)=="undefined")
throw"Control.Selection requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.Selection requires Object.Event to be loaded.";Control.Selection={options:{resize_layout_timeout:125,selected:Prototype.emptyFunction,deselected:Prototype.emptyFunction,change:Prototype.emptyFunction,selection_id:'control_selection',selection_style:{zIndex:999,cursor:'default',border:'1px dotted #000'},filter:function(element){return true;},drag_proxy:false,drag_proxy_threshold:1,drag_proxy_options:{}},selectableElements:[],elements:[],selectableObjects:[],objects:[],active:false,container:false,resizeTimeout:false,load:function(options){Control.Selection.options=Object.extend(Control.Selection.options,options||{});Control.Selection.selection_div=$(document.createElement('div'));Control.Selection.selection_div.id=Control.Selection.options.selection_id;Control.Selection.selection_div.style.display='none';Control.Selection.selection_div.setStyle(Control.Selection.options.selection_style);Control.Selection.border_width=parseInt(Control.Selection.selection_div.getStyle('border-top-width'))*2;Control.Selection.container=Prototype.Browser.IE?window.container:window;$(document.body).insert(Control.Selection.selection_div);Control.Selection.enable();if(Control.Selection.options.drag_proxy&&typeof(Draggable)!='undefined')
Control.Selection.DragProxy.load();Event.observe(window,'resize',function(){if(Control.Selection.resizeTimeout)
window.clearTimeout(Control.Selection.resizeTimeout);Control.Selection.resizeTimeout=window.setTimeout(Control.Selection.recalculateLayout,Control.Selection.options.resize_layout_timeout);});if(Prototype.Browser.IE){var body=$$('body').first();body.observe('mouseleave',Control.Selection.stop);body.observe('mouseup',Control.Selection.stop);}},enable:function(){if(Prototype.Browser.IE){document.onselectstart=function(){return false;}}
Event.observe(Control.Selection.container,'mousedown',Control.Selection.start);Event.observe(Control.Selection.container,'mouseup',Control.Selection.stop);},disable:function(){if(Prototype.Browser.IE){document.onselectstart=function(){return true;}}
Event.stopObserving(Control.Selection.container,'mousedown',Control.Selection.start);Event.stopObserving(Control.Selection.container,'mouseup',Control.Selection.stop);},recalculateLayout:function(){Control.Selection.selectableElements.each(function(element){var dimensions=element.getDimensions();var offset=element.cumulativeOffset();var scroll_offset=element.cumulativeScrollOffset();if(!element._control_selection)
element._control_selection={};element._control_selection.top=offset[1]-scroll_offset[1];element._control_selection.left=offset[0]-scroll_offset[0];element._control_selection.width=dimensions.width;element._control_selection.height=dimensions.height;});},addSelectable:function(element,object,activation_targets,activation_target_callback){element=$(element);if(activation_targets)
activation_targets=activation_targets.each?activation_targets:[activation_targets];var dimensions=element.getDimensions();var offset=Position.cumulativeOffset(element);element._control_selection={activation_targets:activation_targets,is_selected:false,top:offset[1],left:offset[0],width:dimensions.width,height:dimensions.height,activationTargetMouseMove:function(){Control.Selection.notify('activationTargetMouseMove',element);if(activation_targets){activation_targets.each(function(activation_target){activation_target.stopObserving('mousemove',element._control_selection.activationTargetMouseMove);});}
Control.Selection.DragProxy.container.stopObserving('mousemove',element._control_selection.activationTargetMouseMove);},activationTargetMouseDown:function(event){if(!Control.Selection.elements.include(element))
Control.Selection.select(element);Control.Selection.DragProxy.start(event);Control.Selection.DragProxy.container.hide();if(activation_targets){activation_targets.each(function(activation_target){activation_target.observe('mousemove',element._control_selection.activationTargetMouseMove);});}
Control.Selection.DragProxy.container.observe('mousemove',element._control_selection.activationTargetMouseMove);},activationTargetClick:function(){Control.Selection.select(element);if(typeof(activation_target_callback)=="function")
activation_target_callback();if(activation_targets){activation_targets.each(function(activation_target){activation_target.stopObserving('mousemove',element._control_selection.activationTargetMouseMove);});}
Control.Selection.DragProxy.container.stopObserving('mousemove',element._control_selection.activationTargetMouseMove);}};element.onselectstart=function(){return false;};element.unselectable='on';element.style.MozUserSelect='none';if(activation_targets){activation_targets.each(function(activation_target){activation_target.observe('mousedown',element._control_selection.activationTargetMouseDown);activation_target.observe('click',element._control_selection.activationTargetClick);});}
Control.Selection.selectableElements.push(element);Control.Selection.selectableObjects.push(object);},removeSelectable:function(element){element=$(element);if(element._control_selection.activation_targets){element._control_selection.activation_targets.each(function(activation_target){activation_target.stopObserving('mousedown',element._control_selection.activationTargetMouseDown);});element._control_selection.activation_targets.each(function(activation_target){activation_target.stopObserving('click',element._control_selection.activationTargetClick);});}
element._control_selection=null;element.onselectstart=function(){return true;};element.unselectable='off';element.style.MozUserSelect='';var position=0;Control.Selection.selectableElements.each(function(selectable_element,i){if(selectable_element==element){position=i;throw $break;}});Control.Selection.selectableElements=Control.Selection.selectableElements.without(element);Control.Selection.selectableObjects=Control.Selection.selectableObjects.slice(0,position).concat(Control.Selection.selectableObjects.slice(position+1))},select:function(selected_elements){if(typeof(selected_elements)=="undefined"||!selected_elements)
selected_elements=[];if(!selected_elements.each&&!selected_elements._each)
selected_elements=[selected_elements];var selected_items_have_changed=!(Control.Selection.elements.length==selected_elements.length&&Control.Selection.elements.all(function(item,i){return selected_elements[i]==item;}));if(!selected_items_have_changed)
return;var selected_objects_indexed_by_element={};var selected_objects=selected_elements.collect(function(selected_element){var selected_object=Control.Selection.selectableObjects[Control.Selection.selectableElements.indexOf(selected_element)];selected_objects_indexed_by_element[selected_element]=selected_object;return selected_object;});if(Control.Selection.elements.length==0&&selected_elements.length!=0){selected_elements.each(function(element){Control.Selection.notify('selected',element,selected_objects_indexed_by_element[element]);});}else{Control.Selection.elements.each(function(element){if(!selected_elements.include(element)){Control.Selection.notify('deselected',element,selected_objects_indexed_by_element[element]);}});selected_elements.each(function(element){if(!Control.Selection.elements.include(element)){Control.Selection.notify('selected',element,selected_objects_indexed_by_element[element]);}});}
Control.Selection.elements=selected_elements;Control.Selection.objects=selected_objects;Control.Selection.notify('change',Control.Selection.elements,Control.Selection.objects);},deselect:function(){if(Control.Selection.notify('deselect')===false)
return false;Control.Selection.elements.each(function(element){Control.Selection.notify('deselected',element,Control.Selection.selectableObjects[Control.Selection.selectableElements.indexOf(element)]);});Control.Selection.objects=[];Control.Selection.elements=[];Control.Selection.notify('change',Control.Selection.objects,Control.Selection.elements);return true;},start:function(event){if(!event.isLeftClick()||Control.Selection.notify('start',event)===false)
return false;if(!event.shiftKey&&!event.altKey)
Control.Selection.deselect();Event.observe(Control.Selection.container,'mousemove',Control.Selection.onMouseMove);Event.stop(event);return false;},stop:function(){Event.stopObserving(Control.Selection.container,'mousemove',Control.Selection.onMouseMove);Control.Selection.active=false;Control.Selection.selection_div.setStyle({display:'none',top:null,left:null,width:null,height:null});Control.Selection.start_mouse_coordinates={};Control.Selection.current_mouse_coordinates={};},mouseCoordinatesFromEvent:function(event){return{x:Event.pointerX(event),y:Event.pointerY(event)};},onClick:function(event,element,source){var selection=[];if(event.shiftKey){selection=Control.Selection.elements.clone();if(!selection.include(element))
selection.push(element);}else if(event.altKey){selection=Control.Selection.elements.clone();if(selection.include(element))
selection=selection.without(element);}else{selection=[element];}
Control.Selection.select(selection);if(source=='click')
Event.stop(event);},onMouseMove:function(event){if(!Control.Selection.active){Control.Selection.active=true;Control.Selection.start_mouse_coordinates=Control.Selection.mouseCoordinatesFromEvent(event);}else{Control.Selection.current_mouse_coordinates=Control.Selection.mouseCoordinatesFromEvent(event);Control.Selection.drawSelectionDiv();var current_selection=Control.Selection.selectableElements.findAll(function(element){return Control.Selection.options.filter(element)&&Control.Selection.elementWithinSelection(element);});if(event.shiftKey&&!event.altKey){Control.Selection.elements.each(function(element){if(!current_selection.include(element))
current_selection.push(element);});}else if(event.altKey&&!event.shiftKey){current_selection=Control.Selection.elements.findAll(function(element){return!current_selection.include(element);});}
Control.Selection.select(current_selection);}},drawSelectionDiv:function(){if(Control.Selection.start_mouse_coordinates==Control.Selection.current_mouse_coordinates){Control.Selection.selection_div.style.display='none';}else{Control.Selection.viewport=document.viewport.getDimensions();Control.Selection.selection_div.style.position='absolute';Control.Selection.current_direction=(Control.Selection.start_mouse_coordinates.y>Control.Selection.current_mouse_coordinates.y?'N':'S')+(Control.Selection.start_mouse_coordinates.x<Control.Selection.current_mouse_coordinates.x?'E':'W');Control.Selection.selection_div.setStyle(Control.Selection['dimensionsFor'+Control.Selection.current_direction]());Control.Selection.selection_div.style.display='block';}},dimensionsForNW:function(){return{top:(Control.Selection.start_mouse_coordinates.y-(Control.Selection.start_mouse_coordinates.y-Control.Selection.current_mouse_coordinates.y))+'px',left:(Control.Selection.start_mouse_coordinates.x-(Control.Selection.start_mouse_coordinates.x-Control.Selection.current_mouse_coordinates.x))+'px',width:(Control.Selection.start_mouse_coordinates.x-Control.Selection.current_mouse_coordinates.x)+'px',height:(Control.Selection.start_mouse_coordinates.y-Control.Selection.current_mouse_coordinates.y)+'px'};},dimensionsForNE:function(){return{top:(Control.Selection.start_mouse_coordinates.y-(Control.Selection.start_mouse_coordinates.y-Control.Selection.current_mouse_coordinates.y))+'px',left:Control.Selection.start_mouse_coordinates.x+'px',width:Math.min((Control.Selection.viewport.width-Control.Selection.start_mouse_coordinates.x)-Control.Selection.border_width,Control.Selection.current_mouse_coordinates.x-Control.Selection.start_mouse_coordinates.x)+'px',height:(Control.Selection.start_mouse_coordinates.y-Control.Selection.current_mouse_coordinates.y)+'px'};},dimensionsForSE:function(){return{top:Control.Selection.start_mouse_coordinates.y+'px',left:Control.Selection.start_mouse_coordinates.x+'px',width:Math.min((Control.Selection.viewport.width-Control.Selection.start_mouse_coordinates.x)-Control.Selection.border_width,Control.Selection.current_mouse_coordinates.x-Control.Selection.start_mouse_coordinates.x)+'px',height:Math.min((Control.Selection.viewport.height-Control.Selection.start_mouse_coordinates.y)-Control.Selection.border_width,Control.Selection.current_mouse_coordinates.y-Control.Selection.start_mouse_coordinates.y)+'px'};},dimensionsForSW:function(){return{top:Control.Selection.start_mouse_coordinates.y+'px',left:(Control.Selection.start_mouse_coordinates.x-(Control.Selection.start_mouse_coordinates.x-Control.Selection.current_mouse_coordinates.x))+'px',width:(Control.Selection.start_mouse_coordinates.x-Control.Selection.current_mouse_coordinates.x)+'px',height:Math.min((Control.Selection.viewport.height-Control.Selection.start_mouse_coordinates.y)-Control.Selection.border_width,Control.Selection.current_mouse_coordinates.y-Control.Selection.start_mouse_coordinates.y)+'px'};},inBoundsForNW:function(element,selection){return(((element.left>selection.left||element.right>selection.left)&&selection.right>element.left)&&((element.top>selection.top||element.bottom>selection.top)&&selection.bottom>element.top));},inBoundsForNE:function(element,selection){return(((element.left<selection.right||element.left<selection.right)&&selection.left<element.right)&&((element.top>selection.top||element.bottom>selection.top)&&selection.bottom>element.top));},inBoundsForSE:function(element,selection){return(((element.left<selection.right||element.left<selection.right)&&selection.left<element.right)&&((element.bottom<selection.bottom||element.top<selection.bottom)&&selection.top<element.bottom));},inBoundsForSW:function(element,selection){return(((element.left>selection.left||element.right>selection.left)&&selection.right>element.left)&&((element.bottom<selection.bottom||element.top<selection.bottom)&&selection.top<element.bottom));},elementWithinSelection:function(element){if(Control.Selection['inBoundsFor'+Control.Selection.current_direction]({top:element._control_selection.top,left:element._control_selection.left,bottom:element._control_selection.top+element._control_selection.height,right:element._control_selection.left+element._control_selection.width},{top:parseInt(Control.Selection.selection_div.style.top),left:parseInt(Control.Selection.selection_div.style.left),bottom:parseInt(Control.Selection.selection_div.style.top)+parseInt(Control.Selection.selection_div.style.height),right:parseInt(Control.Selection.selection_div.style.left)+parseInt(Control.Selection.selection_div.style.width)})){element._control_selection.is_selected=true;return true;}else{element._control_selection.is_selected=false;return false;}},DragProxy:{active:false,xorigin:0,yorigin:0,load:function(){Control.Selection.DragProxy.container=$(document.createElement('div'));Control.Selection.DragProxy.container.id='control_selection_drag_proxy';Control.Selection.DragProxy.container.setStyle({position:'absolute',top:'1px',left:'1px',zIndex:99999});Control.Selection.DragProxy.container.hide();document.body.appendChild(Control.Selection.DragProxy.container);Control.Selection.observe('selected',Control.Selection.DragProxy.selected);Control.Selection.observe('deselected',Control.Selection.DragProxy.deselected);},start:function(event){if(event.isRightClick()){Control.Selection.DragProxy.container.hide();return;}
if(Control.Selection.DragProxy.xorigin==Event.pointerX(event)&&Control.Selection.DragProxy.yorigin==Event.pointerY(event))
return;Control.Selection.DragProxy.active=true;Control.Selection.DragProxy.container.setStyle({position:'absolute',top:Event.pointerY(event)+'px',left:Event.pointerX(event)+'px'});Control.Selection.DragProxy.container.observe('mouseup',Control.Selection.DragProxy.onMouseUp);Control.Selection.DragProxy.container.show();Control.Selection.DragProxy.container._draggable=new Draggable(Control.Selection.DragProxy.container,Object.extend({onEnd:Control.Selection.DragProxy.stop},Control.Selection.options.drag_proxy_options));Control.Selection.DragProxy.container._draggable.eventMouseDown(event);Control.Selection.DragProxy.notify('start',Control.Selection.DragProxy.container,Control.Selection.elements);},stop:function(){window.setTimeout(function(){Control.Selection.DragProxy.active=false;Control.Selection.DragProxy.container.hide();if(Control.Selection.DragProxy.container._draggable){Control.Selection.DragProxy.container._draggable.destroy();Control.Selection.DragProxy.container._draggable=null;}
Control.Selection.DragProxy.notify('stop');},1);},onClick:function(event){Control.Selection.DragProxy.xorigin=Event.pointerX(event);Control.Selection.DragProxy.yorigin=Event.pointerY(event);if(event.isRightClick())
Control.Selection.DragProxy.container.hide();if(Control.Selection.elements.length>=Control.Selection.options.drag_proxy_threshold&&!(event.shiftKey||event.altKey)&&(Control.Selection.DragProxy.xorigin!=Event.pointerX(event)||Control.Selection.DragProxy.yorigin!=Event.pointerY(event))){Control.Selection.DragProxy.start(event);Event.stop(event);}},onMouseUp:function(event){Control.Selection.DragProxy.stop();Control.Selection.DragProxy.container.stopObserving('mouseup',Control.Selection.DragProxy.onMouseUp);},selected:function(element){element.observe('mousedown',Control.Selection.DragProxy.onClick);},deselected:function(element){element.stopObserving('mousedown',Control.Selection.DragProxy.onClick);}}};Object.Event.extend(Control.Selection);Object.Event.extend(Control.Selection.DragProxy);if(typeof(Prototype)=="undefined"){throw"Control.SelectMultiple requires Prototype to be loaded.";}
if(typeof(Object.Event)=="undefined"){throw"Control.SelectMultiple requires Object.Event to be loaded.";}
Control.SelectMultiple=Class.create({select:false,container:false,numberOfCheckedBoxes:0,checkboxes:[],hasExtraOption:false,initialize:function(select,container,options){this.options={checkboxSelector:'input[type=checkbox]',nameSelector:'span.name',labelSeparator:', ',valueSeparator:',',afterChange:Prototype.emptyFunction,overflowString:function(str){return str.truncate();},overflowLength:30};Object.extend(this.options,options||{});this.select=$(select);this.container=$(container);this.checkboxes=(typeof(this.options.checkboxSelector)=='function')?this.options.checkboxSelector.bind(this)():this.container.getElementsBySelector(this.options.checkboxSelector);var value_was_set=false;if(this.options.value){value_was_set=true;this.setValue(this.options.value);delete this.options.value;}
this.hasExtraOption=false;this.checkboxes.each(function(checkbox){checkbox.observe('click',this.checkboxOnClick.bind(this,checkbox));}.bind(this));this.select.observe('change',this.selectOnChange.bind(this));this.countAndCheckCheckBoxes();if(!value_was_set){this.scanCheckBoxes();}
this.notify('afterChange',this.select.options[this.select.options.selectedIndex].value);},countAndCheckCheckBoxes:function(){this.numberOfCheckedBoxes=this.checkboxes.inject(0,function(number,checkbox){checkbox.checked=(this.select.options[this.select.options.selectedIndex].value==checkbox.value);var value_string=this.select.options[this.select.options.selectedIndex].value;var value_collection=$A(value_string.split?value_string.split(this.options.valueSeparator):value_string);var should_check=value_collection.any(function(value){if(!should_check&&checkbox.value==value){return true;}}.bind(this));checkbox.checked=should_check;if(checkbox.checked){++number;}
return number;}.bind(this));},setValue:function(value_string){this.numberOfCheckedBoxes=0;var value_collection=$A(value_string.split?value_string.split(this.options.valueSeparator):value_string);this.checkboxes.each(function(checkbox){checkbox.checked=false;value_collection.each(function(value){if(checkbox.value==value){++this.numberOfCheckedBoxes;checkbox.checked=true;}}.bind(this));}.bind(this));this.scanCheckBoxes();},selectOnChange:function(){this.removeExtraOption();this.countAndCheckCheckBoxes();this.notify('afterChange',this.select.options[this.select.options.selectedIndex].value);},checkboxOnClick:function(checkbox){this.numberOfCheckedBoxes=this.checkboxes.findAll(function(c){return c.checked;}).length;this.scanCheckBoxes();this.notify('afterChange',this.numberOfCheckedBoxes===0?"":this.select.options[this.select.options.selectedIndex].value);},scanCheckBoxes:function(){switch(this.numberOfCheckedBoxes){case 1:this.checkboxes.each(function(checkbox){if(checkbox.checked){$A(this.select.options).each(function(option,i){if(option.value==checkbox.value){this.select.options.selectedIndex=i;throw $break;}}.bind(this));throw $break;}}.bind(this));break;case 0:this.removeExtraOption();break;default:this.addExtraOption();break;}},getLabelForExtraOption:function(){var label=(typeof(this.options.nameSelector)=='function'?this.options.nameSelector.bind(this)():this.container.getElementsBySelector(this.options.nameSelector).inject([],function(labels,name_element,i){if(this.checkboxes[i].checked){labels.push(name_element.innerHTML);}
return labels;}.bind(this))).join(this.options.labelSeparator);return(label.length>=this.options.overflowLength&&this.options.overflowLength>0)?(typeof(this.options.overflowString)=='function'?this.options.overflowString(label):this.options.overflowString):label;},getValueForExtraOption:function(){return this.checkboxes.inject([],function(values,checkbox){if(checkbox.checked){values.push(checkbox.value);}
return values;}).join(this.options.valueSeparator);},addExtraOption:function(){this.removeExtraOption();this.hasExtraOption=true;this.select.options[this.select.options.length]=new Option(this.getLabelForExtraOption(),this.getValueForExtraOption());this.select.options.selectedIndex=this.select.options.length-1;},removeExtraOption:function(){if(this.hasExtraOption){this.select.remove(this.select.options.length-1);this.hasExtraOption=false;}}});Object.Event.extend(Control.SelectMultiple);if(typeof(Prototype)=="undefined")
throw"Control.Tabs requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.Tabs requires Object.Event to be loaded.";Control.Tabs=Class.create({initialize:function(tab_list_container,options){if(!$(tab_list_container))
throw"Control.Tabs could not find the element: "+tab_list_container;this.activeContainer=false;this.activeLink=false;this.containers=$H({});this.links=[];Control.Tabs.instances.push(this);this.options={beforeChange:Prototype.emptyFunction,afterChange:Prototype.emptyFunction,hover:false,linkSelector:'li a',setClassOnContainer:false,activeClassName:'active',defaultTab:'first',autoLinkExternal:true,targetRegExp:/#(.+)$/,showFunction:Element.show,hideFunction:Element.hide};Object.extend(this.options,options||{});(typeof(this.options.linkSelector=='string')?$(tab_list_container).select(this.options.linkSelector):this.options.linkSelector($(tab_list_container))).findAll(function(link){return(/^#/).exec((Prototype.Browser.WebKit?decodeURIComponent(link.href):link.href).replace(window.location.href.split('#')[0],''));}).each(function(link){this.addTab(link);}.bind(this));this.containers.values().each(Element.hide);if(this.options.defaultTab=='first')
this.setActiveTab(this.links.first());else if(this.options.defaultTab=='last')
this.setActiveTab(this.links.last());else
this.setActiveTab(this.options.defaultTab);var targets=this.options.targetRegExp.exec(window.location);if(targets&&targets[1]){targets[1].split(',').each(function(target){this.setActiveTab(this.links.find(function(link){return link.key==target;}));}.bind(this));}
if(this.options.autoLinkExternal){$A(document.getElementsByTagName('a')).each(function(a){if(!this.links.include(a)){var clean_href=a.href.replace(window.location.href.split('#')[0],'');if(clean_href.substring(0,1)=='#'){if(this.containers.keys().include(clean_href.substring(1))){$(a).observe('click',function(event,clean_href){this.setActiveTab(clean_href.substring(1));}.bindAsEventListener(this,clean_href));}}}}.bind(this));}},addTab:function(link){this.links.push(link);link.key=link.getAttribute('href').replace(window.location.href.split('#')[0],'').split('#').last().replace(/#/,'');var container=$(link.key);if(!container)
throw"Control.Tabs: #"+link.key+" was not found on the page."
this.containers.set(link.key,container);link[this.options.hover?'onmouseover':'onclick']=function(link){if(window.event)
Event.stop(window.event);this.setActiveTab(link);return false;}.bind(this,link);},setActiveTab:function(link){if(!link&&typeof(link)=='undefined')
return;if(typeof(link)=='string'){this.setActiveTab(this.links.find(function(_link){return _link.key==link;}));}else if(typeof(link)=='number'){this.setActiveTab(this.links[link]);}else{if(this.notify('beforeChange',this.activeContainer,this.containers.get(link.key))===false)
return;if(this.activeContainer)
this.options.hideFunction(this.activeContainer);this.links.each(function(item){(this.options.setClassOnContainer?$(item.parentNode):item).removeClassName(this.options.activeClassName);}.bind(this));(this.options.setClassOnContainer?$(link.parentNode):link).addClassName(this.options.activeClassName);this.activeContainer=this.containers.get(link.key);this.activeLink=link;this.options.showFunction(this.containers.get(link.key));this.notify('afterChange',this.containers.get(link.key));}},next:function(){this.links.each(function(link,i){if(this.activeLink==link&&this.links[i+1]){this.setActiveTab(this.links[i+1]);throw $break;}}.bind(this));},previous:function(){this.links.each(function(link,i){if(this.activeLink==link&&this.links[i-1]){this.setActiveTab(this.links[i-1]);throw $break;}}.bind(this));},first:function(){this.setActiveTab(this.links.first());},last:function(){this.setActiveTab(this.links.last());}});Object.extend(Control.Tabs,{instances:[],findByTabId:function(id){return Control.Tabs.instances.find(function(tab){return tab.links.find(function(link){return link.key==id;});});}});Object.Event.extend(Control.Tabs);if(typeof(Prototype)=="undefined"){throw"Control.TextArea requires Prototype to be loaded.";}
if(typeof(Object.Event)=="undefined"){throw"Control.TextArea requires Object.Event to be loaded.";}
Control.TextArea=Class.create({initialize:function(textarea){this.onChangeTimeout=false;this.element=$(textarea);$(this.element).observe('keyup',this.doOnChange.bindAsEventListener(this));$(this.element).observe('paste',this.doOnChange.bindAsEventListener(this));$(this.element).observe('input',this.doOnChange.bindAsEventListener(this));if(!!document.selection){$(this.element).observe('mouseup',this.saveRange.bindAsEventListener(this));$(this.element).observe('keyup',this.saveRange.bindAsEventListener(this));}},doOnChange:function(event){if(this.onChangeTimeout){window.clearTimeout(this.onChangeTimeout);}
this.onChangeTimeout=window.setTimeout(function(){this.notify('change',this.getValue());}.bind(this),Control.TextArea.onChangeTimeoutLength);},saveRange:function(){this.range=document.selection.createRange();},getValue:function(){return this.element.value;},getSelection:function(){if(!!document.selection){return document.selection.createRange().text;}
else if(!!this.element.setSelectionRange){return this.element.value.substring(this.element.selectionStart,this.element.selectionEnd);}
else{return false;}},replaceSelection:function(text){var scroll_top=this.element.scrollTop;if(!!document.selection){this.element.focus();var range=(this.range)?this.range:document.selection.createRange();range.text=text;range.select();}else if(!!this.element.setSelectionRange){var selection_start=this.element.selectionStart;this.element.value=this.element.value.substring(0,selection_start)+text+this.element.value.substring(this.element.selectionEnd);this.element.setSelectionRange(selection_start+text.length,selection_start+text.length);}
this.doOnChange();this.element.focus();this.element.scrollTop=scroll_top;},wrapSelection:function(before,after){var sel=this.getSelection();if(sel.indexOf(before)===0&&sel.lastIndexOf(after)===(sel.length-after.length)){this.replaceSelection(sel.substring(before.length,sel.length-after.length));}else{this.replaceSelection(before+sel+after);}},insertBeforeSelection:function(text){this.replaceSelection(text+this.getSelection());},insertAfterSelection:function(text){this.replaceSelection(this.getSelection()+text);},collectFromEachSelectedLine:function(callback,before,after){this.replaceSelection((before||'')+$A(this.getSelection().split("\n")).collect(callback).join("\n")+(after||''));},insertBeforeEachSelectedLine:function(text,before,after){this.collectFromEachSelectedLine(function(line){},before,after);}});Object.extend(Control.TextArea,{onChangeTimeoutLength:500});Object.Event.extend(Control.TextArea);Control.TextArea.ToolBar=Class.create({initialize:function(textarea,toolbar){this.textarea=textarea;if(toolbar){this.container=$(toolbar);}
else{this.container=$(document.createElement('ul'));this.textarea.element.parentNode.insertBefore(this.container,this.textarea.element);}},attachButton:function(node,callback){node.onclick=function(){return false;};$(node).observe('click',callback.bindAsEventListener(this.textarea));},addButton:function(link_text,callback,attrs){var li=document.createElement('li');var a=document.createElement('a');a.href='#';this.attachButton(a,callback);li.appendChild(a);Object.extend(a,attrs||{});if(link_text){var span=document.createElement('span');span.innerHTML=link_text;a.appendChild(span);}
this.container.appendChild(li);}});if(typeof(Draggable)!='undefined'){Draggable.prototype.draw=function(point){var pos=Position.cumulativeOffset(this.element);if(this.options.ghosting){var r=Position.realOffset(this.element);pos[0]+=r[0]-Position.deltaX;pos[1]+=r[1]-Position.deltaY;}
var d=this.currentDelta();pos[0]-=d[0];pos[1]-=d[1];if(this.options.scroll&&(this.options.scroll!=window&&this._isScrollChild)){pos[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;pos[1]-=this.options.scroll.scrollTop-this.originalScrollTop;}
var p=[0,1].map(function(i){return(point[i]-pos[i]-this.offset[i])}.bind(this));if(this.options.snap){if(typeof this.options.snap=='function'){p=this.options.snap(p[0],p[1],this);}else{if(this.options.snap instanceof Array){p=p.map(function(v,i){return Math.round(v/this.options.snap[i])*this.options.snap[i]}.bind(this))}else{p=p.map(function(v){return Math.round(v/this.options.snap)*this.options.snap}.bind(this))}}}
if(this.options.onDraw)
this.options.onDraw.bind(this)(p);else{var style=this.element.style;if(this.options.constrainToViewport){var viewport_dimensions=document.viewport.getDimensions();var container_dimensions=this.element.getDimensions();var margin_top=parseInt(this.element.getStyle('margin-top'));var margin_left=parseInt(this.element.getStyle('margin-left'));var boundary=[[0-margin_left,0-margin_top],[(viewport_dimensions.width-container_dimensions.width)-margin_left,(viewport_dimensions.height-container_dimensions.height)-margin_top]];if((!this.options.constraint)||(this.options.constraint=='horizontal')){if((p[0]>=boundary[0][0])&&(p[0]<=boundary[1][0]))
this.element.style.left=p[0]+"px";else
this.element.style.left=((p[0]<boundary[0][0])?boundary[0][0]:boundary[1][0])+"px";}
if((!this.options.constraint)||(this.options.constraint=='vertical')){if((p[1]>=boundary[0][1])&&(p[1]<=boundary[1][1]))
this.element.style.top=p[1]+"px";else
this.element.style.top=((p[1]<=boundary[0][1])?boundary[0][1]:boundary[1][1])+"px";}}else{if((!this.options.constraint)||(this.options.constraint=='horizontal'))
style.left=p[0]+"px";if((!this.options.constraint)||(this.options.constraint=='vertical'))
style.top=p[1]+"px";}
if(style.visibility=="hidden")
style.visibility="";}};}
if(typeof(Prototype)=="undefined")
throw"Control.Window requires Prototype to be loaded.";if(typeof(IframeShim)=="undefined")
throw"Control.Window requires IframeShim to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.Window requires Object.Event to be loaded.";Control.Window=Class.create({initialize:function(container,options){Control.Window.windows.push(this);this.container=false;this.isOpen=false;this.href=false;this.sourceContainer=false;this.ajaxRequest=false;this.remoteContentLoaded=false;this.numberInSequence=Control.Window.windows.length+1;this.indicator=false;this.effects={fade:false,appear:false};this.indicatorEffects={fade:false,appear:false};this.options=Object.extend({beforeOpen:Prototype.emptyFunction,afterOpen:Prototype.emptyFunction,beforeClose:Prototype.emptyFunction,afterClose:Prototype.emptyFunction,height:null,width:null,className:false,position:'center',offsetLeft:0,offsetTop:0,iframe:false,hover:false,indicator:false,closeOnClick:false,iframeshim:true,fade:false,fadeDuration:0.75,draggable:false,onDrag:Prototype.emptyFunction,resizable:false,minHeight:false,minWidth:false,maxHeight:false,maxWidth:false,onResize:Prototype.emptyFunction,constrainToViewport:false,method:'post',parameters:{},onComplete:Prototype.emptyFunction,onSuccess:Prototype.emptyFunction,onFailure:Prototype.emptyFunction,onException:Prototype.emptyFunction,onRemoteContentLoaded:Prototype.emptyFunction,insertRemoteContentAt:false},options||{});this.indicator=this.options.indicator?$(this.options.indicator):false;if(container){if(typeof(container)=="string"&&container.match(Control.Window.uriRegex))
this.href=container;else{this.container=$(container);this.createDefaultContainer(container);if(this.container&&((this.container.readAttribute('href')&&this.container.readAttribute('href')!='')||(this.options.hover&&this.options.hover!==true))){if(this.options.hover&&this.options.hover!==true)
this.sourceContainer=$(this.options.hover);else{this.sourceContainer=this.container;this.href=this.container.readAttribute('href');var rel=this.href.match(/^#(.+)$/);if(rel&&rel[1]){this.container=$(rel[1]);this.href=false;}else
this.container=false;}
this.sourceContainerOpenHandler=function(event){this.open(event);event.stop();return false;}.bindAsEventListener(this);this.sourceContainerCloseHandler=function(event){this.close(event);}.bindAsEventListener(this);this.sourceContainerMouseMoveHandler=function(event){this.position(event);}.bindAsEventListener(this);if(this.options.hover){this.sourceContainer.observe('mouseenter',this.sourceContainerOpenHandler);this.sourceContainer.observe('mouseleave',this.sourceContainerCloseHandler);if(this.options.position=='mouse')
this.sourceContainer.observe('mousemove',this.sourceContainerMouseMoveHandler);}else
this.sourceContainer.observe('click',this.sourceContainerOpenHandler);}}}
this.createDefaultContainer(container);if(this.options.insertRemoteContentAt===false)
this.options.insertRemoteContentAt=this.container;var styles={margin:0,position:'absolute',zIndex:Control.Window.initialZIndexForWindow()};if(this.options.width)
styles.width=$value(this.options.width)+'px';if(this.options.height)
styles.height=$value(this.options.height)+'px';this.container.setStyle(styles);if(this.options.className)
this.container.addClassName(this.options.className);this.positionHandler=this.position.bindAsEventListener(this);this.outOfBoundsPositionHandler=this.ensureInBounds.bindAsEventListener(this);this.bringToFrontHandler=this.bringToFront.bindAsEventListener(this);this.container.observe('mousedown',this.bringToFrontHandler);this.container.hide();this.closeHandler=this.close.bindAsEventListener(this);if(this.options.iframeshim){this.iFrameShim=new IframeShim();this.iFrameShim.hide();}
this.applyResizable();this.applyDraggable();Event.observe(window,'resize',this.outOfBoundsPositionHandler);this.notify('afterInitialize');},open:function(event){if(this.isOpen){this.bringToFront();return false;}
if(this.notify('beforeOpen')===false)
return false;if(this.options.closeOnClick){if(this.options.closeOnClick===true)
this.closeOnClickContainer=$(document.body);else if(this.options.closeOnClick=='container')
this.closeOnClickContainer=this.container;else if(this.options.closeOnClick=='overlay'){Control.Overlay.load();this.closeOnClickContainer=Control.Overlay.container;}else
this.closeOnClickContainer=$(this.options.closeOnClick);this.closeOnClickContainer.observe('click',this.closeHandler);}
if(this.href&&!this.options.iframe&&!this.remoteContentLoaded){this.remoteContentLoaded=true;if(this.href.match(/\.(jpe?g|gif|png|tiff?)$/i)){var img=new Element('img');img.observe('load',function(img){this.getRemoteContentInsertionTarget().insert(img);this.position();if(this.notify('onRemoteContentLoaded')!==false){if(this.options.indicator)
this.hideIndicator();this.finishOpen();}}.bind(this,img));img.writeAttribute('src',this.href);}else{if(!this.ajaxRequest){if(this.options.indicator)
this.showIndicator();this.ajaxRequest=new Ajax.Request(this.href,{method:this.options.method,parameters:this.options.parameters,onComplete:function(request){this.notify('onComplete',request);this.ajaxRequest=false;}.bind(this),onSuccess:function(request){this.getRemoteContentInsertionTarget().insert(request.responseText);this.notify('onSuccess',request);if(this.notify('onRemoteContentLoaded')!==false){if(this.options.indicator)
this.hideIndicator();this.finishOpen();}}.bind(this),onFailure:function(request){this.notify('onFailure',request);if(this.options.indicator)
this.hideIndicator();}.bind(this),onException:function(request,e){this.notify('onException',request,e);if(this.options.indicator)
this.hideIndicator();}.bind(this)});}}
return true;}else if(this.options.iframe&&!this.remoteContentLoaded){this.remoteContentLoaded=true;if(this.options.indicator)
this.showIndicator();this.getRemoteContentInsertionTarget().insert(Control.Window.iframeTemplate.evaluate({href:this.href}));var iframe=this.container.down('iframe');iframe.onload=function(){this.notify('onRemoteContentLoaded');if(this.options.indicator)
this.hideIndicator();iframe.onload=null;}.bind(this);}
this.finishOpen(event);return true},close:function(event){if(!this.isOpen||this.notify('beforeClose',event)===false)
return false;if(this.options.closeOnClick)
this.closeOnClickContainer.stopObserving('click',this.closeHandler);if(this.options.fade){this.effects.fade=new Effect.Fade(this.container,{queue:{position:'front',scope:'Control.Window'+this.numberInSequence},from:1,to:0,duration:this.options.fadeDuration/2,afterFinish:function(){if(this.iFrameShim)
this.iFrameShim.hide();this.isOpen=false;this.notify('afterClose');}.bind(this)});}else{this.container.hide();if(this.iFrameShim)
this.iFrameShim.hide();}
if(this.ajaxRequest)
this.ajaxRequest.transport.abort();if(!(this.options.draggable||this.options.resizable)&&this.options.position=='center')
Event.stopObserving(window,'resize',this.positionHandler);if(!this.options.draggable&&this.options.position=='center')
Event.stopObserving(window,'scroll',this.positionHandler);if(this.options.indicator)
this.hideIndicator();if(!this.options.fade){this.isOpen=false;this.notify('afterClose');}
return true;},position:function(event){if(this.options.position=='mouse'){var xy=[Event.pointerX(event),Event.pointerY(event)];this.container.setStyle({top:xy[1]+$value(this.options.offsetTop)+'px',left:xy[0]+$value(this.options.offsetLeft)+'px'});return;}
var container_dimensions=this.container.getDimensions();var viewport_dimensions=document.viewport.getDimensions();Position.prepare();var offset_left=(Position.deltaX+Math.floor((viewport_dimensions.width-container_dimensions.width)/2));var offset_top=(Position.deltaY+((viewport_dimensions.height>container_dimensions.height)?Math.floor((viewport_dimensions.height-container_dimensions.height)/2):0));if(this.options.position=='center'){this.container.setStyle({top:(container_dimensions.height<=viewport_dimensions.height)?((offset_top!=null&&offset_top>0)?offset_top:0)+'px':0,left:(container_dimensions.width<=viewport_dimensions.width)?((offset_left!=null&&offset_left>0)?offset_left:0)+'px':0});}else if(this.options.position=='relative'){var xy=this.sourceContainer.cumulativeOffset();var top=xy[1]+$value(this.options.offsetTop);var left=xy[0]+$value(this.options.offsetLeft);this.container.setStyle({top:(container_dimensions.height<=viewport_dimensions.height)?(this.options.constrainToViewport?Math.max(0,Math.min(viewport_dimensions.height-(container_dimensions.height),top)):top)+'px':0,left:(container_dimensions.width<=viewport_dimensions.width)?(this.options.constrainToViewport?Math.max(0,Math.min(viewport_dimensions.width-(container_dimensions.width),left)):left)+'px':0});}else if(this.options.position.length){var top=$value(this.options.position[1])+$value(this.options.offsetTop);var left=$value(this.options.position[0])+$value(this.options.offsetLeft);this.container.setStyle({top:(container_dimensions.height<=viewport_dimensions.height)?(this.options.constrainToViewport?Math.max(0,Math.min(viewport_dimensions.height-(container_dimensions.height),top)):top)+'px':0,left:(container_dimensions.width<=viewport_dimensions.width)?(this.options.constrainToViewport?Math.max(0,Math.min(viewport_dimensions.width-(container_dimensions.width),left)):left)+'px':0});}
if(this.iFrameShim)
this.updateIFrameShimZIndex();},ensureInBounds:function(){if(!this.isOpen)
return;var viewport_dimensions=document.viewport.getDimensions();var container_offset=this.container.cumulativeOffset();var container_dimensions=this.container.getDimensions();if(container_offset.left+container_dimensions.width>viewport_dimensions.width){this.container.setStyle({left:(Math.max(0,viewport_dimensions.width-container_dimensions.width))+'px'});}
if(container_offset.top+container_dimensions.height>viewport_dimensions.height){this.container.setStyle({top:(Math.max(0,viewport_dimensions.height-container_dimensions.height))+'px'});}},bringToFront:function(){Control.Window.bringToFront(this);this.notify('bringToFront');},destroy:function(){this.container.stopObserving('mousedown',this.bringToFrontHandler);if(this.draggable){Draggables.removeObserver(this.container);this.draggable.handle.stopObserving('mousedown',this.bringToFrontHandler);this.draggable.destroy();}
if(this.resizable){Resizables.removeObserver(this.container);this.resizable.handle.stopObserving('mousedown',this.bringToFrontHandler);this.resizable.destroy();}
if(this.container&&!this.sourceContainer)
this.container.remove();if(this.sourceContainer){if(this.options.hover){this.sourceContainer.stopObserving('mouseenter',this.sourceContainerOpenHandler);this.sourceContainer.stopObserving('mouseleave',this.sourceContainerCloseHandler);if(this.options.position=='mouse')
this.sourceContainer.stopObserving('mousemove',this.sourceContainerMouseMoveHandler);}else
this.sourceContainer.stopObserving('click',this.sourceContainerOpenHandler);}
if(this.iFrameShim)
this.iFrameShim.destroy();Event.stopObserving(window,'resize',this.outOfBoundsPositionHandler);Control.Window.windows=Control.Window.windows.without(this);this.notify('afterDestroy');},applyResizable:function(){if(this.options.resizable){if(typeof(Resizable)=="undefined")
throw"Control.Window requires resizable.js to be loaded.";var resizable_handle=null;if(this.options.resizable===true){resizable_handle=new Element('div',{className:'resizable_handle'});this.container.insert(resizable_handle);}else
resizable_handle=$(this.options.resziable);this.resizable=new Resizable(this.container,{handle:resizable_handle,minHeight:this.options.minHeight,minWidth:this.options.minWidth,maxHeight:this.options.constrainToViewport?function(element){return(document.viewport.getDimensions().height-parseInt(element.style.top||0))-(element.getHeight()-parseInt(element.style.height||0));}:this.options.maxHeight,maxWidth:this.options.constrainToViewport?function(element){return(document.viewport.getDimensions().width-parseInt(element.style.left||0))-(element.getWidth()-parseInt(element.style.width||0));}:this.options.maxWidth});this.resizable.handle.observe('mousedown',this.bringToFrontHandler);Resizables.addObserver(new Control.Window.LayoutUpdateObserver(this,function(){if(this.iFrameShim)
this.updateIFrameShimZIndex();this.notify('onResize');}.bind(this)));}},applyDraggable:function(){if(this.options.draggable){if(typeof(Draggables)=="undefined")
throw"Control.Window requires dragdrop.js to be loaded.";var draggable_handle=null;if(this.options.draggable===true){draggable_handle=new Element('div',{className:'draggable_handle'});this.container.insert(draggable_handle);}else
draggable_handle=$(this.options.draggable);this.draggable=new Draggable(this.container,{handle:draggable_handle,constrainToViewport:this.options.constrainToViewport,zindex:this.container.getStyle('z-index'),starteffect:function(){if(Prototype.Browser.IE){this.old_onselectstart=document.onselectstart;document.onselectstart=function(){return false;};}}.bind(this),endeffect:function(){document.onselectstart=this.old_onselectstart;}.bind(this)});this.draggable.handle.observe('mousedown',this.bringToFrontHandler);Draggables.addObserver(new Control.Window.LayoutUpdateObserver(this,function(){if(this.iFrameShim)
this.updateIFrameShimZIndex();this.notify('onDrag');}.bind(this)));}},createDefaultContainer:function(container){if(!this.container){this.container=new Element('div',{id:'control_window_'+this.numberInSequence});$(document.body).insert(this.container);if(typeof(container)=="string"&&$(container)==null&&!container.match(/^#(.+)$/)&&!container.match(Control.Window.uriRegex))
this.container.update(container);}},finishOpen:function(event){this.bringToFront();if(this.options.fade){if(typeof(Effect)=="undefined")
throw"Control.Window requires effects.js to be loaded."
if(this.effects.fade)
this.effects.fade.cancel();this.effects.appear=new Effect.Appear(this.container,{queue:{position:'end',scope:'Control.Window.'+this.numberInSequence},from:0,to:1,duration:this.options.fadeDuration/2,afterFinish:function(){if(this.iFrameShim)
this.updateIFrameShimZIndex();this.isOpen=true;this.notify('afterOpen');}.bind(this)});}else
this.container.show();this.position(event);if(!(this.options.draggable||this.options.resizable)&&this.options.position=='center')
Event.observe(window,'resize',this.positionHandler,false);if(!this.options.draggable&&this.options.position=='center')
Event.observe(window,'scroll',this.positionHandler,false);if(!this.options.fade){this.isOpen=true;this.notify('afterOpen');}
return true;},showIndicator:function(){this.showIndicatorTimeout=window.setTimeout(function(){if(this.options.fade){this.indicatorEffects.appear=new Effect.Appear(this.indicator,{queue:{position:'front',scope:'Control.Window.indicator.'+this.numberInSequence},from:0,to:1,duration:this.options.fadeDuration/2});}else
this.indicator.show();}.bind(this),Control.Window.indicatorTimeout);},hideIndicator:function(){if(this.showIndicatorTimeout)
window.clearTimeout(this.showIndicatorTimeout);this.indicator.hide();},getRemoteContentInsertionTarget:function(){return typeof(this.options.insertRemoteContentAt)=="string"?this.container.down(this.options.insertRemoteContentAt):$(this.options.insertRemoteContentAt);},updateIFrameShimZIndex:function(){if(this.iFrameShim)
this.iFrameShim.positionUnder(this.container);}});Object.extend(Control.Window,{windows:[],baseZIndex:9999,indicatorTimeout:250,iframeTemplate:new Template('<iframe src="#{href}" width="100%" height="100%" frameborder="0"></iframe>'),uriRegex:/^(\/|\#|https?\:\/\/|[\w]+\/)/,bringToFront:function(w){Control.Window.windows=Control.Window.windows.without(w);Control.Window.windows.push(w);Control.Window.windows.each(function(w,i){var z_index=Control.Window.baseZIndex+i;w.container.setStyle({zIndex:z_index});if(w.isOpen){if(w.iFrameShim)
w.updateIFrameShimZIndex();}
if(w.options.draggable)
w.draggable.options.zindex=z_index;});},open:function(container,options){var w=new Control.Window(container,options);w.open();return w;},initialZIndexForWindow:function(w){return Control.Window.baseZIndex+(Control.Window.windows.length-1);}});Object.Event.extend(Control.Window);Control.Window.LayoutUpdateObserver=Class.create({initialize:function(w,observer){this.w=w;this.element=$(w.container);this.observer=observer;},onStart:Prototype.emptyFunction,onEnd:function(event_name,instance){if(instance.element==this.element&&this.iFrameShim)
this.w.updateIFrameShimZIndex();},onResize:function(event_name,instance){if(instance.element==this.element)
this.observer(this.element);},onDrag:function(event_name,instance){if(instance.element==this.element)
this.observer(this.element);}});Control.Overlay={id:'control_overlay',loaded:false,container:false,lastOpacity:0,styles:{position:'fixed',top:0,left:0,width:'100%',height:'100%',zIndex:9998},ieStyles:{position:'absolute',top:0,left:0,zIndex:9998},effects:{fade:false,appear:false},load:function(){if(Control.Overlay.loaded)
return false;Control.Overlay.loaded=true;Control.Overlay.container=new Element('div',{id:Control.Overlay.id});$(document.body).insert(Control.Overlay.container);if(Prototype.Browser.IE){Control.Overlay.container.setStyle(Control.Overlay.ieStyles);Event.observe(window,'scroll',Control.Overlay.positionOverlay);Event.observe(window,'resize',Control.Overlay.positionOverlay);Control.Overlay.observe('beforeShow',Control.Overlay.positionOverlay);}else
Control.Overlay.container.setStyle(Control.Overlay.styles);Control.Overlay.iFrameShim=new IframeShim();Control.Overlay.iFrameShim.hide();Event.observe(window,'resize',Control.Overlay.positionIFrameShim);Control.Overlay.container.hide();return true;},unload:function(){if(!Control.Overlay.loaded)
return false;Event.stopObserving(window,'resize',Control.Overlay.positionOverlay);Control.Overlay.stopObserving('beforeShow',Control.Overlay.positionOverlay);Event.stopObserving(window,'resize',Control.Overlay.positionIFrameShim);Control.Overlay.iFrameShim.destroy();Control.Overlay.container.remove();Control.Overlay.loaded=false;return true;},show:function(opacity,fade){if(Control.Overlay.notify('beforeShow')===false)
return false;Control.Overlay.lastOpacity=opacity;Control.Overlay.positionIFrameShim();Control.Overlay.iFrameShim.show();if(fade){if(typeof(Effect)=="undefined")
throw"Control.Window requires effects.js to be loaded."
if(Control.Overlay.effects.fade)
Control.Overlay.effects.fade.cancel();Control.Overlay.effects.appear=new Effect.Appear(Control.Overlay.container,{queue:{position:'end',scope:'Control.Overlay'},afterFinish:function(){Control.Overlay.notify('afterShow');},from:0,to:Control.Overlay.lastOpacity,duration:(fade===true?0.75:fade)/2});}else{Control.Overlay.container.setStyle({opacity:opacity||1});Control.Overlay.container.show();Control.Overlay.notify('afterShow');}
return true;},hide:function(fade){if(Control.Overlay.notify('beforeHide')===false)
return false;if(Control.Overlay.effects.appear)
Control.Overlay.effects.appear.cancel();Control.Overlay.iFrameShim.hide();if(fade){Control.Overlay.effects.fade=new Effect.Fade(Control.Overlay.container,{queue:{position:'front',scope:'Control.Overlay'},afterFinish:function(){Control.Overlay.notify('afterHide');},from:Control.Overlay.lastOpacity,to:0,duration:(fade===true?0.75:fade)/2});}else{Control.Overlay.container.hide();Control.Overlay.notify('afterHide');}
return true;},positionIFrameShim:function(){if(Control.Overlay.container.visible())
Control.Overlay.iFrameShim.positionUnder(Control.Overlay.container);},positionOverlay:function(){Control.Overlay.container.setStyle({width:document.body.clientWidth+'px',height:document.body.clientHeight+'px'});}};Object.Event.extend(Control.Overlay);Control.ToolTip=Class.create(Control.Window,{initialize:function($super,container,tooltip,options){$super(tooltip,Object.extend(Object.extend(Object.clone(Control.ToolTip.defaultOptions),options||{}),{position:'mouse',hover:container}));}});Object.extend(Control.ToolTip,{defaultOptions:{offsetLeft:10}});Control.Modal=Class.create(Control.Window,{initialize:function($super,container,options){Control.Modal.InstanceMethods.beforeInitialize.bind(this)();$super(container,Object.extend(Object.clone(Control.Modal.defaultOptions),options||{}));}});Object.extend(Control.Modal,{defaultOptions:{overlayOpacity:0.5,closeOnClick:'overlay'},current:false,open:function(container,options){var modal=new Control.Modal(container,options);modal.open();return modal;},close:function(){if(Control.Modal.current)
Control.Modal.current.close();},InstanceMethods:{beforeInitialize:function(){Control.Overlay.load();this.overlayFinishedOpening=false;this.observe('beforeOpen',Control.Modal.Observers.beforeOpen.bind(this));this.observe('afterOpen',Control.Modal.Observers.afterOpen.bind(this));this.observe('afterClose',Control.Modal.Observers.afterClose.bind(this));}},Observers:{beforeOpen:function(){if(!this.overlayFinishedOpening){Control.Overlay.observeOnce('afterShow',function(){this.overlayFinishedOpening=true;this.open();}.bind(this));Control.Overlay.show(this.options.overlayOpacity,this.options.fade?this.options.fadeDuration:false);throw $break;}else
Control.Window.windows.without(this).invoke('close');},afterOpen:function(){Control.Modal.current=this;},afterClose:function(){Control.Overlay.hide(this.options.fade?this.options.fadeDuration:false);Control.Modal.current=false;this.overlayFinishedOpening=false;}}});Control.LightBox=Class.create(Control.Window,{initialize:function($super,container,options){this.allImagesLoaded=false;if(options.modal){var options=Object.extend(Object.clone(Control.LightBox.defaultOptions),options||{});options=Object.extend(Object.clone(Control.Modal.defaultOptions),options);options=Control.Modal.InstanceMethods.beforeInitialize.bind(this)(options);$super(container,options);}else
$super(container,Object.extend(Object.clone(Control.LightBox.defaultOptions),options||{}));this.hasRemoteContent=this.href&&!this.options.iframe;if(this.hasRemoteContent)
this.observe('onRemoteContentLoaded',Control.LightBox.Observers.onRemoteContentLoaded.bind(this));else
this.applyImageObservers();this.observe('beforeOpen',Control.LightBox.Observers.beforeOpen.bind(this));},applyImageObservers:function(){var images=this.getImages();this.numberImagesToLoad=images.length;this.numberofImagesLoaded=0;images.each(function(image){image.observe('load',function(image){++this.numberofImagesLoaded;if(this.numberImagesToLoad==this.numberofImagesLoaded){this.allImagesLoaded=true;this.onAllImagesLoaded();}}.bind(this,image));image.hide();}.bind(this));},onAllImagesLoaded:function(){this.getImages().each(function(image){this.showImage(image);}.bind(this));if(this.hasRemoteContent){if(this.options.indicator)
this.hideIndicator();this.finishOpen();}else
this.open();},getImages:function(){return this.container.select(Control.LightBox.imageSelector);},showImage:function(image){image.show();}});Object.extend(Control.LightBox,{imageSelector:'img',defaultOptions:{},Observers:{beforeOpen:function(){if(!this.hasRemoteContent&&!this.allImagesLoaded)
throw $break;},onRemoteContentLoaded:function(){this.applyImageObservers();if(!this.allImagesLoaded)
throw $break;}}});var dp={sh:{Toolbar:{},Utils:{},RegexLib:{},Brushes:{},Strings:{AboutDialog:'<html><head><title>About...</title></head><body class="dp-about"><table cellspacing="0"><tr><td class="copy"><p class="title">dp.SyntaxHighlighter</div><div class="para">Version: {V}</p><p><a href="http://www.dreamprojections.com/syntaxhighlighter/?ref=about" target="_blank">http://www.dreamprojections.com/syntaxhighlighter</a></p>&copy;2004-2007 Alex Gorbatchev.</td></tr><tr><td class="footer"><input type="button" class="close" value="OK" onClick="window.close()"/></td></tr></table></body></html>'},ClipboardSwf:null,Version:'1.5'}};dp.SyntaxHighlighter=dp.sh;dp.sh.Toolbar.Commands={ExpandSource:{label:'+ expand source',check:function(highlighter){return highlighter.collapse;},func:function(sender,highlighter)
{sender.parentNode.removeChild(sender);highlighter.div.className=highlighter.div.className.replace('collapsed','');}},ViewSource:{label:'view plain',func:function(sender,highlighter)
{var code=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=highlighter.originalCode;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=150,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();}}};dp.sh.Toolbar.Create=function(highlighter)
{var div=document.createElement('DIV');div.className='tools';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;}
dp.sh.Toolbar.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);}
dp.sh.Utils.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>');}
dp.sh.RegexLib={MultiLineCComments:new RegExp('/\\*[\\s\\S]*?\\*/','gm'),SingleLineCComments:new RegExp('//.*$','gm'),SingleLinePerlComments:new RegExp('#.*$','gm'),DoubleQuotedString:new RegExp('"(?:\\.|(\\\\\\")|[^\\""])*"','g'),SingleQuotedString:new RegExp("'(?:\\.|(\\\\\\')|[^\\''])*'",'g')};dp.sh.Match=function(value,index,css)
{this.value=value;this.index=index;this.length=value.length;this.css=css;}
dp.sh.Highlighter=function()
{this.noGutter=false;this.addControls=true;this.collapse=false;this.tabsToSpaces=true;this.wrapColumn=80;this.showColumns=true;}
dp.sh.Highlighter.SortCallback=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;}
dp.sh.Highlighter.prototype.CreateElement=function(name)
{var result=document.createElement(name);result.highlighter=this;return result;}
dp.sh.Highlighter.prototype.GetMatches=function(regex,css)
{var index=0;var match=null;while((match=regex.exec(this.code))!=null)
this.matches[this.matches.length]=new dp.sh.Match(match[0],match.index,css);}
dp.sh.Highlighter.prototype.AddBit=function(str,css)
{if(str==null||str.length==0)
return;var span=this.CreateElement('SPAN');str=str.replace(/ /g,'&nbsp;');str=str.replace(/</g,'&lt;');str=str.replace(/\n/gm,'&nbsp;<br>');if(css!=null)
{if((/br/gi).test(str))
{var lines=str.split('&nbsp;<br>');for(var i=0;i<lines.length;i++)
{span=this.CreateElement('SPAN');span.className=css;span.innerHTML=lines[i];this.div.appendChild(span);if(i+1<lines.length)
this.div.appendChild(this.CreateElement('BR'));}}
else
{span.className=css;span.innerHTML=str;this.div.appendChild(span);}}
else
{span.innerHTML=str;this.div.appendChild(span);}}
dp.sh.Highlighter.prototype.IsInside=function(match)
{if(match==null||match.length==0)
return false;for(var i=0;i<this.matches.length;i++)
{var c=this.matches[i];if(c==null)
continue;if((match.index>c.index)&&(match.index<c.index+c.length))
return true;}
return false;}
dp.sh.Highlighter.prototype.ProcessRegexList=function()
{for(var i=0;i<this.regexList.length;i++)
this.GetMatches(this.regexList[i].regex,this.regexList[i].css);}
dp.sh.Highlighter.prototype.ProcessSmartTabs=function(code)
{var lines=code.split('\n');var result='';var tabSize=4;var tab='\t';function InsertSpaces(line,pos,count)
{var left=line.substr(0,pos);var right=line.substr(pos+1,line.length);var spaces='';for(var i=0;i<count;i++)
spaces+=' ';return left+spaces+right;}
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;}
for(var i=0;i<lines.length;i++)
result+=ProcessLine(lines[i],tabSize)+'\n';return result;}
dp.sh.Highlighter.prototype.SwitchToList=function()
{var html=this.div.innerHTML.replace(/<(br)\/?>/gi,'\n');var lines=html.split('\n');if(this.addControls==true)
this.bar.appendChild(dp.sh.Toolbar.Create(this));if(this.showColumns)
{var div=this.CreateElement('div');var columns=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++;}}
columns.className='columns';columns.appendChild(div);this.bar.appendChild(columns);}
for(var i=0,lineIndex=this.firstLine;i<lines.length-1;i++,lineIndex++)
{var li=this.CreateElement('LI');var span=this.CreateElement('SPAN');li.className=(i%2==0)?'alt':'';span.innerHTML=lines[i]+'&nbsp;';li.appendChild(span);this.ol.appendChild(li);}
this.div.innerHTML='';}
dp.sh.Highlighter.prototype.Highlight=function(code)
{function Trim(str)
{return str.replace(/^\s*(.*?)[\s\n]*$/g,'$1');}
function Chop(str)
{return str.replace(/\n*$/,'').replace(/^\n*/,'');}
function Unindent(str)
{var lines=str.split('\n');var indents=new Array();var regex=new RegExp('^\\s*','g');var min=1000;for(var i=0;i<lines.length&&min>0;i++)
{if(Trim(lines[i]).length==0)
continue;var matches=regex.exec(lines[i]);if(matches!=null&&matches.length>0)
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');}
function Copy(string,pos1,pos2)
{return string.substr(pos1,pos2-pos1);}
var pos=0;if(code==null)
code='';this.originalCode=code;this.code=Chop(Unindent(code));this.div=this.CreateElement('DIV');this.bar=this.CreateElement('DIV');this.ol=this.CreateElement('OL');this.matches=new Array();this.div.className='dp-highlighter';this.div.highlighter=this;this.bar.className='bar';this.ol.start=this.firstLine;if(this.CssClass!=null)
this.ol.className=this.CssClass;if(this.collapse)
this.div.className+=' collapsed';if(this.noGutter)
this.div.className+=' nogutter';if(this.tabsToSpaces==true)
this.code=this.ProcessSmartTabs(this.code);this.ProcessRegexList();if(this.matches.length==0)
{this.AddBit(this.code,null);this.SwitchToList();this.div.appendChild(this.ol);return;}
this.matches=this.matches.sort(dp.sh.Highlighter.SortCallback);for(var i=0;i<this.matches.length;i++)
if(this.IsInside(this.matches[i]))
this.matches[i]=null;for(var i=0;i<this.matches.length;i++)
{var match=this.matches[i];if(match==null||match.length==0)
continue;this.AddBit(Copy(this.code,pos,match.index),null);this.AddBit(match.value,match.css);pos=match.index+match.length;}
this.AddBit(this.code.substr(pos),null);this.SwitchToList();this.div.appendChild(this.bar);this.div.appendChild(this.ol);}
dp.sh.Highlighter.prototype.GetKeywords=function(str)
{return'\\b'+str.replace(/ /g,'\\b|\\b')+'\\b';}
dp.sh.HighlightAll=function(name,showGutter,showControls,collapseAll,firstLine,showColumns)
{function FindValue()
{var a=arguments;for(var i=0;i<a.length;i++)
{if(a[i]==null)
continue;if(typeof(a[i])=='string'&&a[i]!='')
return a[i]+'';if(typeof(a[i])=='object'&&a[i].value!='')
return a[i].value+'';}
return null;}
function IsOptionSet(value,list)
{for(var i=0;i<list.length;i++)
if(list[i]==value)
return true;return false;}
function GetOptionValue(name,list,defaultValue)
{var regex=new RegExp('^'+name+'\\[(\\w+)\\]$','gi');var matches=null;for(var i=0;i<list.length;i++)
if((matches=regex.exec(list[i]))!=null)
return matches[1];return defaultValue;}
function FindTagsByName(list,name,tagName)
{var tags=document.getElementsByTagName(tagName);for(var i=0;i<tags.length;i++)
if(tags[i].getAttribute('class')==name)
list.push(tags[i]);}
var elements=[];var highlighter=null;var registered={};var propertyName='innerHTML';FindTagsByName(elements,name,'code');if(elements.length==0)
return;for(var brush in dp.sh.Brushes)
{var aliases=dp.sh.Brushes[brush].Aliases;if(aliases==null)
continue;for(var i=0;i<aliases.length;i++)
registered[aliases[i]]=brush;}
for(var i=0;i<elements.length;i++)
{var element=elements[i];var options=FindValue(element.attributes['class'],element.className,element.attributes['language'],element.language);var language='';if(options==null)
continue;options=options.split(':');language=options[0].toLowerCase();if(registered[language]==null)
continue;highlighter=new dp.sh.Brushes[registered[language]]();element.style.display='none';highlighter.noGutter=(showGutter==null)?IsOptionSet('nogutter',options):!showGutter;highlighter.addControls=(showControls==null)?!IsOptionSet('nocontrols',options):showControls;highlighter.collapse=(collapseAll==null)?IsOptionSet('collapse',options):collapseAll;highlighter.showColumns=(showColumns==null)?IsOptionSet('showcolumns',options):showColumns;highlighter.firstLine=(firstLine==null)?parseInt(GetOptionValue('firstline',options,1)):firstLine;highlighter.Highlight(element[propertyName]);highlighter.source=element;element.parentNode.insertBefore(highlighter.div,element);}}
dp.sh.Brushes.JScript=function()
{var keywords='\\$ 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 throw throws transient try typeof var void volatile while with';var constants='true false null TRUE FALSE NULL [0-9]+';var builtin='window document event Object Function Math Array Hash String Date RegExp';this.regexList=[{regex:dp.sh.RegexLib.SingleLineCComments,css:'comment'},{regex:dp.sh.RegexLib.MultiLineCComments,css:'comment'},{regex:dp.sh.RegexLib.DoubleQuotedString,css:'string'},{regex:dp.sh.RegexLib.SingleQuotedString,css:'string'},{regex:new RegExp('^\\s*#.*','gm'),css:'preprocessor'},{regex:new RegExp(this.GetKeywords(keywords),'gm'),css:'keyword'},{regex:new RegExp(this.GetKeywords(builtin),'gm'),css:'builtin'},{regex:new RegExp(this.GetKeywords(constants),'g'),css:'constants'},{regex:new RegExp('this(?=(\\.|\\,|\\)))','g'),css:'_this'},{regex:new RegExp('(\\s|\\{|\\,)[a-zA-Z0-9_]+(?=\\s?:\\s?function)','gm'),css:'func_dec'},{regex:new RegExp('on(R(ow(s(inserted|delete)|e(nter|xit))|e(s(ize(start|end)?|et)|adystatechange))|Mouse(o(ut|ver)|down|up|move)|B(efore(cut|deactivate|u(nload|pdate)|p(aste|rint)|editfocus|activate)|lur)|S(croll|top|ubmit|elect(start|ionchange)?)|H(over|elp)|C(hange|ont(extmenu|rolselect)|ut|ellchange|l(ick|ose))|D(eactivate|ata(setc(hanged|omplete)|available)|r(op|ag(start|over|drop|en(ter|d)|leave)?)|blclick)|Unload|P(aste|ropertychange)|Error(update)?|Key(down|up|press)|Focus|Load|A(ctivate|fter(update|print)|bort))','g'),css:'support_property'},{regex:new RegExp('(s(h(ift|ow(Mod(elessDialog|alDialog)|Help))|croll(X|By(Pages|Lines)?|Y|To)?|t(op|rike)|i(n|zeToContent|debar|gnText)|ort|u(p|b(str(ing)?)?)|pli(ce|t)|e(nd|t(Re(sizable|questHeader)|M(i(nutes|lliseconds)|onth)|Seconds|Ho(tKeys|urs)|Year|Cursor|Time(out)?|Interval|ZOptions|Date|UTC(M(i(nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(ome|andleEvent)|navigate|c(har(CodeAt|At)|o(s|n(cat|textual|firm)|mpile)|eil|lear(Timeout|Interval)?|a(ptureEvents|ll)|reate(StyleSheet|Popup|EventObject))|t(o(GMTString|S(tring|ource)|U(TCString|pperCase)|Lo(caleString|werCase))|est|a(n|int(Enabled)?))|i(s(NaN|Finite)|ndexOf|talics)|d(isableExternalCapture|ump|etachEvent)|u(n(shift|taint|escape|watch)|pdateCommands)|j(oin|avaEnabled)|p(o(p|w)|ush|lugins.refresh|a(ddings|rse(Int|Float)?)|r(int|ompt|eference))|e(scape|nableExternalCapture|val|lementFromPoint|x(p|ec(Script|Command)?))|valueOf|UTC|queryCommand(State|Indeterm|Enabled|Value)|f(i(nd|le(ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(nt(size|color)|rward)|loor|romCharCode)|watch|l(ink|o(ad|g)|astIndexOf)|a(sin|nchor|cos|t(tachEvent|ob|an(2)?)|pply|lert|b(s|ort))|r(ou(nd|teEvents)|e(size(By|To)|calc|turnValue|place|verse|l(oad|ease(Capture|Events)))|andom)|g(o|et(ResponseHeader|M(i(nutes|lliseconds)|onth)|Se(conds|lection)|Hours|Year|Time(zoneOffset)?|Da(y|te)|UTC(M(i(nutes|lliseconds)|onth)|Seconds|Hours|Da(y|te)|FullYear)|FullYear|A(ttention|llResponseHeaders)))|m(in|ove(B(y|elow)|To(Absolute)?|Above)|ergeAttributes|a(tch|rgins|x))|b(toa|ig|o(ld|rderWidths)|link|ack))(?=\\()','g'),css:'support_method'},{regex:new RegExp('(s(ub(stringData|mit)|plitText|e(t(NamedItem|Attribute(Node)?)|lect))|has(ChildNodes|Feature)|namedItem|c(l(ick|o(se|neNode))|reate(C(omment|DATASection|aption)|T(Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(ntityReference|lement)|Attribute))|tabIndex|i(nsert(Row|Before|Cell|Data)|tem)|open|delete(Row|C(ell|aption)|T(Head|Foot)|Data)|focus|write(ln)?|a(dd|ppend(Child|Data))|re(set|place(Child|Data)|move(NamedItem|Child|Attribute(Node)?)?)|get(NamedItem|Element(sBy(Name|TagName)|ById)|Attribute(Node)?)|blur)(?=\\()','g'),css:'support_method'},{regex:new RegExp('on(R(ow(s(inserted|delete)|e(nter|xit))|e(s(ize(start|end)?|et)|adystatechange))|Mouse(o(ut|ver)|down|up|move)|B(efore(cut|deactivate|u(nload|pdate)|p(aste|rint)|editfocus|activate)|lur)|S(croll|top|ubmit|elect(start|ionchange)?)|H(over|elp)|C(hange|ont(extmenu|rolselect)|ut|ellchange|l(ick|ose))|D(eactivate|ata(setc(hanged|omplete)|available)|r(op|ag(start|over|drop|en(ter|d)|leave)?)|blclick)|Unload|P(aste|ropertychange)|Error(update)?|Key(down|up|press)|Focus|Load|A(ctivate|fter(update|print)|bort))','g'),css:'support_property'},{regex:new RegExp('\\.(s(ystemLanguage|cr(ipts|ollbars|een(X|Y|Top|Left))|t(yle(Sheets)?|atus(Text|bar)?)|ibling(Below|Above)|ource|uffixes|e(curity(Policy)?|l(ection|f)))|h(istory|ost(name)?|as(h|Focus))|y|X(MLDocument|SLDocument)|n(ext|ame(space(s|URI)|Prop))|M(IN_VALUE|AX_VALUE)|c(haracterSet|o(n(structor|trollers)|okieEnabled|lorDepth|mp(onents|lete))|urrent|puClass|l(i(p(boardData)?|entInformation)|osed|asses)|alle(e|r)|rypto)|t(o(olbar|p)|ext(Transform|Indent|Decoration|Align)|ags)|SQRT(1_2|2)|i(n(ner(Height|Width)|put)|ds|gnoreCase)|zIndex|o(scpu|n(readystatechange|Line)|uter(Height|Width)|p(sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(i(splay|alog(Height|Top|Width|Left|Arguments)|rectories)|e(scription|fault(Status|Ch(ecked|arset)|View)))|u(ser(Profile|Language|Agent)|n(iqueID|defined)|pdateInterval)|_content|p(ixelDepth|ort|ersonalbar|kcs11|l(ugins|atform)|a(thname|dding(Right|Bottom|Top|Left)|rent(Window|Layer)?|ge(X(Offset)?|Y(Offset)?))|r(o(to(col|type)|duct(Sub)?|mpter)|e(vious|fix)))|e(n(coding|abledPlugin)|x(ternal|pando)|mbeds)|v(isibility|endor(Sub)?|Linkcolor)|URLUnencoded|P(I|OSITIVE_INFINITY)|f(ilename|o(nt(Size|Family|Weight)|rmName)|rame(s|Element)|gColor)|E|whiteSpace|l(i(stStyleType|n(eHeight|kColor))|o(ca(tion(bar)?|lName)|wsrc)|e(ngth|ft(Context)?)|a(st(M(odified|atch)|Index|Paren)|yer(s|X)|nguage))|a(pp(MinorVersion|Name|Co(deName|re)|Version)|vail(Height|Top|Width|Left)|ll|r(ity|guments)|Linkcolor|bove)|r(ight(Context)?|e(sponse(XML|Text)|adyState))|global|x|m(imeTypes|ultiline|enubar|argin(Right|Bottom|Top|Left))|L(N(10|2)|OG(10E|2E))|b(o(ttom|rder(RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(Color|Image)))','g'),css:'support_property'}];this.CssClass='javascript';}
dp.sh.Brushes.JScript.prototype=new dp.sh.Highlighter();dp.sh.Brushes.JScript.Aliases=['js','jscript','javascript'];dp.sh.Brushes.CSS=function()
{var keywords='ascent azimuth background-attachment background-color background-image background-position '+'background-repeat background baseline bbox border-collapse border-color border-spacing border-style border-top '+'border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color '+'border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width '+'border-bottom-width border-left-width border-width border bottom cap-height caption-side centerline clear clip color '+'content counter-increment counter-reset cue-after cue-before cue cursor definition-src descent direction display '+'elevation empty-cells float font-size-adjust font-family font-size font-stretch font-style font-variant font-weight font '+'height letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-top '+'margin-right margin-bottom margin-left margin marker-offset marks mathline max-height max-width min-height min-width orphans '+'outline-color outline-style outline-width outline overflow padding-top padding-right padding-bottom padding-left padding page '+'page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position '+'quotes richness right size slope src speak-header speak-numeral speak-punctuation speak speech-rate stemh stemv stress '+'table-layout text-align text-decoration text-indent text-shadow text-transform unicode-bidi unicode-range units-per-em '+'vertical-align visibility voice-family volume white-space widows width widths word-spacing x-height z-index important';var values='above absolute all always aqua armenian attr aural auto avoid baseline behind below bidi-override black blink block blue bold bolder '+'both bottom braille capitalize caption center center-left center-right circle close-quote 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 fantasy far-left far-right fast faster fixed format fuchsia '+'gray green groove hand handheld hebrew help hidden hide high higher icon inline-table inline inset inside invert italic '+'justify landscape large larger left-side left leftwards level lighter lime line-through list-item local loud lower-alpha '+'lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower '+'navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once open-quote outset '+'outside overline pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side '+'rightwards rtl run-in screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow '+'small small-caps small-caption smaller soft solid speech spell-out 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 teal '+'text-bottom text-top thick thin top transparent tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin '+'upper-roman url visible wait white wider w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow';var fonts='[mM]onospace [tT]ahoma [vV]erdana [aA]rial [hH]elvetica [sS]ans-serif [sS]erif';this.regexList=[{regex:dp.sh.RegexLib.MultiLineCComments,css:'comment'},{regex:dp.sh.RegexLib.DoubleQuotedString,css:'string'},{regex:dp.sh.RegexLib.SingleQuotedString,css:'string'},{regex:new RegExp('\\#[a-fA-F0-9]{3,6}','g'),css:'color'},{regex:new RegExp('-?(\\d+)(px|pt|\:|\\s)?','g'),css:'size'},{regex:new RegExp(this.GetKeywords(keywords),'gm'),css:'keyword'},{regex:new RegExp(this.GetKeywords(values),'g'),css:'value'},{regex:new RegExp(this.GetKeywords(fonts),'g'),css:'fonts'},{regex:new RegExp('(^|\n)[\\s\\#\\._\\-a-zA-Z0-9\\:\\,\\*]+[\\s\\n]*(?=\\{)','gm'),css:'rule'}];this.CssClass='css';}
dp.sh.Brushes.CSS.prototype=new dp.sh.Highlighter();dp.sh.Brushes.CSS.Aliases=['css'];dp.sh.Brushes.Xml=function()
{this.CssClass='xml';}
dp.sh.Brushes.Xml.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Xml.Aliases=['xml','xhtml','xslt','html','xhtml'];dp.sh.Brushes.Xml.prototype.ProcessRegexList=function()
{function push(array,value)
{array[array.length]=value;}
var index=0;var match=null;var regex=null;this.GetMatches(new RegExp('(\&lt;|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\&gt;|>)','gm'),'cdata');this.GetMatches(new RegExp('(\&lt;|<)!--\\s*.*?\\s*--(\&gt;|>)','gm'),'comments');regex=new RegExp('([:\\w-\.]+)\\s*=\\s*(".*?"|\'.*?\'|\\w+)*|(\\w+)','gm');while((match=regex.exec(this.code))!=null)
{if(match[1]==null)
{continue;}
push(this.matches,new dp.sh.Match(match[1],match.index,'attribute'));if(match[2]!=undefined)
{push(this.matches,new dp.sh.Match(match[2],match.index+match[0].indexOf(match[2]),'attribute-value'));}}
this.GetMatches(new RegExp('(\&lt;|<)/*\\?*(?!\\!)|/*\\?*(\&gt;|>)','gm'),'tag');regex=new RegExp('(?:\&lt;|<)/*\\?*\\s*([:\\w-\.]+)','gm');while((match=regex.exec(this.code))!=null)
{push(this.matches,new dp.sh.Match(match[1],match.index+match[0].indexOf(match[1]),'tag-name'));}}
Event.observe(window,'load',function(){dp.sh.HighlightAll('javascript',false,false,false,true,false);dp.sh.HighlightAll('css',false,false,false,true,false);dp.sh.HighlightAll('xml',false,false,false,true,false);});var Showdown={};Showdown.converter=function(){var g_urls;var g_titles;var g_html_blocks;var g_list_level=0;this.makeHtml=function(text){g_urls=new Array();g_titles=new Array();g_html_blocks=new Array();text=text.replace(/~/g,"~T");text=text.replace(/\$/g,"~D");text=text.replace(/\r\n/g,"\n");text=text.replace(/\r/g,"\n");text="\n\n"+text+"\n\n";text=_Detab(text);text=text.replace(/^[ \t]+$/mg,"");text=_HashHTMLBlocks(text);text=_StripLinkDefinitions(text);text=_RunBlockGamut(text);text=_UnescapeSpecialChars(text);text=text.replace(/~D/g,"$$");text=text.replace(/~T/g,"~");return text;}
var _StripLinkDefinitions=function(text){var text=text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,function(wholeMatch,m1,m2,m3,m4){m1=m1.toLowerCase();g_urls[m1]=_EncodeAmpsAndAngles(m2);if(m3){return m3+m4;}else if(m4){g_titles[m1]=m4.replace(/"/g,"&quot;");}
return"";});return text;}
var _HashHTMLBlocks=function(text){text=text.replace(/\n/g,"\n\n");var block_tags_a="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del"
var block_tags_b="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math"
text=text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement);text=text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement);text=text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,hashElement);text=text.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,hashElement);text=text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,hashElement);text=text.replace(/\n\n/g,"\n");return text;}
var hashElement=function(wholeMatch,m1){var blockText=m1;blockText=blockText.replace(/\n\n/g,"\n");blockText=blockText.replace(/^\n/,"");blockText=blockText.replace(/\n+$/g,"");blockText="\n\n~K"+(g_html_blocks.push(blockText)-1)+"K\n\n";return blockText;};var _RunBlockGamut=function(text){text=_DoHeaders(text);var key=hashBlock("<hr />");text=text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key);text=text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key);text=text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);text=_DoLists(text);text=_DoCodeBlocks(text);text=_DoBlockQuotes(text);text=_HashHTMLBlocks(text);text=_FormParagraphs(text);return text;}
var _RunSpanGamut=function(text){text=_DoCodeSpans(text);text=_EscapeSpecialCharsWithinTagAttributes(text);text=_EncodeBackslashEscapes(text);text=_DoImages(text);text=_DoAnchors(text);text=_DoAutoLinks(text);text=_EncodeAmpsAndAngles(text);text=_DoItalicsAndBold(text);text=text.replace(/  +\n/g," <br />\n");return text;}
var _EscapeSpecialCharsWithinTagAttributes=function(text){var regex=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;text=text.replace(regex,function(wholeMatch){var tag=wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`");tag=escapeCharacters(tag,"\\`*_");return tag;});return text;}
var _DoAnchors=function(text){text=text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag);text=text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag);text=text.replace(/(\[([^\[\]]+)\])()()()()()/g,writeAnchorTag);return text;}
var writeAnchorTag=function(wholeMatch,m1,m2,m3,m4,m5,m6,m7){if(m7==undefined)m7="";var whole_match=m1;var link_text=m2;var link_id=m3.toLowerCase();var url=m4;var title=m7;if(url==""){if(link_id==""){link_id=link_text.toLowerCase().replace(/ ?\n/g," ");}
url="#"+link_id;if(g_urls[link_id]!=undefined){url=g_urls[link_id];if(g_titles[link_id]!=undefined){title=g_titles[link_id];}}
else{if(whole_match.search(/\(\s*\)$/m)>-1){url="";}else{return whole_match;}}}
url=escapeCharacters(url,"*_");var result="<a href=\""+url+"\"";if(title!=""){title=title.replace(/"/g,"&quot;");title=escapeCharacters(title,"*_");result+=" title=\""+title+"\"";}
result+=">"+link_text+"</a>";return result;}
var _DoImages=function(text){text=text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag);text=text.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag);return text;}
var writeImageTag=function(wholeMatch,m1,m2,m3,m4,m5,m6,m7){var whole_match=m1;var alt_text=m2;var link_id=m3.toLowerCase();var url=m4;var title=m7;if(!title)title="";if(url==""){if(link_id==""){link_id=alt_text.toLowerCase().replace(/ ?\n/g," ");}
url="#"+link_id;if(g_urls[link_id]!=undefined){url=g_urls[link_id];if(g_titles[link_id]!=undefined){title=g_titles[link_id];}}
else{return whole_match;}}
alt_text=alt_text.replace(/"/g,"&quot;");url=escapeCharacters(url,"*_");var result="<img src=\""+url+"\" alt=\""+alt_text+"\"";title=title.replace(/"/g,"&quot;");title=escapeCharacters(title,"*_");result+=" title=\""+title+"\"";result+=" />";return result;}
var _DoHeaders=function(text){text=text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(wholeMatch,m1){return hashBlock("<h1>"+_RunSpanGamut(m1)+"</h1>");});text=text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(matchFound,m1){return hashBlock("<h2>"+_RunSpanGamut(m1)+"</h2>");});text=text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(wholeMatch,m1,m2){var h_level=m1.length;return hashBlock("<h"+h_level+">"+_RunSpanGamut(m2)+"</h"+h_level+">");});return text;}
var _ProcessListItems;var _DoLists=function(text){text+="~0";var whole_list=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;if(g_list_level){text=text.replace(whole_list,function(wholeMatch,m1,m2){var list=m1;var list_type=(m2.search(/[*+-]/g)>-1)?"ul":"ol";list=list.replace(/\n{2,}/g,"\n\n\n");;var result=_ProcessListItems(list);result=result.replace(/\s+$/,"");result="<"+list_type+">"+result+"</"+list_type+">\n";return result;});}else{whole_list=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;text=text.replace(whole_list,function(wholeMatch,m1,m2,m3){var runup=m1;var list=m2;var list_type=(m3.search(/[*+-]/g)>-1)?"ul":"ol";var list=list.replace(/\n{2,}/g,"\n\n\n");;var result=_ProcessListItems(list);result=runup+"<"+list_type+">\n"+result+"</"+list_type+">\n";return result;});}
text=text.replace(/~0/,"");return text;}
_ProcessListItems=function(list_str){g_list_level++;list_str=list_str.replace(/\n{2,}$/,"\n");list_str+="~0";list_str=list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(wholeMatch,m1,m2,m3,m4){var item=m4;var leading_line=m1;var leading_space=m2;if(leading_line||(item.search(/\n{2,}/)>-1)){item=_RunBlockGamut(_Outdent(item));}
else{item=_DoLists(_Outdent(item));item=item.replace(/\n$/,"");item=_RunSpanGamut(item);}
return"<li>"+item+"</li>\n";});list_str=list_str.replace(/~0/g,"");g_list_level--;return list_str;}
var _DoCodeBlocks=function(text){text+="~0";text=text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(wholeMatch,m1,m2){var codeblock=m1;var nextChar=m2;codeblock=_EncodeCode(_Outdent(codeblock));codeblock=_Detab(codeblock);codeblock=codeblock.replace(/^\n+/g,"");codeblock=codeblock.replace(/\n+$/g,"");codeblock="<pre><code>"+codeblock+"\n</code></pre>";return hashBlock(codeblock)+nextChar;});text=text.replace(/~0/,"");return text;}
var hashBlock=function(text){text=text.replace(/(^\n+|\n+$)/g,"");return"\n\n~K"+(g_html_blocks.push(text)-1)+"K\n\n";}
var _DoCodeSpans=function(text){text=text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(wholeMatch,m1,m2,m3,m4){var c=m3;c=c.replace(/^([ \t]*)/g,"");c=c.replace(/[ \t]*$/g,"");c=_EncodeCode(c);return m1+"<code>"+c+"</code>";});return text;}
var _EncodeCode=function(text){text=text.replace(/&/g,"&amp;");text=text.replace(/</g,"&lt;");text=text.replace(/>/g,"&gt;");text=escapeCharacters(text,"\*_{}[]\\",false);return text;}
var _DoItalicsAndBold=function(text){text=text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>");text=text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>");return text;}
var _DoBlockQuotes=function(text){text=text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(wholeMatch,m1){var bq=m1;bq=bq.replace(/^[ \t]*>[ \t]?/gm,"~0");bq=bq.replace(/~0/g,"");bq=bq.replace(/^[ \t]+$/gm,"");bq=_RunBlockGamut(bq);bq=bq.replace(/(^|\n)/g,"$1  ");bq=bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(wholeMatch,m1){var pre=m1;pre=pre.replace(/^  /mg,"~0");pre=pre.replace(/~0/g,"");return pre;});return hashBlock("<blockquote>\n"+bq+"\n</blockquote>");});return text;}
var _FormParagraphs=function(text){text=text.replace(/^\n+/g,"");text=text.replace(/\n+$/g,"");var grafs=text.split(/\n{2,}/g);var grafsOut=new Array();var end=grafs.length;for(var i=0;i<end;i++){var str=grafs[i];if(str.search(/~K(\d+)K/g)>=0){grafsOut.push(str);}
else if(str.search(/\S/)>=0){str=_RunSpanGamut(str);str=str.replace(/^([ \t]*)/g,"<p>");str+="</p>"
grafsOut.push(str);}}
end=grafsOut.length;for(var i=0;i<end;i++){while(grafsOut[i].search(/~K(\d+)K/)>=0){var blockText=g_html_blocks[RegExp.$1];blockText=blockText.replace(/\$/g,"$$$$");grafsOut[i]=grafsOut[i].replace(/~K\d+K/,blockText);}}
return grafsOut.join("\n\n");}
var _EncodeAmpsAndAngles=function(text){text=text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;");text=text.replace(/<(?![a-z\/?\$!])/gi,"&lt;");return text;}
var _EncodeBackslashEscapes=function(text){text=text.replace(/\\(\\)/g,escapeCharacters_callback);text=text.replace(/\\([`*_{}\[\]()>#+-.!])/g,escapeCharacters_callback);return text;}
var _DoAutoLinks=function(text){text=text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"<a href=\"$1\">$1</a>");text=text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(wholeMatch,m1){return _EncodeEmailAddress(_UnescapeSpecialChars(m1));});return text;}
var _EncodeEmailAddress=function(addr){function char2hex(ch){var hexDigits='0123456789ABCDEF';var dec=ch.charCodeAt(0);return(hexDigits.charAt(dec>>4)+hexDigits.charAt(dec&15));}
var encode=[function(ch){return"&#"+ch.charCodeAt(0)+";";},function(ch){return"&#x"+char2hex(ch)+";";},function(ch){return ch;}];addr="mailto:"+addr;addr=addr.replace(/./g,function(ch){if(ch=="@"){ch=encode[Math.floor(Math.random()*2)](ch);}else if(ch!=":"){var r=Math.random();ch=(r>.9?encode[2](ch):r>.45?encode[1](ch):encode[0](ch));}
return ch;});addr="<a href=\""+addr+"\">"+addr+"</a>";addr=addr.replace(/">.+:/g,"\">");return addr;}
var _UnescapeSpecialChars=function(text){text=text.replace(/~E(\d+)E/g,function(wholeMatch,m1){var charCodeToReplace=parseInt(m1);return String.fromCharCode(charCodeToReplace);});return text;}
var _Outdent=function(text){text=text.replace(/^(\t|[ ]{1,4})/gm,"~0");text=text.replace(/~0/g,"")
return text;}
var _Detab=function(text){text=text.replace(/\t(?=\t)/g,"    ");text=text.replace(/\t/g,"~A~B");text=text.replace(/~B(.+?)~A/g,function(wholeMatch,m1,m2){var leadingText=m1;var numSpaces=4-leadingText.length%4;for(var i=0;i<numSpaces;i++)leadingText+=" ";return leadingText;});text=text.replace(/~A/g,"    ");text=text.replace(/~B/g,"");return text;}
var escapeCharacters=function(text,charsToEscape,afterBackslash){var regexString="(["+charsToEscape.replace(/([\[\]\\])/g,"\\$1")+"])";if(afterBackslash){regexString="\\\\"+regexString;}
var regex=new RegExp(regexString,"g");text=text.replace(regex,escapeCharacters_callback);return text;}
var escapeCharacters_callback=function(wholeMatch,m1){var charCodeToEscape=m1.charCodeAt(0);return"~E"+charCodeToEscape+"E";}}