// JavaScript Document

function URLDecode(psEncodeString)
{
  var lsRegExp = /\+/g;
  return unescape(String(psEncodeString).replace(lsRegExp, ' '));
}
// Get base url
var base_url = 'http://'+document.domain+'/lib/testajax/';

var ajax_get_error = false;

function ajax_do (url) {
	
	// Create new JS element
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;

	// Append JS element (therefore executing the 'AJAX' call)
	document.body.appendChild (jsel);

	return true;
}

function ajax_obtener (url) {
	
	// Create new JS element
	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;

	// Append JS element (therefore executing the 'AJAX' call)
	document.body.appendChild (jsel);

	return true;
}


function ajax_get (url, el) {
	// Has element been passed as object or id-string?
	if (typeof(el) == 'string') {
		el = document.getElementById(el);
		
	}
     
	// Valid el?
	if (el == null) { 
	   alert('Objeto no encontrado: '+el)
	   return false;
	  }
	
// Create getfile URL
	getfile_url = base_url + 'getfile.php?url=' + escape(base_url+url) + '&el=' + escape(el.id);
	// Do Ajax
   
	ajax_do (getfile_url);

	return true;
}

