var Paginators={paginators:new Hash(),group:new Hash(),add:function(b,a){this.paginators.set(b,a);if(Object.isUndefined(this.group.get(b))){this.group.set(b,[a])}else{this.group.get(b).push(a)}return a},get:function(a){a=a||"default";return this.paginators.get(a)},getGroup:function(a){a=a||"default";return this.group.get(a)}};var Paginator=Class.create({sliderMinWidth:20,STYLE_SEO:"pagination-seo",STYLE_CLASSIC:"pagination-lite",STYLE_SLIDER:"pagination-slider",initialize:function(e,f,b){this.group=e||"default";
Paginators.add(this.group,this);this.uniqueId=this.group+f;this.handler=b;this.handler.parameters=$H(this.handler.parameters);this.currentPage=this.handler.config.currentPage;this.totalPages=this.handler.config.totalPages;this.page=null;this.refreshPagination=false;this.loading=false;if(this.totalPages>1){this.visible=true}else{this.hide()}var d=/(pagination-(seo|lite|slider))/g;var c=$("paginationContainer_"+this.uniqueId).className;
var a=d.exec(c);if(a){this.style=a[1]}else{this.style=this.STYLE_SLIDER}if(this.style!=this.STYLE_SEO){this.goTo=$("goTo_"+this.uniqueId);if(this.style==this.STYLE_SLIDER){this.initSlider()}}},initSlider:function(){this.navigationBar=$("navigationBar_"+this.uniqueId);this.slider=$("slider_"+this.uniqueId);this.leftArrow=$("left_"+this.uniqueId);this.rightArrow=$("right_"+this.uniqueId);this.pageNumber=$("pageNumber_"+this.uniqueId);
if(this.visible){this.calculateWidths(true)}this.mouseXPos=0;this.clickXPos=0;this.startPos=0},calculateWidths:function(){this.barWidth=this.navigationBar.getWidth();this.sliderWidth=this.barWidth/this.totalPages;if(this.sliderWidth<this.sliderMinWidth){this.sliderWidth=this.sliderMinWidth;this.stepWidth=(this.barWidth-this.sliderWidth)/this.totalPages}else{this.stepWidth=this.sliderWidth}this.slider.style.width=this.sliderWidth+"px";
this.moveSlider("init",this.currentPage)},addListeners:function(a){if(this.style==this.STYLE_SEO){return}if(!a){this.bGoToPage=this.goToPage.bindAsEventListener(this)}if(this.style==this.STYLE_CLASSIC){Event.observe("form_goTo_"+this.uniqueId,"submit",this.bGoToPage)}else{if(!a){this.bClickOnBar=this.clickOnBar.bindAsEventListener(this);this.bMoveLeft=this.moveLeft.bindAsEventListener(this);this.bMoveRight=this.moveRight.bindAsEventListener(this);
this.bMouseDown=this.mouseDown.bindAsEventListener(this)}Event.observe(this.navigationBar.identify(),"mousedown",this.bClickOnBar);Event.observe(this.leftArrow.identify(),"click",this.bMoveLeft);Event.observe(this.rightArrow.identify(),"click",this.bMoveRight);Event.observe("lnk_"+this.goTo.identify(),"click",this.bGoToPage);Event.observe(this.slider.identify(),"mousedown",this.bMouseDown)}},findPos:function(a){var b=curtop=0;
if(a.offsetParent){b=a.offsetLeft;curtop=a.offsetTop;while(a=a.offsetParent){b+=a.offsetLeft;curtop+=a.offsetTop}}return[b,curtop]},getXOffset:function(){var b=this.findPos(this.navigationBar);var a=this.mouseXPos-b[0];if(a<0){a=0}if(a>=this.barWidth){a=this.barWidth}return a},getTargetPage:function(b){switch(b){case"click":var c=this.getXOffset();var d={page:Math.ceil(this.totalPages*(c/this.barWidth)),xOffset:c};
if(d.page>this.currentPage){d.page=this.currentPage+1}if(d.page<this.currentPage){d.page=this.currentPage-1}return d;break;default:var a;if((a=this.startPos+(this.mouseXPos-this.clickXPos))<=this.barWidth&&a>=18){a=(a<(this.barWidth/2)?a-9:a+9);return{page:Math.ceil(this.totalPages*((a-9)/this.barWidth))}}else{if(a<18){return{page:1}}return{page:this.totalPages}}break}},updateCaption:function(a){this.page=a;
$(this.pageNumber).update(a+"/"+this.totalPages)},moveSlider:function(b,d){if(this.style!=this.STYLE_SLIDER){return}var c=(d?{page:parseInt(d)}:this.getTargetPage(b,d));if(!c.page){return null}else{if(b=="click"||d){if(Object.isUndefined(this.stepWidth)){return}this.slider.style.left=(18+(c.page-1)*parseFloat(this.stepWidth))+"px"}else{var a;var e=(this.mouseXPos-this.clickXPos);if((a=this.startPos+e)>18&&a<(this.barWidth-this.sliderWidth+18)){this.slider.style.left=a+"px"
}}}this.currentPage=d;this.updateCaption(c.page)},clickOnBar:function(a){this.mouseXPos=Event.pointerX(a);this.moveSlider("click");this.go()},mouseDown:function(a){Event.stop(a);this.clickXPos=Event.pointerX(a);this.startPos=parseFloat(this.slider.style.left);this.bMouseMove=this.mouseMove.bindAsEventListener(this);this.bMouseUp=this.mouseUp.bindAsEventListener(this);Event.observe(document.body,"mousemove",this.bMouseMove);
Event.observe(document.body,"mouseup",this.bMouseUp)},mouseMove:function(a){this.mouseXPos=Event.pointerX(a);this.moveSlider()},mouseUp:function(a){Event.stopObserving(document.body,"mousemove",this.mouseMoveBinded);if(!this.page){return}Event.stopObserving(document.body,"mousemove",this.bMouseMove);Event.stopObserving(document.body,"mouseup",this.bMouseUp);this.slider.style.left=18+(this.page-1)*this.stepWidth+"px";
this.go()},moveLeft:function(a){if(this.currentPage==1){Event.stop(a);return}var b=this.currentPage;this.slider.style.left=18+(b-2)*this.stepWidth+"px";this.updateCaption(--b);this.go(b)},moveRight:function(a){if(this.currentPage==this.totalPages){Event.stop(a);return}var b=this.currentPage;this.slider.style.left=18+b*this.stepWidth+"px";this.updateCaption(++b);this.go(b)},goToPage:function(b){b.stop();
var a=parseInt(this.goTo.value);if((0<a)&&(a<=this.totalPages)){this.moveSlider("goTo",a);this.go(a)}else{this.goTo.select()}},go:function(page){if(this.loading){return}if(this.style==this.STYLE_CLASSIC){window.location.replace(this.handler.url+"?"+(this.handler.queryString.length?this.handler.queryString+"&":"")+"page="+page);return}this.loading=true;if(!page){page=this.page}var createHandler=eval(this.handler.onCreate)||Prototype.emptyFunction;
var failureHandler=eval(this.handler.onFailure)||Prototype.emptyFunction;this.handler.parameters.set("page",page);this.handler.parameters.set("paginator",this.group);if(this.refreshPagination){this.handler.parameters.unset("cacheId");this.handler.parameters.set("refreshPagination",this.group)}else{this.handler.parameters.unset("refreshPagination")}createHandler(this);this.handler.parameters.each(function(item){if(item.value.toString()=="[object Object]"){this.unset(item.key);
$H(item.value).each(function(it){var newKey=item.key+"["+it.key+"][]";this.set(newKey,it.value)},this)}},this.handler.parameters);var ajaxParameters={method:"get",parameters:this.handler.parameters,onSuccess:function(tr){var successHandler=!(Object.isFunction(this.handler.onSuccess))?eval(this.handler.onSuccess)||Prototype.emptyFunction:this.handler.onSuccess;var response=null;try{response=tr.responseText.evalJSON()
}catch(ex){if(window.console){window.console.error("The pagination response is not a valid JSON")}}this.loading=false;try{successHandler(tr,response);this.handleUpdate(response)}catch(ex){console.log(ex)}}.bind(this),onFailure:function(tr){this.loading=false;failureHandler(tr)}};if(!Object.isUndefined(this.handler.parameters.get("overlayer"))){ajaxParameters.overlayer={id:this.handler.parameters.get("overlayer")}
}else{if(this.handler.update){ajaxParameters.overlayer={id:this.handler.update}}}if(this.handler.message){ajaxParameters.message=this.handler.message}new Ajax.Request(this.handler.url,ajaxParameters);this.currentPage=page;this.updateFriends(page)},handleUpdate:function(a){if(this.handler.update){$(this.handler.update).update(a.results)}if(this.refreshPagination){Paginators.getGroup(this.group).each(function(b){b.rewind(a.handler.config);
b.setParameters(a.handler.parameters)});this.refreshPagination=false}},refresh:function(a){this.refreshPagination=true;if(!Object.isUndefined(a)){if(!Object.isHash(a)){throw ("'newParameters' must be a Hash object!")}this.setParameters(a);this.currentPage=0;var b=a.get("page");if(Object.isUndefined(b)){this.go(1)}else{this.go(b)}}else{this.go(this.currentPage)}},getHandler:function(){return this.handler
},setHandler:function(a){this.handler=a},setParameters:function(a){this.handler.parameters=$H(a);this.handler.queryString=Object.toQueryString(this.handler.parameters)},getParameters:function(){return this.handler.parameters},getCurrentPage:function(){return this.currentPage},updateFriends:function(a){$A(Paginators.getGroup(this.group)).each(function(b){b.moveSlider("goTo",a)})},hide:function(){$("paginationContainer_"+this.uniqueId).hide();
this.visible=false},show:function(){if(this.visible==false){$("paginationContainer_"+this.uniqueId).show();this.visible=true}},rewind:function(a){if(parseInt(a.totalPages)<2){this.hide()}else{this.show();this.totalPages=a.totalPages;this.currentPage=(a.currentPage?a.currentPage:1);this.calculateWidths();this.moveSlider("rewind",(a.currentPage?a.currentPage:1))}},_garbageCollector:function(){Event.stopObserving(this.navigationBar.identify(),"mousedown",this.bClickOnBar);
Event.stopObserving(this.leftArrow.identify(),"click",this.bMoveLeft);Event.stopObserving(this.rightArrow.identify(),"click",this.bMoveRight);Event.stopObserving("lnk_"+this.goTo.identify(),"click",this.bGoToPage);Event.stopObserving(this.slider.identify(),"mousedown",this.bMouseDown)}});String.prototype.parseColor=function(){var a="#";if(this.slice(0,4)=="rgb("){var c=this.slice(4,this.length-1).split(",");
var b=0;do{a+=parseInt(c[b]).toColorPart()}while(++b<3)}else{if(this.slice(0,1)=="#"){if(this.length==4){for(var b=1;b<4;b++){a+=(this.charAt(b)+this.charAt(b)).toLowerCase()}}if(this.length==7){a=this.toLowerCase()}}}return(a.length==7?a:(arguments[0]||this))};Element.collectTextNodes=function(a){return $A($(a).childNodes).collect(function(b){return(b.nodeType==3?b.nodeValue:(b.hasChildNodes()?Element.collectTextNodes(b):""))
}).flatten().join("")};Element.collectTextNodesIgnoreClass=function(a,b){return $A($(a).childNodes).collect(function(c){return(c.nodeType==3?c.nodeValue:((c.hasChildNodes()&&!Element.hasClassName(c,b))?Element.collectTextNodesIgnoreClass(c,b):""))}).flatten().join("")};Element.setContentZoom=function(a,b){a=$(a);a.setStyle({fontSize:(b/100)+"em"});if(Prototype.Browser.WebKit){window.scrollBy(0,0)}return a
};Element.getInlineOpacity=function(a){return $(a).style.opacity||""};Element.forceRerendering=function(a){try{a=$(a);var c=document.createTextNode(" ");a.appendChild(c);a.removeChild(c)}catch(b){}};var Effect={_elementDoesNotExistError:{name:"ElementDoesNotExistError",message:"The specified DOM element does not exist, but is required for this effect to operate"},Transitions:{linear:Prototype.K,sinoidal:function(a){return(-Math.cos(a*Math.PI)/2)+0.5
},reverse:function(a){return 1-a},flicker:function(a){var a=((-Math.cos(a*Math.PI)/4)+0.75)+Math.random()/4;return a>1?1:a},wobble:function(a){return(-Math.cos(a*Math.PI*(9*a))/2)+0.5},pulse:function(b,a){return(-Math.cos((b*((a||5)-0.5)*2)*Math.PI)/2)+0.5},spring:function(a){return 1-(Math.cos(a*4.5*Math.PI)*Math.exp(-a*6))},none:function(a){return 0},full:function(a){return 1}},DefaultOptions:{duration:1,fps:100,sync:false,from:0,to:1,delay:0,queue:"parallel"},tagifyText:function(a){var b="position:relative";
if(Prototype.Browser.IE){b+=";zoom:1"}a=$(a);$A(a.childNodes).each(function(c){if(c.nodeType==3){c.nodeValue.toArray().each(function(d){a.insertBefore(new Element("span",{style:b}).update(d==" "?String.fromCharCode(160):d),c)});Element.remove(c)}})},multiple:function(b,c){var e;if(((typeof b=="object")||Object.isFunction(b))&&(b.length)){e=b}else{e=$(b).childNodes}var a=Object.extend({speed:0.1,delay:0},arguments[2]||{});
var d=a.delay;$A(e).each(function(g,f){new c(g,Object.extend(a,{delay:f*a.speed+d}))})},PAIRS:{slide:["SlideDown","SlideUp"],blind:["BlindDown","BlindUp"],appear:["Appear","Fade"]},toggle:function(b,c){b=$(b);c=(c||"appear").toLowerCase();var a=Object.extend({queue:{position:"end",scope:(b.id||"global"),limit:1}},arguments[2]||{});Effect[b.visible()?Effect.PAIRS[c][1]:Effect.PAIRS[c][0]](b,a)}};Effect.DefaultOptions.transition=Effect.Transitions.sinoidal;
Effect.ScopedQueue=Class.create(Enumerable,{initialize:function(){this.effects=[];this.interval=null},_each:function(a){this.effects._each(a)},add:function(b){var c=new Date().getTime();var a=Object.isString(b.options.queue)?b.options.queue:b.options.queue.position;switch(a){case"front":this.effects.findAll(function(d){return d.state=="idle"}).each(function(d){d.startOn+=b.finishOn;d.finishOn+=b.finishOn
});break;case"with-last":c=this.effects.pluck("startOn").max()||c;break;case"end":c=this.effects.pluck("finishOn").max()||c;break}b.startOn+=c;b.finishOn+=c;if(!b.options.queue.limit||(this.effects.length<b.options.queue.limit)){this.effects.push(b)}if(!this.interval){this.interval=setInterval(this.loop.bind(this),15)}},remove:function(a){this.effects=this.effects.reject(function(b){return b==a});if(this.effects.length==0){clearInterval(this.interval);
this.interval=null}},loop:function(){var c=new Date().getTime();for(var b=0,a=this.effects.length;b<a;b++){this.effects[b]&&this.effects[b].loop(c)}}});Effect.Queues={instances:$H(),get:function(a){if(!Object.isString(a)){return a}return this.instances.get(a)||this.instances.set(a,new Effect.ScopedQueue())}};Effect.Queue=Effect.Queues.get("global");Effect.Base=Class.create({position:null,start:function(a){function b(d,c){return((d[c+"Internal"]?"this.options."+c+"Internal(this);":"")+(d[c]?"this.options."+c+"(this);":""))
}if(a&&a.transition===false){a.transition=Effect.Transitions.linear}this.options=Object.extend(Object.extend({},Effect.DefaultOptions),a||{});this.currentFrame=0;this.state="idle";this.startOn=this.options.delay*1000;this.finishOn=this.startOn+(this.options.duration*1000);this.fromToDelta=this.options.to-this.options.from;this.totalTime=this.finishOn-this.startOn;this.totalFrames=this.options.fps*this.options.duration;
this.render=(function(){function c(e,d){if(e.options[d+"Internal"]){e.options[d+"Internal"](e)}if(e.options[d]){e.options[d](e)}}return function(d){if(this.state==="idle"){this.state="running";c(this,"beforeSetup");if(this.setup){this.setup()}c(this,"afterSetup")}if(this.state==="running"){d=(this.options.transition(d)*this.fromToDelta)+this.options.from;this.position=d;c(this,"beforeUpdate");if(this.update){this.update(d)
}c(this,"afterUpdate")}}})();this.event("beforeStart");if(!this.options.sync){Effect.Queues.get(Object.isString(this.options.queue)?"global":this.options.queue.scope).add(this)}},loop:function(c){if(c>=this.startOn){if(c>=this.finishOn){this.render(1);this.cancel();this.event("beforeFinish");if(this.finish){this.finish()}this.event("afterFinish");return}var b=(c-this.startOn)/this.totalTime,a=(b*this.totalFrames).round();
if(a>this.currentFrame){this.render(b);this.currentFrame=a}}},cancel:function(){if(!this.options.sync){Effect.Queues.get(Object.isString(this.options.queue)?"global":this.options.queue.scope).remove(this)}this.state="finished"},event:function(a){if(this.options[a+"Internal"]){this.options[a+"Internal"](this)}if(this.options[a]){this.options[a](this)}},inspect:function(){var a=$H();for(property in this){if(!Object.isFunction(this[property])){a.set(property,this[property])
}}return"#<Effect:"+a.inspect()+",options:"+$H(this.options).inspect()+">"}});Effect.Parallel=Class.create(Effect.Base,{initialize:function(a){this.effects=a||[];this.start(arguments[1])},update:function(a){this.effects.invoke("render",a)},finish:function(a){this.effects.each(function(b){b.render(1);b.cancel();b.event("beforeFinish");if(b.finish){b.finish(a)}b.event("afterFinish")})}});Effect.Tween=Class.create(Effect.Base,{initialize:function(c,f,e){c=Object.isString(c)?$(c):c;
var b=$A(arguments),d=b.last(),a=b.length==5?b[3]:null;this.method=Object.isFunction(d)?d.bind(c):Object.isFunction(c[d])?c[d].bind(c):function(g){c[d]=g};this.start(Object.extend({from:f,to:e},a||{}))},update:function(a){this.method(a)}});Effect.Event=Class.create(Effect.Base,{initialize:function(){this.start(Object.extend({duration:0},arguments[0]||{}))},update:Prototype.emptyFunction});Effect.Opacity=Class.create(Effect.Base,{initialize:function(b){this.element=$(b);
if(!this.element){throw (Effect._elementDoesNotExistError)}if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){this.element.setStyle({zoom:1})}var a=Object.extend({from:this.element.getOpacity()||0,to:1},arguments[1]||{});this.start(a)},update:function(a){this.element.setOpacity(a)}});Effect.Move=Class.create(Effect.Base,{initialize:function(b){this.element=$(b);if(!this.element){throw (Effect._elementDoesNotExistError)
}var a=Object.extend({x:0,y:0,mode:"relative"},arguments[1]||{});this.start(a)},setup:function(){this.element.makePositioned();this.originalLeft=parseFloat(this.element.getStyle("left")||"0");this.originalTop=parseFloat(this.element.getStyle("top")||"0");if(this.options.mode=="absolute"){this.options.x=this.options.x-this.originalLeft;this.options.y=this.options.y-this.originalTop}},update:function(a){this.element.setStyle({left:(this.options.x*a+this.originalLeft).round()+"px",top:(this.options.y*a+this.originalTop).round()+"px"})
}});Effect.MoveBy=function(b,a,c){return new Effect.Move(b,Object.extend({x:c,y:a},arguments[3]||{}))};Effect.Scale=Class.create(Effect.Base,{initialize:function(b,c){this.element=$(b);if(!this.element){throw (Effect._elementDoesNotExistError)}var a=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:c},arguments[2]||{});this.start(a)
},setup:function(){this.restoreAfterFinish=this.options.restoreAfterFinish||false;this.elementPositioning=this.element.getStyle("position");this.originalStyle={};["top","left","width","height","fontSize"].each(function(b){this.originalStyle[b]=this.element.style[b]}.bind(this));this.originalTop=this.element.offsetTop;this.originalLeft=this.element.offsetLeft;var a=this.element.getStyle("font-size")||"100%";
["em","px","%","pt"].each(function(b){if(a.indexOf(b)>0){this.fontSize=parseFloat(a);this.fontSizeType=b}}.bind(this));this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;this.dims=null;if(this.options.scaleMode=="box"){this.dims=[this.element.offsetHeight,this.element.offsetWidth]}if(/^content/.test(this.options.scaleMode)){this.dims=[this.element.scrollHeight,this.element.scrollWidth]}if(!this.dims){this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth]
}},update:function(a){var b=(this.options.scaleFrom/100)+(this.factor*a);if(this.options.scaleContent&&this.fontSize){this.element.setStyle({fontSize:this.fontSize*b+this.fontSizeType})}this.setDimensions(this.dims[0]*b,this.dims[1]*b)},finish:function(a){if(this.restoreAfterFinish){this.element.setStyle(this.originalStyle)}},setDimensions:function(a,e){var f={};if(this.options.scaleX){f.width=e.round()+"px"
}if(this.options.scaleY){f.height=a.round()+"px"}if(this.options.scaleFromCenter){var c=(a-this.dims[0])/2;var b=(e-this.dims[1])/2;if(this.elementPositioning=="absolute"){if(this.options.scaleY){f.top=this.originalTop-c+"px"}if(this.options.scaleX){f.left=this.originalLeft-b+"px"}}else{if(this.options.scaleY){f.top=-c+"px"}if(this.options.scaleX){f.left=-b+"px"}}}this.element.setStyle(f)}});Effect.Highlight=Class.create(Effect.Base,{initialize:function(b){this.element=$(b);
if(!this.element){throw (Effect._elementDoesNotExistError)}var a=Object.extend({startcolor:"#ffff99"},arguments[1]||{});this.start(a)},setup:function(){if(this.element.getStyle("display")=="none"){this.cancel();return}this.oldStyle={};if(!this.options.keepBackgroundImage){this.oldStyle.backgroundImage=this.element.getStyle("background-image");this.element.setStyle({backgroundImage:"none"})}if(!this.options.endcolor){this.options.endcolor=this.element.getStyle("background-color").parseColor("#ffffff")
}if(!this.options.restorecolor){this.options.restorecolor=this.element.getStyle("background-color")}this._base=$R(0,2).map(function(a){return parseInt(this.options.startcolor.slice(a*2+1,a*2+3),16)}.bind(this));this._delta=$R(0,2).map(function(a){return parseInt(this.options.endcolor.slice(a*2+1,a*2+3),16)-this._base[a]}.bind(this))},update:function(a){this.element.setStyle({backgroundColor:$R(0,2).inject("#",function(b,c,d){return b+((this._base[d]+(this._delta[d]*a)).round().toColorPart())
}.bind(this))})},finish:function(){this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}))}});Effect.ScrollTo=function(c){var b=arguments[1]||{},a=document.viewport.getScrollOffsets(),d=$(c).cumulativeOffset();if(b.offset){d[1]+=b.offset}return new Effect.Tween(null,a.top,d[1],b,function(e){scrollTo(a.left,e.round())})};Effect.Fade=function(c){c=$(c);var a=c.getInlineOpacity();
var b=Object.extend({from:c.getOpacity()||1,to:0,afterFinishInternal:function(d){if(d.options.to!=0){return}d.element.hide().setStyle({opacity:a})}},arguments[1]||{});return new Effect.Opacity(c,b)};Effect.Appear=function(b){b=$(b);var a=Object.extend({from:(b.getStyle("display")=="none"?0:b.getOpacity()||0),to:1,afterFinishInternal:function(c){c.element.forceRerendering()},beforeSetup:function(c){c.element.setOpacity(c.options.from).show()
}},arguments[1]||{});return new Effect.Opacity(b,a)};Effect.Puff=function(b){b=$(b);var a={opacity:b.getInlineOpacity(),position:b.getStyle("position"),top:b.style.top,left:b.style.left,width:b.style.width,height:b.style.height};return new Effect.Parallel([new Effect.Scale(b,200,{sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true}),new Effect.Opacity(b,{sync:true,to:0})],Object.extend({duration:1,beforeSetupInternal:function(c){Position.absolutize(c.effects[0].element)
},afterFinishInternal:function(c){c.effects[0].element.hide().setStyle(a)}},arguments[1]||{}))};Effect.BlindUp=function(a){a=$(a);a.makeClipping();return new Effect.Scale(a,0,Object.extend({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(b){b.element.hide().undoClipping()}},arguments[1]||{}))};Effect.BlindDown=function(b){b=$(b);var a=b.getDimensions();return new Effect.Scale(b,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:a.height,originalWidth:a.width},restoreAfterFinish:true,afterSetup:function(c){c.element.makeClipping().setStyle({height:"0px"}).show()
},afterFinishInternal:function(c){c.element.undoClipping()}},arguments[1]||{}))};Effect.SwitchOff=function(b){b=$(b);var a=b.getInlineOpacity();return new Effect.Appear(b,Object.extend({duration:0.4,from:0,transition:Effect.Transitions.flicker,afterFinishInternal:function(c){new Effect.Scale(c.element,1,{duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetup:function(d){d.element.makePositioned().makeClipping()
},afterFinishInternal:function(d){d.element.hide().undoClipping().undoPositioned().setStyle({opacity:a})}})}},arguments[1]||{}))};Effect.DropOut=function(b){b=$(b);var a={top:b.getStyle("top"),left:b.getStyle("left"),opacity:b.getInlineOpacity()};return new Effect.Parallel([new Effect.Move(b,{x:0,y:100,sync:true}),new Effect.Opacity(b,{sync:true,to:0})],Object.extend({duration:0.5,beforeSetup:function(c){c.effects[0].element.makePositioned()
},afterFinishInternal:function(c){c.effects[0].element.hide().undoPositioned().setStyle(a)}},arguments[1]||{}))};Effect.Shake=function(d){d=$(d);var b=Object.extend({distance:20,duration:0.5},arguments[1]||{});var e=parseFloat(b.distance);var c=parseFloat(b.duration)/10;var a={top:d.getStyle("top"),left:d.getStyle("left")};return new Effect.Move(d,{x:e,y:0,duration:c,afterFinishInternal:function(f){new Effect.Move(f.element,{x:-e*2,y:0,duration:c*2,afterFinishInternal:function(g){new Effect.Move(g.element,{x:e*2,y:0,duration:c*2,afterFinishInternal:function(h){new Effect.Move(h.element,{x:-e*2,y:0,duration:c*2,afterFinishInternal:function(i){new Effect.Move(i.element,{x:e*2,y:0,duration:c*2,afterFinishInternal:function(j){new Effect.Move(j.element,{x:-e,y:0,duration:c,afterFinishInternal:function(k){k.element.undoPositioned().setStyle(a)
}})}})}})}})}})}})};Effect.SlideDown=function(c){c=$(c).cleanWhitespace();var a=c.down().getStyle("bottom");var b=c.getDimensions();return new Effect.Scale(c,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:window.opera?0:1,scaleMode:{originalHeight:b.height,originalWidth:b.width},restoreAfterFinish:true,afterSetup:function(d){d.element.makePositioned();d.element.down().makePositioned();
if(window.opera){d.element.setStyle({top:""})}d.element.makeClipping().setStyle({height:"0px"}).show()},afterUpdateInternal:function(d){d.element.down().setStyle({bottom:(d.dims[0]-d.element.clientHeight)+"px"})},afterFinishInternal:function(d){d.element.undoClipping().undoPositioned();d.element.down().undoPositioned().setStyle({bottom:a})}},arguments[1]||{}))};Effect.SlideUp=function(c){c=$(c).cleanWhitespace();
var a=c.down().getStyle("bottom");var b=c.getDimensions();return new Effect.Scale(c,window.opera?0:1,Object.extend({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,scaleMode:{originalHeight:b.height,originalWidth:b.width},restoreAfterFinish:true,afterSetup:function(d){d.element.makePositioned();d.element.down().makePositioned();if(window.opera){d.element.setStyle({top:""})}d.element.makeClipping().show()
},afterUpdateInternal:function(d){d.element.down().setStyle({bottom:(d.dims[0]-d.element.clientHeight)+"px"})},afterFinishInternal:function(d){d.element.hide().undoClipping().undoPositioned();d.element.down().undoPositioned().setStyle({bottom:a})}},arguments[1]||{}))};Effect.Squish=function(a){return new Effect.Scale(a,window.opera?1:0,{restoreAfterFinish:true,beforeSetup:function(b){b.element.makeClipping()
},afterFinishInternal:function(b){b.element.hide().undoClipping()}})};Effect.Grow=function(c){c=$(c);var b=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.full},arguments[1]||{});var a={top:c.style.top,left:c.style.left,height:c.style.height,width:c.style.width,opacity:c.getInlineOpacity()};
var g=c.getDimensions();var h,f;var e,d;switch(b.direction){case"top-left":h=f=e=d=0;break;case"top-right":h=g.width;f=d=0;e=-g.width;break;case"bottom-left":h=e=0;f=g.height;d=-g.height;break;case"bottom-right":h=g.width;f=g.height;e=-g.width;d=-g.height;break;case"center":h=g.width/2;f=g.height/2;e=-g.width/2;d=-g.height/2;break}return new Effect.Move(c,{x:h,y:f,duration:0.01,beforeSetup:function(i){i.element.hide().makeClipping().makePositioned()
},afterFinishInternal:function(i){new Effect.Parallel([new Effect.Opacity(i.element,{sync:true,to:1,from:0,transition:b.opacityTransition}),new Effect.Move(i.element,{x:e,y:d,sync:true,transition:b.moveTransition}),new Effect.Scale(i.element,100,{scaleMode:{originalHeight:g.height,originalWidth:g.width},sync:true,scaleFrom:window.opera?1:0,transition:b.scaleTransition,restoreAfterFinish:true})],Object.extend({beforeSetup:function(j){j.effects[0].element.setStyle({height:"0px"}).show()
},afterFinishInternal:function(j){j.effects[0].element.undoClipping().undoPositioned().setStyle(a)}},b))}})};Effect.Shrink=function(c){c=$(c);var b=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.none},arguments[1]||{});var a={top:c.style.top,left:c.style.left,height:c.style.height,width:c.style.width,opacity:c.getInlineOpacity()};
var f=c.getDimensions();var e,d;switch(b.direction){case"top-left":e=d=0;break;case"top-right":e=f.width;d=0;break;case"bottom-left":e=0;d=f.height;break;case"bottom-right":e=f.width;d=f.height;break;case"center":e=f.width/2;d=f.height/2;break}return new Effect.Parallel([new Effect.Opacity(c,{sync:true,to:0,from:1,transition:b.opacityTransition}),new Effect.Scale(c,window.opera?1:0,{sync:true,transition:b.scaleTransition,restoreAfterFinish:true}),new Effect.Move(c,{x:e,y:d,sync:true,transition:b.moveTransition})],Object.extend({beforeStartInternal:function(g){g.effects[0].element.makePositioned().makeClipping()
},afterFinishInternal:function(g){g.effects[0].element.hide().undoClipping().undoPositioned().setStyle(a)}},b))};Effect.Pulsate=function(c){c=$(c);var b=arguments[1]||{},a=c.getInlineOpacity(),e=b.transition||Effect.Transitions.linear,d=function(f){return 1-e((-Math.cos((f*(b.pulses||5)*2)*Math.PI)/2)+0.5)};return new Effect.Opacity(c,Object.extend(Object.extend({duration:2,from:0,afterFinishInternal:function(f){f.element.setStyle({opacity:a})
}},b),{transition:d}))};Effect.Fold=function(b){b=$(b);var a={top:b.style.top,left:b.style.left,width:b.style.width,height:b.style.height};b.makeClipping();return new Effect.Scale(b,5,Object.extend({scaleContent:false,scaleX:false,afterFinishInternal:function(c){new Effect.Scale(b,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(d){d.element.hide().undoClipping().setStyle(a)}})}},arguments[1]||{}))
};Effect.Morph=Class.create(Effect.Base,{initialize:function(c){this.element=$(c);if(!this.element){throw (Effect._elementDoesNotExistError)}var a=Object.extend({style:{}},arguments[1]||{});if(!Object.isString(a.style)){this.style=$H(a.style)}else{if(a.style.include(":")){this.style=a.style.parseStyle()}else{this.element.addClassName(a.style);this.style=$H(this.element.getStyles());this.element.removeClassName(a.style);
var b=this.element.getStyles();this.style=this.style.reject(function(d){return d.value==b[d.key]});a.afterFinishInternal=function(d){d.element.addClassName(d.options.style);d.transforms.each(function(e){d.element.style[e.style]=""})}}}this.start(a)},setup:function(){function a(b){if(!b||["rgba(0, 0, 0, 0)","transparent"].include(b)){b="#ffffff"}b=b.parseColor();return $R(0,2).map(function(c){return parseInt(b.slice(c*2+1,c*2+3),16)
})}this.transforms=this.style.map(function(g){var f=g[0],e=g[1],d=null;if(e.parseColor("#zzzzzz")!="#zzzzzz"){e=e.parseColor();d="color"}else{if(f=="opacity"){e=parseFloat(e);if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){this.element.setStyle({zoom:1})}}else{if(Element.CSS_LENGTH.test(e)){var c=e.match(/^([\+\-]?[0-9\.]+)(.*)$/);e=parseFloat(c[1]);d=(c.length==3)?c[2]:null}}}var b=this.element.getStyle(f);
return{style:f.camelize(),originalValue:d=="color"?a(b):parseFloat(b||0),targetValue:d=="color"?a(e):e,unit:d}}.bind(this)).reject(function(b){return((b.originalValue==b.targetValue)||(b.unit!="color"&&(isNaN(b.originalValue)||isNaN(b.targetValue))))})},update:function(a){var d={},b,c=this.transforms.length;while(c--){d[(b=this.transforms[c]).style]=b.unit=="color"?"#"+(Math.round(b.originalValue[0]+(b.targetValue[0]-b.originalValue[0])*a)).toColorPart()+(Math.round(b.originalValue[1]+(b.targetValue[1]-b.originalValue[1])*a)).toColorPart()+(Math.round(b.originalValue[2]+(b.targetValue[2]-b.originalValue[2])*a)).toColorPart():(b.originalValue+(b.targetValue-b.originalValue)*a).toFixed(3)+(b.unit===null?"":b.unit)
}this.element.setStyle(d,true)}});Effect.Transform=Class.create({initialize:function(a){this.tracks=[];this.options=arguments[1]||{};this.addTracks(a)},addTracks:function(a){a.each(function(b){b=$H(b);var c=b.values().first();this.tracks.push($H({ids:b.keys().first(),effect:Effect.Morph,options:{style:c}}))}.bind(this));return this},play:function(){return new Effect.Parallel(this.tracks.map(function(a){var d=a.get("ids"),c=a.get("effect"),b=a.get("options");
var e=[$(d)||$$(d)].flatten();return e.map(function(f){return new c(f,Object.extend({sync:true},b))})}).flatten(),this.options)}});Element.CSS_PROPERTIES=$w("backgroundColor backgroundPosition borderBottomColor borderBottomStyle borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth borderRightColor borderRightStyle borderRightWidth borderSpacing borderTopColor borderTopStyle borderTopWidth bottom clip color fontSize fontWeight height left letterSpacing lineHeight marginBottom marginLeft marginRight marginTop markerOffset maxHeight maxWidth minHeight minWidth opacity outlineColor outlineOffset outlineWidth paddingBottom paddingLeft paddingRight paddingTop right textIndent top width wordSpacing zIndex");
Element.CSS_LENGTH=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;String.__parseStyleElement=document.createElement("div");String.prototype.parseStyle=function(){var b,a=$H();if(Prototype.Browser.WebKit){b=new Element("div",{style:this}).style}else{String.__parseStyleElement.innerHTML='<div style="'+this+'"></div>';b=String.__parseStyleElement.childNodes[0].style}Element.CSS_PROPERTIES.each(function(c){if(b[c]){a.set(c,b[c])
}});if(Prototype.Browser.IE&&this.include("opacity")){a.set("opacity",this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1])}return a};if(document.defaultView&&document.defaultView.getComputedStyle){Element.getStyles=function(b){var a=document.defaultView.getComputedStyle($(b),null);return Element.CSS_PROPERTIES.inject({},function(c,d){c[d]=a[d];return c})}}else{Element.getStyles=function(b){b=$(b);var a=b.currentStyle,c;
c=Element.CSS_PROPERTIES.inject({},function(d,e){d[e]=a[e];return d});if(!c.opacity){c.opacity=b.getOpacity()}return c}}Effect.Methods={morph:function(a,b){a=$(a);new Effect.Morph(a,Object.extend({style:b},arguments[2]||{}));return a},visualEffect:function(c,e,b){c=$(c);var d=e.dasherize().camelize(),a=d.charAt(0).toUpperCase()+d.substring(1);new Effect[a](c,b);return c},highlight:function(b,a){b=$(b);
new Effect.Highlight(b,a);return b}};$w("fade appear grow shrink fold blindUp blindDown slideUp slideDown pulsate shake puff squish switchOff dropOut").each(function(a){Effect.Methods[a]=function(c,b){c=$(c);Effect[a.charAt(0).toUpperCase()+a.substring(1)](c,b);return c}});$w("getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles").each(function(a){Effect.Methods[a]=Element[a]
});Element.addMethods(Effect.Methods);Object.extend(Event,(function(){var a={};return{delegate:function(d,c){var g={};if(arguments[3]){g[arguments[2]]=arguments[3]}else{g=Object.extend({},arguments[2])}var e=$(d),f=c,h=e.identify?e.identify():"document";if(!a[h]){a[h]={"$observer":function(n){var m=n.element();if(a[h][n.type]){for(var l=0,k=a[h][n.type].length;l<k;l++){for(var j in a[h][n.type][l]){if(a[h][n.type][l][j][1].match(m)){a[h][n.type][l][j][0](n)
}}}}}}}if(!a[h][f]){a[h][f]=[];e.observe(f,a[h]["$observer"])}for(var b in g){g[b]=[g[b],new Selector(b)]}a[h][f].push(g);return e},stopDelegating:function(f,h){if(f===undefined){for(var b in a){Event.stopDelegating(b=="$document"?document:b)}a={};return true}var l=false;if(Object.isString(arguments[2])){l={};l[arguments[2]]=true}else{if(arguments[2]){l=arguments[2]}}var d=$(f),k=h,b=d.identify?d.identify():"$document";
if(a[b]){if(k&&a[b][k]){for(var g=0,j=a[b][k].length;g<j;g++){if(l){for(var e in l){delete a[b][k][g][e]}}if(!l||$H(a[b][k][g]).any()==false){d.stopObserving(k,a[b]["$observer"]);a[b][k][g]="r"}}a[b][k]=a[b][k].without("r")}else{for(var c in a[b]){if(c!="$observer"){d.stopObserving(c,a[b]["$observer"])}}delete a[b]}}return d}}})());Element.addMethods({delegate:Event.delegate,stopDelegating:Event.stopDelegating});
document.delegate=Event.delegate.curry(document);document.stopDelegating=Event.stopDelegating.curry(document);Event.observe(window,"unload",Event.stopDelegating);document.observe("dom:loaded",function(){document.delegate("click",{".vote":voteItem,"#show-awards":showAwards,"#show-rules":showRules})});function showAwards(a){Chat.Confirm.show($("awards").innerHTML,{title:"Jungla sentimentelor",center:true,modal:true,height:280,width:600,zIndex:10})
}function showRules(a){Chat.Confirm.show($("rules").innerHTML,{title:"Jungla sentimentelor",center:true,modal:true,height:380,width:600,zIndex:10})}function voteItem(a){if(a.button==0){var b=Event.element(a);new Ajax.Request("/jungla/index/vote-story.ajax",{method:"POST",parameters:{story:$("story_id").readAttribute("value"),mark:b.readAttribute("title")},asynchronous:true,onSuccess:function(d){var c=d.responseText.evalJSON();
if(!c.success){if(c.reason=="bad"){$("message").innerHTML="Nota "+b.readAttribute("title")+" nu este valida!"}Chat.Confirm.show($("forbidden").innerHTML,{title:"Jungla sentimentelor",center:true,modal:true,height:100,width:300,zIndex:10})}else{markStars(c);Chat.Confirm.show($("allow").innerHTML,{title:"Jungla sentimentelor",center:true,modal:true,height:100,width:300,zIndex:10})}}})}}function markStars(b){var a=$w($("voteItem").className);
$("voteItem").removeClassName(a[1]);var c=Math.floor(b.average);$("voteItem").addClassName("star_"+c.toString());$("votesNr").innerHTML=b.votes;$("votesAvg").innerHTML=parseFloat(b.average).toFixed(2)}function addStory(a){$(a).submit()}function changeEmailText(a,b){if(a.value==b){a.value=""}}function trim(a){newstring=a.replace(/^(\s)*/,"");newstring=newstring.replace(/(\s)*$/,"");return newstring}if($("recommend")){$("recommend").observe("click",respondToClick)
}function respondToClick(d){var b=$("emailFriend").value;var c=$("email").value;var a=$("name").value;$("invalidEmail").hide();$("invalidName").hide();$("errorRecommandation").hide();$("succesRecommandation").hide();if(b.match(/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/)==null||c.match(/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/)==null){$("invalidEmail").show()
}else{if(trim(a)==""){$("invalidName").show()}else{new Ajax.Request("/jungla/send-mail.ajax",{method:"POST",parameters:{name:a,email:b,myemail:c,contentid:$("contentId").value},onSuccess:function(e){$("succesRecommandation").show()},onFailure:function(){$("errorRecommandation").show()}})}}};