Ajax.Responders.register({onCreate:function(a){a.timeoutId=window.setTimeout(function(){switch(a.transport.readyState){case 0:case 1:case 2:case 3:a.transport.abort();if(a.options.onFailure){a.options.onFailure(a.transport,a.json)}break}},5000)},onComplete:function(a){window.clearTimeout(a.timeoutId)}});var siteComponentsElementMethods={getHiddenElementDimensions:function(d){d=$(d);var c=d.getStyle("visibility");var f=d.getStyle("display");var b=d.getStyle("position");d.setStyle({visibility:"hidden",display:"block",position:"absolute"});var a=d.getHeight();var e=d.getWidth();d.setStyle({visibility:c,display:f,position:b});return{height:a,width:e}},getDimensionFromStyle:function(c,d){var a=c.getStyle(d);if(a!=null){var b=a.match(/^([0-9]+)px$/);if(b.length==2){return parseInt(b[1])}else{return 0}}else{return 0}}};Element.addMethods(siteComponentsElementMethods);function getSiteComponentsConfig(b,c,a){if(typeof siteComponentsConfig!="undefined"&&typeof siteComponentsConfig[b]!="undefined"&&siteComponentsConfig[b][c]!="undefined"){return siteComponentsConfig[b][c]}if(typeof a!="undefined"){return a}return null}function recommendCommentPost(a){new Ajax.Updater({success:"commentpost-rating-"+a},"/xmlhttprequest.php?service=entity.rate",{parameters:{entity_id:a,entity_type:"EntityCommentPost",rating:"99"}});return false}function articleOpinion(b,a){new Ajax.Updater({success:"article-opinion-"+b+"-"+(a?"agree":"disagree")},"/xmlhttprequest.php?service=entity.rate",{parameters:{entity_id:b,entity_type:"Article",rating:a?99:1}});return false}function getThemeName(){if(typeof themeName=="undefined"){var b=$$("link[rel=stylesheet]");if(b.size()>0){var a=b[0].readAttribute("href");a=a.substring(0,a.lastIndexOf("/"));themeName=a.substring(a.lastIndexOf("/")+1)}}return themeName}function regenerateAllCaptchas(){var a=Math.floor(Math.random()*100001);$$("div.captcha-image img").each(function(b){b.src=b.src+"&amp;rand="+a})};var Lightbox=Class.create({showHtml:function(a){this.prepareToShow();this.content.update(a);this.lightbox.fire("lightbox:contentUpdated");this.doShow()},show:function(a){this.prepareToShow();lightbox.getAndShowContentFromUrl(a)},hide:function(){this.historyPolling.stop();this.lightbox.hide();this.content.hide();this.overlay.hide();this.spinner.hide();this.htmlElement.setStyle({overflow:this.htmlOverflowStyle});this.contentDimensionChangedRunner.stop();Event.stopObserving(window,"resize",this.windowResizeListenerObj);this.content.stopObserving("lightbox:contentDimensionChanged",this.windowResizeListenerObj);this.lightbox.stopObserving("lightbox:contentUpdated");this.showPersistentObjects(true);this.content.update();if(window.location.hash=="#modal"){history.go(-1)}this.container.setStyle({width:this.originalContainerWidth+"px"})},initializeLightboxAnchors:function(){$$("a.lightbox").each(function(a){a.observe("click",function(c){c.stop();var b=Event.findElement(c,"a");if(b!=document){lightbox.activeElement=b;lightbox.show(b.getAttribute("href"))}})})},isVisible:function(){return this.lightbox.visible},initialize:function(){this.history=new Object();this.htmlElement=$$("html").first();var b=$$("body").first();if(Prototype.Browser.IE){var c=document.createElement("iframe");c.setAttribute("id","lightbox-history-frame");c.src="/history-frame.php";c.style.display="block";c.style.visibility="hidden";c.style.position="absolute";c.style.top="0";c.style.left="0";c.style.width="1px";c.style.height="1px";b.appendChild(c);this.historyFrame=c}b.insert({bottom:'<div id="lightbox"></div><div id="lightbox-spinner"></div>'});var e=$("lightbox");e.setStyle({display:"none"});e.update('<div id="lightbox-overlay"></div><div id="lightbox-container"></div>');var a=$("lightbox-container");a.update('<div id="lightbox-close-container"><a href="#" id="lightbox-close"><span>Close</span></a></div>');a.insert({bottom:'<div id="lightbox-start"><div class="left"></div><div class="right"></div></div><div id="lightbox-content-left"></div><div id="lightbox-content-right"></div><div id="lightbox-outer-content"><div id="lightbox-content"></div></div><div id="lightbox-end"><div class="left"></div><div class="right"></div></div>'});this.content=$("lightbox-content");this.lightbox=$("lightbox");this.container=$("lightbox-container");this.overlay=$("lightbox-overlay");this.spinner=$("lightbox-spinner");this.spinner.setStyle({position:"absolute",zIndex:1000,display:"none"});this.containerTop=Element.getDimensionFromStyle(this.container,"top");if(Prototype.Browser.Gecko){this.overlay.setStyle({background:"url(/images/lightbox/ff-overlay-img.png)"})}else{this.overlay.setStyle({opacity:0.5})}document.observe("keyup",function(f){if(f.keyCode==Event.KEY_ESC){this.clickToCloseListener(f)}}.bind(this));$("lightbox-close").observe("click",this.clickToCloseListener.bindAsEventListener(this));this.overlay.observe("click",this.clickToCloseListener.bindAsEventListener(this));this.lightbox.observe("lightbox:contentReady",this.contentReadyListener.bindAsEventListener(this));this.lightbox.observe("lightbox:cpWriteMediaObjectRun",this.resizeContentToMediaObjectSizeListener.bindAsEventListener(this));if(Prototype.Browser.IE&&(typeof document.documentMode=="undefined"||document.documentMode==7)){var d=1000;this.container.select("div").each(function(f){f.style.zIndex=d--})}},getContainerHorizontalPadding:function(){if(typeof this.containerPadding=="undefined"){var b=this.content;var a=0;while(b!=null&&b!=this.container){a+=Element.getDimensionFromStyle(b,"padding-left");a+=Element.getDimensionFromStyle(b,"padding-right");a+=Element.getDimensionFromStyle(b,"margin-left");a+=Element.getDimensionFromStyle(b,"margin-right");b=b.getOffsetParent()}this.containerPadding=a}return this.containerPadding},prepareHistory:function(){if(Prototype.Browser.IE){this.historyFrame.src="/history-frame.php?modal"}else{window.location.hash="#modal"}this.historyPolling=new PeriodicalExecuter(function(a){var d=false;if(Prototype.Browser.IE){var b=this.historyFrame.contentWindow.document.title;if(b.indexOf("?modal")<0){d=true}}else{var c=window.location.hash;if(window.location.hash!="#modal"){d=true}}if(d){a.stop();if(this.isVisible()){this.hide()}}}.bind(this),0.5)},showPersistentObjects:function(a){$$("select","embed","object").each(function(b){if(a){b.style.visibility="visible"}else{b.style.visibility="hidden"}})},prepareToShow:function(){if(!this.prepared){this.prepareHistory();this.content.hide();this.showPersistentObjects(false);this.overlay.show();this.container.hide();this.lightbox.show();this.scolloffset=document.viewport.getScrollOffsets();this.htmlOverflowStyle=this.htmlElement.getStyle("overflow");this.htmlElement.setStyle({overflow:"hidden"});this.repositionLightboxAndOverlay();this.repositionSpinner();this.spinner.show();this.prepared=true}},repositionLightboxAndOverlay:function(){var c=document.viewport.getScrollOffsets();var a=document.viewport.getDimensions();var d=this.container.getDimensions();var e=[d.height+this.containerTop,a.height].max();var b=[d.width,a.width].max();this.lightbox.setStyle({top:c.top+"px",left:c.left+"px",width:a.width+"px",height:a.height+"px"});this.overlay.setStyle({left:"0px",top:"0px",height:e+"px",width:b+"px"})},doShow:function(){if(!this.preparedForShow){this.prepareToShow()}this.prepared=false;this.content.show();this.container.setStyle({visibility:"hidden"});this.container.show();if(this.originalContainerWidth==null){this.originalContainerWidth=this.container.getWidth()}this.windowResizeListenerObj=this.windowResizeListener.bindAsEventListener(this);Event.observe(window,"resize",this.windowResizeListenerObj);this.content.observe("lightbox:contentDimensionChanged",this.windowResizeListenerObj);this.lastContentDimensions=this.content.getDimensions();this.contentDimensionChangedRunner=new PeriodicalExecuter(function(e){var f=this.content.getDimensions();if(f.height!=this.lastContentDimensions.height||f.width!=this.lastContentDimensions.width){this.content.fire("lightbox:contentDimensionChanged")}this.lastContentDimensions=this.content.getDimensions()}.bind(this),0.5);var a=-1;var d=this.content.down("div");if(typeof d!="undefined"&&d.identify()!="lightbox_flash_container"&&d.getWidth()>0){var a=d.getWidth()}else{var c=this.content.down();if(c!=null&&typeof c!="undefined"){if(c.tagName=="IMG"){a=c.getWidth();if(a==0){c.observe("load",this.resizeContentToImageSizeListener.bindAsEventListener(this))}}else{if(c.identify()=="lightbox_flash_container"&&c.down()!=null){var b=c.down().getDimensionFromStyle("width");if(b>0){this.lightbox.fire("lightbox:contentReady")}}}}}if(a>0){this.container.setStyle({width:a+this.getContainerHorizontalPadding()+"px"});this.lightbox.fire("lightbox:contentReady")}this.lightbox.fire("lightbox:doShowFinished")},getAndShowContentFromUrl:function(f){if(f==null){alert("No URL provided");return}if(f.match(/\.(jpg|jpeg|png|gif)$/)){var g=new Image();Event.observe(g,"load",function(m){this.showHtml('<img src="'+f+'" alt=""/>')}.bindAsEventListener(this));g.src=f}else{if(f.match(/\.(swf|flv)/)){var h='<div id="lightbox_flash_container"></div>';var l=500;var a=300;if(typeof this.activeElement!="undefined"){var b=this.activeElement.readAttribute("name");if(b!=null&&b.match(/width\d+height\d/)){var d=b.match(/width(\d+)/).last();var k=b.match(/height(\d+)/).last()}}var j=f.match(/.(swf|flv)$/).last();var c="";switch(j){case"swf":c="application/x-shockwave-flash";var e={};break;case"flv":c="video/flv";var i={floatingcontrols:"true"};break}this.lightbox.observe("lightbox:contentUpdated",function(m){if(typeof d!="undefined"&&typeof k!="undefined"){this.insertMediaObject(f,d,k,c,i)}else{var n={service:"mmarchive.fileinfo",fileUrl:f};new Ajax.Request("/xmlhttprequest.php",{parameters:n,onSuccess:function(o){var p=o.responseText.evalJSON();this.insertMediaObject(f,p.width,p.height,c,i)}.bind(this),onFailure:function(){this.insertMediaObject(f,l,a,c,i)}.bind(this)})}}.bindAsEventListener(this));this.showHtml(h)}else{new Ajax.Request(f,{method:"get",onSuccess:function(p){var o=p.responseText;if(o.match(/<body\b/)){var n=o.match(/<div id="placeholder-content">([\s\S]*?)<div id="placeholder-/);if(n==null){var n=o.match(/<div id="placeholder-content-no-right">([\s\S]*?)<div id="placeholder-/)}if(n!=null){var m=n.first();var n=m.match(/([\s\S]*)<\/div>/);o=n.first();o=o.replace("placeholder-content","lightbox-placeholder-content")}}this.content.update(o);this.lightbox.fire("lightbox:contentUpdated");this.doShow()}.bind(this),onFailure:function(m){this.hide();alert("Could not connect to URL")}.bind(this)})}}},insertMediaObject:function(b,c,a,e,d){cpWriteMediaObject(b,"null",c,a,e,0,1,"null","lightbox_flash_container",d,true);this.lightbox.fire("lightbox:cpWriteMediaObjectRun")},repositionSpinner:function(){var b=document.viewport.getScrollOffsets();var a=document.viewport.getDimensions();this.spinner.setStyle({top:b.top+"px",left:b.left+"px",width:a.width+"px",height:a.height+"px"})},setContentWidth:function(a){this.container.setStyle({width:a+this.getContainerHorizontalPadding()+"px"})},contentReadyListener:function(a){this.container.setStyle({visibility:"visible"});this.spinner.hide();this.repositionLightboxAndOverlay()},windowResizeListener:function(a){this.repositionLightboxAndOverlay()},resizeContentToImageSizeListener:function(a){this.setContentWidth(a.element().getHiddenElementDimensions().width);this.lightbox.fire("lightbox:contentReady")},resizeContentToMediaObjectSizeListener:function(b){var a=$("lightbox_flash_container").down();if(a!=null){this.setContentWidth(a.getDimensionFromStyle("width"));this.lightbox.fire("lightbox:contentReady")}},clickToCloseListener:function(a){a.stop();this.hide()}});var lightbox;document.observe("dom:loaded",function(a){lightbox=new Lightbox();lightbox.initializeLightboxAnchors()});var Keywords=Class.create({initialize:function(){this.html="";this.replacements={};this.replacementsMacroCounter=0;this.regExpEscapeChars=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];this.defaultSkipTags=["a","textarea","label","legend","option","title","script","style"]},replaceKeywordsInHtml:function(c,a){if(typeof cpKeywords!="undefined"&&cpKeywords instanceof Object){this.html=c.innerHTML;if(a instanceof Array){for(var b=0;b<a.length;b++){this._replaceStringsWithMacrosByPattern(new RegExp("<"+this._escapeRegExpString(a[b])+".*\\/"+this._escapeRegExpString(a[b])+">","ig"))}}this._replaceStringsWithMacrosByPattern(new RegExp("<[^>]*>","g"));for(var b in cpKeywords){switch(cpKeywords[b]["type"]){case"list":case"link":this._replaceStringsWithMacrosByPattern(new RegExp("\\b"+b+"\\b","ig"),true,'<a class="keyword-replacement keyword-replacement-'+cpKeywords[b]["type"]+" keyword-replacement-"+b.toLowerCase().replace(/[^A-Za-z0-9]/ig,"")+'" href="'+cpKeywords[b]["link"]+'" target="'+cpKeywords[b]["target"]+'" title="'+cpKeywords[b]["explanation"]+'">',"</a>");break;case"title":this._replaceStringsWithMacrosByPattern(new RegExp("\\b"+b+"\\b","ig"),true,'<a class="keyword-replacement keyword-replacement-'+cpKeywords[b]["type"]+" keyword-replacement-"+b.toLowerCase().replace(/[^A-Za-z0-9]/ig,"")+'" href="'+cpKeywords[b]["link"]+'" title="'+cpKeywords[b]["explanation"]+'" onclick="return false;">',"</a>");break}}var d;for(var b in this.replacements){this.html=this.html.replace(new RegExp(b,"g"),this.replacements[b])}c.innerHTML=this.html}},_replaceStringsWithMacrosByPattern:function(e,a,f,g){f=f===undefined?"":f;g=g===undefined?"":g;var d=this.html.match(e);if(d instanceof Array){for(var b=0;b<d.length;b++){var c="::"+this.replacementsMacroCounter+++"::";this.replacements[c]=f+d[b]+g;if(a===true){this.html=this.html.replace(new RegExp("\\b"+this._escapeRegExpString(d[b])+"\\b","ig"),c)}else{this.html=this.html.replace(new RegExp(this._escapeRegExpString(d[b]),"ig"),c)}}}},_escapeRegExpString:function(a){return a.replace(new RegExp("(\\"+this.regExpEscapeChars.join("|\\")+")","g"),"\\$1")}});document.observe("dom:loaded",function(c){var d=getSiteComponentsConfig("keywords","elements",[]);if(d.length>0){var b=new Keywords();for(var a=0;a<d.length;a++){b.replaceKeywordsInHtml($(d[a]),getSiteComponentsConfig("keywords","skiptags",[]))}if(getSiteComponentsConfig("keywords","usetooltip",true)&&typeof CtTooltip!="function"){new CtTooltip(getSiteComponentsConfig("tooltip","positionby","element"))}}});var CtTooltip=Class.create({initialize:function(b){switch(b){case"mouse":b="mouse";break;default:case"element":b="element";break}this.positionBy=b;objBody=document.getElementsByTagName("body").item(0);var c=document.createElement("div");c.setAttribute("id","tooltip");c.style.display="none";c.style.position="absolute";c.style.zIndex="100";objBody.appendChild(c);var a=document.createElement("div");a.setAttribute("id","tooltip-top");c.appendChild(a);var e=document.createElement("div");e.setAttribute("id","tooltip-content");c.appendChild(e);var d=document.createElement("div");d.setAttribute("id","tooltip-bottom");c.appendChild(d);this.tooltip=$("tooltip");this.content=$("tooltip-content");this.topDiv=$("tooltip-top");this.bottomDiv=$("tooltip-bottom");$$("a").each(function(f){this.addTooltipToElement(f)}.bind(this));if(Prototype.Browser.IE&&navigator.appVersion.match(/MSIE 6\.0/)){this.tooltip.setStyle({position:"absolute",width:"50px",whiteSpace:"nowrap"})}},addTooltipToElement:function(b){try{title=b.getAttribute("title");if(title!=null&&title.length>0){b.observe("mouseover",function(c){tooltip.show(b,c)});b.observe("mouseout",function(c){tooltip.hide()});if(this.positionBy=="mouse"){b.observe("mousemove",function(c){tooltip.moveTo(c.pointerX(),c.pointerY())})}}}catch(a){}},show:function(b,c){try{if(b.getAttribute("title").length>0){if(this.visible){this.hide()}this.element=b;this.tooltipText=b.getAttribute("title");b.setAttribute("title","");switch(this.positionBy){case"element":this.moveTo(b.cumulativeOffset()[0],b.cumulativeOffset()[1]);break;case"mouse":default:this.moveTo(c.pointerX(),c.pointerY());break}this.content.update(this.tooltipText);try{this.effect=Effect.Appear("tooltip",{duration:0.25,afterFinish:function(){tooltip.effect=null}})}catch(d){this.tooltip.show()}this.visible=true}}catch(a){}},hide:function(){if(this.visible){if(this.effect!=null){this.effect.cancel();this.effect=null}this.tooltip.hide();this.element.setAttribute("title",this.tooltipText);this.tooltipText=null;this.visible=false}},moveTo:function(b,e){b-=10;e+=20;var c=this.tooltip.getWidth();var a=this.tooltip.getHeight();scrollOffsets=document.viewport.getScrollOffsets();var d={top:scrollOffsets.top,bottom:scrollOffsets.top+document.viewport.getHeight(),left:scrollOffsets.left,right:scrollOffsets.left+document.viewport.getWidth()};flipX=false;if(b+c>d.right){b=d.right-c;flipX=true}flipY=false;if(e+a>d.bottom){e=e-a-30;flipY=true}if(flipY){this.tooltip.addClassName("flipped-y")}else{this.tooltip.removeClassName("flipped-y")}this.tooltip.setStyle({left:b+"px",top:e+"px"})}});document.observe("dom:loaded",function(){window.tooltip=new CtTooltip(getSiteComponentsConfig("tooltip","positionby"))});var CtCookie=Class.create({set:function(d,e,b){if(b){var c=new Date();c.setTime(c.getTime()+(b*24*60*60*1000));var a="; expires="+c.toGMTString()}else{a=""}document.cookie=d+"="+e+a+"; path=/"},get:function(a){nameRe=new RegExp("^\\s?"+a+"=.*");var b=document.cookie.split(";").grep(nameRe).collect(function(c){return c.strip()});if(b.size()>0){return b.first().substring(a.length+1)}else{return null}},clear:function(a){var b=new Date();b.setTime(b.getTime()-1);document.cookie=a+"=; expires="+b.toGMTString()}});var CtFontSize=Class.create({initialize:function(){this.c=new CtCookie()},getAvailableFontSizes:function(){return getSiteComponentsConfig("fontsize","sizes",["10pt","12pt","14pt"])},toggle:function(){var a=this.getCurrentIndex();var c=this.getAvailableFontSizes();var b=null;if(a+1>=c.size()){b=c[0]}else{if(a<0){b=c[0]}else{b=c[a+1]}}this.set(b)},getCurrentIndex:function(){var b=this.getAvailableFontSizes();var a=this.c.get("fontsize");return b.indexOf(a)},set:function(a){this.c.set("fontsize",a);$(document.body).setStyle({fontSize:a})},setByIndex:function(a){var b=this.getAvailableFontSizes();if(a>=0&&a<b.size()){this.set(b[a])}},initializeFromCookie:function(){var a=this.getCurrentIndex();var b=this.getAvailableFontSizes();if(a<0){this.set(b[0])}else{this.set(b[a])}}});var SlideshowTile=Class.create({initialize:function(a){this.element=$(a);this.current=0;this.images=a.select("div.slideshow-image");this.navigation=this.element.select(".slideshow-navigation").first();if(typeof this.navigation!="undefined"){this.thumbnailContainer=this.element.select(".slideshow-thumbnails").first();this.thumbnails=this.thumbnailContainer.childElements();this.navigation.show();this.setActiveThumb(this.images[this.current])}else{this.navigation=null}this.addListeners()},addListeners:function(){this.images.each(function(a){a.down("img").observe("click",this.nextListener.bindAsEventListener(this))}.bind(this));if(this.navigation!=null){this.element.select("a.slideshow-previous").first().observe("click",this.previousListener.bindAsEventListener(this));this.element.select("a.slideshow-next").first().observe("click",this.nextListener.bindAsEventListener(this));this.thumbnailContainer.show();this.thumbnailContainer.select("a").each(function(a){a.observe("click",this.thumbnailListener.bindAsEventListener(this))}.bind(this))}else{this.interval=this.element.select("div.slideshow-interval").first().innerHTML;new PeriodicalExecuter(this.periodicalExecutor.bind(this),this.interval)}},previous:function(){var b=this.current;var a=this.current-1;if(a<0){a=this.images.size()-1}this.fadeFromTo(b,a)},next:function(){var b=this.current;var a=this.current+1;if(a>=this.images.size()){a=0}this.fadeFromTo(b,a)},showElementId:function(a){var b=0;this.images.each(function(f){if(f.id==a){throw $break}b++});var e=this.current;var c=b;try{this.fadeFromTo(e,c)}catch(d){}},setActiveThumb:function(b){if(typeof this.thumbnails=="undefined"){return}var a=b.id.substring(b.id.lastIndexOf("-")+1);this.thumbnails.each(function(e){var d=e.down().readAttribute("href");var c=d.substring(d.lastIndexOf("#show_image_")+12);if(e.hasClassName("active")){e.removeClassName("active")}else{if(a==c){e.addClassName("active")}}}.bind(this))},fadeFromTo:function(f,d){if(f==d){return}toImage=this.images[d];fromImage=this.images[f];var c=Effect.Queues.get("slideshow");if(c.effects.length>0){c.each(function(e){e.cancel();if(e.element==this.images[this.current]){e.element.setOpacity(1);e.element.show()}else{e.element.hide();this.current=f;this.images[f].show();this.images[f].setOpacity(1)}}.bind(this))}this.setActiveThumb(toImage);try{var a=Element.getHiddenElementDimensions(toImage);new Effect.Opacity(fromImage,{to:0,from:1,duration:0.3,queue:{scope:"slideshow"},afterFinish:function(){this.eff=new Effect.Morph(fromImage,{duration:0.1,style:{height:a.height+"px"},queue:{scope:"slideshow"},afterFinish:function(){this.eff=new Effect.Appear(toImage,{duration:0.3,queue:{scope:"slideshow"},afterUpdate:function(g){if(g.currentFrame==0){fromImage.hide();fromImage.setOpacity(1);fromImage.setStyle({height:"auto"});try{var e=toImage.select("div.rating-container");if(e.size()>0){e.each(function(i){if(typeof i.enhancer=="object"){i.enhancer.reinitializeElements()}})}}catch(h){}}}.bind(this)})}})}.bind(this)})}catch(b){fromImage.hide();toImage.show()}this.current=d},nextListener:function(a){a.stop();this.next()},previousListener:function(a){a.stop();this.previous()},thumbnailListener:function(c){c.stop();var a=c.findElement("a").readAttribute("href");var b="image-"+this.element.id+"-"+a.substring(a.lastIndexOf("#show_image")+12);this.showElementId(b)},periodicalExecutor:function(a){this.next()}});var EntityCommentUtil=Class.create({initialize:function(a){this.element=$(a);this.openedPosts=new Object();this.initializeSubPostForms();this.initializeToggleLinks()},initializeToggleLinks:function(){this.element.select("a.toggler").each(function(a){a.observe("click",function(b){b.stop();this.toggleSubpost(b.findElement("a"))}.bindAsEventListener(this))}.bind(this))},toggleSubpost:function(c){var d=c.up(2);var a=d.id.match(/[0-9]+$/).first();d.toggleClassName("collapsed");if(typeof this.openedPosts[a]=="undefined"){var e=new Object();e.post_id=a;e.service="entitycommentpost.getBody";new Ajax.Request("/xmlhttprequest.php",{parameters:e,onSuccess:function(h){var i=h.responseText;var f=$("post-body-"+a);try{f.setStyle({height:f.getHeight()+"px"});f.setOpacity(0);f.setStyle({overflow:"hidden"});f.update(i);this.openedPosts[a]=true;new Effect.Opacity(f,{to:1,from:0,duration:0.5});new Effect.Morph(f,{style:{height:f.scrollHeight+"px"},duration:0.5})}catch(g){f.setStyle({height:"auto",overflow:"auto"});f.setOpacity(1);f.update(i)}}.bind(this)})}else{var b=$("post-body-"+a);if(b.getStyle("height")=="0px"){b.setStyle({height:"auto",overflow:"auto"});b.setOpacity(1)}}},initializeSubPostForms:function(){this.element.select("div.entity-comment-answer button").each(function(a){a.observe("click",this.buttonClickListener.bindAsEventListener(this))}.bind(this))},buttonClickListener:function(d){d.stop();this.parentId=d.element().id.substring(15);var c=$("subpost-entitycomment-form");lightbox.showHtml('<div class="subpost-entitycomment-form">'+c.innerHTML+"</div>");var a=lightbox.content.select("input[name=parentpostid]").first();a.value=this.parentId;var b=lightbox.content.select("div.entitycomment-form-quoted").first();b.update($("post-body-"+this.parentId).innerHTML);this.form=lightbox.content.select("form").first();this.form.observe("submit",this.formSubmitListener.bindAsEventListener(this))},formSubmitListener:function(a){a.stop();new Ajax.Request(this.form.readAttribute("action"),{parameters:this.form.serialize(),onSuccess:function(b){var d=b.responseText.evalJSON();alert(d.message);if(!d.isError){var c=this.form.select("input[name=returnpage]").first().value;c=c.substring(0,c.indexOf("#"));location.href=c}}.bind(this)})}});var DatePicker=Class.create({initialize:function(a){this.element=$(a);this.dateField=this.element.select("input").first();this.popup=this.element.select(".datepicker-popup").first();this.element.select("noscript").first().replace('<a class="datepicker-select"><span>Select date</span></a>');this.openLink=this.element.select("a.datepicker-select").first();this.popup.setStyle({position:"absolute",zIndex:1000});this.initializePopupLinks();this.popup.observe("datepicker:contentChanged",this.initializePopupLinks.bindAsEventListener(this));this.openLink.observe("click",this.openLinkListener.bindAsEventListener(this));Event.observe(document,"click",this.windowClickListener.bindAsEventListener(this));this.openLinkListenerObj=this.openLinkListener.bindAsEventListener(this)},initializePopupLinks:function(){this.popup.select("a.day-link").each(function(a){a.observe("click",function(b){b.stop();this.dateField.value=b.element().hash.substr(10);new Effect.Highlight(this.dateField,{queue:{scope:this.element.id,position:"end",limit:2}});this.hide()}.bindAsEventListener(this))}.bind(this))},openLinkListener:function(b){b.stop();this.popup.setStyle({left:this.openLink.positionedOffset()["left"]+"px",top:this.openLink.positionedOffset()["top"]+"px"});try{new Effect.Grow(this.popup,{direction:"top-left",duration:0.3,queue:{scope:this.element.id,position:"end",limit:1}})}catch(a){this.popup.show()}},hide:function(){this.popup.hide()},windowClickListener:function(a){if(!a.element().descendantOf(this.popup)){this.hide()}}});var CoreFader=Class.create({initialize:function(a,b){this.element=$(a);if(typeof b!="undefined"){this.duration=b}else{this.duration=0.5}},fadeTo:function(a){a=$(a);if(typeof this.effect=="object"&&this.effect.state!="finished"){this.effect.cancel()}this.effect=new Effect.Opacity(this.element,{from:1,to:0,duration:this.duration,queue:"end",limit:1,afterFinish:function(){this.element.update(a.innerHTML);this.effect=new Effect.Opacity(this.element,{from:0,to:1,duration:this.duration,queue:"end",limit:1})}.bind(this)})},fadeBetween:function(b,c){if(typeof c=="undefined"){c=10}var a=(this.duration*2)+c;b.next=function(){if(typeof this.currentIndex=="undefined"){this.currentIndex=0}if(this.currentIndex>=b.length){this.currentIndex=0}this.currentElement=this[this.currentIndex];this.currentIndex++;return this.currentElement}.bind(b);new PeriodicalExecuter(function(d){this.frequency=a;this.fadeTo(b.next())}.bind(this),c)}});var CtFormLightbox=Class.create({initialize:function(a){this.element=a;form=this.element;form.observe("submit",function(c){c.stop();var b=c.element();b.select(".ctwebform-element-validationerror").each(function(d){d.up().removeClassName("ctform-element-container-validationerror");d.remove()});new Ajax.Request(b.readAttribute("action"),{method:b.readAttribute("method"),parameters:b.serialize(),onSuccess:function(d){alert(d.responseText.evalJSON());lightbox.hide()},onFailure:function(e){var d=e.responseText.evalJSON();for(i in d){var f=$("ctwebform-element-"+i);if(f==null){f=$("appbase-form-view-default-"+i)}var g=f.select(".ctwebform-element-validationerror");if(g.size()==0){f.insert({bottom:'<span class="ctwebform-element-validationerror">'+d[i]+"</span>"});f.addClassName("ctform-element-container-validationerror")}new Effect.Pulsate(f,{pulses:1,duration:0.5})}}})})}});document.observe("lightbox:contentUpdated",function(a){lightbox.content.select("form.ctform").each(function(b){new CtFormLightbox(b)})});var SmallCalendarTile=Class.create({initialize:function(a){this.element=$(a);this.initializeLinks();Event.observe(document,"click",function(b){this.closeAllTooltips()}.bind(this));this.element.observe("smallcalendar:contentChanged",this.contentChangedListener.bindAsEventListener(this))},initializeLinks:function(){this.element.select("a.calendar_popup_link").each(function(a){a.observe("click",function(d){d.stop();var c=d.findElement("a");var e=$(c.id.substring(20));if(e.visible()){return}this.closeAllTooltips();e.setStyle({left:(c.positionedOffset()["left"]-11)+"px",top:(c.positionedOffset()["top"]+18)+"px"});try{new Effect.Grow(e,{direction:"top-left",duration:0.3,queue:{scope:this.element.id,limit:1}})}catch(b){e.show()}}.bindAsEventListener(this))}.bind(this))},contentChangedListener:function(a){this.initializeLinks();new Effect.Pulsate(a.element().select("table.calendar-header td").first().next(),{duration:0.3,pulses:1})},closeAllTooltips:function(){$$(".small-calendar-popup").each(function(a){a.hide()})}});var TabbedEntityList=Class.create({initialize:function(a){this.element=a;this.cookie=new CtCookie();this.tabs=a.select("div.tab");this.cookieKey="open_tabs_"+this.element.id;this.tabNum=0;if(this.cookie.get(this.cookieKey)==null){this.activeTab=this.tabs[0]}else{this.activeTab=$(this.cookie.get(this.cookieKey))}this.tabs.each(this.initializeTab.bind(this))},initializeTab:function(a){if(a!=this.activeTab){a.down().next().hide()}a.down().down().observe("click",this.toggleActiveTab.bindAsEventListener(this));this.tabNum++},toggleActiveTab:function(c){c.stop();var e=c.findElement("div");if(this.activeTab!=e){var d=this.activeTab.down().next();var b=e.down().next();try{new Effect.SlideUp(d,{duration:0.2});new Effect.BlindDown(b,{duration:0.2})}catch(a){console.log(a);d.hide();b.show()}this.activeTab=e;this.cookie.set(this.cookieKey,this.activeTab.id)}}});var SuggestionTile=Class.create({initialize:function(a){this.element=$(a);this.form=this.element.select("form").first();this.form.observe("submit",this.formSubmitListener.bindAsEventListener(this))},formSubmitListener:function(a){a.stop();new Ajax.Request(this.form.readAttribute("action"),{parameters:this.form.serialize(),onSuccess:function(b){var c=b.responseText.evalJSON();alert(c.message);if(!c.isError){lightbox.hide()}}.bind(this)})}});var StarRating=Class.create({initialize:function(a){this.container=a;this.numberOfStars=5;this.starBackgroundUrl="/themes/"+getThemeName()+"/images/rating/stars.png";this.starImage=new Image();Event.observe(this.starImage,"load",this.imageLoadListener.bindAsEventListener(this));this.starImage.src=this.starBackgroundUrl},initBoxPosition:function(){var b=this.container.cumulativeOffset();var a=this.container.getDimensions();this.box={left:b.left,top:b.top,right:(b.left+a.width),bottom:(b.top+this.getBackgroundHeight())}},reinitializeElements:function(){this.initStyle();this.initBoxPosition()},getBackgroundWidth:function(){return this.starImage.width},getBackgroundHeight:function(){return this.starImage.height/3},getRatingScale:function(){return this.getBackgroundWidth()/100},getInitialRatingWidth:function(){return this.initialStars*this.getStarWidth()},getStarWidth:function(){return this.getBackgroundWidth()/this.numberOfStars},getStarFromPosition:function(a){var b=a.left-this.box.left;return this.getStarFromWidth(b)},getStarFromWidth:function(a){return Math.ceil(a/this.getStarWidth())},getStarFromRating:function(a){if(a>=80){return 5}else{if(a>=60){return 4}else{if(a>=40){return 3}else{if(a>=20){return 2}else{return 1}}}}},getWidthFromStar:function(a){return a*this.getStarWidth()},initStyle:function(){this.container.setStyle({width:this.getBackgroundWidth()+"px",position:"relative",padding:0,margin:0,background:"none"});this.gray.setStyle({position:"absolute",top:"0px",left:"0px",width:this.getBackgroundWidth()+"px",height:this.getBackgroundHeight()+"px",background:"url("+this.starBackgroundUrl+") no-repeat"});this.blue.setStyle({position:"absolute",top:"0px",left:"0px",height:this.getBackgroundHeight()+"px"});this.yellow.setStyle({position:"absolute",top:"0px",left:"0px",height:this.getBackgroundHeight()+"px"})},setInitialStars:function(){this.blue.setStyle({background:"url("+this.starBackgroundUrl+") no-repeat 0 -"+this.getBackgroundHeight()+"px",width:this.getInitialRatingWidth()+"px"});this.yellow.setStyle({background:"url("+this.starBackgroundUrl+") no-repeat 0 -"+this.getBackgroundHeight()*2+"px",width:"0px"});this.label.setStyle({paddingTop:this.getBackgroundHeight()+"px"})},addListeners:function(){Event.observe(this.container,"mousemove",this.mousemoveListener.bindAsEventListener(this));Event.observe(this.container,"click",this.clickListener.bindAsEventListener(this));Event.observe(this.container,"mouseout",this.mouseoutListener.bindAsEventListener(this))},removeListeners:function(){this.container.stopObserving("mousemove");this.container.stopObserving("mouseout");this.container.stopObserving("click")},setRating:function(d){var a=d.responseText.evalJSON();var b=this.getWidthFromStar(this.getStarFromRating(a.avg));try{new Effect.Fade(this.yellow,{duration:0.1,queue:{position:"end",scope:"starrating"}});new Effect.Appear(this.blue,{duration:0.1,queue:{position:"end",scope:"starrating"}});new Effect.Morph(this.blue,{style:"width: "+b+"px",duration:1,queue:{position:"end",scope:"starrating"}});this.updateLabel(a.count)}catch(c){this.yellow.hide();this.blue.show();this.blue.setStyle({width:b+"px"})}this.removeListeners()},updateLabel:function(b){var a=this.labelText.replace(/\{0\}/,b);this.label.update(a)},handleRatingError:function(a){this.removeListeners();this.cancelEffects();try{new Effect.Fade(this.yellow,{duration:0.2,queue:{position:"end",scope:"starrating"}});new Effect.Appear(this.blue,{duration:0.2,queue:{position:"end",scope:"starrating"}})}catch(b){this.yellow.hide();this.blue.show()}},animate:function(){this.cancelEffects();this.yellow.show();this.yellow.setOpacity(1);if(this.blue.visible()){this.blue.hide()}try{this.mousemoveEffect=new Effect.Morph(this.yellow,{style:"width: "+(this.getStarWidth()*this.hoverStar)+"px",duration:0.1,queue:{position:"end",scope:"starrating"}})}catch(a){this.yellow.setStyle({width:(this.getStarWidth()*this.hoverStar)+"px"})}},pointerInsideBox:function(a){return !(a.pointerX()<=this.box.left||a.pointerY()<=this.box.top||a.pointerX()>=this.box.right||a.pointerY()>=this.box.bottom)},mousemoveListener:function(a){if(this.pointerInsideBox(a)){var c=a.pointerX()-a.element().positionedOffset()["left"];var b=this.getStarFromPosition({left:a.pointerX()});if(this.hoverStar!=b){this.hoverStar=b;if(typeof this.timeout!="undefined"){clearTimeout(this.timeout)}this.animate()}}},mouseoutListener:function(b){if(!this.pointerInsideBox(b)){try{this.cancelEffects();new Effect.Fade(this.yellow,{duration:0.3,queue:{position:"end",scope:"starrating"}});new Effect.Appear(this.blue,{duration:0.3,queue:{position:"end",scope:"starrating"}})}catch(a){this.yellow.setStyle({width:"0px"});this.blue.show()}this.hoverStar=null}},cancelEffects:function(){clearTimeout(this.timeout);try{var a=Effect.Queues.get("starrating");a.each(function(c){c.cancel()})}catch(b){}},clickListener:function(b){var a;switch(this.getStarFromPosition({left:b.pointerX()})){case 1:a=0;break;case 2:a=25;break;case 3:a=50;break;case 4:a=75;break;case 5:a=100;break;default:return;break}this.params.set("rating",a);new Ajax.Request(this.form.getAttribute("action"),{parameters:this.params,onSuccess:this.setRating.bindAsEventListener(this),onFailure:this.handleRatingError.bindAsEventListener(this)})},imageLoadListener:function(a){this.form=this.container.select("form").first();this.params=new Hash(this.form.serialize(true));this.initialStars=this.container.select('input[name="initial_stars"]')[0].value;this.initialRatingCount=this.container.select('input[name="rating_count"]')[0].value;this.labelText=this.container.select('input[name="rating_count_label"]')[0].value;this.gray=$(this.container.update('<div></div><div></div><div></div><div class="rating-label"></div>').firstChild);this.yellow=this.gray.next();this.blue=this.yellow.next();this.label=this.blue.next();this.updateLabel(this.initialRatingCount);this.initStyle();this.setInitialStars();this.addListeners();this.initBoxPosition()}});var RecommendRating=Class.create({initialize:function(a){this.form=$(a.down());this.text=this.form.next();this.initStyle();this.form.observe("submit",this.submitListener.bindAsEventListener(this))},initStyle:function(){this.img=new Image();Event.observe(this.img,"load",this.imageLoadListener.bindAsEventListener(this));this.img.src="/themes/"+getThemeName()+"/images/rating/recommended.png";this.gray=new Image();this.gray.src="/themes/"+getThemeName()+"/images/rating/recommended_gray.png"},updateRecommendationCount:function(b){var a=b.responseText.evalJSON();this.text.down().update(a.amount_with_rating);this.submit.setStyle({background:"url("+this.gray.src+") no-repeat"});this.removeListeners()},removeListeners:function(){this.form.stopObserving("submit");this.form.observe("submit",function(a){a.stop()})},imageLoadListener:function(a){this.submit=this.form.select("input[type=submit]")[0];this.submit.value="";this.submit.setStyle({background:"url("+this.img.src+") no-repeat",border:"0px",width:this.img.width+"px",height:this.img.height+"px"})},submitListener:function(a){a.stop();new Ajax.Request(this.form.getAttribute("action"),{parameters:this.form.serialize(),onSuccess:this.updateRecommendationCount.bindAsEventListener(this)})}});var AgreeDisagreeRating=Class.create({initialize:function(a){this.form=a.down();this.text=this.form.next();this.initStyle();this.agree.observe("click",this.submitListener.bindAsEventListener(this));this.disagree.observe("click",this.submitListener.bindAsEventListener(this))},initStyle:function(){var a=this.form.select("button");this.upIconPath="/themes/"+getThemeName()+"/images/rating/thumb_up.png";this.downIconPath="/themes/"+getThemeName()+"/images/rating/thumb_down.png";this.upIconGrayPath="/themes/"+getThemeName()+"/images/rating/thumb_up_gray.png";this.downIconGrayPath="/themes/"+getThemeName()+"/images/rating/thumb_down_gray.png";this.agree=this.transformButton(a[0],this.upIconPath);this.disagree=this.transformButton(a[1],this.downIconPath)},transformButton:function(c,a){var b=new Image();b.src=a;Event.observe(b,"load",function(d){c.update();c.setStyle({background:"url("+a+") no-repeat",border:"0",width:b.width+"px",height:b.height+"px"})});return c},updateRatingCount:function(b){var a=b.responseText.evalJSON();this.eventTrigger.next().down().update(a.amount_with_rating);this.agree.stopObserving("click");this.disagree.stopObserving("click");this.form.observe("submit",function(c){c.stop()});this.agree.setStyle({background:"url("+this.upIconGrayPath+")"});this.disagree.setStyle({background:"url("+this.downIconGrayPath+")"});new Effect.Shake(this.submit,{distance:100})},submitListener:function(a){a.stop();params=this.form.serialize(true);params.rating=a.element().value;this.eventTrigger=a.element();new Ajax.Request(this.form.getAttribute("action"),{parameters:params,onSuccess:this.updateRatingCount.bindAsEventListener(this),onFailure:function(b){}})}});var OffensiveComment=Class.create({rewriteButtonToLink:function(b){this.element=b;var c=b.down();this.ajaxifyForm(c);var a=b.select("button").first();this.link=b.update('<a href="#offensive">'+a.firstChild.nodeValue+"</a>").down();this.link.observe("click",this.submitListener.bindAsEventListener(this))},ajaxifyForm:function(a){this.parameters=a.serialize();this.serviceUrl=a.readAttribute("action");this.tagOffensiveConfirmText=a.select("input[name=tag_offensive_confirm]")[0].value;this.taggedOffensiveText=a.select("input[name=tagged_offensive]")[0].value;this.button=a.select("button").first();this.button.observe("click",this.submitListener.bindAsEventListener(this))},submitListener:function(a){a.stop();if(confirm(this.tagOffensiveConfirmText)){new Ajax.Request(this.serviceUrl,{parameters:this.parameters,onSuccess:this.successListener.bindAsEventListener(this)})}},successListener:function(c){if(typeof this.button=="undefined"){var a=this.element.update("<span>("+this.taggedOffensiveText+")</span>").down();try{new Effect.Highlight(a)}catch(b){}}else{this.button.disabled=true}}});
