var amcBackground = new Class({
    Implements: [Options, Events],

    options: {
		
    },
    
    initialize: function(el,options){
    	this.bgImg = el;
    	this.setOptions(options);
    	this.imageSize = el.getSize();
    	this.resizeImg();
    	
    	//Make sure window resizes resize the image
    	window.addEvent('resize',this.resizeImg.bind(this));
    },
    
    /**
     * Resizes the background image to match the window
     */
    resizeImg: function() {
    	var windowSize = window.getSize();	
    	var browserRatio	= windowSize.x/windowSize.y;
		var imageRatio 		= this.imageSize.x/this.imageSize.y;
		
		//Resize the image appropriately for height or width
		if(browserRatio <= imageRatio) {
			//Browser proportions are narrower than the image proportions
			this.bgImg.setStyles({
				'height': 		windowSize.y,
				'width': 		windowSize.y * imageRatio,
				'margin-top':	0,
				'margin-left':	(-(windowSize.x - (windowSize.y * imageRatio))/-2)	
			});

		} else {
			//Browser proportions are wider than the image proportions
			this.bgImg.setStyles({
				'width':		windowSize.x,
				'height':		windowSize.x/imageRatio,
				'margin-top':	(((windowSize.x/imageRatio) - windowSize.y)/-2),
				'margin-left':	0
			});
		}
    },
    
    /**
     * Takes an image and sets the background
     */
    setImg: function(el) {
    	this.bgImg.src = el.getProperty('src');
    	this.bgImg.setStyles({
    		'height':		'',
    		'width':		''
    	});
    	this.imageSize = el.getSize();
    	this.resizeImg();
    }
});