// Miscelanous, not used
function addEventHandler( a, b, c, d )
{
	if ( a.addEventListener )	a.addEventListener( b, c, !!d );
	else if ( a.attachEvent )	a.attachEvent( 'on'+b, c );
}

// Fetch an HTML element object
function $G( f_szId )
{
	return document.getElementById(f_szId);
}

// Fetch the value/content of an HTML element (form: input, select, etc)
function $F( f_szId )
{
	obj = $G(f_szId);
	nodeName = (obj.nodeName || obj.tagName).toLowerCase();

	if ( 'input' == nodeName && obj.type && 'checkbox' == obj.type.toLowerCase() )
	{
		return obj.checked ? '1' : '0';
	}

	return obj.value;
}

// Add even and odd to rows as className (after refreshing an HTML table)
function rijkleuren( f_tbl, f_nums )
{
	rows = f_tbl.rows;
	c = true;
	for ( i=0; i<rows.length; i++ )
	{
		rows[i].className = c ? 'even' : 'odd';
		if ( f_nums )
		{
			rows[i].cells[0].innerHTML = '' + (i+1) + '.'
		}
		c = !c;
	}
	return false;
}

// Global pre- & post-AjaxVM handlers
// Executed when an ajax call is created and finished
if ( 'function' == typeof AjaxVM && 'function' == typeof AjaxVM.setGlobalHandlers )
{
	var myGlobalHandlers = {
		'onStart' : function()
		{
			if ( $G('loading') ) $G('loading').style.display = "block";
//			document.body.style.backgroundImage = 'url(/images/working.gif)';
		},
		'onComplete' : function()
		{
			if ( !AjaxVM.busy && $G('loading') )
			{
				$G('loading').style.display = "none";
//				document.body.style.backgroundImage = '';
			}
		}
	};
	AjaxVM.setGlobalHandlers(myGlobalHandlers);
}