﻿
//
//This file provides methods for working with the sidebar div of Default.aspx. Verify the 
//following in the implementing page when using this file:
//  
//(1) That names provided in the activeSidebarNames variable match the names supplied   
//    in markup for the onclick event of the header div for each panel. For example:   
//
//    onclick="SetActiveSidebarDiv('findLocation');" 
//
//(2) That element names provided in ClearQueries() match the names of elements provided
//    in the markup, typically in the Find Location panel.  
//
//
//History:
//2008.09.30  Released version 1.0.
//2008.10.16  Added ClearInnerHTML() for query status spans
//



//sidebar header names used in markup
var activeSidebarNames = ['findLocation', 'legend', 'about'];

//Clears values in specified UI elements.
function ClearQueries()
{
    ClearText('uxLocationTextVE');
    ClearText('uxOwnerText');
    ClearText('uxPinText');
    ClearSelect('uxLocationCandidatesVE');
    ClearSelect('uxOwnerCandidates');
    ClearSelect('uxPinCandidates');
    ClearInnerHTML('uxOwnerCandidatesStatusSpan');
    ClearInnerHTML('uxPinCandidatesStatusSpan');
}

function ClearInnerHTML(elementID)
{
    var element = document.getElementById(elementID);
    if (element) element.innerHTML='';    
}

function ClearSelect(selectID)
{
    var select = document.getElementById(selectID);
    if (select) select.style.display='none';    
}

function ClearText(textboxID)
{
    var textbox = document.getElementById(textboxID);
    if (textbox) textbox.value='';
}

//Sets the given sidebar content active. Emulates AJAX Toolkit AccordionPanel.
function SetActiveSidebarDiv(name)
{
    for (var n = 0; n < activeSidebarNames.length; n++)
    {
        var elemHeader = document.getElementById(activeSidebarNames[n] + 'HeaderDiv');
        var elemContent = document.getElementById(activeSidebarNames[n] + 'ContentDiv');
        if (elemHeader && elemContent)
        {
            //set the given sidebar content active
            if (name == activeSidebarNames[n])
            {
                elemHeader.className = 'accordionHeaderSelected';
                elemContent.style.display = 'block';
            }
            //deactivate any other active content
            else if (elemContent.style.display == 'block')
            {
                elemHeader.className = 'accordionHeader';
                elemContent.style.display = 'none';
            }
        }
    }
}
