function Ajax(direccionUrl) {
	this.http = null;
	this.metodo = "GET";
	this.url = direccionUrl;
	this.send = null;

	this.setOnReadyStateChange = setOnReadyStateChange;	
	this.setUrl = setUrl;
	this.setMetodo = setMetodo;
	this.setSend = setSend;
	this.start = start;
	this.crearXMLHttpRequest = crearXMLHttpRequest;
}

function setOnReadyStateChange(valor){
	this.onreadystatechange = valor;
}
function setUrl(valor){
	this.url = valor;
}
function setMetodo(valor){
	this.metodo = valor;
}
function setSend(valor){
	this.send = valor;
}

function crearXMLHttpRequest() {
	if ( window.ActiveXObject ) {
		this.http = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		this.http = new XMLHttpRequest();
	}
	return this.http;
}

function manejador() {

	if ( http.readyState == 4 ) {
		if ( http.status == 404 ) {
			responseError();
		}
		if ( http.status == 200 ) {
			responseText(http.responseText);
			responseXML(http.responseXML);
		}
	}
}

function start() {
	this.http = crearXMLHttpRequest();
	this.http.onreadystatechange = manejador;
	this.http.open(this.metodo,this.url,true);
	this.http.send(this.send);
}


function responseText(valor) {
}
function responseXML(valor) {
}
function responseError() {
	alert("Error 404 - Pagina no econtrada");
}


function llenarComboAjax(id,datos,separador){
	if ( !separador ) {
		separador = "&";
	}
	var obj = document.getElementById(id);
	var resp = datos.split(separador);
	while(obj.hasChildNodes()) {
		obj.removeChild(obj.childNodes[0]);
	}
	//alert(datos);
	//alert("resp.length "+resp.length);
	//alert("resp[0] "+resp[0]);
	//alert("resp[1] "+resp[1]);
	//if ( resp.length > 0 && !empty(resp[0]) && !empty(resp[1]) ) {
	if ( resp.length > 0 && !empty(datos) && !empty(resp[0]) ) {
		for (var i = 0; i < resp.length; i++) {
			var arr = resp[i].split(":");
			obj.options[obj.length] = new Option(arr[1],arr[0]);
		}
	}
}


function xmlTag(nombre,valor) {
	return ("<"+nombre+">"+valor+"<\/"+nombre+">\n");
}

