﻿//Popout menus for navigation

Utils = function(){};

Utils.toggleMenu = function(element, idHdnCurrentActive, show)
{
	//Get the element
	var el = document.getElementById(element);
	
	if (el)
	{
	    if(show)
	    {
		    el.style.display = '';
		}
		else
		{
		    if(document.getElementById(idHdnCurrentActive).value != element)
		    {
		        el.style.display = 'none';
		    }
		}
	}	
}

//******************************************** Saion Scripts *************************************************

function SwitchPanels(AttachedPanelIDToCollapse, AttachedPanelIDToExpand)
{
    TogglePanel(AttachedPanelIDToCollapse);
    TogglePanel(AttachedPanelIDToExpand);
}

function TogglePanel( AttachedPanelID)
{
    var AttachedPanel = document.getElementById(AttachedPanelID);
  if(AttachedPanel.style.display == "none")
  {     
      AttachedPanel.style.display = "block";
  }
  else
  {     
      AttachedPanel.style.display = "none";
  }
}


//for Team Focus ICU
function toggle_tf_divs(show_div) {
		var tab_divs = new Array("tf_open", "tf_close");
	
		// hide each div in the array
		for(var i=0; i<tab_divs.length; i++)
			document.getElementById(tab_divs[i]).style.display = "none";
		
		// show the specified div
		document.getElementById(show_div).style.display = "block";
	}
	
	
function SetValue(t1, t2)
{
    document.getElementById(t2).value = document.getElementById(t1).value;  
}
	

	// 
    function restrictCount(oMessage, subjectObjCounter, counterObjMaxLength, sFocusFlag)
    {
	    var oCounter = document.getElementById(subjectObjCounter);
		var counterObj = oMessage;
    		
	    if(counterObj!=oMessage)
		    counterObjMaxLength -= oMessage.value.length;   
	    if(counterObj.value.length>counterObjMaxLength)
		    counterObj.value = counterObj.value.substring(0, counterObjMaxLength);
    	
	    oCounter.value = counterObjMaxLength - oMessage.value.length;

	    if (oCounter.value < 10 && !oCounter.flash)
        {
            oCounter.flash = true;
            doFlash(oCounter.id, sFocusFlag);
        }
    }
    
    function doFlash(sCounter, sFocusFlag)
    {
        var oCounter = document.getElementById(sCounter);
        
        if (oCounter.bcolor)
        {
            oCounter.style.backgroundColor = "";
            oCounter.bcolor = false;
        }
        else
        {
            oCounter.style.backgroundColor = "#F5D5D6";
            oCounter.bcolor = true;
        }

        var oFocusFlag = document.getElementById(sFocusFlag);
        if (oCounter.value < 10 && oFocusFlag.value == 'true')
        {
            setTimeout("doFlash('" + sCounter + "','" +sFocusFlag+ "')", 300);
        }
        else
        {
            oCounter.style.backgroundColor = "";
            oCounter.bcolor = false;
            oCounter.flash = false;
        }
    }