/**
 * @requires jQuery
 * Setup the background.
 */
 
/* Create the namespace */
if (typeof Dansa === 'undefined') {
	var Dansa = {};
}

/* Create the background class */
Dansa.Background = function () {
	
	var t = this;	
	this.img = $('#bg img');
	
	this.resize();
	this.img.show();
	
	$(window).resize(function() {
		t.resize();
	});
	
};

Dansa.Background.prototype = {
	resize: function () {
		
		this.imgH = this.img.height();
		this.imgW = this.img.width();
		this.imgRatio = this.imgH / this.imgW;
		this.windowH = $(window).height();
		this.windowW = $(window).width();
		this.windowRatio = this.windowH / this.windowW;

		if (this.windowRatio < this.imgRatio ) {
			
			this.img.width(this.windowW);
			this.marginTop = - ((this.img.height() - this.windowH) / 2)
			this.img.css('marginTop', this.marginTop);
			
		} else {

			this.img.height(this.windowH);
			this.marginLeft = - ((this.img.width() - this.windowW) / 2)
			this.img.css('marginLeft', this.marginLeft);
			
		}
		
	}
};
