
var NET_COL_DELIMITER = String.fromCharCode(16);
var NET_ROW_DELIMITER = String.fromCharCode(15);
var __net_m_bPageLoaded = false;

window.onload = __net_Page_OnLoad;

function __net_ClientAPIEnabled()
{
	return typeof(net) != 'undefined';
}


function __net_Page_OnLoad()
{
	if (__net_ClientAPIEnabled())
	{
		var sLoadHandlers = net.getVar('__net_pageload');
		if (sLoadHandlers != null)
			eval(sLoadHandlers);
	}
	__net_m_bPageLoaded = true;
}

function __net_KeyDown(iKeyCode, sFunc, e)
{
	if (e == null)
		e = window.event;

	if (e.keyCode == iKeyCode)
	{
		eval(unescape(sFunc));
		return false;
	}
}

function __net_bodyscroll() 
{
	var oF=document.forms[0];	
	if (__net_ClientAPIEnabled() && __net_m_bPageLoaded)
		oF.ScrollTop.value=net.dom.getByTagName("body")[0].scrollTop;
}

function __net_setScrollTop(iTop)
{
	if (__net_ClientAPIEnabled())
	{
		if (iTop == null)
			iTop = document.forms[0].ScrollTop.value;
	
		var sID = net.getVar('ScrollToControl');
		if (sID != null && sID.length > 0)
		{
			var oCtl = net.dom.getById(sID);
			if (oCtl != null)
			{
				iTop = net.dom.positioning.elementTop(oCtl);
				net.setVar('ScrollToControl', '');
			}
		}
		net.dom.getByTagName("body")[0].scrollTop = iTop;
	}
}

//Focus logic
function __net_SetInitialFocus(sID)
{
	var oCtl = net.dom.getById(sID);	
	if (oCtl != null && __net_CanReceiveFocus(oCtl))
		oCtl.focus();
}	

function __net_CanReceiveFocus(e)
{
	//probably should call getComputedStyle for classes that cause item to be hidden
	if (e.style.display != 'none' && e.tabIndex > -1 && e.disabled == false && e.style.visible != 'hidden')
	{
		var eParent = e.parentElement;
		while (eParent != null && eParent.tagName != 'BODY')
		{
			if (eParent.style.display == 'none' || eParent.disabled || eParent.style.visible == 'hidden')
				return false;
			eParent = eParent.parentElement;
		}
		return true;
	}
	else
		return false;
}

//Max/Min Script
function __net_ContainerMaxMin_OnClick(oLnk, sContentID)
{
	var oContent = net.dom.getById(sContentID);
	if (oContent != null)
	{
		var oBtn = oLnk.childNodes[0];
		var sContainerID = oLnk.getAttribute('containerid');
		var sCookieID = oLnk.getAttribute('cookieid');
		var sCurrentFile = oBtn.src.toLowerCase().substr(oBtn.src.lastIndexOf('/'));
		var sMaxFile;
		var sMaxIcon;
		var sMinIcon;

		if (net.getVar('min_icon_' + sContainerID))
			sMinIcon = net.getVar('min_icon_' + sContainerID);
		else
			sMinIcon = net.getVar('min_icon');

		if (net.getVar('max_icon_' + sContainerID))
			sMaxIcon = net.getVar('max_icon_' + sContainerID);
		else
			sMaxIcon = net.getVar('max_icon');

		sMaxFile = sMaxIcon.toLowerCase().substr(sMaxIcon.lastIndexOf('/'));

		if (sCurrentFile == sMaxFile)
		{
			oBtn.src = sMinIcon;				
			oContent.style.display = '';
			oBtn.title = net.getVar('min_text');
			if (sCookieID != null)
			{
				if (net.getVar('__net_' + sContainerID + ':defminimized') == 'true')
					net.dom.setCookie(sCookieID, 'true', 365);
				else
					net.dom.deleteCookie(sCookieID);
			}
			else
				net.setVar('__net_' + sContainerID + '_Visible', 'true');
		}
		else
		{
			oBtn.src = sMaxIcon;				
			oContent.style.display = 'none';
			oBtn.title = net.getVar('max_text');
			if (sCookieID != null)
			{
				if (net.getVar('__net_' + sContainerID + ':defminimized') == 'true')
					net.dom.deleteCookie(sCookieID);
				else
					net.dom.setCookie(sCookieID, 'false', 365);				
			}
			else
				net.setVar('__net_' + sContainerID + '_Visible', 'false');			
		}
		
		return true;	//cancel postback
	}
	return false;	//failed so do postback
}

function __net_Help_OnClick(sHelpID)
{
	var oHelp = net.dom.getById(sHelpID);
	if (oHelp != null)
	{
		if (oHelp.style.display == 'none')
			oHelp.style.display = '';
		else
			oHelp.style.display = 'none';

		return true;	//cancel postback
	}
	return false;	//failed so do postback
}

function __net_SectionMaxMin(oBtn, sContentID)
{
	var oContent = net.dom.getById(sContentID);
	if (oContent != null)
	{
		var sMaxIcon = oBtn.getAttribute('max_icon');
		var sMinIcon = oBtn.getAttribute('min_icon');
		if (oContent.style.display == 'none')
		{
			oBtn.src = sMinIcon;				
			oContent.style.display = '';
			net.setVar(oBtn.id + ':exp', 1);
		}
		else
		{
			oBtn.src = sMaxIcon;				
			oContent.style.display = 'none';
			net.setVar(oBtn.id + ':exp', 0);
		}
		return true;	//cancel postback
	}
	return false;	//failed so do postback
}

