function ajaxobject(){
	this.a=null;
	try {
		this.a = new ActiveXObject("Msxml2.XMLHTTP");
	}catch (e) {
		try {this. a = new ActiveXObject("Microsoft.XMLHTTP");
		}catch (E) {this.a = false;}
	 } 
	 if (!this.a && typeof XMLHttpRequest!='undefined') this.a = new XMLHttpRequest();
	 return this.a
}
function ocupado() {
	var capa = document.getElementById('ocupado');
		if (capa != null) {
			capa.style.top = (screen.height - 400) / 2;
			capa.style.left = (screen.width - 500) / 2;
			capa.style.visibility = 'visible';
		}
}
function disponible() {
	var capa = document.getElementById('ocupado');
		if (capa != null) {
			capa.style.visibility = 'hidden';
		}
}  
Module=function (){

	this.reqx2=new ajaxobject()
	/** Carga el resultado de una llamada asincrona de ajax en una capa
	 * lay --> Identificador del div donde se carga el JSP
	 * dir --> Dirección que carga el JSP
	 * fnd --> Función javascript llamada tras la carga del JSP
	 */
	function loadJsp(lay,dir,fnd){

		this.reqx2.open("GET",dir, true);
		this.lay=(typeof(lay)=="object")?lay:document.getElementById(lay)
		var instance=this
		
		this.reqx2.onreadystatechange =function (){
			if (instance.reqx2.readyState == 4) {
				if (instance.reqx2.status == 200) {
					instance.lay.innerHTML=instance.reqx2.responseText
					/*"<!-- #scriptjs#--javascript--#scriptjs#-->" Nos permite llamar a javascript 
					generado en el servidor desde dentro de la jsp cargada por ajax*/ 
					var scripts = instance.reqx2.responseText.split("#scriptjs#");
					for(j=0;j<scripts.length;j++){
						if(j%2==1)
							eval(scripts[j]);
					}
					
					
					if(fnd!=null) {eval(fnd);}
					
				}else {
					disponible();
				}
			}
		}
		this.reqx2.send(null); 
	}this.loadJsp=loadJsp
	
}
