/*
 * HIT Cyclone Platform, PERL Power Web Platform.
 * Copyright (C) 2006-2008, HIT IT Consulting & Services, individual authors
 * as indicated by the @author tags.
 *
 * This is CLOSED SOURCE SOFTWARE. You may neither read nor copy
 * and / or distribute any portion of this software without prior
 * permission by HIT IT Consulting & Services.
 *
 * @author Ben Hildebrand (ben.hildebrand [at] hit-consult.net
 */

function ajaxRequest( target, asyncMode, postTxt, onSuccessCallback, activateWaiting, waitingText ) {
	
	// disable waiting message
	activateWaiting = 0;
	
	var opt = {
		// Use get
		url: target,
		method: 'post',
		data: postTxt,
		async: asyncMode,
		encoding: 'iso-8859-1',
		// Handle successful response
		onSuccess: function( text, xml ) {
			hideWaiting();
			onSuccessCallback( text, xml );
		},
		// Handle Cancel
		onCancel: function() {
			hideWaiting();
			showError( ajaxError );
		},
		// Handle other errors
		onFailure: function() {
			hideWaiting();
			showError( ajaxError );
		},
		onException: function( requester, exception ) {
			hideWaiting();
			throw( exception );
		}
	}

	if ( activateWaiting ) {
		showWaiting( waitingText );
	}
	new Request( opt ).send();
}

function deflateJSON( json ) {
	var data = eval( '(' + unescape( json ) + ')' );
	return data;
}

