﻿window.onload = function () {
    popup();
    abrirPopupMovel();
}

/*
//  Função para ajustar a posição do rodapé.   
function getWindowHeight() {

    var windowHeight = 0;
    /*
    if (typeof(window.innerHeight) == 'number') {
        windowHeight = window.innerHeight;
    } else {
    
        if (document.documentElement && document.documentElement.clientHeight) {
            windowHeight = document.documentElement.clientHeight;
        } else {
        
            if (document.body && document.body.clientHeight) {
                windowHeight = document.body.clientHeight;
            }
        }
    }
    
    return windowHeight;
}*/

// Função para Popup.
function abrirPopup() {
    var dPopup = document.getElementById('popup');
    if (dPopup != null) {
        dPopup.style.display = 'block';
        setTimeout("fecharPopup()", 5500);
    }
}


function fecharPopup() {
    document.getElementById('popup').style.display = 'none';
}


var pMovelTimeout;
var pMovelCount = 1;

// Função para Popup móvel.
function abrirPopupMovel() {
    var divPopupMovel = document.getElementById('popMovel');
    if (divPopupMovel) {
        divPopupMovel.style.display = 'block';
        pMovelTimeout = setTimeout("moverPopupMovel()", 500);
    }
}


function moverPopupMovel(clicado) {
    var divPopupMovel = document.getElementById('popMovel');


    // clicado?
    if (clicado != null) {
        clearTimeout(pMovelTimeout);
        divPopupMovel.style.display = 'none';
        window.location.href = "Jogos.aspx";
    }
    

    // fim dos segundo?
    if (pMovelCount >= 250) {
        clearTimeout(pMovelTimeout);
        divPopupMovel.style.display = 'none';

        return;
    }

    var posicao = (0.5 * pMovelCount).toString() + "px";

    divPopupMovel.style.left = posicao;
    divPopupMovel.style.top = posicao;

    pMovelTimeout = setTimeout("moverPopupMovel()", 50);

    pMovelCount++;
}


function fecharPopupMovel(clicado) {
    clearTimeout(pMovelTimeout);
    document.getElementById('popMovel').style.display = 'none';
    if (clicado != null) {
        window.location.href = "Jogos.aspx";
    }
}




function popup() {

    if (!document.getElementsByTagName) {
        return false;
    }

    var Links = document.getElementsByTagName("a");

    for (var i = 0; i < Links.length; i++) {
        switch (Links[i].className) {
            case 'popup':
                Links[i].onclick = function() {
                    window.open(this.href, null, "width=640,height=480,status=yes,toolbar=yes,menubar=no,location=no");
                    return false;
                }
                break;
            default:
                break;
        }
    }

    return true;
}
