var myFooter;

window.addEvent('domready', function() {
	myFooter = new Footer();
});


var Footer = new Class({
	
	initialize: function() {
		this.needIEHack = ((window.ie && window.ie6) == true);
		this.setupTweens();
		this.addListeners();
	},
	
	setupTweens: function() {
		this.expandTween = new Fx.Elements([$('footer_bg'), $('map')], {duration:600});
		if (this.needIEHack) {
			this.expandTween.addEvent('onComplete', this.tweenComplete.bind(this));
			this.fadeTween = $('footer_content').effect('opacity', {duration: 100}).addEvent('onComplete', this.fadeTweenComplete.bind(this));
		}
	},
	
	addListeners: function() {
		$('footer').addEvent('mouseenter', this.expandFooter.bind(this));
		$('footer').addEvent('mouseleave', this.shrinkFooter.bind(this));
	},
	
	expandFooter: function() {
		this.expanding = true;
		
		this.expandTween.stop();
		this.expandTween.start({
    		'0': { // footer_bg
				'height': [225],
				'top': [-225]
			},
			'1': { // map
				'bottom': [209]
			}
		});
	},
	
	shrinkFooter: function() {
		this.expanding = false;
		if (this.needIEHack) {
			this.hideInfo();
		}
		
		this.expandTween.stop();
		
		this.expandTween.start({
			'0': { // footer_bg
				'height': [22],
				'top': [-22]
			},
			'1': { // map
				'bottom': [6]
			}
		});
	},
	
	showInfo: function() {
		this.expanded = true;
		this.fadeTween.start(0, 1);	
		$('footer_content').style.display = 'block';	
	},
	
	hideInfo: function() {
		this.expanded = false;	
		this.fadeTween.start(0);
	},
	
	tweenComplete: function() {
		if (this.expanding) {
			this.showInfo();
		}
	},
	
	fadeTweenComplete: function() {
		if (!this.expanding) {
			$('footer_content').style.display = 'none';	
		}
	}
});