/*
 * @file
 * @description Contains the thiskbox.
 *
 * @author Keve Kutner <keve.kutner@4digits.hu>
 * @owner  4DIGITS Kft. <http://4digits.hu>
 */

/**
 * @class
 * @description thiskBox is a lightweight lightbox implementation.
 *
 * @param grayerDivId The id of the grayer div.
 * @param contentDivId The id of the content div.
 *
 * @returns void
 */
function thiskBox(grayerDivId, contentDivId) {
    this.defPos     = 'center';
    this.cHeight    = 0;
    this.cWidth     = 0;
    this.grayerDiv  = document.getElementById(grayerDivId);
    this.contentDiv = document.getElementById(contentDivId);
}//end thiskBox()

/**
 * @function
 * @description Saves the entered content size in the class.
 *
 * @param w The id of the grayer div.
 * @param h The id of the content div.
 *
 * @returns void
 */
thiskBox.prototype.setSize = function(w, h) {
    this.cHeight = h;
    this.cWidth  = w;
};//end setSize()

/**
 * @function
 * @description Sets the grayer to the screen size.
 *
 * @returns void
 */
thiskBox.prototype.alignGrayer = function() {
    this.setGrayerHeight();
    this.setGrayerWidth();
};//end alignGrayer()

/**
 * @function
 * @description Sets the content div's size and position.
 *
 * @returns void
 */
thiskBox.prototype.alignContent = function() {
    this.setContentSize();
    this.setContentPosition();
};//end alignContent()

/**
 * @function
 * @description Shows the grayer and the content.
 *
 * @returns void
 */
thiskBox.prototype.show = function() {
    this.grayerDiv.style.display  = 'block';
    this.contentDiv.style.display = 'block';
};//end show()

/**
 * @function
 * @description Hides the grayer and the content.
 *
 * @returns void
 */
thiskBox.prototype.hide = function() {
    this.grayerDiv.style.display  = 'none';
    this.contentDiv.style.display = 'none';
};//end hide()

/**
 * @function
 * @description Getter for the screen height.
 *
 * @returns void
 */
thiskBox.prototype.getScreenHeight = function() {
    return document.body.scrollHeight;
};//end getScreenSize()

/**
 * @function
 * @description Getter for the screen width.
 *
 * @returns void
 */
thiskBox.prototype.getScreenWidth = function() {
    return document.body.scrollWidth;
};//end getScreenWidth()

/**
 * @function
 * @description Setter for the grayer div's height.
 *
 * @returns void
 */
thiskBox.prototype.setGrayerHeight = function() {
    this.grayerDiv.style.height = this.getScreenHeight();
};//end setGrayerHeight()

/**
 * @function
 * @description Setter for the grayer div's width.
 *
 * @returns void
 */
thiskBox.prototype.setGrayerWidth = function() {
    this.grayerDiv.style.width = this.getScreenWidth();
};//end setGrayerWidth()

/**
 * @function
 * @description Setter for the content div's size.
 *
 * @returns void
 */
thiskBox.prototype.setContentSize = function() {
    this.contentDiv.style.width  = this.cWidth;
    this.contentDiv.style.height = this.cHeight;
};//end setContentSize()

/**
 * @function
 * @description Setter for the content div's position.
 *
 * @returns void
 */
thiskBox.prototype.setContentPosition = function() {
    var halfW = this.getScreenWidth() / 2 - this.cWidth / 2;
    var halfH = this.getScreenHeight() / 2 - this.cHeight / 2;

    this.contentDiv.style.top  = halfH;
    this.contentDiv.style.left = halfW;
};//end setContentPosition()

/**
 * @function
 * @description Setter for the content div's content.
 *
 * @returns void
 */
thiskBox.prototype.setContent = function(content) {
    this.contentDiv.innerHTML = content;
};//end setContent()