
var count_navigation  = 5;

var background_images = new Array();
var navigation_images = new Array();
var mouseover         = new Array();

for (i=1; i<=count_navigation; i++) {
    mouseover[i]       = false;
    navigation_images[i]     = new Image();
    navigation_images[i].src = "images/navigation/"+i+"on.gif";
}

// Flash background images
function preload_backgrounds() 
{
    for (i=1; i<=6; i++) {
        window.status = "loading background_image "+i+"...";
        background_images[i]     = new Image();
        background_images[i].src = "images/banners/"+i+".jpg";
    }
}

function swap_background(id) {
    if (document.getElementById("flash")) {
        document.getElementById("flash").style.backgroundImage = "url(images/banners/"+id+".jpg)";
    }        
}

function show_navigation(id) {
    for (i=1; i<=count_navigation; i++) {
        hide_navigation_now(i);
    }
    
    mouseover[id] = true;
    
    if (document.getElementById) {
        if (document.getElementById("headflash")) {
            document.getElementById("headflash").style.visibility = "hidden";
        }
        
        if (document.getElementById("navigation"+id)) {
            document.getElementById("navigation"+id).src = "images/navigation/"+id+"on.png";
            document.getElementById("navigation"+id).parentNode.style.backgroundColor = "#F2F6F7";
        }
        if (document.getElementById("sub_navigation_"+id)) {
            document.getElementById("sub_navigation_"+id).style.visibility = "visible";
        }
    }
}

function hide_navigation(id)
{
    if (document.getElementById("headflash")) {
        document.getElementById("headflash").style.visibility = "visible";
    }
    
    mouseover[id] = false;
    
    window.setTimeout("hide_navigation_now("+id+");", 100);
}

function hide_navigation_now(id)
{
    if (mouseover[id] == false && document.getElementById) {
        if (document.getElementById("navigation"+id)) {
            document.getElementById("navigation"+id).src = "images/navigation/"+id+"off.png";
            document.getElementById("navigation"+id).parentNode.style.backgroundColor = "#FFFFFF";
        }
        if (document.getElementById("sub_navigation_"+id)) {
            document.getElementById("sub_navigation_"+id).style.visibility = "hidden";
        }
    }
}

/**** Begin original top navigation ***/
function show_navigation1(id) {
    for (i = 1; i <= count_navigation; i++) {
        hide_navigation_now(i);
    }

    mouseover[id] = true;

    if (document.getElementById) {
        if (document.getElementById("headflash")) {
            document.getElementById("headflash").style.visibility = "hidden";
        }
        if (document.getElementById("sub_navigation_" + id)) {
            document.getElementById("sub_navigation_" + id).style.visibility = "visible";
        }
    }
}

function hide_navigation1(id) {
    if (document.getElementById("headflash")) {
        document.getElementById("headflash").style.visibility = "visible";
    }

    mouseover[id] = false;

    window.setTimeout("hide_navigation_now1(" + id + ");", 100);
}


function hide_navigation_now1(id) {
    if (mouseover[id] == false && document.getElementById) {
        if (document.getElementById("sub_navigation_" + id)) {
            document.getElementById("sub_navigation_" + id).style.visibility = "hidden";
        }
    }
}
/**** End original top navigation ***/

/**** Begin new top navigation ***/
function HideSubMenu(sender) {
    var divs = sender.getElementsByTagName('div');
    divs[0].style.display = 'none';

    var imgs = sender.getElementsByTagName('img');
    imgs[imgs.length - 1].src = imgs[imgs.length - 1].src.replace(/on.jpg/i, 'off.jpg');

    sender.style.backgroundColor = '#FFFFFF';
}

function ShowSubMenu(sender, isDropdown) {
    var divs = sender.getElementsByTagName('div');
    var left = 0;
    var top = 0;
    var parent = sender;

    while (parent != null && parent.tagName != 'BODY') {
        left += parent.offsetLeft;
        top += parent.offsetTop;

        parent = parent.offsetParent;
    }

    divs[0].style.display = 'block';
    divs[0].style.top = top + sender.offsetHeight + 'px';
    divs[0].style.left = left + 'px';


    var imgs = sender.getElementsByTagName('img');
    imgs[imgs.length - 1].src = imgs[imgs.length - 1].src.replace(/off.jpg/i, 'on.jpg');

    if (isDropdown == 'true') {
        sender.style.backgroundColor = '#F2F6F7';
    }
}
/**** End new top navigation ***/
