var countdownElement = false;
var endSeconds = false;
var currentSeconds = false;

var LeadingZero = true;

var inFullscreen = false;

function getDocumentSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
	}
	return new Array(myWidth,myHeight);
}

function fullScreen() {
	var playerElement = document.getElementById('Player');
	var playerBackground = document.getElementById('playerBackground');

	if (!playerElement) {
		playerElement = document.getElementById('embedplayer');
	}
	
	if (playerElement) {
		if (!inFullscreen) {
			var size = getDocumentSize();

			// alert(playerBackground);
			playerBackground.style.position = 'absolute';
			playerBackground.style.top = '0px';
			playerBackground.style.left = '0px';
			playerBackground.style.backgroundColor = '#FFFFFF';
			playerBackground.style.width = size[0] + 'px';
			playerBackground.style.height = size[1] + 'px';
			playerBackground.style.zIndex = '10';
			playerBackground.style.display = 'block';

			playerElement.style.position = 'absolute';
			playerElement.style.top = '10px';
			playerElement.style.left = '0px';
			playerElement.width = size[0] + 'px';
			playerElement.height = size[1] + 'px';
			playerElement.style.zIndex = '11';

			inFullscreen = true;
		}
		else {
			playerElement.style.position = 'static';
			playerElement.width = '360';
			playerElement.height = '315';
			
			playerBackground.style.display = 'none';
			
			inFullscreen = false;
		}
	}
}
function startCountdown(elementName,nowtime) {
	countdownElement = document.getElementById(elementName);
	endSeconds = endSecondsValue;
	currentSeconds = nowtime;
	doCountdown();
}
function calcage(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (LeadingZero && s.length < 2)
    s = "0" + s;
  return s;
}
function doCountdown() {
	var minutes = 1000 * 60;
	var hours = minutes * 60;
	var days = hours * 24;
	var years = days * 365;
	var d = new Date();
	var t = d.getTime();
	currentSeconds = Math.floor(t / 1000);
	
	var differenceInSeconds = endSeconds - currentSeconds;
	
	if (differenceInSeconds <= 0) {
		countdownElement.innerHTML = 'Auktionen er afsluttet.';
	}
	else {
		var days = calcage(differenceInSeconds,86400,100000);
		var hours = calcage(differenceInSeconds,3600,24);
		var minutes = calcage(differenceInSeconds,60,60);
		var seconds = calcage(differenceInSeconds,1,60);
		
		countdownElement.innerHTML = days + ' dage, ' + hours + ' timer, ' + minutes + ' minutter ' + seconds + ' sekunder';
		
		setTimeout(function() {
			doCountdown();
		},1000);
	}
}