var singletonAnimation = null;
var Animation = new Class({
					initialize: function(){
						start = Cookie.get("startAnimation");
						if(start != undefined && start != false)
							this.start = start;
						else
							this.start = 0;
						
						$('photos-haut').setStyles( {'background-position': this.start + 'px 50%',
													 'background-image': 'url("images/banderole.png")',
													 'background-repeat':'repeat-x' });
						img = new Element('img', {'src' : 'images/banderole.png'});
						this.stop = 0 - img.width;
						this.transparence();
						this.launch();
												
						if(window.opera)
							window.addEvent('unload', function(){singletonAnimation.setCook();});
						else
							window.addEvent('beforeunload', function(){singletonAnimation.setCook();});
					},
					setCook: function(){
						Cookie.set("startAnimation", $('photos-haut').getStyle('background-position').toInt());
					},
					transparence: function() {
						for(i=0;i<50;i++)
						{
							div = new Element('div', {'class': 'transparence'});
							div.setOpacity(1-(i*0.02));
							$('photos-haut').adopt(div);
						}
						for(i=0;i<50;i++)
						{
							div = new Element('div', {'class': 'transparenceDroit'});
							div.setOpacity(1-(i*0.02));
							$('photos-haut').adopt(div);
						}
					},
					launch: function() {
						if(this.stop == 0)
						{
							img = new Element('img', {'src' : 'images/banderole.png'});
							this.stop = 0 - img.width;
						}
						delai = (-48 * (this.stop - this.start));
						effect = new Fx.Style($('photos-haut'), 'background-position', { duration:delai,transition: Fx.Transitions.linear });
						effect.start(this.start, this.stop).chain(function(){ this.start = 0; this.launch(this); }.bind(this));
					}
				});

