function get_ajax_data( address, post_data, result_function )
{
	var ajax_handler;
	var post_string;

	// Create the Ajax handler
	if ( window.XMLHttpRequest )
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		ajax_handler = new XMLHttpRequest();
	}
	else if ( window.ActiveXObject )
	{
		// code for IE6, IE5
		ajax_handler=new ActiveXObject( 'Microsoft.XMLHTTP' );
	}
	else
	{
		alert( 'Your browser does not support AJAX. Please upgrade.' );
	}

	// Create handler function for when response is received
	ajax_handler.onreadystatechange = function()
	{
		if( ajax_handler.readyState == 4 )
		{
			result_function( ajax_handler.responseText );
		}
	}

	// Build the data to send
	post_string = '';
	separator = '';

	for ( post_item in post_data )
	{
		post_string += separator + post_item + '=' + php_urlencode( post_data[ post_item ] );
		separator = '&';
	}

	ajax_handler.open( 'POST', address, true );

	//Send the proper header information along with the request
	ajax_handler.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' );
	ajax_handler.setRequestHeader( 'Content-length', post_string.length );
	ajax_handler.setRequestHeader( 'Connection', 'close' );

	ajax_handler.send( post_string );
}

function php_urlencode(str)
{
	str = escape(str);
	return str.replace(/[*+\/@]|%20/g,
			function (s)
			{
				switch (s)
				{
					case '*': s = '%2A'; break;
					case '+': s = '%2B'; break;
					case '/': s = '%2F'; break;
					case '@': s = '%40'; break;
					case '%20': s = '+'; break;
				}
				return s;
			}
		);
}


