var PicsSwapper = Class.create({
	version: {
		version : '1.0',
		author  : 'Vincent Louvet <vincent@e-spiration.com',
		requires: 'prototype.js v1.6'
	},

	initialize: function(pic, pics, duration){
		this.slide    = $(pic);
		this.defPic   = this.slide.src;
		this.pics     = $A($$(pics));
		this.zoomPics = [];
		this.timer    = null;
		this.duration = duration || 500;

		this.pics.each(function(p, i){
			var src = p.src.replace('.jpg', '_zoom.jpg');

			this.zoomPics.push(src);
			this.loadImage(src);
		}.bind(this));

		this.start();
	},
	
	loadImage: function(src){
		var img = new Image();
		img.src = src.replace;
	},
	
	start: function(){
		Event.observe(window, 'unload', this.stop.bind(this));
		
		this.pics.each(function(p, i){
			p.observe('mouseover', this.showPic.bindAsEventListener(this, this.zoomPics[i]));
			p.observe('mouseout',  this.resetPic.bind(this));
		}.bind(this));
	},
	
	showPic: function(event, src){
		if(this.timer){
			clearTimeout(this.timer);
		}

		this.slide.src = src;
	},

	resetPic: function(){
		this.timer = setTimeout(function(){
			this.slide.src = this.defPic;
			clearTimeout(this.timer);
		}.bind(this), 500);
	},
	
	stop: function(){
		if(this.timer){
			clearTimeout(this.timer);
		}
	}
});