var Prototype={Version:'1.6.0.2',Browser:{IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,WebKit:navigator.userAgent.indexOf('AppleWebKit/')>-1,Gecko:navigator.userAgent.indexOf('Gecko')>-1&&navigator.userAgent.indexOf('KHTML')==-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)},BrowserFeatures:{XPath:!!document.evaluate,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:document.createElement('div').__proto__&&document.createElement('div').__proto__!==document.createElement('form').__proto__},ScriptFragment:']*>([\\S\\s]*?)<\/script>',JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){},K:function(x){return x}};if(Prototype.Browser.MobileSafari)Prototype.BrowserFeatures.SpecificElementExtensions=false;var Class={create:function(){var a=null,properties=$A(arguments);if(Object.isFunction(properties[0]))a=properties.shift();function klass(){this.initialize.apply(this,arguments)}Object.extend(klass,Class.Methods);klass.superclass=a;klass.subclasses=[];if(a){var b=function(){};b.prototype=a.prototype;klass.prototype=new b;a.subclasses.push(klass)}for(var i=0;i0){if(match=source.match(a)){c+=source.slice(0,match.index);c+=String.interpret(b(match));source=source.slice(match.index+match[0].length)}else{c+=source,source=''}}return c},sub:function(b,c,d){c=this.gsub.prepareReplacement(c);d=Object.isUndefined(d)?1:d;return this.gsub(b,function(a){if(--d<0)return a[0];return c(a)})},scan:function(a,b){this.gsub(a,b);return String(this)},truncate:function(a,b){a=a||30;b=Object.isUndefined(b)?'...':b;return this.length>a?this.slice(0,a-b.length)+b:String(this)},strip:function(){return this.replace(/^\s+/,'').replace(/\s+$/,'')},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,'')},stripScripts:function(){return this.replace(new RegExp(Prototype.ScriptFragment,'img'),'')},extractScripts:function(){var b=new RegExp(Prototype.ScriptFragment,'img');var c=new RegExp(Prototype.ScriptFragment,'im');return(this.match(b)||[]).map(function(a){return(a.match(c)||['',''])[1]})},evalScripts:function(){return this.extractScripts().map(function(a){return eval(a)})},escapeHTML:function(){var a=arguments.callee;a.text.data=this;return a.div.innerHTML},unescapeHTML:function(){var c=new Element('div');c.innerHTML=this.stripTags();return c.childNodes[0]?(c.childNodes.length>1?$A(c.childNodes).inject('',function(a,b){return a+b.nodeValue}):c.childNodes[0].nodeValue):''},toQueryParams:function(e){var f=this.strip().match(/([^?#]*)(#.*)?$/);if(!f)return{};return f[1].split(e||'&').inject({},function(a,b){if((b=b.split('='))[0]){var c=decodeURIComponent(b.shift());var d=b.length>1?b.join('='):b[0];if(d!=undefined)d=decodeURIComponent(d);if(c in a){if(!Object.isArray(a[c]))a[c]=[a[c]];a[c].push(d)}else a[c]=d}return a})},toArray:function(){return this.split('')},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)},times:function(a){return a<1?'':new Array(a+1).join(this)},camelize:function(){var a=this.split('-'),len=a.length;if(len==1)return a[0];var b=this.charAt(0)=='-'?a[0].charAt(0).toUpperCase()+a[0].substring(1):a[0];for(var i=1;i-1},startsWith:function(a){return this.indexOf(a)===0},endsWith:function(a){var d=this.length-a.length;return d>=0&&this.lastIndexOf(a)===d},empty:function(){return this==''},blank:function(){return/^\s*$/.test(this)},interpolate:function(a,b){return new Template(this,b).evaluate(a)}});if(Prototype.Browser.WebKit||Prototype.Browser.IE)Object.extend(String.prototype,{escapeHTML:function(){return this.replace(/&/g,'&').replace(//g,'>')},unescapeHTML:function(){return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>')}});String.prototype.gsub.prepareReplacement=function(b){if(Object.isFunction(b))return b;var c=new Template(b);return function(a){return c.evaluate(a)}};String.prototype.parseQuery=String.prototype.toQueryParams;Object.extend(String.prototype.escapeHTML,{div:document.createElement('div'),text:document.createTextNode('')});with(String.prototype.escapeHTML)div.appendChild(text);var Template=Class.create({initialize:function(a,b){this.template=a.toString();this.pattern=b||Template.Pattern},evaluate:function(f){if(Object.isFunction(f.toTemplateReplacements))f=f.toTemplateReplacements();return this.template.gsub(this.pattern,function(a){if(f==null)return'';var b=a[1]||'';if(b=='\\')return a[2];var c=f,expr=a[3];var d=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;a=d.exec(expr);if(a==null)return b;while(a!=null){var e=a[1].startsWith('[')?a[2].gsub('\\\\]',']'):a[1];c=c[e];if(null==c||''==a[3])break;expr=expr.substring('['==a[3]?a[1].length:a[0].length);a=d.exec(expr)}return b+String.interpret(c)})}});Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;var $break={};var Enumerable={each:function(b,c){var d=0;b=b.bind(c);try{this._each(function(a){b(a,d++)})}catch(e){if(e!=$break)throw e;}return this},eachSlice:function(a,b,c){b=b?b.bind(c):Prototype.K;var d=-a,slices=[],array=this.toArray();while((d+=a)=e)e=a});return e},min:function(c,d){c=c?c.bind(d):Prototype.K;var e;this.each(function(a,b){a=c(a,b);if(e==null||ab?1:0}).pluck('value')},toArray:function(){return this.map()},zip:function(){var c=Prototype.K,args=$A(arguments);if(Object.isFunction(args.last()))c=args.pop();var d=[this].concat(args).map($A);return this.map(function(a,b){return c(d.pluck(b))})},size:function(){return this.toArray().length},inspect:function(){return'#'}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,filter:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray,every:Enumerable.all,some:Enumerable.any});function $A(a){if(!a)return[];if(a.toArray)return a.toArray();var b=a.length||0,results=new Array(b);while(b--)results[b]=a[b];return results}if(Prototype.Browser.WebKit){$A=function(a){if(!a)return[];if(!(Object.isFunction(a)&&a=='[object NodeList]')&&a.toArray)return a.toArray();var b=a.length||0,results=new Array(b);while(b--)results[b]=a[b];return results}}Array.from=$A;Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse)Array.prototype._reverse=Array.prototype.reverse;Object.extend(Array.prototype,{_each:function(a){for(var i=0,length=this.length;i1?this:this[0]},uniq:function(d){return this.inject([],function(a,b,c){if(0==c||(d?a.last()!=b:!a.include(b)))a.push(b);return a})},intersect:function(c){return this.uniq().findAll(function(b){return c.detect(function(a){return b===a})})},clone:function(){return[].concat(this)},size:function(){return this.length},inspect:function(){return'['+this.map(Object.inspect).join(', ')+']'},toJSON:function(){var c=[];this.each(function(a){var b=Object.toJSON(a);if(!Object.isUndefined(b))c.push(b)});return'['+c.join(', ')+']'}});if(Object.isFunction(Array.prototype.forEach))Array.prototype._each=Array.prototype.forEach;if(!Array.prototype.indexOf)Array.prototype.indexOf=function(a,i){i||(i=0);var b=this.length;if(i<0)i=b+i;for(;i'},toJSON:function(){return Object.toJSON(this.toObject())},clone:function(){return new Hash(this)}}})());Hash.prototype.toTemplateReplacements=Hash.prototype.toObject;Hash.from=$H;var ObjectRange=Class.create(Enumerable,{initialize:function(a,b,c){this.start=a;this.end=b;this.exclusive=c},_each:function(a){var b=this.start;while(this.include(b)){a(b);b=b.succ()}},include:function(a){if(a1&&!((a==4)&&this._complete))this.respondToReadyState(this.transport.readyState)},setRequestHeaders:function(){var b={'X-Requested-With':'XMLHttpRequest','X-Prototype-Version':Prototype.Version,'Accept':'text/javascript, text/html, application/xml, text/xml, */*'};if(this.method=='post'){b['Content-type']=this.options.contentType+(this.options.encoding?'; charset='+this.options.encoding:'');if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005)b['Connection']='close'}if(typeof this.options.requestHeaders=='object'){var c=this.options.requestHeaders;if(Object.isFunction(c.push))for(var i=0,length=c.length;i=200&&a<300)},getStatus:function(){try{return this.transport.status||0}catch(e){return 0}},respondToReadyState:function(a){var b=Ajax.Request.Events[a],response=new Ajax.Response(this);if(b=='Complete'){try{this._complete=true;(this.options['on'+response.status]||this.options['on'+(this.success()?'Success':'Failure')]||Prototype.emptyFunction)(response,response.headerJSON)}catch(e){this.dispatchException(e)}var c=response.getHeader('Content-type');if(this.options.evalJS=='force'||(this.options.evalJS&&this.isSameOrigin()&&c&&c.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))this.evalResponse()}try{(this.options['on'+b]||Prototype.emptyFunction)(response,response.headerJSON);Ajax.Responders.dispatch('on'+b,this,response,response.headerJSON)}catch(e){this.dispatchException(e)}if(b=='Complete'){this.transport.onreadystatechange=Prototype.emptyFunction}},isSameOrigin:function(){var m=this.url.match(/^\s*https?:\/\/[^\/]*/);return!m||(m[0]=='#{protocol}//#{domain}#{port}'.interpolate({protocol:location.protocol,domain:document.domain,port:location.port?':'+location.port:''}))},getHeader:function(a){try{return this.transport.getResponseHeader(a)||null}catch(e){return null}},evalResponse:function(){try{return eval((this.transport.responseText||'').unfilterJSON())}catch(e){this.dispatchException(e)}},dispatchException:function(a){(this.options.onException||Prototype.emptyFunction)(this,a);Ajax.Responders.dispatch('onException',this,a)}});Ajax.Request.Events=['Uninitialized','Loading','Loaded','Interactive','Complete'];Ajax.Response=Class.create({initialize:function(a){this.request=a;var b=this.transport=a.transport,readyState=this.readyState=b.readyState;if((readyState>2&&!Prototype.Browser.IE)||readyState==4){this.status=this.getStatus();this.statusText=this.getStatusText();this.responseText=String.interpret(b.responseText);this.headerJSON=this._getHeaderJSON()}if(readyState==4){var c=b.responseXML;this.responseXML=Object.isUndefined(c)?null:c;this.responseJSON=this._getResponseJSON()}},status:0,statusText:'',getStatus:Ajax.Request.prototype.getStatus,getStatusText:function(){try{return this.transport.statusText||''}catch(e){return''}},getHeader:Ajax.Request.prototype.getHeader,getAllHeaders:function(){try{return this.getAllResponseHeaders()}catch(e){return null}},getResponseHeader:function(a){return this.transport.getResponseHeader(a)},getAllResponseHeaders:function(){return this.transport.getAllResponseHeaders()},_getHeaderJSON:function(){var a=this.getHeader('X-JSON');if(!a)return null;a=decodeURIComponent(escape(a));try{return a.evalJSON(this.request.options.sanitizeJSON||!this.request.isSameOrigin())}catch(e){this.request.dispatchException(e)}},_getResponseJSON:function(){var a=this.request.options;if(!a.evalJSON||(a.evalJSON!='force'&&!(this.getHeader('Content-type')||'').include('application/json'))||this.responseText.blank())return null;try{return this.responseText.evalJSON(a.sanitizeJSON||!this.request.isSameOrigin())}catch(e){this.request.dispatchException(e)}}});Ajax.Updater=Class.create(Ajax.Request,{initialize:function($super,d,e,f){this.container={success:(d.success||d),failure:(d.failure||(d.success?null:d))};f=Object.clone(f);var g=f.onComplete;f.onComplete=(function(a,b){this.updateContent(a.responseText);if(Object.isFunction(g))g(a,b)}).bind(this);$super(e,f)},updateContent:function(a){var b=this.container[this.success()?'success':'failure'],options=this.options;if(!options.evalScripts)a=a.stripScripts();if(b=$(b)){if(options.insertion){if(Object.isString(options.insertion)){var c={};c[options.insertion]=a;b.insert(c)}else options.insertion(b,a)}else b.update(a)}}});Ajax.PeriodicalUpdater=Class.create(Ajax.Base,{initialize:function($super,b,c,d){$super(d);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=b;this.url=c;this.start()},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent()},stop:function(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments)},updateComplete:function(a){if(this.options.decay){this.decay=(a.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=a.responseText}this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency)},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options)}});function $(a){if(arguments.length>1){for(var i=0,elements=[],length=arguments.length;i';delete b.name;return Element.writeAttribute(document.createElement(a),b)}if(!c[a])c[a]=Element.extend(document.createElement(a));return Element.writeAttribute(c[a].cloneNode(false),b)};Object.extend(this.Element,d||{})}).call(window);Element.cache={};Element.Methods={visible:function(a){return $(a).style.display!='none'},toggle:function(a){a=$(a);Element[Element.visible(a)?'hide':'show'](a);return a},hide:function(a){$(a).style.display='none';return a},show:function(a){$(a).style.display='';return a},remove:function(a){a=$(a);a.parentNode.removeChild(a);return a},update:function(a,b){a=$(a);if(b&&b.toElement)b=b.toElement();if(Object.isElement(b))return a.update().insert(b);b=Object.toHTML(b);a.innerHTML=b.stripScripts();b.evalScripts.bind(b).defer();return a},replace:function(a,b){a=$(a);if(b&&b.toElement)b=b.toElement();else if(!Object.isElement(b)){b=Object.toHTML(b);var c=a.ownerDocument.createRange();c.selectNode(a);b.evalScripts.bind(b).defer();b=c.createContextualFragment(b.stripScripts())}a.parentNode.replaceChild(b,a);return a},insert:function(a,b){a=$(a);if(Object.isString(b)||Object.isNumber(b)||Object.isElement(b)||(b&&(b.toElement||b.toHTML)))b={bottom:b};var c,insert,tagName,childNodes;for(var d in b){c=b[d];d=d.toLowerCase();insert=Element._insertionTranslations[d];if(c&&c.toElement)c=c.toElement();if(Object.isElement(c)){insert(a,c);continue}c=Object.toHTML(c);tagName=((d=='before'||d=='after')?a.parentNode:a).tagName.toUpperCase();childNodes=Element._getContentFromAnonymousElement(tagName,c.stripScripts());if(d=='top'||d=='after')childNodes.reverse();childNodes.each(insert.curry(a));c.evalScripts.bind(c).defer()}return a},wrap:function(a,b,c){a=$(a);if(Object.isElement(b))$(b).writeAttribute(c||{});else if(Object.isString(b))b=new Element(b,c);else b=new Element('div',b);if(a.parentNode)a.parentNode.replaceChild(b,a);b.appendChild(a);return b},inspect:function(d){d=$(d);var e='<'+d.tagName.toLowerCase();$H({'id':'id','className':'class'}).each(function(a){var b=a.first(),attribute=a.last();var c=(d[b]||'').toString();if(c)e+=' '+attribute+'='+c.inspect(true)});return e+'>'},recursivelyCollect:function(a,b){a=$(a);var c=[];while(a=a[b])if(a.nodeType==1)c.push(Element.extend(a));return c},ancestors:function(a){return $(a).recursivelyCollect('parentNode')},descendants:function(a){return $(a).select("*")},firstDescendant:function(a){a=$(a).firstChild;while(a&&a.nodeType!=1)a=a.nextSibling;return $(a)},immediateDescendants:function(a){if(!(a=$(a).firstChild))return[];while(a&&a.nodeType!=1)a=a.nextSibling;if(a)return[a].concat($(a).nextSiblings());return[]},previousSiblings:function(a){return $(a).recursivelyCollect('previousSibling')},nextSiblings:function(a){return $(a).recursivelyCollect('nextSibling')},siblings:function(a){a=$(a);return a.previousSiblings().reverse().concat(a.nextSiblings())},match:function(a,b){if(Object.isString(b))b=new Selector(b);return b.match($(a))},up:function(a,b,c){a=$(a);if(arguments.length==1)return $(a.parentNode);var d=a.ancestors();return Object.isNumber(b)?d[b]:Selector.findElement(d,b,c)},down:function(a,b,c){a=$(a);if(arguments.length==1)return a.firstDescendant();return Object.isNumber(b)?a.descendants()[b]:a.select(b)[c||0]},previous:function(a,b,c){a=$(a);if(arguments.length==1)return $(Selector.handlers.previousElementSibling(a));var d=a.previousSiblings();return Object.isNumber(b)?d[b]:Selector.findElement(d,b,c)},next:function(a,b,c){a=$(a);if(arguments.length==1)return $(Selector.handlers.nextElementSibling(a));var d=a.nextSiblings();return Object.isNumber(b)?d[b]:Selector.findElement(d,b,c)},select:function(){var a=$A(arguments),element=$(a.shift());return Selector.findChildElements(element,a)},adjacent:function(){var a=$A(arguments),element=$(a.shift());return Selector.findChildElements(element.parentNode,a).without(element)},identify:function(a){a=$(a);var b=a.readAttribute('id'),self=arguments.callee;if(b)return b;do{b='anonymous_element_'+self.counter++}while($(b));a.writeAttribute('id',b);return b},readAttribute:function(a,b){a=$(a);if(Prototype.Browser.IE){var t=Element._attributeTranslations.read;if(t.values[b])return t.values[b](a,b);if(t.names[b])b=t.names[b];if(b.include(':')){return(!a.attributes||!a.attributes[b])?null:a.attributes[b].value}}return a.getAttribute(b)},writeAttribute:function(a,b,c){a=$(a);var d={},t=Element._attributeTranslations.write;if(typeof b=='object')d=b;else d[b]=Object.isUndefined(c)?true:c;for(var e in d){b=t.names[e]||e;c=d[e];if(t.values[e])b=t.values[e](a,c);if(c===false||c===null)a.removeAttribute(b);else if(c===true)a.setAttribute(b,b);else a.setAttribute(b,c)}return a},getHeight:function(a){return $(a).getDimensions().height},getWidth:function(a){return $(a).getDimensions().width},classNames:function(a){return new Element.ClassNames(a)},hasClassName:function(a,b){if(!(a=$(a)))return;var c=a.className;return(c.length>0&&(c==b||new RegExp("(^|\\s)"+b+"(\\s|$)").test(c)))},addClassName:function(a,b){if(!(a=$(a)))return;if(!a.hasClassName(b))a.className+=(a.className?' ':'')+b;return a},removeClassName:function(a,b){if(!(a=$(a)))return;a.className=a.className.replace(new RegExp("(^|\\s+)"+b+"(\\s+|$)"),' ').strip();return a},toggleClassName:function(a,b){if(!(a=$(a)))return;return a[a.hasClassName(b)?'removeClassName':'addClassName'](b)},cleanWhitespace:function(a){a=$(a);var b=a.firstChild;while(b){var c=b.nextSibling;if(b.nodeType==3&&!/\S/.test(b.nodeValue))a.removeChild(b);b=c}return a},empty:function(a){return $(a).innerHTML.blank()},descendantOf:function(b,c){b=$(b),c=$(c);var d=c;if(b.compareDocumentPosition)return(b.compareDocumentPosition(c)&8)===8;if(b.sourceIndex&&!Prototype.Browser.Opera){var e=b.sourceIndex,a=c.sourceIndex,nextAncestor=c.nextSibling;if(!nextAncestor){do{c=c.parentNode}while(!(nextAncestor=c.nextSibling)&&c.parentNode)}if(nextAncestor&&nextAncestor.sourceIndex)return(e>a&&e','',1],TBODY:['','
',2],TR:['','
',3],TD:['
','
',4],SELECT:['',1]}};(function(){Object.extend(this.tags,{THEAD:this.tags.TBODY,TFOOT:this.tags.TBODY,TH:this.tags.TD})}).call(Element._insertionTranslations);Element.Methods.Simulated={hasAttribute:function(a,b){b=Element._attributeTranslations.has[b]||b;var c=$(a).getAttributeNode(b);return c&&c.specified}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement('div').__proto__){window.HTMLElement={};window.HTMLElement.prototype=document.createElement('div').__proto__;Prototype.BrowserFeatures.ElementExtensions=true}Element.extend=(function(){if(Prototype.BrowserFeatures.SpecificElementExtensions)return Prototype.K;var c={},ByTag=Element.Methods.ByTag;var d=Object.extend(function(a){if(!a||a._extendedByPrototype||a.nodeType!=1||a==window)return a;var b=Object.clone(c),tagName=a.tagName,property,value;if(ByTag[tagName])Object.extend(b,ByTag[tagName]);for(property in b){value=b[property];if(Object.isFunction(value)&&!(property in a))a[property]=value.methodize()}a._extendedByPrototype=Prototype.emptyFunction;return a},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(c,Element.Methods);Object.extend(c,Element.Methods.Simulated)}}});d.refresh();return d})();Element.hasAttribute=function(a,b){if(a.hasAttribute)return a.hasAttribute(b);return Element.Methods.Simulated.hasAttribute(a,b)};Element.addMethods=function(f){var F=Prototype.BrowserFeatures,T=Element.Methods.ByTag;if(!f){Object.extend(Form,Form.Methods);Object.extend(Form.Element,Form.Element.Methods);Object.extend(Element.Methods.ByTag,{"FORM":Object.clone(Form.Methods),"INPUT":Object.clone(Form.Element.Methods),"SELECT":Object.clone(Form.Element.Methods),"TEXTAREA":Object.clone(Form.Element.Methods)})}if(arguments.length==2){var g=f;f=arguments[1]}if(!g)Object.extend(Element.Methods,f||{});else{if(Object.isArray(g))g.each(extend);else extend(g)}function extend(a){a=a.toUpperCase();if(!Element.Methods.ByTag[a])Element.Methods.ByTag[a]={};Object.extend(Element.Methods.ByTag[a],f)}function copy(a,b,c){c=c||false;for(var d in a){var e=a[d];if(!Object.isFunction(e))continue;if(!c||!(d in b))b[d]=e.methodize()}}function findDOMClass(a){var b;var c={"OPTGROUP":"OptGroup","TEXTAREA":"TextArea","P":"Paragraph","FIELDSET":"FieldSet","UL":"UList","OL":"OList","DL":"DList","DIR":"Directory","H1":"Heading","H2":"Heading","H3":"Heading","H4":"Heading","H5":"Heading","H6":"Heading","Q":"Quote","INS":"Mod","DEL":"Mod","A":"Anchor","IMG":"Image","CAPTION":"TableCaption","COL":"TableCol","COLGROUP":"TableCol","THEAD":"TableSection","TFOOT":"TableSection","TBODY":"TableSection","TR":"TableRow","TH":"TableCell","TD":"TableCell","FRAMESET":"FrameSet","IFRAME":"IFrame"};if(c[a])b='HTML'+c[a]+'Element';if(window[b])return window[b];b='HTML'+a+'Element';if(window[b])return window[b];b='HTML'+a.capitalize()+'Element';if(window[b])return window[b];window[b]={};window[b].prototype=document.createElement(a).__proto__;return window[b]}if(F.ElementExtensions){copy(Element.Methods,HTMLElement.prototype);copy(Element.Methods.Simulated,HTMLElement.prototype,true)}if(F.SpecificElementExtensions){for(var h in Element.Methods.ByTag){var i=findDOMClass(h);if(Object.isUndefined(i))continue;copy(T[h],i.prototype)}}Object.extend(Element,Element.Methods);delete Element.ByTag;if(Element.extend.refresh)Element.extend.refresh();Element.cache={}};document.viewport={getDimensions:function(){var a={};var B=Prototype.Browser;$w('width height').each(function(d){var D=d.capitalize();a[d]=(B.WebKit&&!document.evaluate)?self['inner'+D]:(B.Opera)?document.body['client'+D]:document.documentElement['client'+D]});return a},getWidth:function(){return this.getDimensions().width},getHeight:function(){return this.getDimensions().height},getScrollOffsets:function(){return Element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop)}};var Selector=Class.create({initialize:function(a){this.expression=a.strip();this.compileMatcher()},shouldUseXPath:function(){if(!Prototype.BrowserFeatures.XPath)return false;var e=this.expression;if(Prototype.Browser.WebKit&&(e.include("-of-type")||e.include(":empty")))return false;if((/(\[[\w-]*?:|:checked)/).test(this.expression))return false;return true},compileMatcher:function(){if(this.shouldUseXPath())return this.compileXPathMatcher();var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;if(Selector._cache[e]){this.matcher=Selector._cache[e];return}this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in ps){p=ps[i];if(m=e.match(p)){this.matcher.push(Object.isFunction(c[i])?c[i](m):new Template(c[i]).evaluate(m));e=e.replace(m[0],'');break}}}this.matcher.push("return h.unique(n);\n}");eval(this.matcher.join('\n'));Selector._cache[this.expression]=this.matcher},compileXPathMatcher:function(){var e=this.expression,ps=Selector.patterns,x=Selector.xpath,le,m;if(Selector._cache[e]){this.xpath=Selector._cache[e];return}this.matcher=['.//*'];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in ps){if(m=e.match(ps[i])){this.matcher.push(Object.isFunction(x[i])?x[i](m):new Template(x[i]).evaluate(m));e=e.replace(m[0],'');break}}}this.xpath=this.matcher.join('');Selector._cache[this.expression]=this.xpath},findElements:function(a){a=a||document;if(this.xpath)return document._getElementsByXPath(this.xpath,a);return this.matcher(a)},match:function(a){this.tokens=[];var e=this.expression,ps=Selector.patterns,as=Selector.assertions;var b,p,m;while(e&&b!==e&&(/\S/).test(e)){b=e;for(var i in ps){p=ps[i];if(m=e.match(p)){if(as[i]){this.tokens.push([i,Object.clone(m)]);e=e.replace(m[0],'')}else{return this.findElements(document).include(a)}}}}var c=true,name,matches;for(var i=0,token;token=this.tokens[i];i++){name=token[0],matches=token[1];if(!Selector.assertions[name](a,matches)){c=false;break}}return c},toString:function(){return this.expression},inspect:function(){return"#"}});Object.extend(Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:'/following-sibling::*',tagName:function(m){if(m[1]=='*')return'';return"[local-name()='"+m[1].toLowerCase()+"' or local-name()='"+m[1].toUpperCase()+"']"},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:function(m){m[1]=m[1].toLowerCase();return new Template("[@#{1}]").evaluate(m)},attr:function(m){m[1]=m[1].toLowerCase();m[3]=m[5]||m[6];return new Template(Selector.xpath.operators[m[2]]).evaluate(m)},pseudo:function(m){var h=Selector.xpath.pseudos[m[1]];if(!h)return'';if(Object.isFunction(h))return h(m);return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m)},operators:{'=':"[@#{1}='#{3}']",'!=':"[@#{1}!='#{3}']",'^=':"[starts-with(@#{1}, '#{3}')]",'$=':"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",'*=':"[contains(@#{1}, '#{3}')]",'~=':"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",'|=':"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{'first-child':'[not(preceding-sibling::*)]','last-child':'[not(following-sibling::*)]','only-child':'[not(preceding-sibling::* or following-sibling::*)]','empty':"[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]",'checked':"[@checked]",'disabled':"[@disabled]",'enabled':"[not(@disabled)]",'not':function(m){var e=m[6],p=Selector.patterns,x=Selector.xpath,le,v;var a=[];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in p){if(m=e.match(p[i])){v=Object.isFunction(x[i])?x[i](m):new Template(x[i]).evaluate(m);a.push("("+v.substring(1,v.length-1)+")");e=e.replace(m[0],'');break}}}return"[not("+a.join(" and ")+")]"},'nth-child':function(m){return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",m)},'nth-last-child':function(m){return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",m)},'nth-of-type':function(m){return Selector.xpath.pseudos.nth("position() ",m)},'nth-last-of-type':function(m){return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",m)},'first-of-type':function(m){m[6]="1";return Selector.xpath.pseudos['nth-of-type'](m)},'last-of-type':function(m){m[6]="1";return Selector.xpath.pseudos['nth-last-of-type'](m)},'only-of-type':function(m){var p=Selector.xpath.pseudos;return p['first-of-type'](m)+p['last-of-type'](m)},nth:function(c,m){var d,formula=m[6],predicate;if(formula=='even')formula='2n+0';if(formula=='odd')formula='2n+1';if(d=formula.match(/^(\d+)$/))return'['+c+"= "+d[1]+']';if(d=formula.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(d[1]=="-")d[1]=-1;var a=d[1]?Number(d[1]):1;var b=d[2]?Number(d[2]):0;predicate="[((#{fragment} - #{b}) mod #{a} = 0) and "+"((#{fragment} - #{b}) div #{a} >= 0)]";return new Template(predicate).evaluate({fragment:c,a:a,b:b})}}}},criteria:{tagName:'n = h.tagName(n, r, "#{1}", c); c = false;',className:'n = h.className(n, r, "#{1}", c); c = false;',id:'n = h.id(n, r, "#{1}", c); c = false;',attrPresence:'n = h.attrPresence(n, r, "#{1}", c); c = false;',attr:function(m){m[3]=(m[5]||m[6]);return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m)},pseudo:function(m){if(m[6])m[6]=m[6].replace(/"/g,'\\"');return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m)},descendant:'c = "descendant";',child:'c = "child";',adjacent:'c = "adjacent";',laterSibling:'c = "laterSibling";'},patterns:{laterSibling:/^\s*~\s*/,child:/^\s*>\s*/,adjacent:/^\s*\+\s*/,descendant:/^\s/,tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/,pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,attrPresence:/^\[([\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/},assertions:{tagName:function(a,b){return b[1].toUpperCase()==a.tagName.toUpperCase()},className:function(a,b){return Element.hasClassName(a,b[1])},id:function(a,b){return a.id===b[1]},attrPresence:function(a,b){return Element.hasAttribute(a,b[1])},attr:function(a,b){var c=Element.readAttribute(a,b[1]);return c&&Selector.operators[b[2]](c,b[5]||b[6])}},handlers:{concat:function(a,b){for(var i=0,node;node=b[i];i++)a.push(node);return a},mark:function(a){var b=Prototype.emptyFunction;for(var i=0,node;node=a[i];i++)node._countedByPrototype=b;return a},unmark:function(a){for(var i=0,node;node=a[i];i++)node._countedByPrototype=undefined;return a},index:function(a,b,c){a._countedByPrototype=Prototype.emptyFunction;if(b){for(var d=a.childNodes,i=d.length-1,j=1;i>=0;i--){var e=d[i];if(e.nodeType==1&&(!c||e._countedByPrototype))e.nodeIndex=j++}}else{for(var i=0,j=1,d=a.childNodes;e=d[i];i++)if(e.nodeType==1&&(!c||e._countedByPrototype))e.nodeIndex=j++}},unique:function(a){if(a.length==0)return a;var b=[],n;for(var i=0,l=a.length;i0?[b]:[];return $R(1,d).inject([],function(c,i){if(0==(i-b)%a&&(i-b)/a>=0)c.push(i);return c})},nth:function(c,d,e,f,g){if(c.length==0)return[];if(d=='even')d='2n+0';if(d=='odd')d='2n+1';var h=Selector.handlers,results=[],indexed=[],m;h.mark(c);for(var i=0,node;node=c[i];i++){if(!node.parentNode._countedByPrototype){h.index(node.parentNode,f,g);indexed.push(node.parentNode)}}if(d.match(/^\d+$/)){d=Number(d);for(var i=0,node;node=c[i];i++)if(node.nodeIndex==d)results.push(node)}else if(m=d.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(m[1]=="-")m[1]=-1;var a=m[1]?Number(m[1]):1;var b=m[2]?Number(m[2]):0;var k=Selector.pseudos.getIndices(a,b,c.length);for(var i=0,node,l=k.length;node=c[i];i++){for(var j=0;j+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(m){b.push(m[1].strip())});return b},matchElements:function(a,b){var c=$$(b),h=Selector.handlers;h.mark(c);for(var i=0,results=[],element;element=a[i];i++)if(element._countedByPrototype)results.push(element);h.unmark(c);return results},findElement:function(a,b,c){if(Object.isNumber(b)){c=b;b=false}return Selector.matchElements(a,b||'*')[c||0]},findChildElements:function(a,b){b=Selector.split(b.join(','));var c=[],h=Selector.handlers;for(var i=0,l=b.length,selector;i1)?h.unique(c):c}});if(Prototype.Browser.IE){Object.extend(Selector.handlers,{concat:function(a,b){for(var i=0,node;node=b[i];i++)if(node.tagName!=="!")a.push(node);return a},unmark:function(a){for(var i=0,node;node=a[i];i++)node.removeAttribute('_countedByPrototype');return a}})}function $$(){return Selector.findChildElements(document,$A(arguments))}var Form={reset:function(a){$(a).reset();return a},serializeElements:function(c,d){if(typeof d!='object')d={hash:!!d};else if(Object.isUndefined(d.hash))d.hash=true;var e,value,submitted=false,submit=d.submit;var f=c.inject({},function(a,b){if(!b.disabled&&b.name){e=b.name;value=$(b).getValue();if(value!=null&&(b.type!='submit'||(!submitted&&submit!==false&&(!submit||e==submit)&&(submitted=true)))){if(e in a){if(!Object.isArray(a[e]))a[e]=[a[e]];a[e].push(value)}else a[e]=value}}return a});return d.hash?f:Object.toQueryString(f)}};Form.Methods={serialize:function(a,b){return Form.serializeElements(Form.getElements(a),b)},getElements:function(c){return $A($(c).getElementsByTagName('*')).inject([],function(a,b){if(Form.Element.Serializers[b.tagName.toLowerCase()])a.push(Element.extend(b));return a})},getInputs:function(a,b,c){a=$(a);var d=a.getElementsByTagName('input');if(!b&&!c)return $A(d).map(Element.extend);for(var i=0,matchingInputs=[],length=d.length;i=0}).sortBy(function(a){return a.tabIndex}).first();return d?d:c.find(function(a){return['input','select','textarea'].include(a.tagName.toLowerCase())})},focusFirstElement:function(a){a=$(a);a.findFirstElement().activate();return a},request:function(a,b){a=$(a),b=Object.clone(b||{});var c=b.parameters,action=a.readAttribute('action')||'';if(action.blank())action=window.location.href;b.parameters=a.serialize(true);if(c){if(Object.isString(c))c=c.toQueryParams();Object.extend(b.parameters,c)}if(a.hasAttribute('method')&&!b.method)b.method=a.method;return new Ajax.Request(action,b)}};Form.Element={focus:function(a){$(a).focus();return a},select:function(a){$(a).select();return a}};Form.Element.Methods={serialize:function(a){a=$(a);if(!a.disabled&&a.name){var b=a.getValue();if(b!=undefined){var c={};c[a.name]=b;return Object.toQueryString(c)}}return''},getValue:function(a){a=$(a);var b=a.tagName.toLowerCase();return Form.Element.Serializers[b](a)},setValue:function(a,b){a=$(a);var c=a.tagName.toLowerCase();Form.Element.Serializers[c](a,b);return a},clear:function(a){$(a).value='';return a},present:function(a){return $(a).value!=''},activate:function(a){a=$(a);try{a.focus();if(a.select&&(a.tagName.toLowerCase()!='input'||!['button','reset','submit'].include(a.type)))a.select()}catch(e){}return a},disable:function(a){a=$(a);a.blur();a.disabled=true;return a},enable:function(a){a=$(a);a.disabled=false;return a}};var Field=Form.Element;var $F=Form.Element.Methods.getValue;Form.Element.Serializers={input:function(a,b){switch(a.type.toLowerCase()){case'checkbox':case'radio':return Form.Element.Serializers.inputSelector(a,b);default:return Form.Element.Serializers.textarea(a,b)}},inputSelector:function(a,b){if(Object.isUndefined(b))return a.checked?a.value:null;else a.checked=!!b},textarea:function(a,b){if(Object.isUndefined(b))return a.value;else a.value=b},select:function(a,b){if(Object.isUndefined(b))return this[a.type=='select-one'?'selectOne':'selectMany'](a);else{var c,value,single=!Object.isArray(b);for(var i=0,length=a.length;i=0?this.optionValue(a.options[b]):null},selectMany:function(a){var b,length=a.length;if(!length)return null;for(var i=0,b=[];i<\/script>");$("__onDOMContentLoaded").onreadystatechange=function(){if(this.readyState=="complete"){this.onreadystatechange=null;fireContentLoadedEvent()}}}})();Hash.toQueryString=Object.toQueryString;var Toggle={display:Element.toggle};Element.Methods.childOf=Element.Methods.descendantOf;var Insertion={Before:function(a,b){return Element.insert(a,{before:b})},Top:function(a,b){return Element.insert(a,{top:b})},Bottom:function(a,b){return Element.insert(a,{bottom:b})},After:function(a,b){return Element.insert(a,{after:b})}};var $continue=new Error('"throw $continue" is deprecated, use "return" instead');var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},within:function(a,x,y){if(this.includeScrollOffsets)return this.withinIncludingScrolloffsets(a,x,y);this.xcomp=x;this.ycomp=y;this.offset=Element.cumulativeOffset(a);return(y>=this.offset[1]&&y=this.offset[0]&&x=this.offset[1]&&this.ycomp=this.offset[0]&&this.xcomp0})._each(b)},set:function(a){this.element.className=a},add:function(a){if(this.include(a))return;this.set($A(this).concat(a).join(' '))},remove:function(a){if(!this.include(a))return;this.set($A(this).without(a).join(' '))},toString:function(){return $A(this).join(' ')}};Object.extend(Element.ClassNames.prototype,Enumerable);Element.addMethods();var Scriptaculous={Version:'1.8.1',require:function(a){document.write(' > ... */ UI.Carousel = Class.create(UI.Options, { // Group: Options options: { // Property: direction // Can be horizontal or vertical, horizontal by default direction : "horizontal", // Property: previousButton // Selector of previous button inside carousel element, ".previous_button" by default, // set it to false to ignore previous button previousButton : ".previous_button", // Property: nextButton // Selector of next button inside carousel element, ".next_button" by default, // set it to false to ignore next button nextButton : ".next_button", // Property: container // Selector of carousel container inside carousel element, ".container" by default, container : ".container", // Property: scrollInc // Define the maximum number of elements that gonna scroll each time, auto by default scrollInc : "auto", // Property: disabledButtonSuffix // Define the suffix classanme used when a button get disabled, to '_disabled' by default // Previous button classname will be previous_button_disabled disabledButtonSuffix : '_disabled', // Property: overButtonSuffix // Define the suffix classanme used when a button has a rollover status, '_over' by default // Previous button classname will be previous_button_over overButtonSuffix : '_over' }, /* Group: Attributes Property: element DOM element containing the carousel Property: id DOM id of the carousel's element Property: container DOM element containing the carousel's elements Property: elements Array containing the carousel's elements as DOM elements Property: previousButton DOM id of the previous button Property: nextButton DOM id of the next button Property: posAttribute Define if the positions are from left or top Property: dimAttribute Define if the dimensions are horizontal or vertical Property: elementSize Size of each element, it's an integer Property: nbVisible Number of visible elements, it's a float Property: animating Define whether the carousel is in animation or not */ /* Group: Events List of events fired by a carousel Notice: Carousel custom events are automatically namespaced in "carousel:" (see Prototype custom events). Examples: This example will observe all carousels > document.observe('carousel:scroll:ended', function(event) { > alert("Carousel with id " + event.memo.carousel.id + " has just been scrolled"); > }); This example will observe only this carousel > new UI.Carousel('horizontal_carousel').observe('scroll:ended', function(event) { > alert("Carousel with id " + event.memo.carousel.id + " has just been scrolled"); > }); Property: previousButton:enabled Fired when the previous button has just been enabled Property: previousButton:disabled Fired when the previous button has just been disabled Property: nextButton:enabled Fired when the next button has just been enabled Property: nextButton:disabled Fired when the next button has just been disabled Property: scroll:started Fired when a scroll has just started Property: scroll:ended Fired when a scroll has been done, memo.shift = number of elements scrolled, it's a float Property: sizeUpdated Fired when the carousel size has just been updated. Tips: memo.carousel.currentSize() = the new carousel size */ // Group: Constructor /* Method: initialize Constructor function, should not be called directly Parameters: element - DOM element options - (Hash) list of optional parameters Returns: this */ initialize: function(element, options) { this.setOptions(options); this.element = $(element); this.id = this.element.id; this.container = this.element.down(this.options.container).firstDescendant(); this.elements = this.container.childElements(); this.previousButton = this.options.previousButton == false ? null : this.element.down(this.options.previousButton); this.nextButton = this.options.nextButton == false ? null : this.element.down(this.options.nextButton); this.posAttribute = (this.options.direction == "horizontal" ? "left" : "top"); this.dimAttribute = (this.options.direction == "horizontal" ? "width" : "height"); this.elementSize = this.computeElementSize(); this.nbVisible = this.currentSize() / this.elementSize; var scrollInc = this.options.scrollInc; if (scrollInc == "auto") scrollInc = Math.floor(this.nbVisible); [ this.previousButton, this.nextButton ].each(function(button) { if (!button) return; var className = (button == this.nextButton ? "next_button" : "previous_button") + this.options.overButtonSuffix; button.clickHandler = this.scroll.bind(this, (button == this.nextButton ? -1 : 1) * scrollInc * this.elementSize); button.observe("click", button.clickHandler) .observe("mouseover", function() {button.addClassName(className)}.bind(this)) .observe("mouseout", function() {button.removeClassName(className)}.bind(this)); }, this); this.updateButtons(); }, // Group: Destructor /* Method: destroy Cleans up DOM and memory */ destroy: function($super) { [ this.previousButton, this.nextButton ].each(function(button) { if (!button) return; button.stopObserving("click", button.clickHandler); }, this); this.element.remove(); this.fire('destroyed'); }, // Group: Event handling /* Method: fire Fires a carousel custom event automatically namespaced in "carousel:" (see Prototype custom events). The memo object contains a "carousel" property referring to the carousel. Example: > document.observe('carousel:scroll:ended', function(event) { > alert("Carousel with id " + event.memo.carousel.id + " has just been scrolled"); > }); Parameters: eventName - an event name memo - a memo object Returns: fired event */ fire: function(eventName, memo) { memo = memo || { }; memo.carousel = this; return this.element.fire('carousel:' + eventName, memo); }, /* Method: observe Observe a carousel event with a handler function automatically bound to the carousel Parameters: eventName - an event name handler - a handler function Returns: this */ observe: function(eventName, handler) { this.element.observe('carousel:' + eventName, handler.bind(this)); return this; }, /* Method: stopObserving Unregisters a carousel event, it must take the same parameters as this.observe (see Prototype stopObserving). Parameters: eventName - an event name handler - a handler function Returns: this */ stopObserving: function(eventName, handler) { this.element.stopObserving('carousel:' + eventName, handler); return this; }, // Group: Actions /* Method: checkScroll Check scroll position to avoid unused space at right or bottom Parameters: position - position to check updatePosition - should the container position be updated ? true/false Returns: position */ checkScroll: function(position, updatePosition) { if (position > 0) position = 0; else { var limit = this.elements.last().positionedOffset()[this.posAttribute] + this.elementSize; var carouselSize = this.currentSize(); if (this.options.direction == "vertical") { if((position + limit) <= 0) position = position+this.elementSize; } else { if (position + limit < carouselSize) position -= carouselSize - (position + limit); } position = Math.min(position, 0); } if (updatePosition) this.container.style[this.posAttribute] = position + "px"; return position; }, /* Method: scroll Scrolls carousel from maximum deltaPixel Parameters: deltaPixel - a float Returns: this */ scroll: function(deltaPixel) { if (this.animating) return this; // Compute new position var position = this.currentPosition() - deltaPixel; // Check bounds position = this.checkScroll(position, false); // Compute shift to apply deltaPixel = position - this.currentPosition(); if (deltaPixel != 0) { this.animating = true; this.fire("scroll:started"); var that = this; // Move effects this.container.morph("opacity:0.5", {duration: 0.2, afterFinish: function() { that.container.morph(that.posAttribute + ": " + position + "px", { duration: 0.5, delay: 0.2, transition:Effect.Transitions.easeInOutQuad, //transition:Effect.Transitions.easeOutBack, afterFinish: function() { that.container.morph("opacity:1", { duration: 0.2, afterFinish: function() { that.animating = false; that.updateButtons() .fire("scroll:ended", { shift: deltaPixel / that.currentSize() }); } }); } }); }}); } return this; }, /* Method: scrollTo Scrolls carousel, so that element with specified index is the left-most. This method is convenient when using carousel in a tabbed navigation. Clicking on first tab should scroll first container into view, clicking on a fifth - fifth one, etc. Indexing starts with 0. Parameters: Index of an element which will be a left-most visible in the carousel Returns: this */ scrollTo: function(index) { if (this.animating || index < 0 || index > this.elements.length || index == this.currentIndex() || isNaN(parseInt(index))) return this; return this.scroll((this.currentIndex() - index) * this.elementSize); }, /* Method: updateButtons Update buttons status to enabled or disabled Them status is defined by classNames and fired as carousel's custom events Returns: this */ updateButtons: function() { this.updatePreviousButton(); this.updateNextButton(); return this; }, updatePreviousButton: function() { var position = this.currentPosition(); var lastPosition = this.currentLastPosition(); var size = this.currentSize(); var previousClassName = "previous_button" + this.options.disabledButtonSuffix; if (this.options.direction == "vertical") { if (this.previousButton.hasClassName(previousClassName) && (lastPosition - this.elementSize) != 0) { this.previousButton.removeClassName(previousClassName); this.fire('previousButton:enabled'); } if (!this.previousButton.hasClassName(previousClassName) && (lastPosition - this.elementSize) == 0) { this.previousButton.addClassName(previousClassName); this.fire('previousButton:disabled'); } }else { if (this.previousButton.hasClassName(previousClassName) && position != 0) { this.previousButton.removeClassName(previousClassName); this.fire('previousButton:enabled'); } if (!this.previousButton.hasClassName(previousClassName) && position == 0) { this.previousButton.addClassName(previousClassName); this.fire('previousButton:disabled'); } } }, updateNextButton: function() { var lastPosition = this.currentLastPosition(); var size = this.currentSize(); var position = this.currentPosition(); var nextClassName = "next_button" + this.options.disabledButtonSuffix; if (this.options.direction == "vertical") { if (this.nextButton.hasClassName(nextClassName) && position != 0) { this.nextButton.removeClassName(nextClassName); this.fire('nextButton:enabled'); } if (!this.nextButton.hasClassName(nextClassName) && position == 0) { this.nextButton.addClassName(nextClassName); this.fire('nextButton:disabled'); } }else { if (this.nextButton.hasClassName(nextClassName) && lastPosition != size) { this.nextButton.removeClassName(nextClassName); this.fire('nextButton:enabled'); } if (!this.nextButton.hasClassName(nextClassName) && lastPosition == size) { this.nextButton.addClassName(nextClassName); this.fire('nextButton:disabled'); } } }, // Group: Size and Position /* Method: computeElementSize Return elements size in pixel, height or width depends on carousel orientation. Returns: an integer value */ computeElementSize: function() { return this.elements.first().getDimensions()[this.dimAttribute]; }, /* Method: currentIndex Returns current visible index of a carousel. For example, a horizontal carousel with image #3 on left will return 3 and with half of image #3 will return 3.5 Don't forget that the first image have an index 0 Returns: a float value */ currentIndex: function() { return - this.currentPosition() / this.elementSize; }, /* Method: currentLastPosition Returns the current position from the end of the last element. This value is in pixel. Returns: an integer value, if no images a present it will return 0 */ currentLastPosition: function() { if (this.container.childElements().empty()) return 0; return this.currentPosition() + this.elements.last().positionedOffset()[this.posAttribute] + this.elementSize; }, /* Method: currentPosition Returns the current position in pixel. Tips: To get the position in elements use currentIndex() Returns: an integer value */ currentPosition: function() { return this.container.getNumStyle(this.posAttribute); }, /* Method: currentSize Returns the current size of the carousel in pixel Returns: Carousel's size in pixel */ currentSize: function() { return this.container.parentNode.getDimensions()[this.dimAttribute]; }, /* Method: updateSize Should be called if carousel size has been changed (usually called with a liquid layout) Returns: this */ updateSize: function() { this.nbVisible = this.currentSize() / this.elementSize; var scrollInc = this.options.scrollInc; if (scrollInc == "auto") scrollInc = Math.floor(this.nbVisible); [ this.previousButton, this.nextButton ].each(function(button) { if (!button) return; button.stopObserving("click", button.clickHandler); button.clickHandler = this.scroll.bind(this, (button == this.nextButton ? -1 : 1) * scrollInc * this.elementSize); button.observe("click", button.clickHandler); }, this); this.checkScroll(this.currentPosition(), true); this.updateButtons().fire('sizeUpdated'); return this; } }); /* Class: UI.Ajax.Carousel Gives the AJAX power to carousels. An AJAX carousel : * Use AJAX to add new elements on the fly Example: > new UI.Ajax.Carousel("horizontal_carousel", > {url: "get-more-elements", elementSize: 250}); */ UI.Ajax.Carousel = Class.create(UI.Carousel, { // Group: Options // // Notice: // It also include of all carousel's options options: { // Property: elementSize // Required, it define the size of all elements elementSize : -1, // Property: url // Required, it define the URL used by AJAX carousel to request new elements details url : null }, /* Group: Attributes Notice: It also include of all carousel's attributes Property: elementSize Size of each elements, it's an integer Property: endIndex Index of the last loaded element Property: hasMore Flag to define if there's still more elements to load Property: requestRunning Define whether a request is processing or not Property: updateHandler Callback to update carousel, usually used after request success Property: url URL used to request additional elements */ /* Group: Events List of events fired by an AJAX carousel, it also include of all carousel's custom events Property: request:started Fired when the request has just started Property: request:ended Fired when the request has succeed */ // Group: Constructor /* Method: initialize Constructor function, should not be called directly Parameters: element - DOM element options - (Hash) list of optional parameters Returns: this */ initialize: function($super, element, options) { if (!options.url) throw("url option is required for UI.Ajax.Carousel"); if (!options.elementSize) throw("elementSize option is required for UI.Ajax.Carousel"); $super(element, options); this.endIndex = 0; this.hasMore = true; // Cache handlers this.updateHandler = this.update.bind(this); this.updateAndScrollHandler = function(nbElements, transport, json) { this.update(transport, json); this.scroll(nbElements); }.bind(this); // Run first ajax request to fill the carousel this.runRequest.bind(this).defer({parameters: {from: 0, to: Math.ceil(this.nbVisible) - 1}, onSuccess: this.updateHandler}); }, // Group: Actions /* Method: runRequest Request the new elements details Parameters: options - (Hash) list of optional parameters Returns: this */ runRequest: function(options) { this.requestRunning = true; new Ajax.Request(this.options.url, Object.extend({method: "GET"}, options)); this.fire("request:started"); return this; }, /* Method: scroll Scrolls carousel from maximum deltaPixel Parameters: deltaPixel - a float Returns: this */ scroll: function($super, deltaPixel) { if (this.animating || this.requestRunning) return this; var nbElements = (-deltaPixel) / this.elementSize; // Check if there is not enough if (this.hasMore && nbElements > 0 && this.currentIndex() + this.nbVisible + nbElements - 1 > this.endIndex) { var from = this.endIndex + 1; var to = Math.ceil(from + this.nbVisible - 1); this.runRequest({parameters: {from: from, to: to}, onSuccess: this.updateAndScrollHandler.curry(deltaPixel).bind(this)}); return this; } else $super(deltaPixel); }, /* Method: update Update the carousel Parameters: transport - XMLHttpRequest object json - JSON object Returns: this */ update: function(transport, json) { this.requestRunning = false; this.fire("request:ended"); if (!json) json = transport.responseJSON; this.hasMore = json.more; this.endIndex = Math.max(this.endIndex, json.to); this.elements = this.container.insert({bottom: json.html}).childElements(); return this.updateButtons(); }, // Group: Size and Position /* Method: computeElementSize Return elements size in pixel Returns: an integer value */ computeElementSize: function() { return this.options.elementSize; }, /* Method: updateSize Should be called if carousel size has been changed (usually called with a liquid layout) Returns: this */ updateSize: function($super) { var nbVisible = this.nbVisible; $super(); // If we have enough space for at least a new element if (Math.floor(this.nbVisible) - Math.floor(nbVisible) >= 1 && this.hasMore) { if (this.currentIndex() + Math.floor(this.nbVisible) >= this.endIndex) { var nbNew = Math.floor(this.currentIndex() + Math.floor(this.nbVisible) - this.endIndex); this.runRequest({parameters: {from: this.endIndex + 1, to: this.endIndex + nbNew}, onSuccess: this.updateHandler}); } } return this; }, updateNextButton: function($super) { var lastPosition = this.currentLastPosition(); var size = this.currentSize(); var nextClassName = "next_button" + this.options.disabledButtonSuffix; if (this.nextButton.hasClassName(nextClassName) && lastPosition != size) { this.nextButton.removeClassName(nextClassName); this.fire('nextButton:enabled'); } if (!this.nextButton.hasClassName(nextClassName) && lastPosition == size && !this.hasMore) { this.nextButton.addClassName(nextClassName); this.fire('nextButton:disabled'); } } }); /** * Easing Equations for Script.aculo.us * @author Brian Crescimanno * @version 0.8.1 * @revised November 20, 2008 * @copyright 2008 Brian Crescimanno, all rights reserved * * Released under terms of the BSD License * http://www.opensource.org/licenses/bsd-license.php * * The math for these equations was created by Robert Penner * http://www.robertpenner.com/profmx * * ----------------------------------------------------------------------------------------- * Do not remove any comments above this line, below comments may be removed to save space. * * An adaptation of Robert Penner's "easing equations" as seen in many Flash animations for * Script.aculo.us 1.8. One of my great pains in working with Script.aculo.us over other * libraries was the lack of these easing equations so I set about to port as many of the * equations as I could. * * Imlements from Penner's equations: * Quadratic * Cubic * Quartic * Quintic * Sinusoidal * Exponential * Circular * Bounce (easeOut only) * Back * * Does not implement (yet) * Elastic * Bounce (easeIn, easeInOut) * * Ken Snyder provided a few reference implementations of Penner equations for * Script.aculo.us; these reference implementations aided my work in porting a * (more) complete set. * */ /****** Quadratic ******/ Effect.Transitions.easeInQuad = function(pos){ return Math.pow(pos, 2); } Effect.Transitions.easeOutQuad = function(pos){ return -(Math.pow((pos-1), 2) -1); } Effect.Transitions.easeInOutQuad = function(pos){ if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,2); return -0.5 * ((pos-=2)*pos - 2); } /****** Cubic ******/ Effect.Transitions.easeInCubic = function(pos){ return Math.pow(pos, 3); } Effect.Transitions.easeOutCubic = function(pos){ return (Math.pow((pos-1), 3) +1); } Effect.Transitions.easeInOutCubic = function(pos){ if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,3); return 0.5 * (Math.pow((pos-2),3) + 2); } /****** Quartic ******/ Effect.Transitions.easeInQuart = function(pos){ return Math.pow(pos, 4); } Effect.Transitions.easeOutQuart = function(pos){ return -(Math.pow((pos-1), 4) -1) } Effect.Transitions.easeInOutQuart = function(pos){ if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,4); return -0.5 * ((pos-=2)*Math.pow(pos,3) - 2); } /****** Quintic ******/ Effect.Transitions.easeInQuint = function(pos){ return Math.pow(pos, 5); } Effect.Transitions.easeOutQuint = function(pos){ return (Math.pow((pos-1), 5) +1); } Effect.Transitions.easeInOutQuint = function(pos){ if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,5); return 0.5 * (Math.pow((pos-2),5) + 2); } /****** Sinusoidal ******/ Effect.Transitions.easeInSine = function(pos){ return -Math.cos(pos * (Math.PI/2)) + 1; } Effect.Transitions.easeOutSine = function(pos){ return Math.sin(pos * (Math.PI/2)); } Effect.Transitions.easeInOutSine = function(pos){ return (-.5 * (Math.cos(Math.PI*pos) -1)); } /****** Exponential ******/ Effect.Transitions.easeInExpo = function(pos){ return (pos==0) ? 0 : Math.pow(2, 10 * (pos - 1)); } Effect.Transitions.easeOutExpo = function(pos){ return (pos==1) ? 1 : -Math.pow(2, -10 * pos) + 1; } Effect.Transitions.easeInOutExpo = function(pos){ if(pos==0) return 0; if(pos==1) return 1; if((pos/=0.5) < 1) return 0.5 * Math.pow(2,10 * (pos-1)); return 0.5 * (-Math.pow(2, -10 * --pos) + 2); } /****** Circular ******/ Effect.Transitions.easeInCirc = function(pos){ return -(Math.sqrt(1 - (pos*pos)) - 1); } Effect.Transitions.easeOutCirc = function(pos){ return Math.sqrt(1 - Math.pow((pos-1), 2)) } Effect.Transitions.easeInOutCirc = function(pos){ if((pos/=0.5) < 1) return -0.5 * (Math.sqrt(1 - pos*pos) - 1); return 0.5 * (Math.sqrt(1 - (pos-=2)*pos) + 1); } /****** Bounce ******/ Effect.Transitions.easeInBounce = function(pos){ return 1; } Effect.Transitions.easeOutBounce = function(pos){ if ((pos) < (1/2.75)) { return (7.5625*pos*pos); } else if (pos < (2/2.75)) { return (7.5625*(pos-=(1.5/2.75))*pos + .75); } else if (pos < (2.5/2.75)) { return (7.5625*(pos-=(2.25/2.75))*pos + .9375); } else { return (7.5625*(pos-=(2.625/2.75))*pos + .984375); } } Effect.Transitions.easeInOutBounce = function(pos){ return 1; } /****** Back ******/ Effect.Transitions.easeInBack = function(pos){ var s = 1.70158; return (pos)*pos*((s+1)*pos - s); } Effect.Transitions.easeOutBack = function(pos){ var s = 1.70158; return (pos=pos-1)*pos*((s+1)*pos + s) + 1; } Effect.Transitions.easeInOutBack = function(pos){ var s = 1.70158; if((pos/=0.5) < 1) return 0.5*(pos*pos*(((s*=(1.525))+1)*pos -s)); return 0.5*((pos-=2)*pos*(((s*=(1.525))+1)*pos +s) +2); } /****** Elastic ******/ Effect.Transitions.easeInElastic = function(pos){ return 1; } Effect.Transitions.easeOutElastic = function(pos){ return 1; } Effect.Transitions.easeInOutElastic = function(pos){ return 1; }