(function(d){d.tools=d.tools||{version:{}};d.tools.version.scrollable="1.0.5";var f=null;function e(c,v){var F=this;if(!f){f=F;}function u(h,g){d(F).bind(h,function(i,j){if(g&&g.call(this,j.index)===false&&j){j.proceed=false;}});return F;}d.each(v,function(h,g){if(d.isFunction(g)){u(h,g);}});var E=!v.vertical;var C=d(v.items,c);var y=0;function w(g,h){return g.indexOf("#")!=-1?d(g).eq(0):h.siblings(g).eq(0);}var b=w(v.navi,c);var B=w(v.prev,c);var z=w(v.next,c);var A=w(v.prevPage,c);var t=w(v.nextPage,c);d.extend(F,{getIndex:function(){return y;},getConf:function(){return v;},getSize:function(){return F.getItems().size();},getPageAmount:function(){return Math.ceil(this.getSize()/v.size);},getPageIndex:function(){return Math.ceil(y/v.size);},getRoot:function(){return c;},getItemWrap:function(){return C;},getItems:function(){return C.children();},getVisibleItems:function(){return F.getItems().slice(y,y+v.size);},seekTo:function(l,n,h){if(n===undefined){n=v.speed;}if(d.isFunction(n)){h=n;n=v.speed;}if(l<0){l=0;}if(l>F.getSize()-v.size){return F;}var g=F.getItems().eq(l);if(!g.length){return F;}var o={index:l,proceed:true};d(F).trigger("onBeforeSeek",o);if(!o.proceed){return F;}if(E){var m=-g.position().left;C.animate({left:m},n,v.easing,h?function(){h.call(F);}:null);}else{var i=-g.position().top;C.animate({top:i},n,v.easing,h?function(){h.call(F);}:null);}if(b.length){var k=v.activeClass;var j=Math.ceil(l/v.size);j=Math.min(j,b.children().length-1);b.children().removeClass(k).eq(j).addClass(k);}if(l===0){B.add(A).addClass(v.disabledClass);}else{B.add(A).removeClass(v.disabledClass);}if(l>=F.getSize()-v.size){z.add(t).addClass(v.disabledClass);}else{z.add(t).removeClass(v.disabledClass);}f=F;y=l;d(F).trigger("onSeek",{index:l});return F;},move:function(h,i,j){var g=y+h;if(v.loop&&g>(F.getSize()-v.size)){g=0;}return this.seekTo(g,i,j);},next:function(g,h){return this.move(1,g,h);},prev:function(g,h){return this.move(-1,g,h);},movePage:function(g,h,i){return this.move(v.size*g,h,i);},setPage:function(g,l,i){var j=v.size;var k=j*g;var h=k+j>=this.getSize();if(h){k=this.getSize()-v.size;}return this.seekTo(k,l,i);},prevPage:function(g,h){return this.setPage(this.getPageIndex()-1,g,h);},nextPage:function(g,h){return this.setPage(this.getPageIndex()+1,g,h);},begin:function(g,h){return this.seekTo(0,g,h);},end:function(g,h){return this.seekTo(this.getSize()-v.size,g,h);},reload:function(){return a();},click:function(j,g,i){var h=F.getItems().eq(j);var k=v.activeClass;if(j<0||j>=this.getSize()){return F;}if(v.size==2){if(j==F.getIndex()){j--;}F.getItems().removeClass(k);h.addClass(k);return this.seekTo(j,g,i);}if(!h.hasClass(k)){F.getItems().removeClass(k);h.addClass(k);var l=Math.floor(v.size/2);var m=j-l;if(m>F.getSize()-v.size){m=F.getSize()-v.size;}if(m!==j){return this.seekTo(m,g,i);}}return F;},onBeforeSeek:function(g){return u("onBeforeSeek",g);},onSeek:function(g){return u("onSeek",g);}});if(d.isFunction(d.fn.mousewheel)){c.bind("mousewheel.scrollable",function(h,g){var i=d.browser.opera?1:-1;F.move(g>0?i:-i,50);return false;});}B.addClass(v.disabledClass).click(function(){F.prev();});z.click(function(){F.next();});t.click(function(){F.nextPage();});A.addClass(v.disabledClass).click(function(){F.prevPage();});if(v.keyboard){d(document).unbind("keydown.scrollable").bind("keydown.scrollable",function(h){var g=f;if(!g||h.altKey||h.ctrlKey){return;}if(E&&(h.keyCode==37||h.keyCode==39)){g.move(h.keyCode==37?-1:1);return h.preventDefault();}if(!E&&(h.keyCode==38||h.keyCode==40)){g.move(h.keyCode==38?-1:1);return h.preventDefault();}return true;});}function a(){if(b.is(":empty")||b.data("me")==F){b.empty();b.data("me",F);for(var h=0;h<F.getPageAmount();h++){var g=d("<"+v.naviItem+"/>").attr("href",h).click(function(j){var k=d(this);k.parent().children().removeClass(v.activeClass);k.addClass(v.activeClass);F.setPage(k.attr("href"));return j.preventDefault();});if(h===0){g.addClass(v.activeClass);}b.append(g);}}else{var i=b.children();i.each(function(k){var j=d(this);j.attr("href",k);if(k===0){j.addClass(v.activeClass);}j.click(function(){b.find("."+v.activeClass).removeClass(v.activeClass);j.addClass(v.activeClass);F.setPage(j.attr("href"));});});}if(v.clickable){F.getItems().each(function(j,k){var l=d(this);if(!l.data("set")){l.bind("click.scrollable",function(){F.click(j);});l.data("set",true);}});}if(v.hoverClass){F.getItems().hover(function(){d(this).addClass(v.hoverClass);},function(){d(this).removeClass(v.hoverClass);});}return F;}a();var D=null;function x(){if(D){return;}D=setInterval(function(){if(v.interval===0){clearInterval(D);D=0;return;}F.next();},v.interval);}if(v.interval>0){c.hover(function(){clearInterval(D);D=0;},function(){x();});x();}}d.fn.scrollable=function(c){var b=this.eq(typeof c=="number"?c:0).data("scrollable");if(b){return b;}var a={size:5,vertical:false,clickable:true,loop:false,interval:0,speed:400,keyboard:true,activeClass:"active",disabledClass:"disabled",hoverClass:null,easing:"swing",items:".items",prev:".prev",next:".next",prevPage:".prevPage",nextPage:".nextPage",navi:".navi",naviItem:"a",api:false,onBeforeSeek:null,onSeek:null};d.extend(a,c);this.each(function(){b=new e(d(this),a);d(this).data("scrollable",b);});return a.api?b:this;};})(jQuery);$(window).load(function(){var b=document.location.toString();if(b.match("#")){var a=b.split("#")[1];$.scrollTo("a[name="+a+"]",{duration:200});}});$(document).ready(function(){$(".acordeon").find("first:child").addClass("active");$(".acordeon").accordion({header:".entrada",autoheight:false});if($.cookie("noscroll")!=1){var b=1;var a=236;if($.browser.msie&&$.browser.version<=6){$.getScript("/js/lib/ie6scroll.js",function(){$("#scrollpages").scrollFollow({speed:100,offset:20});});}else{if(b==1&&$(window).scrollTop()>a){$("#scrollpages").css("position","fixed");b=2;}$(window).scroll(function(){var c=$(window).scrollTop();if(b==1&&c>a){$("#scrollpages").css("position","fixed");b=2;}else{if(b==2&&c<a){$("#scrollpages").css("position","absolute");b=1;}}});}}$("#togglefav").hover(function(){$(this).addClass("desplegado");$("#favinfo").show();},function(){$(this).removeClass("desplegado");$("#favinfo").hide();});setQuotes();setClickable();$(".galeria").each(function(){var c=new Image();var d=$(this);$(c).load(function(){$(this).wrap('<a href="'+$(this).attr("src").replace(".","_full.")+'" target="_blank"></a>');d.children(".tehimg").append($(this).parent());}).attr("src",$(this).find(".wrapitem:eq(0)").children("div").children("a").attr("href"));});$(".scrollable").scrollable({size:5,hoverClass:"hover"});$(".wrapitem").click(function(){var d=$(this).parents(".galeria");var c=new Image();$(c).load(function(){$(this).wrap('<a href="'+$(this).attr("src").replace(".","_full.")+'" target="_blank"></a>');d.children(".tehimg").html($(this).parent());}).error(function(){d.children(".tehimg").html("No puedo cargar la imagen");}).attr("src",$(this).children("div").children("a").attr("href"));return false;});$(".boxgrid.captionfull").hover(function(){$(".cover",this).stop().animate({top:"34px"},{queue:false,duration:160});},function(){$(".cover",this).stop().animate({top:"54px"},{queue:false,duration:160});});$(".share").tipsy({offsetTop:2});$("#togglefav2");$(".masmola").click(function(){var c=$(this).prev();$.post("/foro/post_mola.php",{token:$("#token").val(),tid:$("#tid").val(),num:$(this).attr("rel")},function(d){var f=false;switch(d){case"1":var e=parseInt(c.text())+1;if(c.css("visibility")=="hidden"){c.text(e);c.css("visibility","visible");}else{c.flash(e);}break;case"-1":f="Ya has votado este post";break;case"-2":f="No puedes votar más posts hoy";break;case"-3":f="Regístrate para votar posts";break;case"-4":f="No puedes votar este post";break;default:f="Se ha producido un error, inténtalo más tarde";break;}if(f){alert(f);}});return false;});});function fav(b){csrftoken=$("#token").val();action=$("#togglefav").attr("rel");if(action=="fav"){var a="Quitar de favoritos";newaction="delfav";}else{var a="A&ntilde;adir a favoritos";newaction="fav";}$.post("/foro/acciones_fav.php",{todo:action,tid:b,token:csrftoken},function(c){if(c==1){if(newaction=="fav"){$("#togglefav").removeClass("fav");$("#togglefav2").removeClass("editfav");}else{$("#togglefav").addClass("fav");$("#togglefav2").addClass("editfav");}$("#togglefav").attr("rel",newaction);$("#favinfo").html(a);}else{if(c==-1){alert("Tu lista de favoritos está llena, borra alguno si quieres añadir más");}else{alert("Error, vuelve a intentarlo más tarde");}}},"text");}function setQuotes(){var b=$("#tid").val();var a=$("#token").val();$("a.quote").tooltip({track:true,delay:0,bodyHandler:function(){$("#tooltip").html("cargando...");num=$(this).attr("rel");getPost(num,b,a);return"cargando...";},showURL:false});$("a.quote").click(function(){num=$(this).attr("rel");if($(this).hasClass("toggled")){$(this).next("div.quote").remove();$(this).removeClass("toggled");$.tooltip.unblock();}else{$(this).addClass("toggled");showPost($(this),num,b,a);$.tooltip.block();}return false;});}var postCache=new Array();var postCacheMax=20;var postCacheSize=0;function showPost(c,a,d,b){if(typeof(postCache[a])!="undefined"&&typeof(postCache[a][1])!="undefined"){c.after('<div class="quote">'+postCache[a][1]+"</div>");}else{$.post("/foro/post_quote.php",{num:a,tid:d,token:b},function(e){postCache[a]=new Array(2);postCache[a][0]=e.min;postCache[a][1]=e.full;postCacheSize++;c.after('<div class="quote">'+e.full+"</div>");},"json");if(postCacheSize>postCacheMax){postCache.splice(0,1);postCacheSize--;}}return true;}function getPost(a,c,b){if(typeof(postCache[a])!="undefined"&&typeof(postCache[a][0])!="undefined"){$("#tooltip").html(postCache[a][0]);}else{$.post("/foro/post_quote.php",{num:a,tid:c,token:b},function(d){postCache[a]=new Array(2);postCache[a][0]=d.min;postCache[a][1]=d.full;postCacheSize++;$("#tooltip").html(d.min);},"json");if(postCacheSize>postCacheMax){postCache.splice(0,1);postCacheSize--;}}}function toggle(a){$("#a"+a).toggleClass("less");$("#"+a).toggle().find(".limit").each(function(){imgLimit($(this));});return false;}function resetLimit(a){$(a).children(".limit").each(function(){$(this).parent().fancybox();});}function setClickable(){var a=400;$(".editable").dblclick(function(){var b=$(this).html();var d=$(this).attr("id").substr(7);var f=$(this).height();var c=$(this);var e=$("#tid").val();if(f<30){f=30;}else{if(f<a){a=f;}}$.post("/foro/post_contents.php",{tid:e,num:d,token:$("#token").val()},function(i){if(i!=""){var g='<div><textarea style="margin: -5px -6px 5px -6px;font-size: 11px;width: 620px; height: '+a+'px;">'+i+'</textarea><input type="hidden" name="num" value="'+d+'">';var h='<div class="mbuttons sbuttons"><button type="button" class="positive right saveButton">Guardar</button> <button type="button" class="negative cancelButton">Cancelar</button></div></div>';$(c).after(g+h).remove();$(".saveButton").click(function(){saveChanges(this,false);});$(".cancelButton").click(function(){saveChanges(this,b);});}else{alert("Error cargando el mensaje");}});});}function saveChanges(f,d){var c=$(f).parent().siblings("input").val();var b="#cuerpo_"+c;var e=$("#tid").val();if(!d){var a=$(f).parent().siblings("textarea").val();$.post("/foro/post_action.php",{cuerpo:a,tid:e,num:c,token:$("#token").val()},function(g){$(f).parent().parent().after('<div id="cuerpo_'+c+'" class="editable">'+g.msg+"</div>").remove();setClickable();},"json");}else{$(f).parent().parent().after('<div id="cuerpo_'+c+'" class="editable">'+d+"</div>").remove();setClickable();}}function favorito(a){$.ajax({url:"/foro/favorito.php",type:"POST",data:"tid="+a,timeout:2000,dataType:"text",error:function(d,c,b){alert(d.responseText);},success:function(b){alert(b);}});}jQuery.fn.flash=function(a){return this.each(function(){jQuery(this).fadeOut(300,function(){jQuery(this).html(a);jQuery(this).fadeIn(300);});});};(function(e){e.ui=e.ui||{};e.fn.extend({accordion:function(h,i){var g=Array.prototype.slice.call(arguments,1);return this.each(function(){if(typeof h=="string"){var j=e.data(this,"ui-accordion");j[h].apply(j,g);}else{if(!e(this).is(".ui-accordion")){e.data(this,"ui-accordion",new e.ui.accordion(this,h));}}});},activate:function(g){return this.accordion("activate",g);}});e.ui.accordion=function(g,h){this.options=h=e.extend({},e.ui.accordion.defaults,h);this.element=g;e(g).addClass("ui-accordion");if(h.navigation){var k=e(g).find("a").filter(h.navigationFilter);if(k.length){if(k.filter(h.header).length){h.active=k;}else{h.active=k.parent().parent().prev();k.addClass("current");}}}h.headers=e(g).find(h.header);h.active=c(h.headers,h.active);if(h.fillSpace){var j=e(g).parent().height();h.headers.each(function(){j-=e(this).outerHeight();});var i=0;h.headers.next().each(function(){i=Math.max(i,e(this).innerHeight()-e(this).height());}).height(j-i);}else{if(h.autoheight){var j=0;h.headers.next().each(function(){j=Math.max(j,e(this).outerHeight());}).height(j);}}h.headers.not(h.active||"").next().hide();h.active.parent().andSelf().addClass(h.selectedClass);if(h.event){e(g).bind((h.event)+".ui-accordion",f);}};e.ui.accordion.prototype={activate:function(g){f.call(this.element,{target:c(this.options.headers,g)[0]});},enable:function(){this.options.disabled=false;},disable:function(){this.options.disabled=true;},destroy:function(){this.options.headers.next().css("display","");if(this.options.fillSpace||this.options.autoheight){this.options.headers.next().css("height","");}e.removeData(this.element,"ui-accordion");e(this.element).removeClass("ui-accordion").unbind(".ui-accordion");}};function b(h,g){return function(){return h.apply(g,arguments);};}function d(i){if(!e.data(this,"ui-accordion")){return;}var g=e.data(this,"ui-accordion");var h=g.options;h.running=i?0:--h.running;if(h.running){return;}if(h.clearStyle){h.toShow.add(h.toHide).css({height:"",overflow:""});}e(this).triggerHandler("change.ui-accordion",[h.data],h.change);}function a(g,k,l,j,m){var i=e.data(this,"ui-accordion").options;i.toShow=g;i.toHide=k;i.data=l;var h=b(d,this);i.running=k.size()==0?g.size():k.size();if(!i.alwaysOpen&&j){g.slideDown("fast");}else{k.slideUp("fast");g.slideDown("fast");}h(true);}function f(l){var j=e.data(this,"ui-accordion").options;if(j.disabled){return false;}if(!l.target&&!j.alwaysOpen){j.active.parent().andSelf().toggleClass(j.selectedClass);var i=j.active.next(),m={instance:this,options:j,newHeader:jQuery([]),oldHeader:j.active,newContent:jQuery([]),oldContent:i},g=j.active=e([]);a.call(this,g,i,m);return false;}var k=e(l.target);if(k.parents(j.header).length){while(!k.is(j.header)){k=k.parent();}}var h=k[0]==j.active[0];if(j.running||(j.alwaysOpen&&h)){return false;}if(!k.is(j.header)){return;}j.active.parent().andSelf().toggleClass(j.selectedClass);if(!h){k.parent().andSelf().addClass(j.selectedClass);}var g=k.next(),i=j.active.next(),m={instance:this,options:j,newHeader:k,oldHeader:j.active,newContent:g,oldContent:i},n=j.headers.index(j.active[0])>j.headers.index(k[0]);j.active=h?e([]):k;a.call(this,g,i,m,h,n);return false;}function c(h,g){return g!=undefined?typeof g=="number"?h.filter(":eq("+g+")"):h.not(h.not(g)):g===false?e([]):h.filter(":eq(0)");}e.extend(e.ui.accordion,{defaults:{selectedClass:"selected",alwaysOpen:true,animated:false,event:"click",header:"a",autoheight:true,running:0,navigationFilter:function(){return this.href.toLowerCase()==location.href.toLowerCase();}}});})(jQuery);