/*Element.shortcuts.js Aaron Newton*/ 
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('3.c({8:1(){2 0.9(\'5\')!=\'b\'},p:1(){2 0[0.8()?\'d\':\'f\']()},d:1(){0.4=0.9(\'5\');0.g(\'5\',\'b\');2 0},f:1(a){0.4=(0.4=="b")?\'h\':0.4;0.g(\'5\',(a||0.4||\'h\'));2 0},6:1(){i{7(0.j().6())0.q=0.j().6()}k(e){r.s(\'t.6 u: %o\',e)}},v:1(){7(!w.x)2 l;m a=y;i{7(z A(0.9(\'B\')))a=l}k(e){}2 a}});3.C=3.8;7(!3.n){3.c({n:1(){2 0.D(\'\')}})}m $E=$$;',41,41,'this|function|return|Element|originalDisplay|display|tidy|if|isVisible|getStyle||none|extend|hide||show|setStyle|block|try|getValue|catch|true|var|empty||toggle|value|dbug|log|element|error|fxOpacityOk|window|ie6|false|new|Color|backgroundColor|visible|setHTML|S'.split('|'),0,{}))
/*mooScroller.js by Aaron Newton CNET bidouillé par ma pomme*/
var MooScroller = new Class({
	options: {
		mode: 'vertical',
		width: 0, //required only for mode: horizontal
		scrollSteps: 10,
		wheel: true,
		scrollLinks: {
			forward: 'scrollForward',
			back: 'scrollBack'
		},
		onScroll: Class.empty
	},
	initialize: function(container, scrollBar, options) {
		this.setOptions(options);
		this.horz = (this.options.mode == "horizontal");
		this.container = $(container).setStyle('overflow', 'hidden');
		this.content = new Element('div', {
			'class':'ScrollerWrapper',
			styles: {
				overflow: 'visible'
			}
		}).injectInside(this.container);
		this.container.getChildren().each(function(el){
			if(el == this.content) return;
			this.content.adopt(el);
		}, this);
		this.scrollBar = $(scrollBar);
		this.sizeScrollBar();
		this.makeSlider();
		this.setupWheel();
		var scrolling;
		['forward','back'].each(function(direction) {
			var lnk = $(this.options.scrollLinks[direction]);
			if(lnk) {
				lnk.addEvents({
					mousedown: function() {
						scrolling = this[direction].periodical(50, this);
					}.bind(this),
					mouseup: function(){
						$clear(scrolling);
					}.bind(this)
				});
			}
		}, this);
		var side = (this.horz?"offsetWidth":"offsetHeight");
		var size = this.content[side];
	},

	sizeScrollBar: function(){
		if (!this.isOverFlown()) return this.hide();		
		else this.scrollBar.show();
		var plain = (this.horz)?"width":"height";
		if(this.horz) {
			this.scrollBar.setStyle("width", 
				(this.scrollBar.getParent().getCoordinates().width / 
				(this.options.width / this.container.getCoordinates().width)).toInt() + 'px');
		} else {
			this.scrollBar.setStyle("height", 
				(this.scrollBar.getParent().getCoordinates().height / 
				(this.content.getCoordinates().height / this.container.getCoordinates().height)).toInt() + 'px');
		}		
		return this.scrollBar;
	},
	scroll: function(direction, steps){
		steps = steps||this.options.scrollSteps;
		this.slider.set(this.slider.step+((direction=="forward")?+steps:-steps));
	},
	forward: function(steps) { this.scroll("forward", steps); },
	back: function(steps) { this.scroll("back", steps); },
	page: function(forward) {
		this.fireEvent('onPage', forward);
		this.scroll(($pick(forward, true))?"forward":"back", (this.horz)?this.options.width:this.container.offsetHeight);
	},
	setupWheel: function(){
		if(this.options.wheel) {
			var handleScroll = function(e){
				e = new Event(e);
				if (e.wheel < 0) this.forward();
				else if (e.wheel > 0) this.back();
				e.stop();
			};
			this.container.addEvent('mousewheel', handleScroll.bind(this));
			this.scrollBar.getParent().addEvent('mousewheel', handleScroll.bind(this));
		}
	},
	isOverFlown: function(){
		var plain = (this.horz)?"width":"height";
		return (this.horz)?
					this.options.width > this.container.getCoordinates().width:
					this.content.getCoordinates().height > this.container.getCoordinates().height;
	},
	makeSlider: function(){
		var sldr = Slider.extend({
			clickedElement: function(event){
				var position = event.page[this.z] - this.getPos() - this.half;
				position = position.limit(-this.options.offset, this.max -this.options.offset);
				this.fireEvent('onPage', [this.toStep(position), this.step]);
			}
		});
		var plain = (this.horz)?"width":"height";
		this.slider = new sldr(this.scrollBar.getParent(), this.scrollBar, {
			steps: (this.horz)
				?this.options.width-this.container['offset'+plain.capitalize()]
				:this.content['offset'+plain.capitalize()]-this.container['offset'+plain.capitalize()],
			mode: this.options.mode,
			onChange: function(step) {
				this.content.setStyle(
					(this.horz)?'margin-left':'margin-top', 
					((this.isOverFlown())?step-(step*2):0)+'px'
				);
				this.fireEvent('onScroll', step);
			}.bind(this),
			onPage: function(position, step){
				this.page(position > (step||0));
			}.bind(this)
		});
		if(this.isOverFlown()) this.slider.set(0);
	},
	update: function(){
		this.sizeScrollBar();
		var s = this.slider; //saving a few bytes
		var axis = (this.horz)?'Width':'Height';
		s.options.steps = (this.horz)
			?this.options.width-this.container['offset'+axis]
			:this.content['offset'+axis]-this.container['offset'+axis];
		s.max = s.element['offset'+axis]-s.knob['offset'+axis];
		s.half = s.knob['offset'+axis]/2;
		s.getPos = s.element['get'+((axis=="Width")?'Left':'Top')].bind(s.element);
		s.drag.options.limit[(axis == "Width")?'x':'y'] = [0, s.max];
		this.slider.set(this.slider.step||0);
	},
	hide: function(){
		this.scrollBar.getParent().getParent().setStyle('display', 'none');
	}
});
MooScroller.implement(new Options);
MooScroller.implement(new Events);
