﻿var boldedDiv = null;
var currentBG = null;
var blockClick = false;

function pageLoad()
{
    //get div
    var div = $get(divBannerId);
    if (div == null)
        div = window.parent.document.getElementById(divBannerId);
        
    //only hide on services pages
    if (window.location.href.indexOf('Services.aspx') > -1 || window.location.href.indexOf('services.aspx') > -1)
        div.style.visibility = 'hidden';
    else
        div.style.visibility = 'visible';
}

function MenuHover(div)
{
    //store div's BG color
    currentBG = div.style.color;
    
    //set hover color
    div.style.color = '#666666';
}

function MenuUnHover(div)
{
    //restore div's BG color
    div.style.color = currentBG;
}

function LoadPage(pageName)
{
    //set page
    blockClick = true;  
    $get(pageContentId).src = pageName + '.aspx?IsInFrame=True';

    ////fade in
    //new AjaxControlToolkit.Animation.FadeInAnimation($get(divContentId), 1, 30, 0, 1, true).play();

    //allow click
    setTimeout('blockClick = false;', 1.5);
}

function CollapseAllChildren(parent)
{
    //collapse all children
    for (var n = 0; n < parent.childNodes.length; n++)
    {
        //the children with blank ids are the content containers
        if (parent.childNodes[n].id == '')
        {
            //get each container
            var content = parent.childNodes[n].childNodes[0];
            for (var m = 0; m < content.childNodes.length; m++)
            {
                //hide the sub menus
                if (content.childNodes[m].id && content.childNodes[m].id.indexOf('_content_submenu_') > -1)
                    content.childNodes[m].style.display = 'none';
            }
        }
    }

    //clear selection
    if (boldedDiv != null)
    {
        boldedDiv.style.fontWeight = 'normal';
        boldedDiv = null;
    }
}

function ToggleSubMenu(parent, childIds)
{
    //hide everything
    for (var n = 0; n < parent.childNodes.length; n++) 
    {
        if (parent.childNodes[n].id != null && parent.childNodes[n].id != '' && childIds.indexOf(parent.childNodes[n].id) == -1)
            parent.childNodes[n].style.display = 'none';
    }
    
    //get an array of all ids
    var ids = childIds.split('|');
    for (var n = 0; n < ids.length; n++)
    {
        //skip blanks
        if (ids[n].length > 0)
        {
            //toggle visibility
            var menuItem = $get(ids[n]);
            menuItem.style.display = menuItem.style.display == 'none' ? 'block' : 'none';
        }
    }
}

function FadeOut()
{        
    ////fade out
    //new AjaxControlToolkit.Animation.FadeOutAnimation($get(divContentId), .25, 30, 0, 1, true).play()
}

function UpdateBold(control)
{
    //dont bold during blocks    
    if (blockClick)
        return;

    //unbold all siblings
    for (var n = 0; n < control.parentNode.childNodes.length; n++)
        if (control.parentNode.childNodes[n].style)
            control.parentNode.childNodes[n].style.fontWeight = 'normal';

    //enbloden clicked control
    boldedDiv = control;
    control.style.fontWeight = 'bold';
}