﻿function resizeContent() {
  resizeFont();
  resizeLogo();
  resizeFacts();
  resizeContacts();
  resizeIntro();
  resizeDescription();
  showContainer();
}

function resizeFont() {
  this.setFontSize(document.body, 2);
  this.setFontSize(document.getElementsByTagName("h1")[0], 4);
}

function resizeLogo() {
  var element = document.getElementById("logo");

  this.setHeight(element, 50);
  this.setLeftAbs(element, this.getWidth() / 2 - this.getLogoWidth() / 2);
  this.setTop(element, 10);
}

function resizeFacts() {
  var element = document.getElementById("facts");

  this.setLeftAbs(element, this.getLogoLeft() - 200);
  this.setTop(element, 5);
  this.setWidthAbs(element, this.getLogoPositionA() + 200);
}

function resizeContacts() {
  var element = document.getElementById("contacts");

  this.setLeftAbs(element, this.getLogoLeft());
  this.setTop(element, 20);
  this.setWidthAbs(element, this.getLogoPositionA());
}

function resizeIntro() {
  var element = document.getElementById("intro");

  this.setLeftAbs(element, this.getLogoLeft() + this.getLogoPositionB());
  this.setTop(element, 5);
}

function resizeDescription() {
  var element = document.getElementById("description");

  this.setLeftAbs(element, this.getLogoLeft() + this.getLogoPositionB());
  this.setTop(element, 20);
}

function showContainer() {
  document.getElementById("container").style.visibility = "visible";
}

/* General elements */
function getWidth() {
  return document.documentElement.clientWidth;
}

function getHeight() {
  return document.documentElement.clientHeight;
}

function getFontSize(percents) {
  return this.getHeight() / 100.0 * percents;
}

function setLeft(element, percents) {
  element.style.left = this.getWidth() / 100.0 * percents + "px"
}

function setLeftAbs(element, pixels) {
  element.style.left = pixels + "px"
}

function setTop(element, percents) {
  element.style.top = this.getHeight() / 100.0 * percents + "px"
}

function setTopAbs(element, pixels) {
  element.style.top = pixels + "px"
}

function setWidth(element, percents) {
  element.style.width = this.getWidth() / 100.0 * percents + "px"
}

function setWidthAbs(element, pixels) {
  element.style.width = pixels + "px"
}

function setHeight(element, percents) {
  element.style.height = this.getHeight() / 100.0 * percents + "px"
}

function setHeightAbs(element, pixels) {
  element.style.height = pixels + "px"
}

function setFontSize(element, percents) {
  element.style.fontSize = this.getFontSize(percents) + "px";
}

/* Logo element */
function getLogoLeft() {
  return parseInt(document.getElementById("logo").style.left);
}

function getLogoTop() {
  return parseInt(document.getElementById("logo").style.top);
}

function getLogoWidth() {
  return parseInt(document.getElementById("logo").width);
}

function getLogoHeight() {
  return parseInt(document.getElementById("logo").height);
}

function getLogoPositionA() {
  return this.getLogoWidth() * 0.38;
}

function getLogoPositionB() {
  return this.getLogoWidth() * 0.475;
}
