﻿// Popout code, this is used for help buttons
// To make a section "popout", call "ShowHideSection", the other code in this file is used to support that function
// Only one help popout should be shown at a time, so this keeps track of
// _which ones were opened on the page, and closes them when one is opened.

var sAryPopoutList; //array keeping track of which popouts were opened on the page
var iPopoutListArrayIndex=0; //index for the above array

//This is used to show/hide sections like the "change year" popout
function ShowHideSection(sTargetId)
{   
//add the control to the list of popout controls
    AddTargetToPopoutList(sTargetId);
    //see what mode the target is in currently
    var oCurrentStyle = document.getElementById(sTargetId).style;
	if(oCurrentStyle.display=="")
	{   //visible, hide the target
	    oCurrentStyle.display="none";
	}
	else
	{   //hide all other popouts for the page
	    HideAllPopouts();
	    //hidden, show the target
	    oCurrentStyle.display="";
	}
}
//This is used to show/hide sections like the "change year" popout
function ShowHideHelpSection(sTargetId)
{   
//add the control to the list of popout controls
    //AddTargetToPopoutList(sTargetId);
    //see what mode the target is in currently
    var oCurrentStyle = document.getElementById(sTargetId).style;
	if(oCurrentStyle.display=="")
	{   //visible, hide the target
	    oCurrentStyle.display="none";
	}
	else
	{   //hide all other popouts for the page
	    //HideAllPopouts();
	    //hidden, show the target
	    oCurrentStyle.display="";
	}
}



//hide all known popout windows, this will hide all those
// _that have been opened since the page loaded
function HideAllPopouts()
{   var oCurrentStyle;
    if(sAryPopoutList)
    {   for(var i=0;i<sAryPopoutList.length;i++)
        {   oCurrentStyle = document.getElementById(sAryPopoutList[i]).style;
            oCurrentStyle.display="none";
        }
    }
}
//add the target control id to the array of popout controls
function AddTargetToPopoutList(sTargetId)
{   if(sAryPopoutList)
    {   //add the control if it isnt already in the array
        if(!ItemExistsInArray(sAryPopoutList, sTargetId))
        {   sAryPopoutList[iPopoutListArrayIndex]=sTargetId;
            iPopoutListArrayIndex++;
        }
    }
    else //new array
    {   sAryPopoutList=new Array(sTargetId);
        iPopoutListArrayIndex++;
    }
}
//check to see if an item exists in an array
function ItemExistsInArray(sAry, sItem)
{   //loop through the array and see if the item exists
    for(var i=0;i<sAry.length;i++)
    {   if(sAry[i]==sItem) return true;
    }
    return false;
}

