/**
 * Sets initial style for presentation objects:
 * - Hides the container (with the object and close button
 * - Sets the overlay dimensions and places it on top of window
 */
function setHotelTransportPresentationStyle()
{
    var width = (document.documentElement.clientWidth > 998) ? 998 : document.documentElement.clientWidth;

    document.getElementById('hotel-transport-presentation-container').style.display = 'none';
    document.getElementById('hotel-transport-presentation-overlay').style.width = width + 'px';
    document.getElementById('hotel-transport-presentation-overlay').style.height = document.documentElement.clientHeight + 'px';
    document.getElementById('hotel-transport-presentation-overlay').style.top = '-100%';
    document.getElementById('hotel-transport-presentation-overlay').style.display = 'block';
}

/**
 * Shows the overlay and loads the region presentation
 * Redirects Firefox 1.0 users due to fact swfobject doesn't work properly in this browser
 */
function showHotelTransportPresentation()
{
    showHotelTransportPresentationOverlay();
    return false;
}

/**
 * Slides in the overlay
 */
function showHotelTransportPresentationOverlay()
{
    // set html node's overlay to hidden, so we can't scroll anymore
    var html = document.documentElement;
    html.style.overflow = 'hidden';

    var overlay = document.getElementById('hotel-transport-presentation-overlay');

    if (overlay){

        // calculate top position
        var top = parseInt(overlay.style.top);

        // make sure it is a number
        if (isNaN(top)) top = -100;

        if (top < 0){

            // calculate difference in positions, times the easing factor
            var dy = parseInt((0 - top)*0.2);

            // make sure movement doesn't go below 1 (otherwise we could be trapped in this loop forever)
            if (dy < 1) dy = 1;

            // set the top style
            overlay.style.top = (top + dy) + "%";

            // call this function again
            setTimeout(function() { showHotelTransportPresentationOverlay(); }, .0001);
        } else {
            // overlay is positioned, load the presentation
            document.getElementById('hotel-transport-presentation-container').style.display = 'block';
        }
    }
}

/**
 * Slides out the overlay
 */
function hidePresentationOverlay()
{
    var overlay = document.getElementById('hotel-transport-presentation-overlay');

    if (overlay){

        // calculate top position
        var top = parseInt(overlay.style.top);

        // make sure it is a number
        if (isNaN(top)) top = 0;

        if (top > -100){

            // calculate difference in positions, times the easing factor
            var dy = parseInt((-100 - top)*0.2);

            // make sure movement doesn't go below 1 (otherwise we could be trapped in this loop forever)
            if (dy > -1) dy = -1;

            // set the top style
            overlay.style.top = (top + dy) + "%";

            // call this function again
            setTimeout(function() { hidePresentationOverlay(); }, .0001);
        } else {

            // let there be scrolling once again
            var html = document.documentElement;
            html.style.overflow = 'auto';
        }
    }
}
/**
 * Closes presentation and removes the overlay
 */
function closePresentation()
{
    // remove flash object
    var flashObj = document.getElementById('regiopresentatie');
    if (flashObj) {
        flashObj.parentNode.removeChild(flashObj);
    }

    // hide overlay
    hidePresentationOverlay();

    // hide button
    document.getElementById('hotel-transport-presentation-container').style.display = 'none';
}

