'use strict';

var Fullscreen = (function () {

	var element = null;
	var isFullscreen = false;

	function Begin () {
		isFullscreen = true;

		if(element.requestFullscreen) {
			element.requestFullscreen();
		} else if(element.mozRequestFullScreen) {
			element.mozRequestFullScreen();
		} else if(element.webkitRequestFullscreen) {
			element.webkitRequestFullscreen();
		} else if(element.msRequestFullscreen) {
			element.msRequestFullscreen();
		}
	}

	function End () {
		isFullscreen = false;

		if(document.exitFullscreen) {
			document.exitFullscreen();
		} else if(document.mozCancelFullScreen) {
			document.mozCancelFullScreen();
		} else if(document.webkitExitFullscreen) {
			document.webkitExitFullscreen();
		}
	}

	function Switch () {
		if (isFullscreen) {
			End();
		} else {
			Begin();
		}
	}

	function Init () {
		element = document.documentElement;

		return {
			Switch: Switch,
		};
	}

	return Init();

})();
