//Slideshow promo

function switchContent(id) {
numPromos = 4;
promoContent = document.getElementById(id);
    for (var i=1;i<=numPromos;i++) {
        document.getElementById("promoContent" + i).style.display='none';
    }
    promoContent.style.display='block';
}

function showLayer(id) {
var div = returnDiv(id);
    div.visibility = "visible";
}

function hideLayer(id) {
var div = returnDiv(id);
    div.visibility = "hidden";
}

var tim;
var tim2;
var tim3;
// var tim4;
var previousLayer = "";
var open_sub_layer = "";

function mouseOutOfLayer(id) {
    if(id.indexOf("sub_") >= 0) {
    //		alert("previousLayer = " + previousLayer);
        func = "hideLayer('"+previousLayer+"')";
        tim = setTimeout(func, 500);
        func = "hideLayer('"+id+"')";
        tim2 = setTimeout(func, 500);
    }
    else {
    if(open_sub_layer != "") {		
        func = "hideLayer('"+open_sub_layer+"')";
        tim2 = setTimeout(func, 500);
    }
    func = "hideLayer('"+id+"')";
    tim = setTimeout(func, 500);
    }
}

function mouseIntoLayer(id) {
    clearTimeout(tim);
    clearTimeout(tim2);
    clearTimeout(tim3);

    if(id.indexOf("sub_") >= 0){  // we're mousing into a sub_layer
    if(open_sub_layer != id && open_sub_layer != "")
        hideLayer(open_sub_layer);
        clearTimeout(tim3);
        showLayer(id);
        showLayer(previousLayer);
        open_sub_layer = id;
    }
    else {  // we're just mousing into a regular layer

    if (open_sub_layer != "")
        hideLayer(open_sub_layer);
        if(previousLayer != id && previousLayer != "") {
            hideLayer(previousLayer);
        }
        showLayer(id);
        previousLayer = id;
        }
    }

function returnDiv(id) {
    if (document.all) { // IE 
        var div = document.all(id).style;
    }
    else if (document.layers) { // NS4
        var div = document.layers[id];
    }
    else if (document.getElementById) { // NS6
        var div = document.getElementById(id).style;
    }
    return div;
}
