﻿/*
---------------------------------------------------------------------------
NAME:			togglePanel
PARAMETERS:		sPanel - div name, minus the panel_ prefix
DESCRIPTION:	toggles show/hide for a panel and image that share
				a name suffix, will also set a cookie to remember
				the state
--------------------------------------------------------------------------
*/
function togglePanel(sPanel)
	{
	try
		{		
		sDiv = 'panel_' + sPanel
		sImage = 'img_' + sPanel
		sCookie = 'cookie_' + sPanel
		getPopped(sDiv);
		sState = readCookie(sCookie);
		if ((sState == null) || (sState == 'open'))
			{
			hide(sDiv)
			document[sImage].src = 'WebResource.axd?d=TKeeeUiNcWqB6RlpWq8WL0tC_VhIGARP-V76j0JHPdmCeTXUciNACkWk8CH2P-TJmxvS6_gdjQkFu7GhwGHuDw2&t=633794830200000000';
			createCookie(sCookie,'closed',365)
			} 
		else 
			{
			show(sDiv)
			document[sImage].src = 'WebResource.axd?d=TKeeeUiNcWqB6RlpWq8WL0tC_VhIGARP-V76j0JHPdmCeTXUciNACkWk8CH2P-TJiSm2yhwUwQYs3N7zdsPoww2&t=633794830200000000';
			createCookie(sCookie,'open',365)
			}
		}
	catch(err)
		{
		}			
	}

/*
---------------------------------------------------------------------------
NAME:			setPanels
PARAMETERS:		aPanels - array of panel names
DESCRIPTION:	sets initial state of panels using the stored cookie
				if available
--------------------------------------------------------------------------
*/
function setPanels(aPanels) 
	{
	try
		{
		for (i = 0; i < aPanels.length; i++)
			{
			sDiv = 'panel_' + aPanels[i];
			sImage = 'img_' + aPanels[i];
			sCookie = 'cookie_' + aPanels[i];

			if (readCookie(sCookie) == 'closed')
				{
				hide(sDiv);
				document[sImage].src = 'WebResource.axd?d=TKeeeUiNcWqB6RlpWq8WL0tC_VhIGARP-V76j0JHPdmCeTXUciNACkWk8CH2P-TJmxvS6_gdjQkFu7GhwGHuDw2&t=633794830200000000';
				createCookie(sCookie,'closed',0);
				}
			}
		}
	catch(err)
		{
		}
	}

/*
---------------------------------------------------------------------------
NAME:			toggleSection
PARAMETERS:		sSection - div name, minus the section_ prefix
DESCRIPTION:	toggles show/hide for a panel and image that share
				a name suffix, will also set a cookie to remember
				the state
--------------------------------------------------------------------------
*/
function toggleSection(sSection, sGroup, bAutoCollapse)
	{
	try
		{
		var frm = document.forms[0];
		var sDiv = 'section_' + sSection;
		var sImage = 'img_' + sSection;
		var sHidden = 'hidden_' + sSection;
		var sState = 'open'
		var sGroupPrefix = 'hidden_' + sGroup;
		getPopped(sDiv);
		
		if ( !document.poppedLayer )
			{
			return;
			}
				
		if ( "hidden" == document.poppedLayer.style.visibility || "none" == document.poppedLayer.style.display )
			{
			sState = 'closed';
			}
		
		if (sState == 'open')
			{
			hide(sDiv);
			document[sImage].src = 'WebResource.axd?d=TKeeeUiNcWqB6RlpWq8WL0tC_VhIGARP-V76j0JHPdmCeTXUciNACkWk8CH2P-TJmxvS6_gdjQkFu7GhwGHuDw2&t=633794830200000000';
			if ( null != frm && null != frm[sHidden] )
				{
				frm[sHidden].value = '0';
				}
			} 
		else 
			{
			show(sDiv);
			document[sImage].src = 'WebResource.axd?d=TKeeeUiNcWqB6RlpWq8WL0tC_VhIGARP-V76j0JHPdmCeTXUciNACkWk8CH2P-TJiSm2yhwUwQYs3N7zdsPoww2&t=633794830200000000';
			if ( null != frm && null != frm[sHidden] )
				{
				frm[sHidden].value = '1';
				}
				
			if ( bAutoCollapse )
				{
				// walk through the form collapsing all of the other sections
				// we find a section by looking for the hidden field, this way we can loop through the form
				// instead of all of the divs in the document, then we rely on our naming conventions
				// to hide the div				
				for ( var i = 0; i < frm.length; ++i )
					{
					if ( frm[i].name.substring(0, sGroupPrefix.length) == sGroupPrefix && frm[i].name != sHidden )
						{
						hide(frm[i].name.replace('hidden_', 'section_'));
						document[frm[i].name.replace('hidden_', 'img_')].src = 'WebResource.axd?d=TKeeeUiNcWqB6RlpWq8WL0tC_VhIGARP-V76j0JHPdmCeTXUciNACkWk8CH2P-TJmxvS6_gdjQkFu7GhwGHuDw2&t=633794830200000000';
						frm[i].value = '0';						
						}			
					}
				}				
			}
		}
	catch(err)
		{
		//alert(err.description);
		}			
	}
