// JavaScript Document
	function Abrir_ventana (pagina, wd, hd, px, py, nombre) {
		var mywindow = new Array();
		var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, height="+hd+", width=" + wd;
		mywindow[nombre] = window.open(pagina,nombre,opciones);
		mywindow[nombre].moveTo(px,py);
	}
	
	function Borrar(x, msn) {
		if(!msn)
			msn = "¿Realmente desea borrar ese archivo?";
		if(confirm(msn)){
			window.location.href = x;
		}
	}

//Create a boolean variable to check for a valid IE instance.
	var xmlhttp = false;
	
	//Check if we are using IE.
	try {
		//If the javascript version is greater than 5.
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		//If not, then use the older active x object.
		try {
			//If we are using IE.
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			//Else we must be using a non-IE browser.
			xmlhttp = false;
		}
	}
	
	//If we are using a non-IE browser, create a JavaScript instance of the object.
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	function closetask (objID){
		
		theObject = document.getElementById(objID);
		
		theObject.style.visibility = "hidden";
		theObject.style.height = "0px";
		theObject.style.width = "0px";
	}
	
	function abrir (e, objID , serverPage){
		
		theObject = document.getElementById(objID);
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
		
	}
	
	function pop_up (e, objID , serverPage, w, h){
		var theObject = document.getElementById(objID);
		
		// Recupera las dimensiones de la ventana
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
			desplazamiento = window.pageYOffset;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
			desplazamiento = document.documentElement.scrollTop;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
			desplazamiento = document.body.scrollTop;
		}
		// Final de recuperar las dimensiones de la ventana
		
		theObject.style.visibility = "visible";
		theObject.style.height = h + "px";
		theObject.style.width = w + "px";
		
		var posx = 0;
		var posy = 0;
		var IE = document.all?true:false;
		
		posx = (myWidth - w)/2;
		posy = ((myHeight - h)/2)+ desplazamiento;
		
		if(posx < 0) posx = 0;
		if(posy < 0) posy = 0;
		
		//alert(" Altura patalla = "+myHeight+ "\n Altura="+h+ "\n desplazamiento="+desplazamiento+"\n posy="+posy);
		//posy = parseFloat(mouseY(e)) - 150;

		theObject.style.left = posx + "px";
		theObject.style.top = posy + "px";
		
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				theObject.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
		
	}
	function cerrar_pop_up(objID){
		var theObject = document.getElementById(objID);
		theObject.innerHTML = "";
		theObject.style.visibility = "hidden";
		theObject.style.height = "0px";
		theObject.style.width = "0px";
	}
	function vaciar_div(objID){
		var theObject = document.getElementById(objID);
		theObject.innerHTML = "Loading...";
	}
	function mouseX(evt) {
		if (evt.pageX) return evt.pageX;
		else if (evt.clientX)
		   return evt.clientX + (document.documentElement.scrollLeft ?
		   document.documentElement.scrollLeft :
		   document.body.scrollLeft);
		else return null;
	}
	function mouseY(evt) {
		if (evt.pageY) return evt.pageY;
		else if (evt.clientY)
		   return evt.clientY + (document.documentElement.scrollTop ?
		   document.documentElement.scrollTop :
		   document.body.scrollTop);
		else return null;
	}
	function trim(inputString) {
	   // Elimina los espacios iniciales y finales de la cadena que recibe. También elimina
	   // espacios consecutivos y los sustituye por uno solo. Si se recibe algo que no sea una 
	   //cadena (null, objeto personalizado, ...), devuelve la entrada.
	   if (typeof inputString != "string") { return inputString; }
	   var retValue = inputString;
	   var ch = retValue.substring(0, 1);
	   while (ch == " ") { // Busca espacios al principio de la cadena
	      retValue = retValue.substring(1, retValue.length);
	      ch = retValue.substring(0, 1);
	   }
	   ch = retValue.substring(retValue.length-1, retValue.length);
	   while (ch == " ") { // Busca espacios al final de la cadena
	      retValue = retValue.substring(0, retValue.length-1);
	      ch = retValue.substring(retValue.length-1, retValue.length);
	   }
	   while (retValue.indexOf("  ") != -1) { // Comprueba si hay espacios consecutivos
	      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
	   }
	   return retValue; // Devuelve la cadena sin espacios
	} // Final de la función "trim"
	
	//Funciones para enviar un formulario.
	function getformvalues (fobj, valfunc){ 
		var str = "";
		aok = true;
		var val;
		//Recorrer la lista de todos los objetos que contiene el formulario.
		for(var i = 0; i < fobj.elements.length; i++){
			if(valfunc) {
				if (aok == true){
					val = valfunc (fobj.elements[i].value,fobj.elements[i].name); 
					if (val == false){
						aok = false;
					}
				}
			}
			str += fobj.elements[i].name + "=" + escape(fobj.elements[i].value) + "&";
		}
		//Devolver los valores de la cadena
		return str;
	}
	
	function submitform (theform, serverPage, objID, valfunc){
		var file = serverPage;
		var str = getformvalues(theform,valfunc);
		//Si la validación es correcta.
		if (aok == true){
			obj = document.getElementById(objID);
			processajax (serverPage, obj, "post", str);
		}
	}
	
	function altoIMG(archivo, carpeta){
		var _i = new Image();
		_i.src=carpeta+archivo;
		return _i.height
	}
	
	function anchoIMG(archivo, carpeta){
		var _i = new Image();
		_i.src=carpeta+archivo;
		return _i.width
	}