var MenuImage = new Class({
    initialize: function(id, smallHeight, smallWidth, fullHeight, fullWidth) {
        this.id = id;
        this.fullImgSrc = $(this.id).src.replace('-s.gif', '.gif');
        this.smallImgSrc = $(this.id).src;
        this.fullHeight = fullHeight;
        this.fullWidth = fullWidth;
        this.smallHeight = smallHeight;
        this.smallWidth = smallWidth;
        this.runningEffect = undefined;
        $(this.id).onmouseover = this.mouseOver.bind(this);
        $(this.id).onmouseout = this.mouseOut.bind(this);
    },
    mouseOver: function(event) {
		if (this.runningEffect !== undefined) this.runningEffect.stop();
		$(this.id).src = this.fullImgSrc;
		$(this.id).height = this.smallHeight;
		$(this.id).width = this.smallWidth;
    	this.runningEffect = $(this.id).effects().start({
			'height': this.fullHeight,
			'width': this.fullWidth,
			'margin-top': '-' + (this.fullHeight - this.smallHeight) / 2
		});
    },
    mouseOut: function(event) {
    	if (this.runningEffect !== undefined) this.runningEffect.stop();
    	this.runningEffect = $(this.id).effects().start({
			'height': this.smallHeight,
			'width': this.smallWidth,
			'margin-top': 0
		}).chain(function(){
			$(this.id).src = this.smallImgSrc;
		}.bind(this));
    }
});

window.addEvent('domready', function() {
	new MenuImage('accueil', 67, 43, 94, 60);
	new MenuImage('presentation', 67, 70, 94, 98);
	new MenuImage('faq', 67, 28, 94, 39);
	new MenuImage('evolution', 67, 65, 94, 91);
	new MenuImage('tarifs', 67, 40, 94, 54);
	new MenuImage('cadeau', 67, 74, 94, 104);
	new MenuImage('presse', 67, 45, 94, 63);
	new MenuImage('galerie', 67, 40, 94, 56);
	new MenuImage('temoignages', 67, 53, 94, 75);
	new MenuImage('concours', 67, 49, 94, 67);
	new MenuImage('contact', 67, 43, 94, 60);
/*
	//Adding the target=new stuff to all external links
	$$('#content a').each(function(a){
//		if (!('' != a.getAttribute('name') | a.getAttribute('href').test('[?]*babymovie.be[?]*', 'i') | a.getAttribute('href').test('#[?]*', 'i') | a.getAttribute('href').test('mailto:[?]*', 'i'))) {
		if (a.getAttribute('href') && a.getAttribute('href').test('http://[?]*', 'i')) {
			a.setAttribute('target', '_new');
		}
	});*/
});
