﻿/*
 *  Common scripts for controls
 */

function ValidateSearch()
{
    if( document.getElementById('pSearch_tbxSearch').value.length < 3 )
    {
        document.getElementById('ValidationMsg').style.display = 'block';
        return false;
    }

    WaitPanel();

    return true;
}


function WaitPanel()
{
    if( document.getElementById('ValidationMsg') )
        document.getElementById('ValidationMsg').style.display = 'none';
        
    return;

    // Variables
    var height = 0;
    var canvas = document.getElementById('Canvas');
    var sectionContent = document.getElementById('SectionContent');
    var noSearchResults = document.getElementById('NoSearchResults');
    var searchResults = document.getElementById('pSearch_Results');
    
    

    // No search results
   if( noSearchResults )
   {
       noSearchResults.style.display = 'none';
   }

   // Section content
   if( sectionContent )
   {
       height = sectionContent.offsetHeight;
       sectionContent.style.display = 'none';
   }
   
   if( searchResults )
    {
        height = searchResults.offsetHeight;
        searchResults.style.display = 'none';
    }

    // Canvas
    if( canvas && height < 50 )
    {
        height += canvas.offsetHeight;
        canvas.style.display = 'none';
    }
    else if( canvas )
        canvas.style.display = 'none';

    var waitPanel = document.getElementById('PanelWait');
    waitPanel.style.display = 'block';
    waitPanel.style.height = (height == 0) ? 'auto' : height-15 + 'px';


    return true;
}

function RemoveCanvas()
{
    var ob = document.getElementById('Canvas');
    if( ob )
        ob.style.display = 'none';

}

function RemoveSectionContentLinks()
{
    var ob = document.getElementById('SectionContentLinks');
    if( ob )
        ob.parentNode.removeChild(ob);
}

