/*
FUNKTIONS-SCRIPT
*/


//########## Footer neu positionieren

$(function($) {

	getSize();
	var geofooter = $('#footer').offset();
	if(geofooter.top < 530) {
		var newmarginfooter = 538 - geofooter.top;
		$('#footer').css({'margin-top': newmarginfooter});
	}
});


//########## Hintergrund neu positionieren

MYAPP = {};
MYAPP.imglist = new Array(2,3,1,2,3,2,1,1,1,2,3,1);
var aknow = new Date();
var month = aknow.getMonth();

function getSize() {

	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	MYAPP.winwidth = window.innerWidth;
	MYAPP.winheight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	MYAPP.winwidth = document.documentElement.clientWidth;
	MYAPP.winheight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	MYAPP.winwidth = document.body.clientWidth;
	MYAPP.winheight = document.body.clientHeight;
	}
	
	MYAPP.coverheight = MYAPP.winwidth;
	MYAPP.coverwidth = MYAPP.winheight;
	MYAPP.cover = document.getElementById("cover");
	
	if (MYAPP.winwidth > MYAPP.winheight) {
	if((MYAPP.winwidth * 0.625) < MYAPP.winheight) {
	MYAPP.coverwidth = MYAPP.winheight * 1.6;
	MYAPP.coverheight = MYAPP.winheight;
	} else {
	MYAPP.coverwidth = MYAPP.winwidth;
	MYAPP.coverheight = MYAPP.winwidth * 0.625;
	}
	} else {
	MYAPP.coverwidth = MYAPP.winheight*1.6;
	MYAPP.coverheight = MYAPP.winheight;
	}
	MYAPP.cover.width = MYAPP.coverwidth;
	MYAPP.cover.height = MYAPP.coverheight;
	MYAPP.cover.style.left = "-"+parseInt((MYAPP.coverwidth - MYAPP.winwidth) /2)+"px";
	MYAPP.cover.style.top = "-"+parseInt((MYAPP.coverheight - MYAPP.winheight) /2)+"px";
	return true;
	}
	
	var addEvent = function(elem, type, eventHandle) {
	if (elem == null || elem == undefined) return;
	if ( elem.addEventListener ) {
	elem.addEventListener( type, eventHandle, false );
	} else if ( elem.attachEvent ) {
	elem.attachEvent( "on" + type, eventHandle );
	}
};

addEvent(window, "resize", function() { getSize(); });


