﻿// JScript File
var debug = true;
function WorldShowCountries(obj, tabid) {
    try {
        var continents = document.getElementById('Continents').getElementsByTagName('a');
        for (i = 0; i < continents.length; i++) {
            continents[i].style.fontWeight = (continents[i].id == obj.id) ? 'bold' : '';
        }

        var country = document.getElementById('Countries');
        country.style.display = 'block';
        var countries = country.getElementsByTagName('div');
        for (i = 0; i < countries.length; i++) {
            if (countries[i].id == tabid) {
                countries[i].style.display = 'block';
            }
            else {
                countries[i].style.display = 'none';
            }
        }
        WorldShowContacts('undefined', '');
    }
    catch (err) {
        //Handle errors here
        if (debug)
            alert(err);
    }
}

function WorldShowContacts(obj, tabid) {
    try {
        var countries = document.getElementById('Countries').getElementsByTagName('a');
        for (i = 0; i < countries.length; i++)
            countries[i].style.fontWeight = (countries[i].id == obj.id) ? 'bold' : '';

        var contact = document.getElementById('Contacts');
        contact.style.display = (obj == 'undefined') ? 'none' : 'block';
        var contacts = contact.getElementsByTagName('div');
        for (i = 0; i < contacts.length; i++) {
            if (contacts[i].id == tabid)
                contacts[i].style.display = 'block';
            else
                contacts[i].style.display = 'none';
        }
    }
    catch (err) {
        //Handle errors here
        if (debug)
            alert(err);
    }
}

function switchHighlightVisible(divid, ismouseover) {
    var divs = document.getElementById('HighlightsContent').getElementsByTagName('div');
    var preid = divid.id.replace('HighlightsText', '');
    divid.style.backgroundColor = '#FFFFFF';
    divid.getElementsByTagName('a')[0].className = 'HighlightsLinkOn';
    for (i = 0; i < divs.length; i++) {
        if (divs[i].id.match('HighlightsImage')) {
            if (divs[i].id == preid + 'HighlightsImage') {
                divs[i].style.display = (ismouseover) ? 'block' : 'none';
            }
            else {
                divs[i].style.display = (ismouseover) ? 'none' : 'block';
            }
        }
        else if (divs[i].id.match('HighlightsText') && divs[i].id != divid.id) {
            divs[i].style.backgroundColor = '#f2f0ef';
            divs[i].getElementsByTagName('a')[0].className = 'HighlightsLinkOff';
        }
    }
}

function MenuOnMouseOver(divid, seltabid) {
    if (divid != seltabid) {
        if (document.getElementById('div' + seltabid) != null)
            document.getElementById('div' + seltabid).style.display = 'none';
        if (document.getElementById('div' + divid) != null)
            document.getElementById('div' + divid).style.display = 'block';
    }
    else {
        if (document.getElementById('div' + seltabid) != null)
            document.getElementById('div' + seltabid).style.display = 'block';
    }

    document.getElementById('topdiv' + divid).style.color = '#a29061';
    document.getElementById('topdiv' + divid).style.backgroundColor = '#000000';
}

function MenuOnMouseOut(divid, seltabid) {
    if (divid != seltabid) {
        if (document.getElementById('div' + divid) != null) {
            document.getElementById('div' + divid).style.display = 'none';
        }
        document.getElementById('topdiv' + divid).style.color = '#000000';
        document.getElementById('topdiv' + divid).style.backgroundColor = '#FFFFFF';
        if (document.getElementById('div' + seltabid) != null)
            document.getElementById('div' + seltabid).style.display = 'block';
    }
}
function SetDisplayNone(divid, display) {
    document.getElementById('div' + divid).style.display = display;
}

function clickButton(e, buttonid) {
    var bt = document.getElementById(buttonid);
    var keyCode = e.charCode ? e.charCode : e.keyCode;

    if (keyCode == 13) {
        if (bt.tagName == 'A')
            eval(bt.href);
        else if (bt.tagName == 'input')
            bt.click();

        return false;
    }
}
function clickButton1(e, buttonid) {
    var bt = document.getElementById(buttonid);
    var keyCode = e.charCode ? e.charCode : e.keyCode;

    if (keyCode == 13) {
        bt.click();
        return false;
    }
}

function mouseOverImage(imageid, imageurl) {
    document.getElementById(imageid).src = imageurl;
    return true;
}

function mouseOutImage(imageid, imageurl) {
    document.getElementById(imageid).src = imageurl;
    return true;
}

function ClearTextBox(obj, bit, msg) {
    var elem = document.getElementById(obj);

    if (bit) {
        if (elem.value == msg) {
            elem.value = '';
        }
    }
    else { if (elem.value == '') { elem.value = msg; } else { elem.value; } }
    return false;
}
function ChangeType(obj, bit, msg, e) {
    var elem = document.getElementById(obj);
    var keyCode = e.keyCode;
    if (bit || e.type == 'keypress') {
        if (elem.value == msg) {
            elem.value = '';
            elem.type = 'Password';
        }
    }
    else {
        if (elem.value == '') {
            elem.type = 'Text';
            elem.value = msg;

        }
        else {
            elem.value;
        }
    }
    return false;
}



function HideInputPassword(input, inputToHide, bit, e) {
    var InputPassword = input;
    var FakeInPut = inputToHide;
    var keyCode = e.keyCode;

    if (e.type == "focus" || e.type == "click" || keyCode == 9) {
        FakeInPut.style.display = 'none';
        InputPassword.style.display = 'block';
        InputPassword.focus();
    } else if (e.type == "blur" && bit == true && InputPassword.value != "") {
        FakeInPut.style.display = 'none';
        InputPassword.style.display = 'block';
    }
    else {
        InputPassword.style.display = 'none';
        FakeInPut.style.display = 'block';
    }
    return true;
}
function HideInputPasswordHelper(input, inputToHide, e) {
    var InputPassword = input;  
    var FakeInPut = inputToHide;
    var keyCode = e.keyCode;
    if (keyCode == 9) {
        FakeInPut.style.display = 'none';
        InputPassword.style.display = 'block';
        InputPassword.focus();

    }
    return false;


}


var oldLeftMenuShow = null;
var oldLeftMenuDivShow = null;
function ShowSubMenu(elem) {
    if (elem.childNodes.length == 2 && oldLeftMenuShow == elem.childNodes[1].childNodes[0]) {
        oldLeftMenuShow.style.display = 'none';
        oldLeftMenuDivShow.style.display = 'none';
        oldLeftMenuShow = null;
        return;
    }
    else {
        if (oldLeftMenuShow != null && oldLeftMenuShow != elem) {
        }
    }
    if (elem.childNodes.length == 2) {
        if (elem.childNodes[0].href == null || elem.childNodes[0].href == "") {
            var subMenu = elem.childNodes[1].childNodes[0];
            var subMenuDiv = elem.childNodes[1];
            if (subMenu.style.display == 'none' || subMenu.style.display == "") {
                subMenu.style.display = 'block';
                subMenuDiv.style.display = 'block';
                oldLeftMenuShow = subMenu;
                oldLeftMenuDivShow = elem.childNodes[1];
            }
            else {
                subMenu.style.display = 'none';
                subMenuDiv.style.display = 'none';
            }
        }
    }

    return false;
}


function imageRotator(imageid, image, descriptionid, description) {

    document.getElementById(imageid).src = image;
    document.getElementById(descriptionid).innerHTML = description;

}

function videoRotator(imageid, image, descriptionid, description) {

    document.getElementById(imageid).src = image;
    document.getElementById(descriptionid).innerHTML = description;

}
function HideDiv(id) {
    // Esconde  a janela
    if (document.getElementById(id).style.display == 'block') {
        document.getElementById(id).style.display = 'none'
    } else {
        document.getElementById(id).style.display = 'block'

    }
    function Openpage(url, windowsname, windowsfeature) {

        alert("funcao");
        window.open(url, windowsname, windowsfeature).focus();


    }

}
