try{if(typeof PanelsBox=="undefined"&&typeof Usefull=="undefined"){var PanelsBox=null,Usefull=null}else{throw {name:"Error de variables",message:"Hay duplicidad de variables."}}Usefull={version:"1.0.3",libVersion:"1.0.1",requiredPrototype:"1.6.1",IE6:navigator.userAgent.match(/MSIE (\d).\d/i)?(RegExp.$1=="6"?true:false):false,convertVersionString:function(a){return parseInt(a.replace(/\./g,""))},testPrototypeVersion:function(a){if(typeof Prototype=="undefined"||typeof Element=="undefined"||typeof Element.Methods=="undefined"||this.convertVersionString(Prototype.Version)<this.convertVersionString(a)){throw {name:"Error de version",message:"Se necesita Prototype >= "+a}}return true}};Usefull.testPrototypeVersion(Usefull.requiredPrototype);PanelsBox=Class.create(Abstract,{initialize:function(a){this.version="1.0.9";this.container=a;this.panels=[];this.jumpers=[];this.previous=null;this.current=null;this.previousIndex=null;this.currentIndex=null;this.options={initial:0,jumperClassName:"PB-jumper",jumpersContainer:null,panelClassName:"PB-panel",selectedClassName:"PB-selected"};document.observe("dom:loaded",this.onLoadDom.bindAsEventListener(this));Event.observe(window,"load",this.onLoadDoc.bindAsEventListener(this))},onLoadDom:function(e){var opts=this.options;this.container=$(this.container);this.panels=this.container.select("."+opts.panelClassName).each(function(panel,index){panel.store("_index",index)});if(!this.panels.length){return}if(opts.jumpersContainer){opts.jumpersContainer=$(opts.jumpersContainer);with(opts.jumpersContainer){this.jumpers=select("."+opts.jumperClassName);setStyle({display:"block"})}with(this.jumpers){if(length){var difJumpers=this.panels.length-length,refclone=null;for(var i=0;i<difJumpers;i++){last().up("li").insert({after:refclone=last().up("li").clone(true)});push(refclone.firstChild)}each(function(jumper,index){jumper.store("_index",index).observe("click",this._click.bindAsEventListener(this))},this)}}}},onLoadDoc:function(b){var a=0;switch(typeof this.options.initial){case"number":a=this.validateIndex(this.options.initial);break;case"string":a=$(this.options.initial).retrieve("_index")}this.show(a)},_click:function(b){var a=b.findElement("a");return a.hasClassName(this.options.selectedClassName)?null:a},show:function(){this.updateCurrent(arguments[0])},updateCurrent:function(){var a=typeof arguments[0]=="number"?this.panels[arguments[0]]:arguments[0];this.previous=this.current;this.current=$(a);if(this.previous){this.previousIndex=this.previous.retrieve("_index")}this.currentIndex=this.current.retrieve("_index")},firstIndex:function(){return 0},lastIndex:function(){return this.panels.length-1},validateIndex:function(a){if(typeof a=="undefined"){alert("El panel al que saltar no est&aacute; definido correctamente.");return this.firstIndex()}return a<this.firstIndex()?this.firstIndex():(a>this.lastIndex()?this.lastIndex():a)},updateJumpers:function(){if(this.options.selectedClassName&&this.jumpers.length&&this.previous){this.jumpers.invoke("removeClassName",this.options.selectedClassName)}}})}catch(e){alert(e.name+": "+e.message)}Element.addMethods({accumulateDimensions:function(b,a){return a.inject(0,function(c,d,f){return c+parseInt($(b).getStyle(d))})},getOnlyWidth:function(a){return $(a).getWidth()-$(a).accumulateDimensions(["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"])},getOnlyHeight:function(a){return $(a).getHeight()-$(a).accumulateDimensions(["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"])}});var CookieJar=Class.create(Abstract,{initialize:function(b){this.appendString="_CJ_";this.options=Object.extend({expires:3600,path:"",domain:"",secure:""},b||{});if(this.options.expires!=""){var a=new Date();a=new Date(a.getTime()+(this.options.expires*1000));this.options.expires="; expires="+a.toGMTString()}if(this.options.path!=""){this.options.path="; path="+escape(this.options.path)}if(this.options.domain!=""){this.options.domain="; domain="+escape(this.options.domain)}if(this.options.secure=="secure"){this.options.secure="; secure"}else{this.options.secure=""}},put:function(name,value){name=this.appendString+name;switch(typeof value){case"undefined":case"function":case"unknown":return false;case"boolean":case"string":case"number":value=String(value.toString())}var cookie_str=name+"="+escape(Object.toJSON(value));try{with(this.options){document.cookie=cookie_str+expires+path+domain+secure}}catch(e){return false}return true},remove:function(c){var d=new RegExp("^"+this.appendString);if(!c.match(d)){c=this.appendString+c}cookie=this.options;try{var b=new Date();b.setTime(b.getTime()-(3600*1000));var a="; expires="+b.toGMTString();document.cookie=c+"="+a+cookie.path+cookie.domain+cookie.secure}catch(f){return false}return true},get:function(a){var b=new RegExp("^"+this.appendString);if(!a.match(b)){a=this.appendString+a}var c=document.cookie.match(a+"=(.*?)(;|$)");if(c){return(unescape(c[1])).evalJSON()}else{return null}},empty:function(){keys=this.getKeys();for(var a=0;a<keys.length;a++){this.remove(keys[a])}},getPack:function(){pack={};keys=this.getKeys();for(var a=0;a<keys.length;a++){pack[keys[a]]=this.get(keys[a])}return pack},getKeys:function(){keys=$A();keyRe=/[^=; ]+(?=\=)/g;str=document.cookie;CJRe=new RegExp("^"+this.appendString);while((match=keyRe.exec(str))!=undefined){if(CJRe.test(match[0].strip())){keys.push(match[0].strip().gsub("^"+this.appendString,""))}}return keys}});
