var background = {
	config: {
		e2_widthFactor: 1		//scrollingfactor des hintergrundbildes
	},
	
	returnWindowSize: function() {
		return {
			width: jQuery(window).width(),
			height: jQuery(window).height()
		}
	},
	
	win : {
		ratio: false,
		size: false
	},
	
	img : {
		id : false,
		ratio: false,	
		size: {
			width: 0,
			height: 0
		},
		
		pos: {
			left: 0,
			top: 0,
			max : 0
		}
	},

	
	addStyle : function(target, property, value) {
		var style = new Object();
			style[property] = value;			
			jQuery(target).css(style);
	},
	
	calculateSizes: function() {
		
		this.win.size = this.returnWindowSize();
		this.win.ratio = (this.win.size.height / this.win.size.width).toPrecision(4);
		
		if(this.img.ratio <= this.win.ratio) {
			this.img.size.width =  Math.round(this.win.size.height / this.img.ratio);
			this.img.size.height = this.win.size.height;
			this.img.pos.max = (this.win.size.width - this.img.size.width)/2;
			this.img.pos.left = (this.win.size.width - this.img.size.width) / 2
			this.img.pos.top = 0;
		} else {
			this.img.size.width =  Math.round(this.win.size.width * this.config.e2_widthFactor);
			this.img.size.height = Math.round(this.img.size.width * this.img.ratio);
			this.img.pos.max = (this.win.size.width - this.img.size.width)/2;
			this.img.pos.left = 0;
			this.img.pos.top = (this.win.size.height - this.img.size.height) / 2;
		}
		
	},
	
	setSize: function() {
	
		this.calculateSizes();
		
		this.addStyle('.e2', 'width', this.img.size.width+'px');
		this.addStyle('.e2', 'height', this.img.size.height+'px');
		this.addStyle('.e2', 'left', this.img.pos.left + 'px');
		this.addStyle('.e2', 'top', this.img.pos.top +'px');
		

	},
	
	moveUp: function() {
		img.pos.top = -200;
		jQuery('.e2').animate({
				top: img.pos.top
		}, animations.config.animation.speed);
	},
	
	moveDown: function() {
		img.pos.top = 0;
		jQuery('.e2').animate({
				top: img.pos.top
		}, animations.config.animation.speed);
	}
}
