﻿$(document).ready(function(){
	var start;
	var end;
	
	$('#header').animate({
		top: Math.floor(($(window).height() - $('#header').height()) / 2), 
		left: Math.floor(($(window).width() - $('#header').width()) / 2),
	}, 0);
	
	$(window).resize(function() {
		start = new Date().getTime();
		$('#header').animate({
			top: Math.floor(($(window).height() - $('#header').height()) / 2), 
			left: Math.floor(($(window).width() - $('#header').width()) / 2)
		}, 1000);
		end = new Date().getTime();
		$('#measurements').html('<p>Zeit: ' + days_between(start, end) + '</p>')
	});
	
	function days_between(date1, date2) {
    // The number of milliseconds in one day
    var oneday = 1000 * 60 * 60 * 24;

    // Convert both dates to milliseconds
    var dateOne = date1.getTime();
    var dateTwo = date2.getTime();

    // Calculate the difference in milliseconds
    var difference = Math.abs(dateOne - dateTwo);
    
    // Convert back to days and return
    return Math.round(difference/oneday);
	}
});
