﻿// 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 = '#000000';
//    document.getElementById('topdiv' + divid).style.backgroundColor = '#FFFFFF';
}

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 = '#FFFFFF';
//        document.getElementById('topdiv' + divid).style.backgroundColor = '#000000';
        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 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;
} 

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)
        {
            //oldLeftMenuShow.style.display= 'none';
            //oldLeftMenuDivShow.style.display= 'none';
        }
    }
    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;
}
