function Ajax(){
	var xmlob;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlob=new XMLHttpRequest();
  }
else
  {
  // code for IE6, IE5
  xmlob=new ActiveXObject("Microsoft.XMLHTTP");
  }
	return xmlob;
}

/*CUADROS DE SELECCION DINAMICOS CON AJAX*/
function aj_select_handler(){
	this.html_response = '';
	this.select = new Array();
}
aj_select_handler.prototype.set_html_response = function(html_response){
	this.html_response = html_response;
	ar_campos = html_response.split('|;|');
	for(k=0;k<ar_campos.length;k++){
		if(ar_campos[k] != ''){
			ar_campos2 		= ar_campos[k].split('|$|');
			campo_nombre 	= ar_campos2[0];
			cad_options 	= ar_campos2[1];
			ar_valores 		= cad_options.split('|,|');
			for(i=0;i<ar_valores.length;i++){
				if(ar_valores[i] != ''){
					ar_v2 = ar_valores[i].split('|=|');
					this.select[campo_nombre].options[i] 		= new Option();
					this.select[campo_nombre].options[i].value  = ar_v2[0];
					this.select[campo_nombre].options[i].text 	= ar_v2[1];
				}
			}
		}
	}
	this.optcatch.save_options(this.changing_input,this.index,html_response);
}
aj_select_handler.prototype.set_select = function(select,index){
	if(typeof(index) == 'undefined' || index == null)index = 1;
	this.select[index] = select;
}
aj_select_handler.prototype.set_optcatch = function(optcatch,changing_input,index){
	this.optcatch 		= optcatch;
	this.changing_input = changing_input;
	this.index 			= index;
}

aj_select_handler.prototype.change_options = function(changing_field,the_other_field_id,url){
	var form_id = changing_field.form.id;
	document.forms[form_id].elements[the_other_field_id].options.length = 0;
	var new_value = changing_field.value;
	var input_id = changing_field.id;
	this.set_optcatch(optcatch,input_id,new_value);
	this.set_select(document.forms[form_id].elements[the_other_field_id],the_other_field_id);
	if(typeof(optcatch.opciones[input_id])!='undefined' && typeof(optcatch.opciones[input_id][new_value])!='undefined'){
		this.set_html_response(optcatch.opciones[input_id][new_value]);
	}else{
		url += new_value;
		ajax_load_get(this,url,'variable');
	}
}

/*CACHEO DE LAS OPCIONES RECIBIDAS CON AJAX PARA CUADROS DE SELECCION DINAMICOS*/
function aj_options_catching(){
	/*Este objeto sirve para guardar las opciones recuperadas con ajax*/
	this.opciones = new Array();
}
aj_options_catching.prototype.save_options = function(changing_input,index,html_response){
	if(!this.opciones[changing_input]){
		this.opciones[changing_input] = new Array();
	}
	this.opciones[changing_input][index] = html_response;
}

function ajax_load_get(div,url,tipo,img_loading){
	
	
	var contenedor;
	if(typeof(tipo) == 'undefined' || tipo == null){tipo = 'innerHTML';}
	if(typeof(img_loading) == 'undefined' || img_loading == null){img_loading = 'div_loading1';}
	if(tipo == 'innerHTML'){
		contenedor = document.getElementById(div);
		//alert(contenedor)
		//alert(img_loading)
		if(typeof(top.document.getElementById(img_loading)) != 'undefined'){
//			div_loading = top.document.getElementById(img_loading);
			//alert(div_loading)
/*			contenedor.innerHTML = div_loading.innerHTML;
*/		}
		//contenedor.style.display = 'block';
	}
	cadena = '';
	aj = Ajax();
	url = url + '&use_ajax=true';
	aj.open('GET',url,true);
	aj.onreadystatechange=function() {
		if (aj.readyState==4) {
			
			cadena = aj.responseText;			
			if(tipo == 'innerHTML'){
				
				contenedor.innerHTML = cadena;				
			}else if(tipo == 'variable'){
				div.set_html_response(cadena);
			}
	 	}
	}
	
	aj.send(null);
	return aj.responseText;
}

var ar_elementos_cargados = new Array();
var ar_scripts_cargados   = new Array();
/*Array con el contenido de los javascripts de los modulos*/
var js_temp2	= new Array();
var araj2 		= new Array();
var optcatch = new aj_options_catching();
var dfi_url_actual;
var ar_divs_urls = new Array(); /*Array con las direcciones cargadas*/
