var ranNum = 0;

function setRandom() {
    ranNum = Math.floor(Math.random()*100) % 100;
    var image = document.getElementById("imgcode");
    var num = document.getElementById("numCode");
    if (num != null) {
        num.value=ranNum;
    }
    if (image != null) {
        image.src="images/sec/t_" + ranNum + ".png";
    }
    ranHeader = Math.floor(Math.random()*10) % 7 + 1;
    var header = document.getElementById("header");
    header.className = "header" + ranHeader;
}


function showImg (url) {
    var w = window.open(url,"Imaxe", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=600")
    w.moveTo(0,0);
}


function showMap (url) {
    var w = window.open(url,"Mapa", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=640,height=620")
    w.moveTo(0,0);
}

function login(url) {
    var wl = window.open("User.do?forward=" + url, "Login", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=400,height=180");
    wl.moveTo((screen.width-400)/2, (screen.height-180)/2);
}

function windowed(url, title, width, height) {
    var wd = window.open(url, title, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=" + width + ",height=" + height);
    wd.moveTo((screen.width-width)/2, (screen.height-height)/2);
}

function show(id) {                
    var ar = document.getElementsByTagName("span");
    for (var i=0; i<ar.length; i++){
        if (ar[i].className == "subMenu") {
            ar[i].style.display = "none";
        }
    }
    obj = document.getElementById(id);		
    obj.style.display = "";
}

function toggleMenu(id) {
    thisMenu = "menu" + id;
    for (var i = 1; i <= 6; i++) {
        menuName = "menu" + i;
        rightName = "right" + i;
        downName = "down" + i;
        menu = document.getElementById(menuName);
        right = document.getElementById(rightName);
        down = document.getElementById(downName);
        if (menuName == thisMenu) {
            if (menu.style.display == "") {
                menu.style.display = "none";
                right.style.display = "";
                down.style.display = "none";
            } else {
                menu.style.display = "";
                right.style.display = "none";
                down.style.display = "";
            }
        } else {                    
            menu.style.display= "none";                        
            right.style.display = "";
            down.style.display = "none";
        }
    }                
}
