﻿/*
centra oggetto al body
*/
function centraOggetto(idel) {
    element = document.getElementById(idel);
    element.style.top = (getPageScrollY() + ((getPageHeight() - 70) / 2)) + "px";
    element.style.left = ((getPageWidth() - 170) / 2) + "px";
}

/*
restituisce lunghrzza dello scoll della pagina lungo l'asse X
*/
function getPageScrollX() {
    var xScroll;
    if (self.pageYOffset) {
        xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
        xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
        xScroll = document.body.scrollLeft;
    }

    return xScroll;
}

/*
restituisce l'altezza dello scoll della pagina lungo l'asse Y
*/
function getPageScrollY() {
    var yScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
    }

    return yScroll;
}


/*
page max Height (altezza più scroll)
*/
function getPageMaxHeight() {
    var yScroll;
    if (window.innerHeight && window.scrollMaxY) {
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        yScroll = document.body.offsetHeight;
    }

    if (yScroll < getPageHeight()) {
        yScroll = getPageHeight();
    }

    return yScroll;
}

/*
page Height
*/
function getPageHeight() {
    var windowHeight;
    if (self.innerHeight) {	// all except Explorer
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowHeight = document.body.clientHeight;
    }
    return windowHeight;
}

/*
page Width
*/
function getPageWidth() {
    var windowWidth;
    if (self.innerHeight) {	// all except Explorer
        if (document.documentElement.clientWidth) {
            windowWidth = document.documentElement.clientWidth;
        } else {
            windowWidth = self.innerWidth;
        }
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
    }
    return windowWidth;
}

function ClosePopup() {
    document.getElementById("PopupDisservizio").style.display = "none"; ;
    document.getElementById("OverlayPagina").style.display = "none"; ;
}
