// call backend bean and JS callback afterwards
function invoke( bean, method, callback, ajaxPar0, ajaxPar1, ajaxPar2, ajaxPar3, ajaxPar4, ajaxPar5, ajaxPar6, ajaxPar7 )
{
	// add timestamp to make sure request is sent by IE
	var requestURI = document.location.pathname + "?ajaxBean=" + bean + "&ajaxMethod=" + method  + "&timestamp=" + new Date().getTime();

	// collect call parameters
	if ( typeof ajaxPar0 != 'undefined' )
		requestURI = requestURI + "&ajaxPar0=" + encodeURIComponent(ajaxPar0);
	if ( typeof ajaxPar1 != 'undefined' )
		requestURI = requestURI + "&ajaxPar1=" + encodeURIComponent(ajaxPar1);
	if ( typeof ajaxPar2 != 'undefined' )
		requestURI = requestURI + "&ajaxPar2=" + encodeURIComponent(ajaxPar2);
	if ( typeof ajaxPar3 != 'undefined' )
		requestURI = requestURI + "&ajaxPar3=" + encodeURIComponent(ajaxPar3);
	if ( typeof ajaxPar4 != 'undefined' )
		requestURI = requestURI + "&ajaxPar4=" + encodeURIComponent(ajaxPar4);
	if ( typeof ajaxPar5 != 'undefined' )
		requestURI = requestURI + "&ajaxPar5=" + encodeURIComponent(ajaxPar5);
	if ( typeof ajaxPar6 != 'undefined' )
		requestURI = requestURI + "&ajaxPar6=" + encodeURIComponent(ajaxPar6);
	if ( typeof ajaxPar7 != 'undefined' )
		requestURI = requestURI + "&ajaxPar7=" + encodeURIComponent(ajaxPar7);

	// enable for debugging
	// alert( requestURI );

	// get request object
	var req;
	if (window.XMLHttpRequest)
		req = new XMLHttpRequest();
	else if (window.ActiveXObject)
		req = new ActiveXObject("Microsoft.XMLHTTP");

	// define the callback
	req.onreadystatechange = function()
	{
		if (req.readyState == 4 && req.status == 200)
		{
			var str = req.responseText;
			
			// trim preceeding blanks in case the handler stmt was not the first line in the JSP
			while ((str.charAt(0) == " ") || (str.charAt(0) == "\t") || (str.charAt(0) == "\r") || (str.charAt(0) == "\n"))
				str = str.substring(1, str.length);

			if ( callback == null )
			{
				// default handler
				if ( str != "" )
					alert( str );

			}
			else
				// custom handler
				callback( str );
				
			// cleanup
			req = null;
		}
	}

	// launch the call
	req.open("GET", requestURI);
	req.send(null);
}
