
/* NEW VERSION */
// preload...
var img = new Image();    
img.src='/images/check.gif';

var popupodb = document.getElementById("popup-odb");
var popupodbq = document.getElementById("popup-q");


var check1 = document.getElementById("pop-check1");
var check2 = document.getElementById("pop-check2");

function checkCond(e) {
    if (this.check) {
        this.check = false;
        this.className = "pop-uncheck";
    } else {
        this.check = true;
        this.className = "pop-check";
    }
}

var hrefs = popupodbq.getElementsByTagName("a");
for (a in hrefs) {
    hrefs[a].onclick = handleHref;
}
function handleHref(e) {

    if(e && typeof e.stopPropagation == 'function') {
        e.stopPropagation();    
    } else if (window.event) { 
        window.event.cancelBubble = true;
    }
    
    if (this.className == 'pop-yes') {
        return canProceed(this);
    }      
}
function canProceed(e) {
    if (check1.check && check2.check) {
        //alert('Všechno ok, můžeme pokračovat, ale abysme nemuseli přemazávat cookies tak pokračovat nebudeme. :)');
        return true;
    } else {
        alert("Pro pokračování do odborné sekce je potřeba souhlasit s podmínkami.");
        return false;
    }
}

var navig = navigator.appName;

// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
    
    var xScroll, yScroll;
    
    if (window.innerHeight && window.scrollMaxY) {    
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    
    var windowWidth, windowHeight;
    if (self.innerHeight) {    // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }    
    
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else { 
        pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){    
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }

    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight, xScroll, yScroll); 
    return arrayPageSize;
}


function showPopupOdb() {
        
        var pagesize = getPageSize();    
        
        popupodb.style.display = "block";
        popupodb.style.height = pagesize[1]+"px";
        
        popupodbq.style.margin = ((pagesize[3]-490)/2) +"px auto 0 auto";
        
        document.body.style.overflow="hidden";

}

function resizePopupOdb() {

        var pagesize = getPageSize();
    
        popupodb.style.display = "block";
        popupodb.style.height = pagesize[1]+"px";

}

check1.onclick = checkCond;
check2.onclick = checkCond;

check1.check = false;
check2.check = false;

showPopupOdb();
window.onload = showPopupOdb;
window.onresize = showPopupOdb;

