AICMedia.Footer = {

	showState: false,
	time: 500,

	initialize: function() {
		this.el = $('#footer');
		this.transparent = this.el.find('.transparent:first');
		this.content = this.el.find('.content');
		this.toggler = $('#footer-toggler');
        this.phones = this.el.find('.phones .phone-list span.group');
		this.toggler.click($.proxy(this.toggle, this));

		this.transparent.css('opacity', .6);
		this.toggler.children().css('opacity', .6);


		this.endHeight = this.content.height();
		this.el.removeClass('b-footer_toggled').addClass('b-footer_start');
		this.startHeight = this.content.height();
        this.el.removeClass('b-footer_start');
		this.content.height(this.startHeight);

		this.el.css('visibility', 'visible');

        this.el.find('#pointer td.group h2 a').hover(function() {
            $(this).addClass('base-color').find('.base-color').removeClass('base-color').addClass('not-base-color');
        }, function() {
            $(this).removeClass('base-color').find('.not-base-color').removeClass('not-base-color').addClass('base-color');
        }).append('<div class="bg"><span class="left"></span><span class="right"></span></div>');
	},

	show: function() {
		if ( !this.showState ) {
			var opacity = .8;
			var height = this.endHeight;
			var easing = 'easeOutExpo';
			this.animate(opacity, height, easing);
			this.showState = true;
		}
	},

	hide: function() {
		if ( this.showState ) {
			var opacity = .6;
			var height = this.startHeight;
			var easing = 'easeOutExpo';
			this.animate(opacity, height, easing);
			this.showState = false;
		}
	},

    dropHide: function() {
        if (!this.el) {
            setTimeout($.proxy(this.dropHide, this), 50);
            return;
        }
        this.el.hide('drop', { direction: 'down' });
    },

    dropShow: function() {
        this.el.show('drop', { direction: 'down' });
    },

	animate: function(opacity, height, easing) {
		this.el.toggleClass('b-footer_toggled')

		this.transparent.animate({ opacity: opacity }, this.time, easing);
		this.toggler.children().animate({ opacity: opacity }, this.time, easing);
		this.content.animate({ height: height }, this.time, easing);
	},

	toggle: function() {
		if ( this.showState ) this.hide(); else this.show();
	},

	setMenu: function() {
		$('#footer h2').removeClass('active');
		if ( AICMedia.PageLoader.currentPage ) {
			$('#footer h2 a[href="#'+AICMedia.PageLoader.currentPage+'"]').parent().addClass('active');
		}
	}

};

