
var globalCurrentHighlight = "divBannerItem1";
var debug = 0;

function InitJS()
    {
    var id;
//    alert( globalBaseURL);

    // determine page highlight
    // horizontal tabs
    if ( globalPostName == 'home') // page name
        id = 'divBannerItem1';


    // highlight
    SetCurrentHighlight ( id);

    // fix columns
    SetColumnHeights( 'divMainContainer', 'divSidebar')
    }

//
function BuildImageName( filename)
    {
    var name;

    name = "url(" + globaltemplateURL + "/images/" + filename + ")";

//    alert( name);
    return( name);
    }


//
function SetCurrentHighlight ( id)
    {
    globalCurrentHighlight = id;

    return;

    if ( debug) return;

    // change color
//    document.getElementById( id).style.backgroundColor = '#E1D2E7';

    // only do this for divBannerItem elements
    var name = id.substring( 0, 9);
    if ( name == 'divBanner')
        {
        document.getElementById( id).style.backgroundImage = BuildImageName( 'tab_on.jpg');
        document.getElementById( id).style.borderBottom = '1px solid #E1D2E7';
        }
    else // divBrowse
        {
//        document.getElementById( id).style.backgroundImage = "url('http://babystayasleep.andregagnon.com/images/button_on.jpg')";
//        document.getElementById( id).style.backgroundImage = "url('" + globalBaseURL + "/images/button_on.jpg')";
        document.getElementById( id).style.backgroundImage = BuildImageName( 'button_on.jpg');
        }

//    alert( globalCurrentHighlight);  // test
    }

// highlight a horizontal tab
function HighlightTab ( id, on)
    {
    return;

    if ( debug) return;

    if ( on == true)
        {
        // change color
        document.getElementById( id).style.backgroundImage = BuildImageName( 'tab_on.jpg');
        document.getElementById( id).style.borderBottom = '1px solid #E1D2E7';
        }
    else
        {
        if ( id != globalCurrentHighlight)
            {
            // change color
            document.getElementById( id).style.backgroundImage = BuildImageName( 'tab_off.jpg');
            document.getElementById( id).style.borderBottom = '1px solid #FDEF97';
            }
        }
    }


// highlight a left column navigation button
function HighlightButton ( id, on)
    {
    return;

    if ( debug) return;

    if ( on == true)
        {
//        document.getElementById( id).style.backgroundColor = '#E1D2E7';
//        document.getElementById( id).style.backgroundImage = "url('http://babystayasleep.andregagnon.com/images/button_on.jpg')";
//        document.getElementById( id).style.backgroundImage = "url('" + globalBaseURL + "/images/button_on.jpg')";
        document.getElementById( id).style.backgroundImage = BuildImageName( 'button_on.jpg');
        }
    else
        {
        if ( id != globalCurrentHighlight)
//            document.getElementById( id).style.backgroundImage = "url('http://babystayasleep.andregagnon.com/images/button_off.jpg')";
//            document.getElementById( id).style.backgroundImage = "url('" + globalBaseURL + "/images/button_off.jpg')";
            document.getElementById( id).style.backgroundImage = BuildImageName( 'button_off.jpg');
//            document.getElementById( id).style.backgroundColor = '#FDEF97';
        }
    }


function SetColumnHeights( id1, id2)
    {
    // find the height of the tallest column, set the columns
    var h, h1, h2;
    var d1 = document.getElementById( id1);
    var d2 = document.getElementById( id2);

    if ( d1 && d2)
    {

    h1 = d1.offsetHeight;
    h2 = d2.offsetHeight;

//    alert( ' d1 oh ' + d1.offsetHeight);
//    alert( ' d2 oh ' + d2.offsetHeight);

    h = h1;
    if ( h2 > h)
        h = h2;

//    h = h + "px";

//    alert( '1 dml h ' + document.getElementById( 'div_menuleft').style.height);
//    alert( '1 dr h ' + document.getElementById( 'div_right').style.height);

    var hMod = h - 37;
    document.getElementById( id1).style.height = (hMod) + "px";
    document.getElementById( id2).style.height = h + "px";

//    alert( '2 dml h ' + document.getElementById( 'div_menuleft').style.height);
//    alert( '2 dr h ' + document.getElementById( 'div_right').style.height);

    }
    else
        alert( 'no div?');

    }
