/////////////////////////////////////////////////////////////////////////////
// 
//                            HEATWAVE  FRAMEWORK
// 
// -------------------------------------------------------------------------
//                                 LICENSE
// -------------------------------------------------------------------------
// 
// This source file is under the License Agreement that is present in the
// file LICENSE.txt.
// 
// The License Agreement is also available at the following URL:
// http://heatwave.heartbeat.ro/license/
// 
// If you did not receive a copy of the license and are unable to obtain it
// through the world-wide-web, please send an e-mail to
// heatwave.license@heartbeat.ro so we can send you a copy immediately.
// 
/////////////////////////////////////////////////////////////////////////////

/**
 * @function get_response
 * 
 * @description
 * 		Gets response from server. If the response is a XML, it will be
 * 		converted to an array.
 * 
 * @parameters
 * 		@param request
 * 			@type
 * 				Object
 * 
 * 			@description
 * 				The request object used to send the request.
 * 
 * 		@param type
 * 			@type
 * 				string
 * 
 * 			@description
 * 				The type of the response. It can only be 'TEXT' or 'XML'.
 * 
 * @return
 * 		@type
 * 			mixed
 * 
 * 		@description
 * 			Returns the script response as a string or an array.
 * 
 * @changelog
 *		@version 1.0.0
 *			Creation of the function.
 */
function get_response(request, type)
{
	// default values
	var allowed_types = ["TEXT", "XML"];
	var result = "";
	
	// check request object and URL
	if ((request !== null) && (request !== undefined) && (request !== false))
	{
		// check type
		if (!allowed_types.in_array(type.toUpperCase()))
		{
			// set default method
			type = "TEXT";
		}
		
		// get response
		if (type == "TEXT")
		{
			// get text
			result = request.responseText;
		}
		else
		{
			// get XML
			var xml = request.responseXML;
			
			
		}
	}
	
	return result;
}
