var MooResize = new Class({
  Implements: Options,
	options: {
	 mainMinX:980,
	 mainMinY:700,
	 mainID:'mainFlash',
   footerID:'mloFooter' 
	},

	initialize: function(options) {
		if(Browser.loaded){
			this.setup(options);
		} else{
			window.addEvent('domready', this.setup.pass([options],this));
		}
	},
	setup: function(options) { 
    
	  this.setOptions(options);
    //$(this.options.footerID).setStyle('visibility','hidden');
    //$(this.options.mainID).style.visibility = 'hidden';
	  this.resize();
	  
  },
  resize: function() {
    
    var windowSize = $(window).getSize();
    var documentSize = $(window).getScrollSize();
	  
	  var footerEl = $(this.options.footerID);
	  var footerSize = footerEl.getSize();
    
    var mainHeight = windowSize.y - footerSize.y;
    
   var mainWidth = windowSize.x+"px";
      
    if (mainHeight < this.options.mainMinY) {
      mainHeight = this.options.mainMinY;    
    }
    if (windowSize.x < this.options.mainMinX) {
      mainWidth = this.options.mainMinX+"px";  
        
    }

    var mainEl = $(this.options.mainID);
    if (mainEl) { 
      $(this.options.mainID).style.height = mainHeight+"px";
      $(this.options.mainID).style.width = mainWidth;  
      footerEl.setStyle('width',mainWidth);   
    }
    if (((documentSize.x > windowSize.x) && (windowSize.x >= this.options.mainMinX))) {
      // resize again, because ff shows scrollbars while resizing and therefore has not the wright dimensions on first resize
      this.resize();
    }
    this.showElements.delay(500,this);
  },
  showElements: function() {
    $(this.options.footerID).setStyle('visibility','visible');
    $(this.options.mainID).style.visibility = 'visible';
  }
});
