window.addEvent('domready',function(){
	new FooterManager({container_class:'.footer'});
});
var FooterManager=new Class({
	Implements:[Events,Options],
	options:{
		footerFX:null,
		position_type:"relative"
	},
	initialize:function(conf)
	{
		this.setOptions(conf);
		this.addListeners();
		this.setup();
	}
});
FooterManager.prototype.addListeners=function()
{
	window.addEvent('show:footer',this.update_footer.bind(this));
	window.addEvent('footer:init',this.show.bind(this));
};
FooterManager.prototype.setup=function()
{
	if($$(this.options.container_class)[0]){
		this.options.footerFX=new Fx.Morph($$(this.options.container_class)[0],{onComplete:function(){this.addResizeListener()}.bind(this)});
		//var newY=this.getPosition();
		//$$(this.options.container_class)[0].setStyles({'opacity':0});
		
		this.show();
		//console.log($$('body')[0].getComputedSize().totalHeight,$$('.header')[0].getComputedSize().totalHeight);
	}
};
FooterManager.prototype.addResizeListener=function()
{
	window.addEvent('resize',this.update_footer.bind(this));
	
	
};
FooterManager.prototype.show=function()
{
	if(this.options.footerFX){
		//var newY=this.getPosition();
		this.options.footerFX.start({'opacity':1});
	}
};
FooterManager.prototype.getPosition=function()
{
	var fHeight=$$(this.options.container_class)[0].getSize().y;
	var ws=window.getSize();
	var pc=($$('.page-content')[0]) ? $$('.page-content')[0].getComputedSize().totalHeight : $$('.page-wrapper')[0].getComputedSize().totalHeight;
	this.options.min_y=pc+20+$$('.header')[0].getComputedSize().totalHeight;
	//this.options.min_y=pc+20+$$(this.options.container_class)[0].getSize().y;
	var ds=$$('body')[0].getComputedSize();
	var newY=(ws.y>this.options.min_y) ? (ws.y-fHeight) : this.options.min_y-fHeight;
	this.options.position_type=(ws.y>this.options.min_y) ? "fixed" : "relative";
	return newY;
};
FooterManager.prototype.update_footer=function()
{
	
	//this.getPosition();
	//$$(this.options.container_class)[0].setStyles({'position':this.options.position_type});
};